feat(linter): support eslint v8 (#7800)

* feat(core): support eslint v8

* fix(core): align version of eslint across all packages
This commit is contained in:
James Henry 2021-11-19 21:22:21 +04:00 committed by Victor Savkin
parent 8fa36ff3e8
commit 98ffe8574b
37 changed files with 1044 additions and 980 deletions

View File

@ -197,7 +197,7 @@ jobs:
- run: - run:
name: Run E2E Tests name: Run E2E Tests
command: | command: |
npx nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --exclude=e2e-react-native,e2e-detox --parallel --max-parallel=1 npx nx affected --target=e2e --base=$NX_BASE --head=$NX_HEAD --exclude=e2e-react-native,e2e-detox,e2e-gatsby --parallel --max-parallel=1
no_output_timeout: 45m no_output_timeout: 45m
- run: - run:
name: Stop All Running Agents for This CI Run name: Stop All Running Agents for This CI Run
@ -257,6 +257,10 @@ workflows:
name: 'agent9' name: 'agent9'
pm: 'npm' pm: 'npm'
os: 'macos' os: 'macos'
- agent:
name: 'agent10'
pm: 'npm'
os: 'macos'
# - agent: # - agent:
# name: 'agent10' # name: 'agent10'
# pm: 'npm' # pm: 'npm'

View File

@ -1061,9 +1061,9 @@ By default javascript-style comments are allowed.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1113,9 +1113,9 @@ Reads a json file, removes all comments and parses JSON.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1139,9 +1139,9 @@ Reads a JSON file and returns the object the JSON content represents.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1346,9 +1346,9 @@ By default the JSON string is formatted with a 2 space intendation to be easy re
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters
@ -1459,10 +1459,10 @@ Updates a JSON value to the file system tree
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
| `U` | extends ` object``T ` | | `U` | extends `object` = `T` |
#### Parameters #### Parameters
@ -1569,9 +1569,9 @@ Writes a JSON value to the file system tree
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters
@ -1596,9 +1596,9 @@ Serializes the given data to JSON and writes it to a file.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters

View File

@ -1061,9 +1061,9 @@ By default javascript-style comments are allowed.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1113,9 +1113,9 @@ Reads a json file, removes all comments and parses JSON.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1139,9 +1139,9 @@ Reads a JSON file and returns the object the JSON content represents.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1346,9 +1346,9 @@ By default the JSON string is formatted with a 2 space intendation to be easy re
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters
@ -1459,10 +1459,10 @@ Updates a JSON value to the file system tree
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
| `U` | extends ` object``T ` | | `U` | extends `object` = `T` |
#### Parameters #### Parameters
@ -1569,9 +1569,9 @@ Writes a JSON value to the file system tree
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters
@ -1596,9 +1596,9 @@ Serializes the given data to JSON and writes it to a file.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters

View File

@ -1061,9 +1061,9 @@ By default javascript-style comments are allowed.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1113,9 +1113,9 @@ Reads a json file, removes all comments and parses JSON.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1139,9 +1139,9 @@ Reads a JSON file and returns the object the JSON content represents.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
#### Parameters #### Parameters
@ -1346,9 +1346,9 @@ By default the JSON string is formatted with a 2 space intendation to be easy re
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters
@ -1459,10 +1459,10 @@ Updates a JSON value to the file system tree
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :---------------------- | | :--- | :----------------------- |
| `T` | extends ` object``any ` | | `T` | extends `object` = `any` |
| `U` | extends ` object``T ` | | `U` | extends `object` = `T` |
#### Parameters #### Parameters
@ -1569,9 +1569,9 @@ Writes a JSON value to the file system tree
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters
@ -1596,9 +1596,9 @@ Serializes the given data to JSON and writes it to a file.
#### Type parameters #### Type parameters
| Name | Type | | Name | Type |
| :--- | :------------------------- | | :--- | :-------------------------- |
| `T` | extends ` object``object ` | | `T` | extends `object` = `object` |
#### Parameters #### Parameters

View File

@ -23,8 +23,13 @@
"sitemap" "sitemap"
], ],
"useDaemonProcess": true, "useDaemonProcess": true,
"runtimeCacheInputs": ["echo $SELECTED_CLI", "echo $E2E_CI_CACHE_KEY"], "runtimeCacheInputs": [
"cacheDirectory": "/tmp/nx-cache" "echo $SELECTED_CLI",
"echo $NX_E2E_CI_CACHE_KEY"
],
"cacheDirectory": "/tmp/nx-cache",
"parallel": 1,
"scan": false
} }
} }
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@nrwl/nx-source", "name": "@nrwl/nx-source",
"version": "13.1.3", "version": "13.3.0-beta.2",
"description": "Smart, Extensible Build Framework", "description": "Smart, Extensible Build Framework",
"homepage": "https://nx.dev", "homepage": "https://nx.dev",
"private": true, "private": true,
@ -61,18 +61,19 @@
"@ngrx/schematics": "~13.0.0", "@ngrx/schematics": "~13.0.0",
"@ngrx/store": "~13.0.0", "@ngrx/store": "~13.0.0",
"@ngrx/store-devtools": "~13.0.0", "@ngrx/store-devtools": "~13.0.0",
"@nrwl/cli": "13.2.0-rc.4", "@nrwl/cli": "13.3.0-beta.2",
"@nrwl/cypress": "13.2.0-rc.4", "@nrwl/js": "13.3.0-beta.2",
"@nrwl/eslint-plugin-nx": "13.2.0-rc.4", "@nrwl/workspace": "13.3.0-beta.2",
"@nrwl/jest": "13.2.0-rc.4", "@nrwl/cypress": "13.3.0-beta.2",
"@nrwl/linter": "13.2.0-rc.4", "@nrwl/eslint-plugin-nx": "13.3.0-beta.2",
"@nrwl/next": "13.2.0-rc.4", "@nrwl/jest": "13.3.0-beta.2",
"@nrwl/node": "13.2.0-rc.4", "@nrwl/linter": "13.3.0-beta.2",
"@nrwl/nx-cloud": "13.0.0-beta.11", "@nrwl/next": "13.3.0-beta.2",
"@nrwl/react": "13.2.0-rc.4", "@nrwl/node": "13.3.0-beta.2",
"@nrwl/tao": "13.2.0-rc.4", "@nrwl/nx-cloud": "13.0.0-beta.12",
"@nrwl/web": "13.2.0-rc.4", "@nrwl/react": "13.3.0-beta.2",
"@nrwl/workspace": "13.2.0-rc.4", "@nrwl/tao": "13.3.0-beta.2",
"@nrwl/web": "13.3.0-beta.2",
"@parcel/watcher": "2.0.0-alpha.11", "@parcel/watcher": "2.0.0-alpha.11",
"@phenomnomnominal/tsquery": "4.1.1", "@phenomnomnominal/tsquery": "4.1.1",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.1", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.1",
@ -299,4 +300,3 @@
"**/xmlhttprequest-ssl": "~1.6.2" "**/xmlhttprequest-ssl": "~1.6.2"
} }
} }

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/angular"] "outputs": ["coverage/packages/angular"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/angular", "outputPath": "build/packages/angular",
"tsConfig": "packages/angular/tsconfig.lib.json", "tsConfig": "packages/angular/tsconfig.lib.json",
"packageJson": "packages/angular/package.json",
"main": "packages/angular/index.ts", "main": "packages/angular/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/angular", "input": "packages/angular",

