@nx/workspace 16.10.0 → 17.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators.json +0 -12
- package/migrations.json +0 -135
- package/package.json +4 -4
- package/src/generators/ci-workflow/ci-workflow.js +2 -1
- package/src/generators/new/files-integrated-repo/__dot__gitignore +2 -0
- package/src/generators/new/files-package-based-repo/__dot__gitignore +2 -0
- package/src/generators/new/files-root-app/__dot__gitignore +2 -0
- package/src/generators/new/generate-workspace-files.js +13 -13
- package/src/utils/testing-utils.d.ts +0 -9
- package/src/utils/testing-utils.js +1 -55
- package/testing.d.ts +1 -1
- package/testing.js +1 -3
- package/src/generators/workspace-generator/schema.d.ts +0 -1
- package/src/generators/workspace-generator/schema.json +0 -9
- package/src/generators/workspace-generator/workspace-generator.d.ts +0 -3
- package/src/generators/workspace-generator/workspace-generator.js +0 -15
- package/src/migrations/update-12-5-0/add-target-dependencies.d.ts +0 -3
- package/src/migrations/update-12-5-0/add-target-dependencies.js +0 -36
- package/src/migrations/update-13-0-0/config-locations/config-locations.d.ts +0 -2
- package/src/migrations/update-13-0-0/config-locations/config-locations.js +0 -30
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.d.ts +0 -3
- package/src/migrations/update-13-0-0/set-default-base-if-not-set.js +0 -24
- package/src/migrations/update-13-10-0/update-decorate-cli.d.ts +0 -3
- package/src/migrations/update-13-10-0/update-decorate-cli.js +0 -12
- package/src/migrations/update-13-10-0/update-tasks-runner.d.ts +0 -3
- package/src/migrations/update-13-10-0/update-tasks-runner.js +0 -15
- package/src/migrations/update-13-2-0/set-parallel-default.d.ts +0 -3
- package/src/migrations/update-13-2-0/set-parallel-default.js +0 -22
- package/src/migrations/update-13-3-0/update-tsc-executor-location.d.ts +0 -3
- package/src/migrations/update-13-3-0/update-tsc-executor-location.js +0 -27
- package/src/migrations/update-13-6-0/remove-old-task-runner-options.d.ts +0 -3
- package/src/migrations/update-13-6-0/remove-old-task-runner-options.js +0 -15
- package/src/migrations/update-13-9-0/replace-tao-with-nx.d.ts +0 -3
- package/src/migrations/update-13-9-0/replace-tao-with-nx.js +0 -26
- package/src/migrations/update-13-9-0/update-decorate-cli.d.ts +0 -3
- package/src/migrations/update-13-9-0/update-decorate-cli.js +0 -11
- package/src/migrations/update-14-0-0/change-npm-script-executor.d.ts +0 -3
- package/src/migrations/update-14-0-0/change-npm-script-executor.js +0 -16
- package/src/migrations/update-14-0-0/change-nx-json-presets.d.ts +0 -3
- package/src/migrations/update-14-0-0/change-nx-json-presets.js +0 -20
- package/src/migrations/update-14-2-0/enable-source-analysis.d.ts +0 -3
- package/src/migrations/update-14-2-0/enable-source-analysis.js +0 -23
- package/src/migrations/update-14-8-0/change-run-commands-executor.d.ts +0 -3
- package/src/migrations/update-14-8-0/change-run-commands-executor.js +0 -16
- package/src/utilities/buildable-libs-utils.d.ts +0 -41
- package/src/utilities/buildable-libs-utils.js +0 -316
package/generators.json
CHANGED
|
@@ -19,12 +19,6 @@
|
|
|
19
19
|
"schema": "./src/generators/convert-to-monorepo/schema.json",
|
|
20
20
|
"description": "Convert a Nx project to a monorepo."
|
|
21
21
|
},
|
|
22
|
-
"workspace-generator": {
|
|
23
|
-
"factory": "./src/generators/workspace-generator/workspace-generator",
|
|
24
|
-
"schema": "./src/generators/workspace-generator/schema.json",
|
|
25
|
-
"aliases": ["workspace-schematic"],
|
|
26
|
-
"description": "Generates a workspace generator."
|
|
27
|
-
},
|
|
28
22
|
"run-commands": {
|
|
29
23
|
"factory": "./src/generators/run-commands/run-commands#runCommandsSchematic",
|
|
30
24
|
"schema": "./src/generators/run-commands/schema.json",
|
|
@@ -69,12 +63,6 @@
|
|
|
69
63
|
"description": "Create a workspace.",
|
|
70
64
|
"hidden": true
|
|
71
65
|
},
|
|
72
|
-
"workspace-generator": {
|
|
73
|
-
"factory": "./src/generators/workspace-generator/workspace-generator",
|
|
74
|
-
"schema": "./src/generators/workspace-generator/schema.json",
|
|
75
|
-
"aliases": ["workspace-schematic"],
|
|
76
|
-
"description": "Generates a workspace generator."
|
|
77
|
-
},
|
|
78
66
|
"run-commands": {
|
|
79
67
|
"factory": "./src/generators/run-commands/run-commands#runCommandsGenerator",
|
|
80
68
|
"schema": "./src/generators/run-commands/schema.json",
|
package/migrations.json
CHANGED
|
@@ -1,83 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"generators": {
|
|
3
|
-
"add-target-dependencies": {
|
|
4
|
-
"version": "12.5.0-beta.1",
|
|
5
|
-
"description": "Rename the workspace-schematic script into workspace-generator script",
|
|
6
|
-
"factory": "./src/migrations/update-12-5-0/add-target-dependencies",
|
|
7
|
-
"cli": "nx"
|
|
8
|
-
},
|
|
9
|
-
"set-default-base-if-not-set": {
|
|
10
|
-
"version": "13.0.0-beta.1",
|
|
11
|
-
"description": "Add default base to nx.json if its not currently set",
|
|
12
|
-
"factory": "./src/migrations/update-13-0-0/set-default-base-if-not-set",
|
|
13
|
-
"cli": "nx"
|
|
14
|
-
},
|
|
15
|
-
"13-0-0-config-locations": {
|
|
16
|
-
"version": "13.0.0-beta.4",
|
|
17
|
-
"description": "Move global settings into nx.json, and project specific settings into workspace.json",
|
|
18
|
-
"cli": "nx",
|
|
19
|
-
"implementation": "./src/migrations/update-13-0-0/config-locations/config-locations"
|
|
20
|
-
},
|
|
21
|
-
"set-parallel-default": {
|
|
22
|
-
"version": "13.2.0",
|
|
23
|
-
"description": "Set --parallel=1 for existing repos to preserve the existing behavior",
|
|
24
|
-
"cli": "nx",
|
|
25
|
-
"implementation": "./src/migrations/update-13-2-0/set-parallel-default"
|
|
26
|
-
},
|
|
27
|
-
"13-3-0-tsc-location": {
|
|
28
|
-
"version": "13.3.0-beta.0",
|
|
29
|
-
"description": "@nrwl/workspace:tsc is now @nrwl/js:tsc",
|
|
30
|
-
"cli": "nx",
|
|
31
|
-
"implementation": "./src/migrations/update-13-3-0/update-tsc-executor-location"
|
|
32
|
-
},
|
|
33
|
-
"13-6-0-remove-old-task-runner-options": {
|
|
34
|
-
"version": "13.6.0-beta.0",
|
|
35
|
-
"description": "Remove old options that are no longer used",
|
|
36
|
-
"cli": "nx",
|
|
37
|
-
"implementation": "./src/migrations/update-13-6-0/remove-old-task-runner-options"
|
|
38
|
-
},
|
|
39
|
-
"13-9-0-replace-tao-with-nx": {
|
|
40
|
-
"version": "13.9.0-beta.0",
|
|
41
|
-
"description": "Replace @nrwl/tao with nx",
|
|
42
|
-
"cli": "nx",
|
|
43
|
-
"implementation": "./src/migrations/update-13-9-0/replace-tao-with-nx"
|
|
44
|
-
},
|
|
45
|
-
"13-10-0-update-decorate-cli": {
|
|
46
|
-
"version": "13.10.0-beta.0",
|
|
47
|
-
"description": "Update the decorate-angular-cli script to require nx instead of @nrwl/cli",
|
|
48
|
-
"cli": "nx",
|
|
49
|
-
"implementation": "./src/migrations/update-13-10-0/update-decorate-cli"
|
|
50
|
-
},
|
|
51
|
-
"13-10-0-update-tasks-runner": {
|
|
52
|
-
"version": "13.10.0-beta.0",
|
|
53
|
-
"description": "Update the tasks runner property to import it from the nx package instead of @nrwl/workspace",
|
|
54
|
-
"cli": "nx",
|
|
55
|
-
"implementation": "./src/migrations/update-13-10-0/update-tasks-runner"
|
|
56
|
-
},
|
|
57
|
-
"14-0-0-change-nx-json-presets": {
|
|
58
|
-
"version": "14.0.0-beta.0",
|
|
59
|
-
"description": "Changes the presets in nx.json to come from the nx package",
|
|
60
|
-
"cli": "nx",
|
|
61
|
-
"implementation": "./src/migrations/update-14-0-0/change-nx-json-presets"
|
|
62
|
-
},
|
|
63
|
-
"14-0-0-change-npm-script-executor": {
|
|
64
|
-
"version": "14.0.0-beta.0",
|
|
65
|
-
"description": "Migrates from @nrwl/workspace:run-script to nx:run-script",
|
|
66
|
-
"cli": "nx",
|
|
67
|
-
"implementation": "./src/migrations/update-14-0-0/change-npm-script-executor"
|
|
68
|
-
},
|
|
69
|
-
"14-2-0-enable-source-analysis": {
|
|
70
|
-
"version": "14.2.0",
|
|
71
|
-
"description": "Explicitly enable sourceAnalysis for all workspaces extending from npm.json or core.json (this was default behavior prior to 14.2)",
|
|
72
|
-
"cli": "nx",
|
|
73
|
-
"implementation": "./src/migrations/update-14-2-0/enable-source-analysis"
|
|
74
|
-
},
|
|
75
|
-
"14-8-0-change-run-commands-executor": {
|
|
76
|
-
"version": "14.8.0-beta.0",
|
|
77
|
-
"description": "Migrates from @nrwl/workspace:run-commands to nx:run-commands",
|
|
78
|
-
"cli": "nx",
|
|
79
|
-
"implementation": "./src/migrations/update-14-8-0/change-run-commands-executor"
|
|
80
|
-
},
|
|
81
3
|
"15-7-0-split-configuration-into-project-json-files": {
|
|
82
4
|
"version": "15.7.0-beta.0",
|
|
83
5
|
"description": "Split global configuration files (e.g., workspace.json) into individual project.json files.",
|
|
@@ -104,63 +26,6 @@
|
|
|
104
26
|
}
|
|
105
27
|
},
|
|
106
28
|
"packageJsonUpdates": {
|
|
107
|
-
"12.5.0": {
|
|
108
|
-
"version": "12.5.0",
|
|
109
|
-
"packages": {
|
|
110
|
-
"prettier": {
|
|
111
|
-
"version": "^2.3.1",
|
|
112
|
-
"alwaysAddToPackageJson": false
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
"12.6.0": {
|
|
117
|
-
"version": "12.6.0-beta.8",
|
|
118
|
-
"packages": {
|
|
119
|
-
"typescript": {
|
|
120
|
-
"version": "~4.3.5"
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
"12.7.0": {
|
|
125
|
-
"version": "12.7.0-beta.0",
|
|
126
|
-
"packages": {
|
|
127
|
-
"dotenv": {
|
|
128
|
-
"version": "~10.0.0"
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
"13.5.0": {
|
|
133
|
-
"version": "13.5.0",
|
|
134
|
-
"packages": {
|
|
135
|
-
"prettier": {
|
|
136
|
-
"version": "^2.5.1",
|
|
137
|
-
"alwaysAddToPackageJson": false
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
"14.2.0": {
|
|
142
|
-
"version": "14.2.0-beta.4",
|
|
143
|
-
"packages": {
|
|
144
|
-
"typescript": {
|
|
145
|
-
"version": "~4.7.2",
|
|
146
|
-
"alwaysAddToPackageJson": false
|
|
147
|
-
},
|
|
148
|
-
"prettier": {
|
|
149
|
-
"version": "^2.6.2",
|
|
150
|
-
"alwaysAddToPackageJson": false
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
"14.8.0": {
|
|
155
|
-
"version": "14.8.0-beta.0",
|
|
156
|
-
"x-prompt": "Do you want to update to TypeScript v4.8?",
|
|
157
|
-
"packages": {
|
|
158
|
-
"typescript": {
|
|
159
|
-
"version": "~4.8.2",
|
|
160
|
-
"alwaysAddToPackageJson": false
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
29
|
"15.8.0": {
|
|
165
30
|
"version": "15.8.0-beta.2",
|
|
166
31
|
"x-prompt": "Do you want to update to TypeScript v4.9?",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Workspace plugin contains executors and generators that are useful for any Nx workspace. It should be present in every Nx workspace and other plugins build on it.",
|
|
6
6
|
"repository": {
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@nx/devkit": "
|
|
64
|
+
"@nx/devkit": "17.0.0-beta.2",
|
|
65
65
|
"chalk": "^4.1.0",
|
|
66
66
|
"enquirer": "~2.3.6",
|
|
67
67
|
"ignore": "^5.0.4",
|
|
68
68
|
"rxjs": "^7.8.0",
|
|
69
69
|
"tslib": "^2.3.0",
|
|
70
70
|
"yargs-parser": "21.1.1",
|
|
71
|
-
"nx": "
|
|
72
|
-
"@nrwl/workspace": "
|
|
71
|
+
"nx": "17.0.0-beta.2",
|
|
72
|
+
"@nrwl/workspace": "17.0.0-beta.2"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
@@ -8,7 +8,8 @@ async function ciWorkflowGenerator(host, schema) {
|
|
|
8
8
|
const ci = schema.ci;
|
|
9
9
|
const options = normalizeOptions(schema);
|
|
10
10
|
const nxJson = (0, devkit_1.readJson)(host, 'nx.json');
|
|
11
|
-
const nxCloudUsed =
|
|
11
|
+
const nxCloudUsed = nxJson.nxCloudAccessToken ??
|
|
12
|
+
Object.values(nxJson.tasksRunnerOptions ?? {}).find((r) => r.runner == '@nrwl/nx-cloud' || r.runner == 'nx-cloud');
|
|
12
13
|
if (!nxCloudUsed) {
|
|
13
14
|
throw new Error('This workspace is not connected to Nx Cloud.');
|
|
14
15
|
}
|
|
@@ -38,8 +38,6 @@ function setPresetProperty(tree, options) {
|
|
|
38
38
|
(0, devkit_1.updateJson)(tree, (0, path_1.join)(options.directory, 'nx.json'), (json) => {
|
|
39
39
|
if (options.preset === presets_1.Preset.NPM) {
|
|
40
40
|
addPropertyWithStableKeys(json, 'extends', 'nx/presets/npm.json');
|
|
41
|
-
delete json.implicitDependencies;
|
|
42
|
-
delete json.targetDefaults;
|
|
43
41
|
}
|
|
44
42
|
return json;
|
|
45
43
|
});
|
|
@@ -50,18 +48,20 @@ function createNxJson(tree, { directory, defaultBase, preset }) {
|
|
|
50
48
|
affected: {
|
|
51
49
|
defaultBase,
|
|
52
50
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
targetDefaults: {
|
|
52
|
+
build: {
|
|
53
|
+
cache: true,
|
|
54
|
+
dependsOn: ['^build'],
|
|
55
|
+
},
|
|
56
|
+
lint: {
|
|
57
|
+
cache: true,
|
|
58
|
+
},
|
|
59
|
+
test: {
|
|
60
|
+
cache: true,
|
|
61
|
+
},
|
|
62
|
+
e2e: {
|
|
63
|
+
cache: true,
|
|
59
64
|
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
nxJson.targetDefaults = {
|
|
63
|
-
build: {
|
|
64
|
-
dependsOn: ['^build'],
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
if (defaultBase === 'main') {
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import type { Tree } from '@angular-devkit/schematics';
|
|
2
1
|
import { Architect, BuilderContext, Target } from '@angular-devkit/architect';
|
|
3
2
|
import { TestingArchitectHost } from '@angular-devkit/architect/testing';
|
|
4
3
|
import { json, JsonObject } from '@angular-devkit/core';
|
|
5
4
|
import { ScheduleOptions } from '@angular-devkit/architect/src/api';
|
|
6
5
|
import { LoggerApi, LogLevel } from '@angular-devkit/core/src/logger';
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated This will be removed in v17. Prefer writing Nx Generators with @nx/devkit. Use tree.read(filePath, 'utf-8') instead.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getFileContent(tree: Tree, path: string): string;
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated This will be removed in v17. Prefer writing Nx Generators with @nx/devkit. Tests for Generators can use 'createTreeWithEmptyWorkspace()' from @nx/devkit/testing.
|
|
13
|
-
*/
|
|
14
|
-
export declare function createEmptyWorkspace(tree: Tree): Tree;
|
|
15
6
|
declare class NoopLogger implements LoggerApi {
|
|
16
7
|
private _log;
|
|
17
8
|
createChild(name: string): any;
|
|
@@ -1,60 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockBuilderContext =
|
|
4
|
-
const core_1 = require("@angular-devkit/core/src/workspace/core");
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated This will be removed in v17. Prefer writing Nx Generators with @nx/devkit. Use tree.read(filePath, 'utf-8') instead.
|
|
7
|
-
*/
|
|
8
|
-
function getFileContent(tree, path) {
|
|
9
|
-
const fileEntry = tree.get(path);
|
|
10
|
-
if (!fileEntry) {
|
|
11
|
-
throw new Error(`The file (${path}) does not exist.`);
|
|
12
|
-
}
|
|
13
|
-
return fileEntry.content.toString();
|
|
14
|
-
}
|
|
15
|
-
exports.getFileContent = getFileContent;
|
|
16
|
-
/**
|
|
17
|
-
* @deprecated This will be removed in v17. Prefer writing Nx Generators with @nx/devkit. Tests for Generators can use 'createTreeWithEmptyWorkspace()' from @nx/devkit/testing.
|
|
18
|
-
*/
|
|
19
|
-
function createEmptyWorkspace(tree) {
|
|
20
|
-
(0, core_1._test_addWorkspaceFile)('workspace.json', core_1.WorkspaceFormat.JSON);
|
|
21
|
-
tree.create('/workspace.json', JSON.stringify({ version: 1, projects: {}, newProjectRoot: '' }));
|
|
22
|
-
tree.create('/package.json', JSON.stringify({
|
|
23
|
-
name: 'test-name',
|
|
24
|
-
dependencies: {},
|
|
25
|
-
devDependencies: {},
|
|
26
|
-
}));
|
|
27
|
-
tree.create('/nx.json', JSON.stringify({
|
|
28
|
-
npmScope: 'proj',
|
|
29
|
-
projects: {},
|
|
30
|
-
affected: {
|
|
31
|
-
defaultBase: 'main',
|
|
32
|
-
},
|
|
33
|
-
tasksRunnerOptions: {
|
|
34
|
-
default: {
|
|
35
|
-
runner: 'nx/tasks-runners/default',
|
|
36
|
-
options: {
|
|
37
|
-
cacheableOperations: ['build', 'lint', 'test', 'e2e'],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
}));
|
|
42
|
-
tree.create('/tsconfig.base.json', JSON.stringify({ compilerOptions: { paths: {} } }));
|
|
43
|
-
tree.create('/tslint.json', JSON.stringify({
|
|
44
|
-
rules: {
|
|
45
|
-
'nx-enforce-module-boundaries': [
|
|
46
|
-
true,
|
|
47
|
-
{
|
|
48
|
-
npmScope: '<%= npmScope %>',
|
|
49
|
-
lazyLoad: [],
|
|
50
|
-
allow: [],
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
},
|
|
54
|
-
}));
|
|
55
|
-
return tree;
|
|
56
|
-
}
|
|
57
|
-
exports.createEmptyWorkspace = createEmptyWorkspace;
|
|
3
|
+
exports.MockBuilderContext = void 0;
|
|
58
4
|
class NoopLogger {
|
|
59
5
|
constructor() {
|
|
60
6
|
this._log = '';
|
package/testing.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { MockBuilderContext } from './src/utils/testing-utils';
|
package/testing.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockBuilderContext =
|
|
3
|
+
exports.MockBuilderContext = void 0;
|
|
4
4
|
var testing_utils_1 = require("./src/utils/testing-utils");
|
|
5
|
-
Object.defineProperty(exports, "createEmptyWorkspace", { enumerable: true, get: function () { return testing_utils_1.createEmptyWorkspace; } });
|
|
6
|
-
Object.defineProperty(exports, "getFileContent", { enumerable: true, get: function () { return testing_utils_1.getFileContent; } });
|
|
7
5
|
Object.defineProperty(exports, "MockBuilderContext", { enumerable: true, get: function () { return testing_utils_1.MockBuilderContext; } });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export interface Schema {}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
async function default_1(host, schema) {
|
|
5
|
-
const message = (0, devkit_1.stripIndents) `Workspace Generators are no longer supported. Instead,
|
|
6
|
-
Nx now supports executing generators or executors from local plugins. To get
|
|
7
|
-
started, install @nx/plugin and run \`nx g plugin\`.
|
|
8
|
-
|
|
9
|
-
Afterwards, or if you already have an Nx plugin, you can run
|
|
10
|
-
\`nx g generator --project {my-plugin}\` to add a new generator.
|
|
11
|
-
|
|
12
|
-
For more information, see: https://nx.dev/deprecated/workspace-generators`;
|
|
13
|
-
throw new Error(message);
|
|
14
|
-
}
|
|
15
|
-
exports.default = default_1;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setTargetDependencies = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const output_1 = require("../../utilities/output");
|
|
6
|
-
async function setTargetDependencies(host) {
|
|
7
|
-
const config = (0, devkit_1.readNxJson)(host);
|
|
8
|
-
const strictlyOrderedTargets = config.tasksRunnerOptions?.['default']?.options
|
|
9
|
-
?.strictlyOrderedTargets || ['build'];
|
|
10
|
-
delete config.tasksRunnerOptions?.['default']?.options
|
|
11
|
-
?.strictlyOrderedTargets;
|
|
12
|
-
config.targetDependencies = config.targetDependencies ?? {};
|
|
13
|
-
const updatedStrictlyOrderedTargets = [];
|
|
14
|
-
strictlyOrderedTargets.forEach((target) => {
|
|
15
|
-
if (!config.targetDependencies[target]) {
|
|
16
|
-
config.targetDependencies[target] = [
|
|
17
|
-
{ target, projects: 'dependencies' },
|
|
18
|
-
];
|
|
19
|
-
updatedStrictlyOrderedTargets.push(target);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
(0, devkit_1.updateNxJson)(host, config);
|
|
23
|
-
if (updatedStrictlyOrderedTargets.length > 0) {
|
|
24
|
-
output_1.output.note({
|
|
25
|
-
title: 'Target dependencies have been updated in nx.json',
|
|
26
|
-
bodyLines: [
|
|
27
|
-
`Nx has deprecated strictlyOrderedTargets in favour of targetDependencies.`,
|
|
28
|
-
`Based on your configuration the migration has configured targetDependencies for the following targets: ${updatedStrictlyOrderedTargets.join(', ')}.`,
|
|
29
|
-
`Read more here: https://nx.dev/reference/project-configuration`,
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
await (0, devkit_1.formatFiles)(host);
|
|
34
|
-
}
|
|
35
|
-
exports.setTargetDependencies = setTargetDependencies;
|
|
36
|
-
exports.default = setTargetDependencies;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const devkit_1 = require("@nx/devkit");
|
|
4
|
-
async function update(tree) {
|
|
5
|
-
const nxJson = (0, devkit_1.readJson)(tree, 'nx.json');
|
|
6
|
-
// updateProjectConfiguration automatically saves the project opts into workspace/project.json
|
|
7
|
-
if (nxJson.projects) {
|
|
8
|
-
Object.entries(nxJson.projects).forEach(([p, nxJsonConfiguration]) => {
|
|
9
|
-
const configuration = (0, devkit_1.readProjectConfiguration)(tree, p);
|
|
10
|
-
configuration.tags ??= nxJsonConfiguration.tags;
|
|
11
|
-
configuration.implicitDependencies ??=
|
|
12
|
-
nxJsonConfiguration.implicitDependencies;
|
|
13
|
-
(0, devkit_1.updateProjectConfiguration)(tree, p, configuration);
|
|
14
|
-
});
|
|
15
|
-
delete nxJson.projects;
|
|
16
|
-
}
|
|
17
|
-
(0, devkit_1.writeJson)(tree, 'nx.json', nxJson);
|
|
18
|
-
movePropertiesAreInNewLocations(tree); // move config options to new spots.
|
|
19
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
20
|
-
}
|
|
21
|
-
exports.default = update;
|
|
22
|
-
/**
|
|
23
|
-
* `updateWorkspaceConfiguration` already handles
|
|
24
|
-
* placing properties in their new locations, so
|
|
25
|
-
* reading + updating it ensures that props are placed
|
|
26
|
-
* correctly.
|
|
27
|
-
*/
|
|
28
|
-
function movePropertiesAreInNewLocations(tree) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setDefaultBaseIfNotSet = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const output_1 = require("../../utilities/output");
|
|
6
|
-
async function setDefaultBaseIfNotSet(host) {
|
|
7
|
-
const config = (0, devkit_1.readNxJson)(host);
|
|
8
|
-
if (!config.affected?.defaultBase) {
|
|
9
|
-
config.affected ??= {};
|
|
10
|
-
config.affected.defaultBase ??= 'master';
|
|
11
|
-
output_1.output.note({
|
|
12
|
-
title: 'Default Base has been set in nx.json',
|
|
13
|
-
bodyLines: [
|
|
14
|
-
`Nx is moving to "main" as the default branch.`,
|
|
15
|
-
`To avoid your current defaults changing, defaultBase has been set to "master" in nx.json`,
|
|
16
|
-
`Read more here: https://nx.dev/using-nx/affected`,
|
|
17
|
-
],
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
(0, devkit_1.updateNxJson)(host, config);
|
|
21
|
-
await (0, devkit_1.formatFiles)(host);
|
|
22
|
-
}
|
|
23
|
-
exports.setDefaultBaseIfNotSet = setDefaultBaseIfNotSet;
|
|
24
|
-
exports.default = setDefaultBaseIfNotSet;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDecorateAngularCLI = void 0;
|
|
4
|
-
function updateDecorateAngularCLI(host) {
|
|
5
|
-
const decorate = host.read('decorate-angular-cli.js')?.toString();
|
|
6
|
-
if (decorate) {
|
|
7
|
-
host.write('decorate-angular-cli.js', decorate.replace('@nrwl/cli/lib/decorate-cli', 'nx/src/adapter/decorate-cli'));
|
|
8
|
-
host.write('decorate-angular-cli.js', decorate.replace('nx/src/cli/decorate-cli', 'nx/src/adapter/decorate-cli'));
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.updateDecorateAngularCLI = updateDecorateAngularCLI;
|
|
12
|
-
exports.default = updateDecorateAngularCLI;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateTasksRunner = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function updateTasksRunner(host) {
|
|
6
|
-
const config = (0, devkit_1.readNxJson)(host);
|
|
7
|
-
if (config?.tasksRunnerOptions?.['default'] &&
|
|
8
|
-
config?.tasksRunnerOptions['default'].runner ==
|
|
9
|
-
'@nrwl/workspace/tasks-runners/default') {
|
|
10
|
-
config.tasksRunnerOptions['default'].runner = 'nx/tasks-runners/default';
|
|
11
|
-
}
|
|
12
|
-
(0, devkit_1.updateNxJson)(host, config);
|
|
13
|
-
}
|
|
14
|
-
exports.updateTasksRunner = updateTasksRunner;
|
|
15
|
-
exports.default = updateTasksRunner;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setParallelDefault = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
async function setParallelDefault(host) {
|
|
6
|
-
const config = (0, devkit_1.readNxJson)(host);
|
|
7
|
-
const defaultTaskRunnerOptions = config.tasksRunnerOptions?.['default']?.options;
|
|
8
|
-
if (defaultTaskRunnerOptions) {
|
|
9
|
-
if (defaultTaskRunnerOptions.parallel) {
|
|
10
|
-
defaultTaskRunnerOptions.parallel =
|
|
11
|
-
defaultTaskRunnerOptions.maxParallel || 3;
|
|
12
|
-
delete defaultTaskRunnerOptions.maxParallel;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
defaultTaskRunnerOptions.parallel = 1;
|
|
16
|
-
}
|
|
17
|
-
(0, devkit_1.updateNxJson)(host, config);
|
|
18
|
-
}
|
|
19
|
-
await (0, devkit_1.formatFiles)(host);
|
|
20
|
-
}
|
|
21
|
-
exports.setParallelDefault = setParallelDefault;
|
|
22
|
-
exports.default = setParallelDefault;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateTscExecutorLocation = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const versions_1 = require("../../utils/versions");
|
|
6
|
-
async function updateTscExecutorLocation(host) {
|
|
7
|
-
const projects = (0, devkit_1.getProjects)(host);
|
|
8
|
-
let used = false;
|
|
9
|
-
for (const [project, projectConfig] of projects.entries()) {
|
|
10
|
-
for (const [target, targetConfig] of Object.entries(projectConfig.targets || {})) {
|
|
11
|
-
if (targetConfig.executor === '@nrwl/workspace:tsc') {
|
|
12
|
-
projectConfig.targets[target].executor = '@nrwl/js:tsc';
|
|
13
|
-
(0, devkit_1.updateProjectConfiguration)(host, project, projectConfig);
|
|
14
|
-
used = true;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (used) {
|
|
19
|
-
(0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
20
|
-
'@nrwl/js': versions_1.nxVersion,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
await (0, devkit_1.formatFiles)(host);
|
|
24
|
-
return () => (0, devkit_1.installPackagesTask)(host);
|
|
25
|
-
}
|
|
26
|
-
exports.updateTscExecutorLocation = updateTscExecutorLocation;
|
|
27
|
-
exports.default = updateTscExecutorLocation;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeOldTaskRunnerOptions = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function removeOldTaskRunnerOptions(host) {
|
|
6
|
-
const nxJson = (0, devkit_1.readNxJson)(host);
|
|
7
|
-
const options = nxJson.tasksRunnerOptions?.['default']?.options;
|
|
8
|
-
if (options) {
|
|
9
|
-
delete options.scan;
|
|
10
|
-
delete options.analytics;
|
|
11
|
-
(0, devkit_1.updateNxJson)(host, nxJson);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.removeOldTaskRunnerOptions = removeOldTaskRunnerOptions;
|
|
15
|
-
exports.default = removeOldTaskRunnerOptions;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceTaoWithNx = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
function replaceTaoWithNx(host) {
|
|
6
|
-
(0, devkit_1.updateJson)(host, 'package.json', (json) => {
|
|
7
|
-
if (json.dependencies?.['@nrwl/workspace']) {
|
|
8
|
-
json.dependencies['nx'] = json.dependencies['@nrwl/workspace'];
|
|
9
|
-
}
|
|
10
|
-
else if (json.devDependencies?.['@nrwl/workspace']) {
|
|
11
|
-
json.devDependencies['nx'] = json.devDependencies['@nrwl/workspace'];
|
|
12
|
-
}
|
|
13
|
-
removeTao(json.dependencies);
|
|
14
|
-
removeTao(json.devDependencies);
|
|
15
|
-
return json;
|
|
16
|
-
});
|
|
17
|
-
const pmc = (0, devkit_1.getPackageManagerCommand)();
|
|
18
|
-
devkit_1.logger.info(`Please run ${pmc.install} to ensure the correct version of Nx is installed.`);
|
|
19
|
-
}
|
|
20
|
-
exports.replaceTaoWithNx = replaceTaoWithNx;
|
|
21
|
-
function removeTao(json) {
|
|
22
|
-
if (!json)
|
|
23
|
-
return;
|
|
24
|
-
json['@nrwl/tao'] = undefined;
|
|
25
|
-
}
|
|
26
|
-
exports.default = replaceTaoWithNx;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateDecorateAngularCLI = void 0;
|
|
4
|
-
function updateDecorateAngularCLI(host) {
|
|
5
|
-
const decorate = host.read('decorate-angular-cli.js')?.toString();
|
|
6
|
-
if (decorate) {
|
|
7
|
-
host.write('decorate-angular-cli.js', decorate.replace('@nrwl/cli/lib/decorate-cli', 'nx/src/cli/decorate-cli'));
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.updateDecorateAngularCLI = updateDecorateAngularCLI;
|
|
11
|
-
exports.default = updateDecorateAngularCLI;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeNpmScriptExecutor = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
async function changeNpmScriptExecutor(tree) {
|
|
7
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/workspace:run-script', (currentValue, project, target) => {
|
|
8
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
9
|
-
const targetConfig = projectConfig.targets[target];
|
|
10
|
-
targetConfig.executor = 'nx:run-script';
|
|
11
|
-
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfig);
|
|
12
|
-
});
|
|
13
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
14
|
-
}
|
|
15
|
-
exports.changeNpmScriptExecutor = changeNpmScriptExecutor;
|
|
16
|
-
exports.default = changeNpmScriptExecutor;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeNxJsonPresets = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
async function changeNxJsonPresets(tree) {
|
|
6
|
-
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
7
|
-
const replacements = {
|
|
8
|
-
'@nrwl/workspace/presets/npm.json': 'nx/presets/npm.json',
|
|
9
|
-
'@nrwl/workspace/presets/core.json': 'nx/presets/core.json',
|
|
10
|
-
};
|
|
11
|
-
if (nxJson.extends && replacements[nxJson.extends]) {
|
|
12
|
-
(0, devkit_1.updateNxJson)(tree, {
|
|
13
|
-
...nxJson,
|
|
14
|
-
extends: replacements[nxJson.extends],
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
18
|
-
}
|
|
19
|
-
exports.changeNxJsonPresets = changeNxJsonPresets;
|
|
20
|
-
exports.default = changeNxJsonPresets;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enableSourceAnalysis = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
async function enableSourceAnalysis(tree) {
|
|
6
|
-
(0, devkit_1.updateJson)(tree, 'nx.json', (config) => {
|
|
7
|
-
if (config.extends === 'nx/presets/core.json' ||
|
|
8
|
-
config.extends === 'nx/presets/npm.json') {
|
|
9
|
-
const explicitlyDisabled = config.pluginsConfig &&
|
|
10
|
-
config.pluginsConfig['@nrwl/js'] &&
|
|
11
|
-
config.pluginsConfig['@nrwl/js'].analyzeSourceFiles === false;
|
|
12
|
-
if (!explicitlyDisabled) {
|
|
13
|
-
config.pluginsConfig ||= {};
|
|
14
|
-
config.pluginsConfig['@nrwl/js'] ||= {};
|
|
15
|
-
config.pluginsConfig['@nrwl/js'].analyzeSourceFiles = true;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return config;
|
|
19
|
-
});
|
|
20
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
21
|
-
}
|
|
22
|
-
exports.enableSourceAnalysis = enableSourceAnalysis;
|
|
23
|
-
exports.default = enableSourceAnalysis;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.changeRunCommandsExecutor = void 0;
|
|
4
|
-
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
6
|
-
async function changeRunCommandsExecutor(tree) {
|
|
7
|
-
(0, executor_options_utils_1.forEachExecutorOptions)(tree, '@nrwl/workspace:run-commands', (currentValue, project, target) => {
|
|
8
|
-
const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, project);
|
|
9
|
-
const targetConfig = projectConfig.targets[target];
|
|
10
|
-
targetConfig.executor = 'nx:run-commands';
|
|
11
|
-
(0, devkit_1.updateProjectConfiguration)(tree, project, projectConfig);
|
|
12
|
-
});
|
|
13
|
-
await (0, devkit_1.formatFiles)(tree);
|
|
14
|
-
}
|
|
15
|
-
exports.changeRunCommandsExecutor = changeRunCommandsExecutor;
|
|
16
|
-
exports.default = changeRunCommandsExecutor;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ProjectGraph, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
|
-
import { ProjectGraphExternalNode } from '@nx/devkit';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated This type will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
5
|
-
*/
|
|
6
|
-
export type DependentBuildableProjectNode = {
|
|
7
|
-
name: string;
|
|
8
|
-
outputs: string[];
|
|
9
|
-
node: ProjectGraphProjectNode | ProjectGraphExternalNode;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
13
|
-
*/
|
|
14
|
-
export declare function calculateProjectDependencies(projGraph: ProjectGraph, root: string, projectName: string, targetName: string, configurationName: string, shallow?: boolean): {
|
|
15
|
-
target: ProjectGraphProjectNode;
|
|
16
|
-
dependencies: DependentBuildableProjectNode[];
|
|
17
|
-
nonBuildableDependencies: string[];
|
|
18
|
-
topLevelDependencies: DependentBuildableProjectNode[];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
22
|
-
*/
|
|
23
|
-
export declare function createTmpTsConfig(tsconfigPath: string, workspaceRoot: string, projectRoot: string, dependencies: DependentBuildableProjectNode[]): string;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
26
|
-
*/
|
|
27
|
-
export declare function checkDependentProjectsHaveBeenBuilt(root: string, projectName: string, targetName: string, projectDependencies: DependentBuildableProjectNode[]): boolean;
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
30
|
-
*/
|
|
31
|
-
export declare function findMissingBuildDependencies(root: string, projectName: string, targetName: string, projectDependencies: DependentBuildableProjectNode[]): DependentBuildableProjectNode[];
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
34
|
-
*/
|
|
35
|
-
export declare function updatePaths(dependencies: DependentBuildableProjectNode[], paths: Record<string, string[]>): void;
|
|
36
|
-
/**
|
|
37
|
-
* Updates the peerDependencies section in the `dist/lib/xyz/package.json` with
|
|
38
|
-
* the proper dependency and version
|
|
39
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
40
|
-
*/
|
|
41
|
-
export declare function updateBuildableProjectPackageJsonDependencies(root: string, projectName: string, targetName: string, configurationName: string, node: ProjectGraphProjectNode, dependencies: DependentBuildableProjectNode[], typeOfDependency?: 'dependencies' | 'peerDependencies'): void;
|
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateBuildableProjectPackageJsonDependencies = exports.updatePaths = exports.findMissingBuildDependencies = exports.checkDependentProjectsHaveBeenBuilt = exports.createTmpTsConfig = exports.calculateProjectDependencies = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const fileutils_1 = require("./fileutils");
|
|
6
|
-
const devkit_1 = require("@nx/devkit");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const output_1 = require("./output");
|
|
9
|
-
const operators_1 = require("nx/src/project-graph/operators");
|
|
10
|
-
const typescript_1 = require("./typescript");
|
|
11
|
-
let tsModule;
|
|
12
|
-
function isBuildable(target, node) {
|
|
13
|
-
return (node.data.targets &&
|
|
14
|
-
node.data.targets[target] &&
|
|
15
|
-
node.data.targets[target].executor !== '');
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
19
|
-
*/
|
|
20
|
-
function calculateProjectDependencies(projGraph, root, projectName, targetName, configurationName, shallow) {
|
|
21
|
-
const target = projGraph.nodes[projectName];
|
|
22
|
-
// gather the library dependencies
|
|
23
|
-
const nonBuildableDependencies = [];
|
|
24
|
-
const topLevelDependencies = [];
|
|
25
|
-
const collectedDeps = collectDependencies(projectName, projGraph, [], shallow);
|
|
26
|
-
const missing = collectedDeps.reduce((missing, { name: dep }) => {
|
|
27
|
-
const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep];
|
|
28
|
-
if (!depNode) {
|
|
29
|
-
missing = missing || [];
|
|
30
|
-
missing.push(dep);
|
|
31
|
-
}
|
|
32
|
-
return missing;
|
|
33
|
-
}, null);
|
|
34
|
-
if (missing) {
|
|
35
|
-
throw new Error(`Unable to find ${missing.join(', ')} in project graph.`);
|
|
36
|
-
}
|
|
37
|
-
const dependencies = collectedDeps
|
|
38
|
-
.map(({ name: dep, isTopLevel }) => {
|
|
39
|
-
let project = null;
|
|
40
|
-
const depNode = projGraph.nodes[dep] || projGraph.externalNodes[dep];
|
|
41
|
-
if (depNode.type === 'lib') {
|
|
42
|
-
if (isBuildable(targetName, depNode)) {
|
|
43
|
-
const libPackageJsonPath = (0, path_1.join)(root, depNode.data.root, 'package.json');
|
|
44
|
-
project = {
|
|
45
|
-
name: (0, fileutils_1.fileExists)(libPackageJsonPath)
|
|
46
|
-
? (0, devkit_1.readJsonFile)(libPackageJsonPath).name // i.e. @workspace/mylib
|
|
47
|
-
: dep,
|
|
48
|
-
outputs: (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
49
|
-
overrides: {},
|
|
50
|
-
target: {
|
|
51
|
-
project: projectName,
|
|
52
|
-
target: targetName,
|
|
53
|
-
configuration: configurationName,
|
|
54
|
-
},
|
|
55
|
-
}, depNode),
|
|
56
|
-
node: depNode,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
nonBuildableDependencies.push(dep);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (depNode.type === 'npm') {
|
|
64
|
-
project = {
|
|
65
|
-
name: depNode.data.packageName,
|
|
66
|
-
outputs: [],
|
|
67
|
-
node: depNode,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
if (project && isTopLevel) {
|
|
71
|
-
topLevelDependencies.push(project);
|
|
72
|
-
}
|
|
73
|
-
return project;
|
|
74
|
-
})
|
|
75
|
-
.filter((x) => !!x);
|
|
76
|
-
dependencies.sort((a, b) => (a.name > b.name ? 1 : b.name > a.name ? -1 : 0));
|
|
77
|
-
return {
|
|
78
|
-
target,
|
|
79
|
-
dependencies,
|
|
80
|
-
nonBuildableDependencies,
|
|
81
|
-
topLevelDependencies,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
exports.calculateProjectDependencies = calculateProjectDependencies;
|
|
85
|
-
function collectDependencies(project, projGraph, acc, shallow, areTopLevelDeps = true) {
|
|
86
|
-
(projGraph.dependencies[project] || []).forEach((dependency) => {
|
|
87
|
-
const existingEntry = acc.find((dep) => dep.name === dependency.target);
|
|
88
|
-
if (!existingEntry) {
|
|
89
|
-
// Temporary skip this. Currently the set of external nodes is built from package.json, not lock file.
|
|
90
|
-
// As a result, some nodes might be missing. This should not cause any issues, we can just skip them.
|
|
91
|
-
if (dependency.target.startsWith('npm:') &&
|
|
92
|
-
!projGraph.externalNodes[dependency.target])
|
|
93
|
-
return;
|
|
94
|
-
acc.push({ name: dependency.target, isTopLevel: areTopLevelDeps });
|
|
95
|
-
const isInternalTarget = projGraph.nodes[dependency.target];
|
|
96
|
-
if (!shallow && isInternalTarget) {
|
|
97
|
-
collectDependencies(dependency.target, projGraph, acc, shallow, false);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (areTopLevelDeps && !existingEntry.isTopLevel) {
|
|
101
|
-
existingEntry.isTopLevel = true;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
return acc;
|
|
105
|
-
}
|
|
106
|
-
function readTsConfigWithRemappedPaths(tsConfig, generatedTsConfigPath, dependencies) {
|
|
107
|
-
const generatedTsConfig = { compilerOptions: {} };
|
|
108
|
-
generatedTsConfig.extends = (0, path_1.relative)((0, path_1.dirname)(generatedTsConfigPath), tsConfig);
|
|
109
|
-
generatedTsConfig.compilerOptions.paths = computeCompilerOptionsPaths(tsConfig, dependencies);
|
|
110
|
-
if (process.env.NX_VERBOSE_LOGGING_PATH_MAPPINGS === 'true') {
|
|
111
|
-
output_1.output.log({
|
|
112
|
-
title: 'TypeScript path mappings have been rewritten.',
|
|
113
|
-
});
|
|
114
|
-
console.log(JSON.stringify(generatedTsConfig.compilerOptions.paths, null, 2));
|
|
115
|
-
}
|
|
116
|
-
return generatedTsConfig;
|
|
117
|
-
}
|
|
118
|
-
function computeCompilerOptionsPaths(tsConfig, dependencies) {
|
|
119
|
-
const paths = readPaths(tsConfig) || {};
|
|
120
|
-
updatePaths(dependencies, paths);
|
|
121
|
-
return paths;
|
|
122
|
-
}
|
|
123
|
-
function readPaths(tsConfig) {
|
|
124
|
-
if (!tsModule) {
|
|
125
|
-
tsModule = (0, typescript_1.ensureTypescript)();
|
|
126
|
-
}
|
|
127
|
-
try {
|
|
128
|
-
let config;
|
|
129
|
-
if (typeof tsConfig === 'string') {
|
|
130
|
-
const configFile = tsModule.readConfigFile(tsConfig, tsModule.sys.readFile);
|
|
131
|
-
config = tsModule.parseJsonConfigFileContent(configFile.config, tsModule.sys, (0, path_1.dirname)(tsConfig));
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
config = tsConfig;
|
|
135
|
-
}
|
|
136
|
-
if (config.options?.paths) {
|
|
137
|
-
return config.options.paths;
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
149
|
-
*/
|
|
150
|
-
function createTmpTsConfig(tsconfigPath, workspaceRoot, projectRoot, dependencies) {
|
|
151
|
-
const tmpTsConfigPath = (0, path_1.join)(workspaceRoot, 'tmp', projectRoot, 'tsconfig.generated.json');
|
|
152
|
-
const parsedTSConfig = readTsConfigWithRemappedPaths(tsconfigPath, tmpTsConfigPath, dependencies);
|
|
153
|
-
process.on('exit', () => cleanupTmpTsConfigFile(tmpTsConfigPath));
|
|
154
|
-
(0, devkit_1.writeJsonFile)(tmpTsConfigPath, parsedTSConfig);
|
|
155
|
-
return (0, path_1.join)(tmpTsConfigPath);
|
|
156
|
-
}
|
|
157
|
-
exports.createTmpTsConfig = createTmpTsConfig;
|
|
158
|
-
function cleanupTmpTsConfigFile(tmpTsConfigPath) {
|
|
159
|
-
try {
|
|
160
|
-
if (tmpTsConfigPath) {
|
|
161
|
-
(0, fs_1.unlinkSync)(tmpTsConfigPath);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
catch (e) { }
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
168
|
-
*/
|
|
169
|
-
function checkDependentProjectsHaveBeenBuilt(root, projectName, targetName, projectDependencies) {
|
|
170
|
-
const missing = findMissingBuildDependencies(root, projectName, targetName, projectDependencies);
|
|
171
|
-
if (missing.length > 0) {
|
|
172
|
-
console.error((0, devkit_1.stripIndents) `
|
|
173
|
-
It looks like all of ${projectName}'s dependencies have not been built yet:
|
|
174
|
-
${missing.map((x) => ` - ${x.node.name}`).join('\n')}
|
|
175
|
-
|
|
176
|
-
You might be missing a "targetDefaults" configuration in your root nx.json (https://nx.dev/reference/project-configuration#target-defaults),
|
|
177
|
-
or "dependsOn" configured in ${projectName}'s project.json (https://nx.dev/reference/project-configuration#dependson)
|
|
178
|
-
`);
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
exports.checkDependentProjectsHaveBeenBuilt = checkDependentProjectsHaveBeenBuilt;
|
|
186
|
-
/**
|
|
187
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
188
|
-
*/
|
|
189
|
-
function findMissingBuildDependencies(root, projectName, targetName, projectDependencies) {
|
|
190
|
-
const depLibsToBuildFirst = [];
|
|
191
|
-
// verify whether all dependent libraries have been built
|
|
192
|
-
projectDependencies.forEach((dep) => {
|
|
193
|
-
if (dep.node.type !== 'lib') {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const paths = dep.outputs.map((p) => (0, path_1.join)(root, p));
|
|
197
|
-
if (!paths.some(fileutils_1.directoryExists)) {
|
|
198
|
-
depLibsToBuildFirst.push(dep);
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
return depLibsToBuildFirst;
|
|
202
|
-
}
|
|
203
|
-
exports.findMissingBuildDependencies = findMissingBuildDependencies;
|
|
204
|
-
/**
|
|
205
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
206
|
-
*/
|
|
207
|
-
function updatePaths(dependencies, paths) {
|
|
208
|
-
const pathsKeys = Object.keys(paths);
|
|
209
|
-
// For each registered dependency
|
|
210
|
-
dependencies.forEach((dep) => {
|
|
211
|
-
// If there are outputs
|
|
212
|
-
if (dep.outputs && dep.outputs.length > 0) {
|
|
213
|
-
// Directly map the dependency name to the output paths (dist/packages/..., etc.)
|
|
214
|
-
paths[dep.name] = dep.outputs;
|
|
215
|
-
// check for secondary entrypoints
|
|
216
|
-
// For each registered path
|
|
217
|
-
for (const path of pathsKeys) {
|
|
218
|
-
const nestedName = `${dep.name}/`;
|
|
219
|
-
// If the path points to the current dependency and is nested (/)
|
|
220
|
-
if (path.startsWith(nestedName)) {
|
|
221
|
-
const nestedPart = path.slice(nestedName.length);
|
|
222
|
-
// Bind secondary endpoints for ng-packagr projects
|
|
223
|
-
let mappedPaths = dep.outputs.map((output) => `${output}/${nestedPart}`);
|
|
224
|
-
// Get the dependency's package name
|
|
225
|
-
const { root } = (dep.node?.data || {});
|
|
226
|
-
if (root) {
|
|
227
|
-
// Update nested mappings to point to the dependency's output paths
|
|
228
|
-
mappedPaths = mappedPaths.concat(paths[path].flatMap((path) => dep.outputs.map((output) => path.replace(root, output))));
|
|
229
|
-
}
|
|
230
|
-
paths[path] = mappedPaths;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
exports.updatePaths = updatePaths;
|
|
237
|
-
/**
|
|
238
|
-
* Updates the peerDependencies section in the `dist/lib/xyz/package.json` with
|
|
239
|
-
* the proper dependency and version
|
|
240
|
-
* @deprecated This function will be removed from @nx/workspace in version 17. Prefer importing from @nx/js.
|
|
241
|
-
*/
|
|
242
|
-
function updateBuildableProjectPackageJsonDependencies(root, projectName, targetName, configurationName, node, dependencies, typeOfDependency = 'dependencies') {
|
|
243
|
-
const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
244
|
-
overrides: {},
|
|
245
|
-
target: {
|
|
246
|
-
project: projectName,
|
|
247
|
-
target: targetName,
|
|
248
|
-
configuration: configurationName,
|
|
249
|
-
},
|
|
250
|
-
}, node);
|
|
251
|
-
const packageJsonPath = `${outputs[0]}/package.json`;
|
|
252
|
-
let packageJson;
|
|
253
|
-
let workspacePackageJson;
|
|
254
|
-
try {
|
|
255
|
-
packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
|
|
256
|
-
workspacePackageJson = (0, devkit_1.readJsonFile)(`${root}/package.json`);
|
|
257
|
-
}
|
|
258
|
-
catch (e) {
|
|
259
|
-
// cannot find or invalid package.json
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
packageJson.dependencies = packageJson.dependencies || {};
|
|
263
|
-
packageJson.peerDependencies = packageJson.peerDependencies || {};
|
|
264
|
-
let updatePackageJson = false;
|
|
265
|
-
dependencies.forEach((entry) => {
|
|
266
|
-
const packageName = (0, operators_1.isNpmProject)(entry.node)
|
|
267
|
-
? entry.node.data.packageName
|
|
268
|
-
: entry.name;
|
|
269
|
-
if (!hasDependency(packageJson, 'dependencies', packageName) &&
|
|
270
|
-
!hasDependency(packageJson, 'devDependencies', packageName) &&
|
|
271
|
-
!hasDependency(packageJson, 'peerDependencies', packageName)) {
|
|
272
|
-
try {
|
|
273
|
-
let depVersion;
|
|
274
|
-
if (entry.node.type === 'lib') {
|
|
275
|
-
const outputs = (0, devkit_1.getOutputsForTargetAndConfiguration)({
|
|
276
|
-
overrides: {},
|
|
277
|
-
target: {
|
|
278
|
-
project: projectName,
|
|
279
|
-
target: targetName,
|
|
280
|
-
configuration: configurationName,
|
|
281
|
-
},
|
|
282
|
-
}, entry.node);
|
|
283
|
-
const depPackageJsonPath = (0, path_1.join)(root, outputs[0], 'package.json');
|
|
284
|
-
depVersion = (0, devkit_1.readJsonFile)(depPackageJsonPath).version;
|
|
285
|
-
packageJson[typeOfDependency][packageName] = depVersion;
|
|
286
|
-
}
|
|
287
|
-
else if ((0, operators_1.isNpmProject)(entry.node)) {
|
|
288
|
-
// If an npm dep is part of the workspace devDependencies, do not include it the library
|
|
289
|
-
if (!!workspacePackageJson.devDependencies?.[entry.node.data.packageName]) {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
depVersion = entry.node.data.version;
|
|
293
|
-
packageJson[typeOfDependency][entry.node.data.packageName] =
|
|
294
|
-
depVersion;
|
|
295
|
-
}
|
|
296
|
-
updatePackageJson = true;
|
|
297
|
-
}
|
|
298
|
-
catch (e) {
|
|
299
|
-
// skip if cannot find package.json
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
if (updatePackageJson) {
|
|
304
|
-
(0, devkit_1.writeJsonFile)(packageJsonPath, packageJson);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
exports.updateBuildableProjectPackageJsonDependencies = updateBuildableProjectPackageJsonDependencies;
|
|
308
|
-
// verify whether the package.json already specifies the dep
|
|
309
|
-
function hasDependency(outputJson, depConfigName, packageName) {
|
|
310
|
-
if (outputJson[depConfigName]) {
|
|
311
|
-
return outputJson[depConfigName][packageName];
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
|
-
}
|