Skip to content

Commit 5784576

Browse files
added nx project
1 parent 386c72b commit 5784576

35 files changed

+1639
-0
lines changed

org/.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
actions: read
11+
contents: read
12+
13+
jobs:
14+
main:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
22+
23+
# This enables task distribution via Nx Cloud
24+
# Run this command as early as possible, before dependencies are installed
25+
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
26+
- run: npx nx-cloud start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build"
27+
28+
29+
# Cache node_modules
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
cache: 'npm'
34+
35+
- run: npm ci --legacy-peer-deps
36+
- uses: nrwl/nx-set-shas@v4
37+
38+
# Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud
39+
# - run: npx nx-cloud record -- echo Hello World
40+
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
41+
- run: npx nx affected -t lint test build

org/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
dist
5+
tmp
6+
/out-tsc
7+
8+
# dependencies
9+
node_modules
10+
11+
# IDEs and editors
12+
/.idea
13+
.project
14+
.classpath
15+
.c9/
16+
*.launch
17+
.settings/
18+
*.sublime-workspace
19+
20+
# IDE - VSCode
21+
.vscode/*
22+
!.vscode/settings.json
23+
!.vscode/tasks.json
24+
!.vscode/launch.json
25+
!.vscode/extensions.json
26+
27+
# misc
28+
/.sass-cache
29+
/connect.lock
30+
/coverage
31+
/libpeerconnection.log
32+
npm-debug.log
33+
yarn-error.log
34+
testem.log
35+
/typings
36+
37+
# System Files
38+
.DS_Store
39+
Thumbs.db
40+
41+
.nx/cache
42+
.nx/workspace-data

org/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
/.nx/cache
5+
/.nx/workspace-data

org/.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

org/.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"nrwl.angular-console",
4+
"esbenp.prettier-vscode",
5+
"ms-playwright.playwright",
6+
"firsttris.vscode-jest-runner"
7+
]
8+
}

org/README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Org
2+
3+
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
4+
5+
✨ Your new, shiny [Nx workspace](https://nx.dev) is almost ready ✨.
6+
7+
[Learn more about this workspace setup and its capabilities](https://nx.dev/nx-api/js?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed!
8+
9+
## Finish your CI setup
10+
11+
[Click here to finish setting up your workspace!](https://cloud.nx.app/connect/nZ5qDbSIBK)
12+
13+
14+
## Generate a library
15+
16+
```sh
17+
npx nx g @nx/js:lib packages/pkg1 --publishable --importPath=@my-org/pkg1
18+
```
19+
20+
## Run tasks
21+
22+
To build the library use:
23+
24+
```sh
25+
npx nx build pkg1
26+
```
27+
28+
To run any task with Nx use:
29+
30+
```sh
31+
npx nx <target> <project-name>
32+
```
33+
34+
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files.
35+
36+
[More about running tasks in the docs &raquo;](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
37+
38+
## Versioning and releasing
39+
40+
To version and release the library use
41+
42+
```
43+
npx nx release
44+
```
45+
46+
Pass `--dry-run` to see what would happen without actually releasing the library.
47+
48+
[Learn more about Nx release &raquo;](hhttps://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
49+
50+
## Keep TypeScript project references up to date
51+
52+
Nx automatically updates TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) in `tsconfig.json` files to ensure they remain accurate based on your project dependencies (`import` or `require` statements). This sync is automatically done when running tasks such as `build` or `typecheck`, which require updated references to function correctly.
53+
54+
To manually trigger the process to sync the project graph dependencies information to the TypeScript project references, run the following command:
55+
56+
```sh
57+
npx nx sync
58+
```
59+
60+
You can enforce that the TypeScript project references are always in the correct state when running in CI by adding a step to your CI job configuration that runs the following command:
61+
62+
```sh
63+
npx nx sync:check
64+
```
65+
66+
[Learn more about nx sync](https://nx.dev/reference/nx-commands#sync)
67+
68+
69+
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
70+
71+
## Install Nx Console
72+
73+
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
74+
75+
[Install Nx Console &raquo;](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
76+
77+
## Useful links
78+
79+
Learn more:
80+
81+
- [Learn more about this workspace setup](https://nx.dev/nx-api/js?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects)
82+
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
83+
- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
84+
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
85+
86+
And join the Nx community:
87+
- [Discord](https://go.nx.dev/community)
88+
- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl)
89+
- [Our Youtube channel](https://www.youtube.com/@nxdevtools)
90+
- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)

org/eslint.config.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const nx = require('@nx/eslint-plugin');
2+
3+
module.exports = [
4+
...nx.configs['flat/base'],
5+
...nx.configs['flat/typescript'],
6+
...nx.configs['flat/javascript'],
7+
{
8+
ignores: ['**/dist'],
9+
},
10+
{
11+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
12+
rules: {
13+
'@nx/enforce-module-boundaries': [
14+
'error',
15+
{
16+
enforceBuildableLibDependency: true,
17+
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
18+
depConstraints: [
19+
{
20+
sourceTag: '*',
21+
onlyDependOnLibsWithTags: ['*'],
22+
},
23+
],
24+
},
25+
],
26+
},
27+
},
28+
{
29+
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
30+
// Override or add rules here
31+
rules: {},
32+
},
33+
];