View File

@ -68,7 +68,7 @@ function buildAppWithCustomWebpackConfiguration(
context: BuilderContext, context: BuilderContext,
pathToWebpackConfig: string pathToWebpackConfig: string
) { ) {
return executeBrowserBuilder(options, context, { return executeBrowserBuilder(options, context as any, {
webpackConfiguration: async (baseWebpackConfig) => { webpackConfiguration: async (baseWebpackConfig) => {
const customWebpackConfiguration = require(pathToWebpackConfig); const customWebpackConfiguration = require(pathToWebpackConfig);
// The extra Webpack configuration file can export a synchronous or asynchronous function, // The extra Webpack configuration file can export a synchronous or asynchronous function,
@ -127,4 +127,4 @@ function run(
); );
} }
export default createBuilder<JsonObject & BrowserBuilderSchema>(run); export default createBuilder<JsonObject & BrowserBuilderSchema>(run) as any;

View File

@ -41,24 +41,28 @@ export function webpackServer(schema: Schema, context: BuilderContext) {
); );
if (existsSync(pathToWebpackConfig)) { if (existsSync(pathToWebpackConfig)) {
return serveWebpackBrowser(options as DevServerBuilderOptions, context, { return serveWebpackBrowser(
webpackConfiguration: async (baseWebpackConfig) => { options as DevServerBuilderOptions,
const customWebpackConfiguration = require(pathToWebpackConfig); context as any,
// The extra Webpack configuration file can export a synchronous or asynchronous function, {
// for instance: `module.exports = async config => { ... }`. webpackConfiguration: async (baseWebpackConfig) => {
if (typeof customWebpackConfiguration === 'function') { const customWebpackConfiguration = require(pathToWebpackConfig);
return customWebpackConfiguration(baseWebpackConfig); // The extra Webpack configuration file can export a synchronous or asynchronous function,
} else { // for instance: `module.exports = async config => { ... }`.
return merge( if (typeof customWebpackConfiguration === 'function') {
baseWebpackConfig, return customWebpackConfiguration(baseWebpackConfig);
// The extra Webpack configuration file can also export a Promise, for instance: } else {
// `module.exports = new Promise(...)`. If it exports a single object, but not a Promise, return merge(
// then await will just resolve that object. baseWebpackConfig,
await customWebpackConfiguration // The extra Webpack configuration file can also export a Promise, for instance:
); // `module.exports = new Promise(...)`. If it exports a single object, but not a Promise,
} // then await will just resolve that object.
}, await customWebpackConfiguration
}); );
}
},
}
);
} else { } else {
throw new Error( throw new Error(
`Custom Webpack Config File Not Found!\nTo use a custom webpack config, please ensure the path to the custom webpack file is correct: \n${pathToWebpackConfig}` `Custom Webpack Config File Not Found!\nTo use a custom webpack config, please ensure the path to the custom webpack file is correct: \n${pathToWebpackConfig}`
@ -66,7 +70,10 @@ export function webpackServer(schema: Schema, context: BuilderContext) {
} }
} }
return serveWebpackBrowser(options as DevServerBuilderOptions, context); return serveWebpackBrowser(
options as DevServerBuilderOptions,
context as any
);
} }
export default createBuilder<JsonObject & Schema>(webpackServer); export default createBuilder<JsonObject & Schema>(webpackServer) as any;

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/cli"] "outputs": ["coverage/packages/cli"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/cli", "outputPath": "build/packages/cli",
"tsConfig": "packages/cli/tsconfig.lib.json", "tsConfig": "packages/cli/tsconfig.lib.json",
"packageJson": "packages/cli/package.json",
"main": "packages/cli/bin/nx.ts", "main": "packages/cli/bin/nx.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/cli", "input": "packages/cli",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/create-nx-plugin"] "outputs": ["coverage/packages/create-nx-plugin"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/create-nx-plugin", "outputPath": "build/packages/create-nx-plugin",
"tsConfig": "packages/create-nx-plugin/tsconfig.lib.json", "tsConfig": "packages/create-nx-plugin/tsconfig.lib.json",
"packageJson": "packages/create-nx-plugin/package.json",
"main": "packages/create-nx-plugin/bin/create-nx-plugin.ts", "main": "packages/create-nx-plugin/bin/create-nx-plugin.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/create-nx-plugin", "input": "packages/create-nx-plugin",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/create-nx-workspace"] "outputs": ["coverage/packages/create-nx-workspace"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/create-nx-workspace", "outputPath": "build/packages/create-nx-workspace",
"tsConfig": "packages/create-nx-workspace/tsconfig.lib.json", "tsConfig": "packages/create-nx-workspace/tsconfig.lib.json",
"packageJson": "packages/create-nx-workspace/package.json",
"main": "packages/create-nx-workspace/bin/create-nx-workspace.ts", "main": "packages/create-nx-workspace/bin/create-nx-workspace.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/create-nx-workspace", "input": "packages/create-nx-workspace",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/cypress"] "outputs": ["coverage/packages/cypress"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/cypress", "outputPath": "build/packages/cypress",
"tsConfig": "packages/cypress/tsconfig.lib.json", "tsConfig": "packages/cypress/tsconfig.lib.json",
"packageJson": "packages/cypress/package.json",
"main": "packages/cypress/index.ts", "main": "packages/cypress/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/cypress", "input": "packages/cypress",

