@nx/workspace 17.0.0-beta.1 → 17.0.0-beta.4
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 -43
- package/index.d.ts +1 -1
- package/index.js +1 -2
- package/package.json +6 -6
- package/src/generators/convert-to-monorepo/convert-to-monorepo.d.ts +0 -1
- package/src/generators/convert-to-monorepo/convert-to-monorepo.js +1 -2
- package/src/generators/convert-to-nx-project/convert-to-nx-project.d.ts +0 -1
- package/src/generators/convert-to-nx-project/convert-to-nx-project.js +1 -2
- package/src/generators/move/move.d.ts +0 -1
- package/src/generators/move/move.js +1 -2
- package/src/generators/new/new.d.ts +0 -1
- package/src/generators/new/new.js +0 -9
- package/src/generators/new/schema.json +0 -5
- package/src/generators/npm-package/npm-package.d.ts +0 -1
- package/src/generators/npm-package/npm-package.js +1 -2
- package/src/generators/remove/remove.d.ts +0 -1
- package/src/generators/remove/remove.js +1 -2
- package/src/generators/run-commands/run-commands.d.ts +0 -1
- package/src/generators/run-commands/run-commands.js +1 -2
- 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/utilities/buildable-libs-utils.d.ts +0 -41
- package/src/utilities/buildable-libs-utils.js +0 -316
package/generators.json
CHANGED
|
@@ -1,43 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx/workspace",
|
|
3
3
|
"version": "0.1",
|
|
4
|
-
"schematics": {
|
|
5
|
-
"move": {
|
|
6
|
-
"factory": "./src/generators/move/move#moveSchematic",
|
|
7
|
-
"schema": "./src/generators/move/schema.json",
|
|
8
|
-
"aliases": ["mv"],
|
|
9
|
-
"description": "Move an application or library to another folder."
|
|
10
|
-
},
|
|
11
|
-
"remove": {
|
|
12
|
-
"factory": "./src/generators/remove/remove#removeSchematic",
|
|
13
|
-
"schema": "./src/generators/remove/schema.json",
|
|
14
|
-
"aliases": ["rm"],
|
|
15
|
-
"description": "Remove an application or library."
|
|
16
|
-
},
|
|
17
|
-
"convert-to-monorepo": {
|
|
18
|
-
"factory": "./src/generators/convert-to-monorepo/convert-to-monorepo#monorepoSchematic",
|
|
19
|
-
"schema": "./src/generators/convert-to-monorepo/schema.json",
|
|
20
|
-
"description": "Convert a Nx project to a monorepo."
|
|
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
|
-
"run-commands": {
|
|
29
|
-
"factory": "./src/generators/run-commands/run-commands#runCommandsSchematic",
|
|
30
|
-
"schema": "./src/generators/run-commands/schema.json",
|
|
31
|
-
"aliases": ["run-command", "target"],
|
|
32
|
-
"description": "Generates a target to run any command in the terminal."
|
|
33
|
-
},
|
|
34
|
-
"npm-package": {
|
|
35
|
-
"factory": "./src/generators/npm-package/npm-package#npmPackageSchematic",
|
|
36
|
-
"schema": "./src/generators/npm-package/schema.json",
|
|
37
|
-
"description": "Create a minimal NPM package.",
|
|
38
|
-
"x-type": "library"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
4
|
"generators": {
|
|
42
5
|
"preset": {
|
|
43
6
|
"factory": "./src/generators/preset/preset#presetGenerator",
|
|
@@ -69,12 +32,6 @@
|
|
|
69
32
|
"description": "Create a workspace.",
|
|
70
33
|
"hidden": true
|
|
71
34
|
},
|
|
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
35
|
"run-commands": {
|
|
79
36
|
"factory": "./src/generators/run-commands/run-commands#runCommandsGenerator",
|
|
80
37
|
"schema": "./src/generators/run-commands/schema.json",
|
package/index.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export { checkAndCleanWithSemver } from './src/utils/version-utils';
|
|
|
16
16
|
export { moveGenerator } from './src/generators/move/move';
|
|
17
17
|
export { removeGenerator } from './src/generators/remove/remove';
|
|
18
18
|
export { runCommandsGenerator } from './src/generators/run-commands/run-commands';
|
|
19
|
-
export { convertToNxProjectGenerator
|
|
19
|
+
export { convertToNxProjectGenerator } from './src/generators/convert-to-nx-project/convert-to-nx-project';
|
|
20
20
|
export declare const stringUtils: typeof strings;
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringUtils = exports.
|
|
3
|
+
exports.stringUtils = exports.convertToNxProjectGenerator = exports.runCommandsGenerator = exports.removeGenerator = exports.moveGenerator = exports.checkAndCleanWithSemver = exports.visitNotIgnoredFiles = exports.deleteFile = exports.formatFiles = exports.addInstallTask = exports.updateBuilderConfig = exports.updateWorkspace = exports.getWorkspace = exports.serializeTarget = exports.parseTarget = exports.editTarget = exports.getWorkspacePath = exports.readPackageJson = exports.readWorkspaceConfig = exports.output = exports.names = exports.createDirectory = exports.copyFile = exports.updateJsonFile = exports.renameSync = exports.projectRootDir = exports.ProjectType = exports.readTsConfig = void 0;
|
|
4
4
|
var ts_config_1 = require("./src/utilities/ts-config");
|
|
5
5
|
Object.defineProperty(exports, "readTsConfig", { enumerable: true, get: function () { return ts_config_1.readTsConfig; } });
|
|
6
6
|
var project_type_1 = require("./src/utils/project-type");
|
|
@@ -47,5 +47,4 @@ var run_commands_1 = require("./src/generators/run-commands/run-commands");
|
|
|
47
47
|
Object.defineProperty(exports, "runCommandsGenerator", { enumerable: true, get: function () { return run_commands_1.runCommandsGenerator; } });
|
|
48
48
|
var convert_to_nx_project_1 = require("./src/generators/convert-to-nx-project/convert-to-nx-project");
|
|
49
49
|
Object.defineProperty(exports, "convertToNxProjectGenerator", { enumerable: true, get: function () { return convert_to_nx_project_1.convertToNxProjectGenerator; } });
|
|
50
|
-
Object.defineProperty(exports, "convertToNxProjectSchematic", { enumerable: true, get: function () { return convert_to_nx_project_1.convertToNxProjectSchematic; } });
|
|
51
50
|
exports.stringUtils = strings;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/workspace",
|
|
3
|
-
"version": "17.0.0-beta.
|
|
3
|
+
"version": "17.0.0-beta.4",
|
|
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": {
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"url": "https://github.com/nrwl/nx/issues"
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://nx.dev",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"generators": "./generators.json",
|
|
31
|
+
"executors": "./executors.json",
|
|
32
32
|
"ng-update": {
|
|
33
33
|
"requirements": {},
|
|
34
34
|
"migrations": "./migrations.json",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@nx/devkit": "17.0.0-beta.
|
|
64
|
+
"@nx/devkit": "17.0.0-beta.4",
|
|
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": "17.0.0-beta.
|
|
72
|
-
"@nrwl/workspace": "17.0.0-beta.
|
|
71
|
+
"nx": "17.0.0-beta.4",
|
|
72
|
+
"@nrwl/workspace": "17.0.0-beta.4"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.monorepoGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const move_1 = require("../move/move");
|
|
6
6
|
async function monorepoGenerator(tree, options) {
|
|
@@ -35,4 +35,3 @@ async function monorepoGenerator(tree, options) {
|
|
|
35
35
|
}
|
|
36
36
|
exports.monorepoGenerator = monorepoGenerator;
|
|
37
37
|
exports.default = monorepoGenerator;
|
|
38
|
-
exports.monorepoSchematic = (0, devkit_1.convertNxGenerator)(monorepoGenerator);
|
|
@@ -3,4 +3,3 @@ import { Schema } from './schema';
|
|
|
3
3
|
export declare function validateSchema(schema: Schema, configName: string): Promise<void>;
|
|
4
4
|
export declare function convertToNxProjectGenerator(host: Tree, schema: Schema): Promise<void>;
|
|
5
5
|
export default convertToNxProjectGenerator;
|
|
6
|
-
export declare const convertToNxProjectSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.convertToNxProjectGenerator = exports.validateSchema = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const angular_json_1 = require("nx/src/adapter/angular-json");
|
|
@@ -77,4 +77,3 @@ async function convertToNxProjectGenerator(host, schema) {
|
|
|
77
77
|
}
|
|
78
78
|
exports.convertToNxProjectGenerator = convertToNxProjectGenerator;
|
|
79
79
|
exports.default = convertToNxProjectGenerator;
|
|
80
|
-
exports.convertToNxProjectSchematic = (0, devkit_1.convertNxGenerator)(convertToNxProjectGenerator);
|
|
@@ -3,4 +3,3 @@ import { Schema } from './schema';
|
|
|
3
3
|
export declare function moveGenerator(tree: Tree, rawSchema: Schema): Promise<void>;
|
|
4
4
|
export declare function moveGeneratorInternal(tree: Tree, rawSchema: Schema): Promise<void>;
|
|
5
5
|
export default moveGenerator;
|
|
6
|
-
export declare const moveSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.moveGeneratorInternal = exports.moveGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const check_destination_1 = require("./lib/check-destination");
|
|
6
6
|
const create_project_configuration_in_new_destination_1 = require("./lib/create-project-configuration-in-new-destination");
|
|
@@ -58,4 +58,3 @@ async function moveGeneratorInternal(tree, rawSchema) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.moveGeneratorInternal = moveGeneratorInternal;
|
|
60
60
|
exports.default = moveGenerator;
|
|
61
|
-
exports.moveSchematic = (0, devkit_1.convertNxGenerator)(moveGenerator);
|
|
@@ -12,7 +12,6 @@ async function newGenerator(tree, opts) {
|
|
|
12
12
|
validateOptions(options, tree);
|
|
13
13
|
await (0, generate_workspace_files_1.generateWorkspaceFiles)(tree, { ...options, nxCloud: undefined });
|
|
14
14
|
(0, generate_preset_1.addPresetDependencies)(tree, options);
|
|
15
|
-
addCloudDependencies(tree, options);
|
|
16
15
|
return async () => {
|
|
17
16
|
const pmc = (0, devkit_1.getPackageManagerCommand)(options.packageManager);
|
|
18
17
|
if (pmc.preInstall) {
|
|
@@ -37,9 +36,6 @@ function validateOptions(options, host) {
|
|
|
37
36
|
options.preset !== presets_1.Preset.NPM) {
|
|
38
37
|
throw new Error(`Cannot select a preset when skipInstall is set to true.`);
|
|
39
38
|
}
|
|
40
|
-
if (options.skipInstall && options.nxCloud) {
|
|
41
|
-
throw new Error(`Cannot select nxCloud when skipInstall is set to true.`);
|
|
42
|
-
}
|
|
43
39
|
if ((options.preset === presets_1.Preset.NodeStandalone ||
|
|
44
40
|
options.preset === presets_1.Preset.NodeMonorepo) &&
|
|
45
41
|
!options.framework) {
|
|
@@ -84,8 +80,3 @@ function normalizeOptions(options) {
|
|
|
84
80
|
normalized.isCustomPreset = !Object.values(presets_1.Preset).includes(options.preset);
|
|
85
81
|
return normalized;
|
|
86
82
|
}
|
|
87
|
-
function addCloudDependencies(host, options) {
|
|
88
|
-
if (options.nxCloud) {
|
|
89
|
-
return (0, devkit_1.addDependenciesToPackageJson)(host, {}, { 'nx-cloud': 'latest' }, (0, path_1.join)(options.directory, 'package.json'));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -47,11 +47,6 @@
|
|
|
47
47
|
"type": "string",
|
|
48
48
|
"description": "Application name."
|
|
49
49
|
},
|
|
50
|
-
"nxCloud": {
|
|
51
|
-
"description": "Connect the workspace to the free tier of the distributed cache provided by Nx Cloud.",
|
|
52
|
-
"type": "boolean",
|
|
53
|
-
"default": false
|
|
54
|
-
},
|
|
55
50
|
"linter": {
|
|
56
51
|
"description": "The tool to use for running lint checks.",
|
|
57
52
|
"type": "string",
|
|
@@ -7,4 +7,3 @@ export interface ProjectOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function npmPackageGenerator(tree: Tree, options: ProjectOptions): Promise<void>;
|
|
9
9
|
export declare function npmPackageGeneratorInternal(tree: Tree, _options: ProjectOptions): Promise<void>;
|
|
10
|
-
export declare const npmPackageSchematic: (generatorOptions: ProjectOptions) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.npmPackageGeneratorInternal = exports.npmPackageGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -51,4 +51,3 @@ async function npmPackageGeneratorInternal(tree, _options) {
|
|
|
51
51
|
await (0, devkit_1.formatFiles)(tree);
|
|
52
52
|
}
|
|
53
53
|
exports.npmPackageGeneratorInternal = npmPackageGeneratorInternal;
|
|
54
|
-
exports.npmPackageSchematic = (0, devkit_1.convertNxGenerator)(npmPackageGenerator);
|
|
@@ -2,4 +2,3 @@ import { Tree } from '@nx/devkit';
|
|
|
2
2
|
import { Schema } from './schema';
|
|
3
3
|
export declare function removeGenerator(tree: Tree, schema: Schema): Promise<void>;
|
|
4
4
|
export default removeGenerator;
|
|
5
|
-
export declare const removeSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.removeGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const check_project_is_safe_to_remove_1 = require("./lib/check-project-is-safe-to-remove");
|
|
6
6
|
const check_dependencies_1 = require("./lib/check-dependencies");
|
|
@@ -24,4 +24,3 @@ async function removeGenerator(tree, schema) {
|
|
|
24
24
|
}
|
|
25
25
|
exports.removeGenerator = removeGenerator;
|
|
26
26
|
exports.default = removeGenerator;
|
|
27
|
-
exports.removeSchematic = (0, devkit_1.convertNxGenerator)(removeGenerator);
|
|
@@ -2,4 +2,3 @@ import { Schema } from './schema';
|
|
|
2
2
|
import { Tree } from '@nx/devkit';
|
|
3
3
|
export declare function runCommandsGenerator(host: Tree, schema: Schema): Promise<void>;
|
|
4
4
|
export default runCommandsGenerator;
|
|
5
|
-
export declare const runCommandsSchematic: (generatorOptions: Schema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.runCommandsGenerator = void 0;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
async function runCommandsGenerator(host, schema) {
|
|
6
6
|
const project = (0, devkit_1.readProjectConfiguration)(host, schema.project);
|
|
@@ -23,4 +23,3 @@ async function runCommandsGenerator(host, schema) {
|
|
|
23
23
|
}
|
|
24
24
|
exports.runCommandsGenerator = runCommandsGenerator;
|
|
25
25
|
exports.default = runCommandsGenerator;
|
|
26
|
-
exports.runCommandsSchematic = (0, devkit_1.convertNxGenerator)(runCommandsGenerator);
|
|
@@ -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,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
|
-
}
|