org/jest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { getJestProjectsAsync } from '@nx/jest';
2+
3+
export default async () => ({
4+
projects: await getJestProjectsAsync(),
5+
});

org/jest.preset.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const nxPreset = require('@nx/jest/preset').default;
2+
3+
module.exports = { ...nxPreset };

org/nx.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"$schema": "./node_modules/nx/schemas/nx-schema.json",
3+
"namedInputs": {
4+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
5+
"production": [
6+
"default",
7+
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
8+
"!{projectRoot}/tsconfig.spec.json",
9+
"!{projectRoot}/.eslintrc.json",
10+
"!{projectRoot}/eslint.config.js",
11+
"!{projectRoot}/jest.config.[jt]s",
12+
"!{projectRoot}/src/test-setup.[jt]s",
13+
"!{projectRoot}/test-setup.[jt]s"
14+
],
15+
"sharedGlobals": ["{workspaceRoot}/.github/workflows/ci.yml"]
16+
},
17+
"nxCloudId": "67192170f21f0e4878104e6b",
18+
"plugins": [
19+
{
20+
"plugin": "@nx/js/typescript",
21+
"options": {
22+
"typecheck": {
23+
"targetName": "typecheck"
24+
},
25+
"build": {
26+
"targetName": "build",
27+
"configName": "tsconfig.lib.json"
28+
}
29+
}
30+
},
31+
{
32+
"plugin": "@nx/vite/plugin",
33+
"options": {
34+
"buildTargetName": "build",
35+
"testTargetName": "test",
36+
"serveTargetName": "serve",
37+
"previewTargetName": "preview",
38+
"serveStaticTargetName": "serve-static",
39+
"typecheckTargetName": "typecheck"
40+
}
41+
},
42+
{
43+
"plugin": "@nx/eslint/plugin",
44+
"options": {
45+
"targetName": "lint"
46+
}
47+
},
48+
{
49+
"plugin": "@nx/playwright/plugin",
50+
"options": {
51+
"targetName": "e2e"
52+
}
53+
},
54+
{
55+
"plugin": "@nx/jest/plugin",
56+
"options": {
57+
"targetName": "test"
58+
}
59+
}
60+
],
61+
"defaultBase": "main",
62+
"targetDefaults": {
63+
"e2e-ci--**/*": {
64+
"dependsOn": ["^build"]
65+
}
66+
},
67+
"generators": {
68+
"@nx/react": {
69+
"application": {
70+
"babel": true,
71+
"style": "none",
72+
"linter": "eslint",
73+
"bundler": "vite"
74+
},
75+
"component": {
76+
"style": "none"
77+
},
78+
"library": {
79+
"style": "none",
80+
"linter": "eslint"
81+
}
82+
}
83+
}
84+
}

0 commit comments

Comments
 (0)