View File

@ -26,13 +26,11 @@
"outputs": ["coverage/packages/detox"] "outputs": ["coverage/packages/detox"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/detox", "outputPath": "build/packages/detox",
"tsConfig": "packages/detox/tsconfig.lib.json", "tsConfig": "packages/detox/tsconfig.lib.json",
"packageJson": "packages/detox/package.json",
"main": "packages/detox/index.ts", "main": "packages/detox/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/detox", "input": "packages/detox",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/devkit"] "outputs": ["coverage/packages/devkit"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/devkit", "outputPath": "build/packages/devkit",
"tsConfig": "packages/devkit/tsconfig.lib.json", "tsConfig": "packages/devkit/tsconfig.lib.json",
"packageJson": "packages/devkit/package.json",
"main": "packages/devkit/index.ts", "main": "packages/devkit/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/devkit", "input": "packages/devkit",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/eslint-plugin-nx"] "outputs": ["coverage/packages/eslint-plugin-nx"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/eslint-plugin-nx", "outputPath": "build/packages/eslint-plugin-nx",
"tsConfig": "packages/eslint-plugin-nx/tsconfig.lib.json", "tsConfig": "packages/eslint-plugin-nx/tsconfig.lib.json",
"packageJson": "packages/eslint-plugin-nx/package.json",
"main": "packages/eslint-plugin-nx/src/index.ts", "main": "packages/eslint-plugin-nx/src/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/eslint-plugin-nx", "input": "packages/eslint-plugin-nx",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/express"] "outputs": ["coverage/packages/express"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/express", "outputPath": "build/packages/express",
"tsConfig": "packages/express/tsconfig.lib.json", "tsConfig": "packages/express/tsconfig.lib.json",
"packageJson": "packages/express/package.json",
"main": "packages/express/index.ts", "main": "packages/express/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/express", "input": "packages/express",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/gatsby"] "outputs": ["coverage/packages/gatsby"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/gatsby", "outputPath": "build/packages/gatsby",
"tsConfig": "packages/gatsby/tsconfig.lib.json", "tsConfig": "packages/gatsby/tsconfig.lib.json",
"packageJson": "packages/gatsby/package.json",
"main": "packages/gatsby/index.ts", "main": "packages/gatsby/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/gatsby/src", "input": "packages/gatsby/src",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/jest"] "outputs": ["coverage/packages/jest"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/jest", "outputPath": "build/packages/jest",
"tsConfig": "packages/jest/tsconfig.lib.json", "tsConfig": "packages/jest/tsconfig.lib.json",
"packageJson": "packages/jest/package.json",
"main": "packages/jest/index.ts", "main": "packages/jest/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/jest", "input": "packages/jest",

View File

@ -19,13 +19,11 @@
} }
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/js", "outputPath": "build/packages/js",
"tsConfig": "packages/js/tsconfig.lib.json", "tsConfig": "packages/js/tsconfig.lib.json",
"packageJson": "packages/js/package.json",
"main": "packages/js/src/index.ts", "main": "packages/js/src/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/js", "input": "packages/js",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/linter"] "outputs": ["coverage/packages/linter"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/linter", "outputPath": "build/packages/linter",
"tsConfig": "packages/linter/tsconfig.lib.json", "tsConfig": "packages/linter/tsconfig.lib.json",
"packageJson": "packages/linter/package.json",
"main": "packages/linter/index.ts", "main": "packages/linter/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/linter", "input": "packages/linter",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/nest"] "outputs": ["coverage/packages/nest"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/nest", "outputPath": "build/packages/nest",
"tsConfig": "packages/nest/tsconfig.lib.json", "tsConfig": "packages/nest/tsconfig.lib.json",
"packageJson": "packages/nest/package.json",
"main": "packages/nest/index.ts", "main": "packages/nest/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/nest", "input": "packages/nest",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/next"] "outputs": ["coverage/packages/next"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/next", "outputPath": "build/packages/next",
"tsConfig": "packages/next/tsconfig.lib.json", "tsConfig": "packages/next/tsconfig.lib.json",
"packageJson": "packages/next/package.json",
"main": "packages/next/index.ts", "main": "packages/next/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/next", "input": "packages/next",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/node"] "outputs": ["coverage/packages/node"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/node", "outputPath": "build/packages/node",
"tsConfig": "packages/node/tsconfig.lib.json", "tsConfig": "packages/node/tsconfig.lib.json",
"packageJson": "packages/node/package.json",
"main": "packages/node/index.ts", "main": "packages/node/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/node", "input": "packages/node",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/nx-plugin"] "outputs": ["coverage/packages/nx-plugin"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/nx-plugin", "outputPath": "build/packages/nx-plugin",
"tsConfig": "packages/nx-plugin/tsconfig.lib.json", "tsConfig": "packages/nx-plugin/tsconfig.lib.json",
"packageJson": "packages/nx-plugin/package.json",
"main": "packages/nx-plugin/index.ts", "main": "packages/nx-plugin/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/nx-plugin", "input": "packages/nx-plugin",

