@nx/workspace 17.0.0-beta.1 → 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/package.json +4 -4
- 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
|
@@ -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/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.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": "17.0.0-beta.
|
|
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": "17.0.0-beta.
|
|
72
|
-
"@nrwl/workspace": "17.0.0-beta.
|
|
71
|
+
"nx": "17.0.0-beta.2",
|
|
72
|
+
"@nrwl/workspace": "17.0.0-beta.2"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
@@ -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
|
-
}
|