Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add nx #11461

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "@nrwl/nx-cloud",
"options": {
"cacheableOperations": [
"build",
"lint",
"typecheck",
"test-unit",
"test-build",
"test-docs",
"docs-build"
],
"accessToken": "NjYwZGFlNWYtZGYyNS00MTIzLTkzYTEtYzAxZTZiYzUwYTVifHJlYWQtd3JpdGU="
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned in my general comment, this key must not provide write access to the cache or it would be far too dangerous to use.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. The accessToken that is committed to an open source repo should always be a read only token. I'm sure @jaysoo set this token to read only. You can use a read-write token in a .env file that is not committed to the repo on trusted dev machines or only use the read-write token in the environment variables in CI.

}
}
},
"namedInputs": {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See description for how inputs and namedInputs can help local dev and CI experience.

"default": [
"{workspaceRoot}/packages/**/*",
{
"runtime": "node -e \"console.log(process.platform)\""
}
],
"production": [
"default",
"!{workspaceRoot}/packages/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{workspaceRoot}/vitest.config.e2e.ts",
"!{workspaceRoot}/vitest.config.ts",
"!{workspaceRoot}/.eslintignore",
"!{workspaceRoot}/.eslintrc.cjs",
"!{projectRoot}/tsconfig.check.json"
],
"playground": [
"default",
"{workspaceRoot}/playground/**/*",
{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inputs can include environment variables or the result of a shell script.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it also include extra cli arguments? eg pnpm test-serve some-test-file-to-focus.ts

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, extra args should be included already

"env": "VITE_TEST_BUILD"
},
{
"env": "VITE_TEST_WITHOUT_PLUGIN_COMMONJS"
}
]
},
"targetDefaults": {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section configures tasks and their dependencies + inputs that affect their computation.

"typecheck": {
"dependsOn": [
"default",
"{projectRoot}/tsconfig.check.json",
"{projectRoot}/**/*.[jt]sx?"
]
},
"build": {
"dependsOn": ["^build"],
"inputs": ["production", "!{projectRoot}/LICENSE.md"],
"outputs": ["{projectRoot}/dist"]
},
"test-unit": {
"dependsOn": ["^build"],
"inputs": ["default", "^production", "{workspaceRoot}/vitest.config.ts"]
},
"test-build": {
"dependsOn": ["^build"],
"inputs": ["playground", "{workspaceRoot}/vitest.config.e2e.ts"]
},
"test-serve": {
"dependsOn": ["^build"],
"inputs": ["playground", "{workspaceRoot}/vitest.config.e2e.ts"]
},
"docs": {
"dependsOn": ["^build"],
"inputs": ["{workspaceRoot}/docs/**/*"]
},
"docs-build": {
"dependsOn": ["^build"],
"inputs": ["{workspaceRoot}/docs/**/*"],
"outputs": ["{workspaceRoot}/docs/.vitepress/dist"]
},
"docs-serve": {
"dependsOn": ["^build"],
"inputs": ["{workspaceRoot}/docs/**/*"]
}
},
"defaultBase": "main"
}
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
"lint": "eslint --cache .",
"typecheck": "tsc -p scripts --noEmit && pnpm -r --parallel run typecheck",
"test": "run-s test-unit test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"test-serve": "nx exec -- vitest run -c vitest.config.e2e.ts",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nx exec is used to wrap any package scripts that that should run through Nx. This way non of the local or CI scripts need to be updated to integrate with Nx.

For example, users continue to use pnpm run docs not nx run docs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the nx cli prefix/modify log output of the original command?
does it allow passing additional args like focussing a test?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the nx exec command executes whatever command you pass to it (including any flags). The output is rendered with the exact same colors and formatting. The only modification is that Nx adds a message at the end saying "replayed from cache" or something similar.

"test-build": "VITE_TEST_BUILD=1 nx exec -- vitest run -c vitest.config.e2e.ts",
"test-build-without-plugin-commonjs": "VITE_TEST_WITHOUT_PLUGIN_COMMONJS=1 pnpm test-build",
"test-unit": "vitest run",
"test-docs": "pnpm run docs-build",
"test-unit": "nx exec -- vitest run",
"test-docs": "nx exec -- pnpm run docs-build",
"debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts",
"debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts",
"docs": "vitepress dev docs",
"docs-build": "vitepress build docs",
"docs-serve": "vitepress serve docs",
"build": "pnpm -r --filter='./packages/*' run build",
"docs": "nx exec -- vitepress dev docs",
"docs-build": "nx exec -- vitepress build docs",
"docs-serve": "nx exec -- vitepress serve docs",
"build": "nx run-many --target=build --projects=vite,@vitejs/plugin-legacy,create-vite",
"dev": "pnpm -r --parallel --filter='./packages/*' run dev",
"release": "tsx scripts/release.ts",
"ci-publish": "tsx scripts/publishCI.ts",
Expand Down Expand Up @@ -90,7 +90,9 @@
"vite": "workspace:*",
"vitepress": "^1.0.0-alpha.31",
"vitest": "^0.25.7",
"vue": "^3.2.45"
"vue": "^3.2.45",
"nx": "15.3.3",
"@nrwl/nx-cloud": "latest"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged --concurrent false"
Expand Down
2 changes: 1 addition & 1 deletion packages/create-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild",
"typecheck": "tsc --noEmit",
"typecheck": "nx exec -- tsc --noEmit",
"prepublishOnly": "npm run build"
},
"engines": {
Expand Down
31 changes: 1 addition & 30 deletions packages/vite/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2933,35 +2933,6 @@ Repository: lukeed/sirv

---------------------------------------

## sourcemap-codec
License: MIT
By: Rich Harris
Repository: https://github.com/Rich-Harris/sourcemap-codec

> The MIT License
>
> Copyright (c) 2015 Rich Harris
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.

---------------------------------------

## statuses
License: MIT
By: Douglas Christopher Wilson, Jonathan Ong
Expand Down Expand Up @@ -3163,7 +3134,7 @@ Repository: unjs/ufo

> MIT License
>
> Copyright (c) 2020 Nuxt Contrib
> Copyright (c) Pooya Parsa <pooya@pi0.io>
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"build-types-roll": "api-extractor run && rimraf temp",
"build-types-post-patch": "tsx scripts/postPatchTypes.ts",
"build-types-check": "tsx scripts/checkBuiltTypes.ts && tsc --project tsconfig.check.json",
"typecheck": "tsc --noEmit",
"typecheck": "nx exec -- tsc --noEmit",
"lint": "eslint --cache --ext .ts src/**",
"format": "prettier --write --cache --parser typescript \"src/**/*.ts\"",
"prepublishOnly": "npm run build"
Expand Down
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"private": true,
"version": "1.0.0",
"scripts": {
"typecheck": "tsc --noEmit"
"typecheck": "nx exec -- tsc --noEmit"
},
"devDependencies": {
"convert-source-map": "^2.0.0",
Expand Down
Loading