View File

@ -4,13 +4,11 @@
"projectType": "library", "projectType": "library",
"targets": { "targets": {
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/nx", "outputPath": "build/packages/nx",
"tsConfig": "packages/nx/tsconfig.lib.json", "tsConfig": "packages/nx/tsconfig.lib.json",
"packageJson": "packages/nx/package.json",
"main": "packages/nx/bin/nx.ts", "main": "packages/nx/bin/nx.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/nx", "input": "packages/nx",

View File

@ -26,13 +26,11 @@
"outputs": ["coverage/packages/react-native"] "outputs": ["coverage/packages/react-native"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/react-native", "outputPath": "build/packages/react-native",
"tsConfig": "packages/react-native/tsconfig.lib.json", "tsConfig": "packages/react-native/tsconfig.lib.json",
"packageJson": "packages/react-native/package.json",
"main": "packages/react-native/index.ts", "main": "packages/react-native/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
"packages/react-native/*.md", "packages/react-native/*.md",
{ {

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/react"] "outputs": ["coverage/packages/react"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/react", "outputPath": "build/packages/react",
"tsConfig": "packages/react/tsconfig.lib.json", "tsConfig": "packages/react/tsconfig.lib.json",
"packageJson": "packages/react/package.json",
"main": "packages/react/index.ts", "main": "packages/react/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/react", "input": "packages/react",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/storybook"] "outputs": ["coverage/packages/storybook"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/storybook", "outputPath": "build/packages/storybook",
"tsConfig": "packages/storybook/tsconfig.lib.json", "tsConfig": "packages/storybook/tsconfig.lib.json",
"packageJson": "packages/storybook/package.json",
"main": "packages/storybook/index.ts", "main": "packages/storybook/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/storybook", "input": "packages/storybook",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/tao"] "outputs": ["coverage/packages/tao"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/tao", "outputPath": "build/packages/tao",
"tsConfig": "packages/tao/tsconfig.lib.json", "tsConfig": "packages/tao/tsconfig.lib.json",
"packageJson": "packages/tao/package.json",
"main": "packages/tao/index.ts", "main": "packages/tao/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/tao", "input": "packages/tao",

View File

@ -12,13 +12,11 @@
"outputs": ["coverage/packages/web"] "outputs": ["coverage/packages/web"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/web", "outputPath": "build/packages/web",
"tsConfig": "packages/web/tsconfig.lib.json", "tsConfig": "packages/web/tsconfig.lib.json",
"packageJson": "packages/web/package.json",
"main": "packages/web/index.ts", "main": "packages/web/index.ts",
"updateBuildableProjectDepsInPackageJson": false,
"assets": [ "assets": [
{ {
"input": "packages/web", "input": "packages/web",

View File

@ -13,7 +13,7 @@
"outputs": ["coverage/packages/workspace"] "outputs": ["coverage/packages/workspace"]
}, },
"build-base": { "build-base": {
"executor": "@nrwl/node:package", "executor": "@nrwl/js:tsc",
"options": { "options": {
"outputPath": "build/packages/workspace", "outputPath": "build/packages/workspace",
"tsConfig": "packages/workspace/tsconfig.lib.json", "tsConfig": "packages/workspace/tsconfig.lib.json",
@ -24,8 +24,7 @@
{ {
"input": "packages/workspace", "input": "packages/workspace",
"glob": "**/files/**", "glob": "**/files/**",
"output": "/", "output": "/"
"dot": true
}, },
{ {
"input": "packages/workspace", "input": "packages/workspace",

View File

@ -10,7 +10,6 @@ import { DefaultTasksRunnerOptions } from './default-tasks-runner';
import { TaskStatus } from './tasks-runner'; import { TaskStatus } from './tasks-runner';
import { import {
calculateReverseDeps, calculateReverseDeps,
getCustomHasher,
getExecutorForTask, getExecutorForTask,
getOutputs, getOutputs,
removeTasksFromTaskGraph, removeTasksFromTaskGraph,
@ -22,6 +21,7 @@ export class TaskOrchestrator {
private workspace = new Workspaces(appRootPath); private workspace = new Workspaces(appRootPath);
private forkedProcessTaskRunner = new ForkedProcessTaskRunner(this.options); private forkedProcessTaskRunner = new ForkedProcessTaskRunner(this.options);
private tasksSchedule = new TasksSchedule( private tasksSchedule = new TasksSchedule(
this.hasher,
this.taskGraph, this.taskGraph,
this.workspace, this.workspace,
this.options this.options
@ -46,7 +46,7 @@ export class TaskOrchestrator {
async run() { async run() {
// initial scheduling // initial scheduling
this.tasksSchedule.scheduleNextTasks(); await this.tasksSchedule.scheduleNextTasks();
performance.mark('task-execution-begins'); performance.mark('task-execution-begins');
const threads = []; const threads = [];
@ -198,15 +198,6 @@ export class TaskOrchestrator {
batch batch
); );
const batchResultEntries = Object.entries(results); const batchResultEntries = Object.entries(results);
// Hash tasks after the batch is done
// Tasks that are not at the root might need to be updated
await Promise.all(
batchResultEntries.map(([taskId]) =>
this.hashTask(this.taskGraph.tasks[taskId])
)
);
return batchResultEntries.map(([taskId, result]) => ({ return batchResultEntries.map(([taskId, result]) => ({
task: this.taskGraph.tasks[taskId], task: this.taskGraph.tasks[taskId],
status: (result.success ? 'success' : 'failure') as TaskStatus, status: (result.success ? 'success' : 'failure') as TaskStatus,
@ -288,8 +279,6 @@ export class TaskOrchestrator {
// region Lifecycle // region Lifecycle
private async preRunSteps(tasks: Task[]) { private async preRunSteps(tasks: Task[]) {
// Hash the task before it is run
await Promise.all(tasks.map((task) => this.hashTask(task)));
this.options.lifeCycle.startTasks(tasks); this.options.lifeCycle.startTasks(tasks);
} }
@ -338,7 +327,7 @@ export class TaskOrchestrator {
}) })
); );
this.tasksSchedule.scheduleNextTasks(); await this.tasksSchedule.scheduleNextTasks();
} }
private complete( private complete(
@ -372,15 +361,6 @@ export class TaskOrchestrator {
// region utils // region utils
private async hashTask(task: Task) {
const customHasher = getCustomHasher(task, this.workspace);
const { value, details } = await (customHasher
? customHasher(task, this.taskGraph, this.hasher)
: this.hasher.hashTaskWithDepsAndContext(task));
task.hash = value;
task.hashDetails = details;
}
private pipeOutputCapture(task: Task) { private pipeOutputCapture(task: Task) {
try { try {
return ( return (

View File

@ -82,13 +82,22 @@ describe('TasksSchedule', () => {
}, },
}; };
taskSchedule = new TasksSchedule(taskGraph, workspace as Workspaces, { const hasher = {
lifeCycle: { hashTaskWithDepsAndContext: () => 'hash',
startTask: jest.fn(), } as any;
endTask: jest.fn(),
scheduleTask: jest.fn(), taskSchedule = new TasksSchedule(
}, hasher,
}); taskGraph,
workspace as Workspaces,
{
lifeCycle: {
startTask: jest.fn(),
endTask: jest.fn(),
scheduleTask: jest.fn(),
},
}
);
}); });
describe('Without Batch Mode', () => { describe('Without Batch Mode', () => {
@ -107,14 +116,14 @@ describe('TasksSchedule', () => {
expect(taskSchedule.nextTask()).toBeNull(); expect(taskSchedule.nextTask()).toBeNull();
}); });
it('should schedule root tasks first', () => { it('should schedule root tasks first', async () => {
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
expect(taskSchedule.nextTask()).toEqual(lib1Build); expect(taskSchedule.nextTask()).toEqual(lib1Build);
expect(taskSchedule.nextTask()).toEqual(app2Build); expect(taskSchedule.nextTask()).toEqual(app2Build);
}); });
it('should not schedule any tasks that still have uncompleted dependencies', () => { it('should not schedule any tasks that still have uncompleted dependencies', async () => {
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
taskSchedule.nextTask(); taskSchedule.nextTask();
taskSchedule.nextTask(); taskSchedule.nextTask();
expect(taskSchedule.nextTask()).toBeNull(); expect(taskSchedule.nextTask()).toBeNull();
@ -124,18 +133,18 @@ describe('TasksSchedule', () => {
expect(taskSchedule.nextTask()).toBeNull(); expect(taskSchedule.nextTask()).toBeNull();
}); });
it('should continue to schedule tasks that have completed dependencies', () => { it('should continue to schedule tasks that have completed dependencies', async () => {
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
taskSchedule.nextTask(); taskSchedule.nextTask();
taskSchedule.nextTask(); taskSchedule.nextTask();
taskSchedule.complete([lib1Build.id]); taskSchedule.complete([lib1Build.id]);
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
expect(taskSchedule.nextTask()).toEqual(app1Build); expect(taskSchedule.nextTask()).toEqual(app1Build);
}); });
it('should run out of tasks when they are all complete', () => { it('should run out of tasks when they are all complete', async () => {
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
taskSchedule.nextTask(); taskSchedule.nextTask();
taskSchedule.nextTask(); taskSchedule.nextTask();
taskSchedule.complete([lib1Build.id, app1Build.id, app2Build.id]); taskSchedule.complete([lib1Build.id, app1Build.id, app2Build.id]);
@ -143,8 +152,8 @@ describe('TasksSchedule', () => {
expect(taskSchedule.hasTasks()).toEqual(false); expect(taskSchedule.hasTasks()).toEqual(false);
}); });
it('should not schedule batches', () => { it('should not schedule batches', async () => {
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
expect(taskSchedule.nextTask()).not.toBeNull(); expect(taskSchedule.nextTask()).not.toBeNull();
@ -163,8 +172,8 @@ describe('TasksSchedule', () => {
process.env['NX_BATCH_MODE'] = original; process.env['NX_BATCH_MODE'] = original;
}); });
it('should schedule batches of tasks by different executors', () => { it('should schedule batches of tasks by different executors', async () => {
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
expect(taskSchedule.nextTask()).toBeNull(); expect(taskSchedule.nextTask()).toBeNull();
@ -181,8 +190,8 @@ describe('TasksSchedule', () => {
}); });
}); });
it('should run out of tasks when all batches are done', () => { it('should run out of tasks when all batches are done', async () => {
taskSchedule.scheduleNextTasks(); await taskSchedule.scheduleNextTasks();
taskSchedule.nextBatch(); taskSchedule.nextBatch();
taskSchedule.nextBatch(); taskSchedule.nextBatch();
taskSchedule.complete(['app1:build', 'lib1:build', 'app2:build']); taskSchedule.complete(['app1:build', 'lib1:build', 'app2:build']);

View File

@ -4,11 +4,13 @@ import { Workspaces } from '@nrwl/tao/src/shared/workspace';
import { import {
calculateReverseDeps, calculateReverseDeps,
getCustomHasher,
getExecutorForTask, getExecutorForTask,
getExecutorNameForTask, getExecutorNameForTask,
removeTasksFromTaskGraph, removeTasksFromTaskGraph,
} from './utils'; } from './utils';
import { DefaultTasksRunnerOptions } from './default-tasks-runner'; import { DefaultTasksRunnerOptions } from './default-tasks-runner';
import { Hasher } from '@nrwl/workspace/src/core/hasher/hasher';
export interface Batch { export interface Batch {
executorName: string; executorName: string;
@ -26,18 +28,19 @@ export class TasksSchedule {
private completedTasks = new Set<string>(); private completedTasks = new Set<string>();
constructor( constructor(
private readonly hasher: Hasher,
private taskGraph: TaskGraph, private taskGraph: TaskGraph,
private workspace: Workspaces, private workspace: Workspaces,
private options: DefaultTasksRunnerOptions private options: DefaultTasksRunnerOptions
) {} ) {}
public scheduleNextTasks() { public async scheduleNextTasks() {
if (process.env.NX_BATCH_MODE === 'true') { if (process.env.NX_BATCH_MODE === 'true') {
this.scheduleBatches(); this.scheduleBatches();
} }
for (let root of this.notScheduledTaskGraph.roots) { for (let root of this.notScheduledTaskGraph.roots) {
if (this.canBeScheduled(root)) { if (this.canBeScheduled(root)) {
this.scheduleTask(root); await this.scheduleTask(root);
} }
} }
} }
@ -75,8 +78,9 @@ export class TasksSchedule {
: null; : null;
} }
private scheduleTask(taskId: string) { private async scheduleTask(taskId: string) {
const task = this.taskGraph.tasks[taskId]; const task = this.taskGraph.tasks[taskId];
await this.hashTask(task);
this.notScheduledTaskGraph = removeTasksFromTaskGraph( this.notScheduledTaskGraph = removeTasksFromTaskGraph(
this.notScheduledTaskGraph, this.notScheduledTaskGraph,
@ -155,4 +159,13 @@ export class TasksSchedule {
this.completedTasks.has(id) this.completedTasks.has(id)
); );
} }
private async hashTask(task: Task) {
const customHasher = getCustomHasher(task, this.workspace);
const { value, details } = await (customHasher
? customHasher(task, this.taskGraph, this.hasher)
: this.hasher.hashTaskWithDepsAndContext(task));
task.hash = value;
task.hashDetails = details;
}
} }

View File

@ -4,7 +4,7 @@
"projectType": "library", "projectType": "library",
"targets": { "targets": {
"build-base": { "build-base": {
"executor": "@nrwl/workspace:tsc", "executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"], "outputs": ["{options.outputPath}"],
"options": { "options": {
"outputPath": "dist/typedoc-theme", "outputPath": "dist/typedoc-theme",

1599
yarn.lock

File diff suppressed because it is too large Load Diff