nx 19.2.0-canary.20240604-0594deb → 19.2.0-canary.20240605-5a06daa
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/migrations.json +6 -0
- package/package.json +13 -12
- package/release/changelog-renderer/index.d.ts +6 -3
- package/release/changelog-renderer/index.js +53 -50
- package/schemas/nx-schema.json +8 -0
- package/src/command-line/add/add.d.ts +1 -1
- package/src/command-line/add/command-object.js +3 -1
- package/src/command-line/affected/command-object.js +10 -5
- package/src/command-line/deprecated/command-objects.js +12 -6
- package/src/command-line/examples.js +18 -0
- package/src/command-line/generate/generate.d.ts +1 -1
- package/src/command-line/migrate/migrate.d.ts +1 -1
- package/src/command-line/new/new.d.ts +1 -1
- package/src/command-line/release/changelog.d.ts +17 -1
- package/src/command-line/release/changelog.js +305 -76
- package/src/command-line/release/command-object.d.ts +14 -5
- package/src/command-line/release/command-object.js +52 -24
- package/src/command-line/release/config/config.js +38 -6
- package/src/command-line/release/config/filter-release-groups.d.ts +3 -1
- package/src/command-line/release/config/filter-release-groups.js +1 -0
- package/src/command-line/release/config/version-plans.d.ts +24 -0
- package/src/command-line/release/config/version-plans.js +184 -0
- package/src/command-line/release/plan.d.ts +3 -0
- package/src/command-line/release/plan.js +184 -0
- package/src/command-line/release/publish.d.ts +1 -1
- package/src/command-line/release/release.d.ts +1 -1
- package/src/command-line/release/release.js +40 -0
- package/src/command-line/release/utils/git.d.ts +10 -2
- package/src/command-line/release/utils/git.js +45 -10
- package/src/command-line/release/utils/shared.d.ts +12 -2
- package/src/command-line/release/utils/shared.js +3 -2
- package/src/command-line/release/version.d.ts +3 -2
- package/src/command-line/release/version.js +43 -5
- package/src/command-line/repair/repair.d.ts +1 -1
- package/src/command-line/reset/command-object.d.ts +6 -1
- package/src/command-line/reset/command-object.js +15 -2
- package/src/command-line/reset/reset.d.ts +2 -1
- package/src/command-line/reset/reset.js +98 -16
- package/src/command-line/run/command-object.js +6 -3
- package/src/command-line/run/run.d.ts +2 -2
- package/src/command-line/run-many/command-object.js +6 -3
- package/src/command-line/show/command-object.js +6 -6
- package/src/config/misc-interfaces.d.ts +15 -3
- package/src/config/nx-json.d.ts +11 -0
- package/src/core/graph/main.js +1 -1
- package/src/daemon/tmp-dir.js +1 -1
- package/src/devkit-exports.d.ts +1 -1
- package/src/migrations/update-19-2-0/move-workspace-data-directory.d.ts +4 -0
- package/src/migrations/update-19-2-0/move-workspace-data-directory.js +34 -0
- package/src/plugins/js/index.js +2 -2
- package/src/plugins/js/project-graph/affected/lock-file-changes.js +11 -0
- package/src/plugins/js/project-graph/affected/npm-packages.js +12 -0
- package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +3 -11
- package/src/plugins/js/utils/config.js +4 -0
- package/src/plugins/js/utils/register.d.ts +4 -3
- package/src/plugins/js/utils/register.js +47 -4
- package/src/project-graph/affected/affected-project-graph.js +6 -6
- package/src/project-graph/nx-deps-cache.js +6 -6
- package/src/project-graph/plugins/loader.js +1 -1
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/tasks-runner/task-env.js +12 -0
- package/src/utils/cache-directory.d.ts +1 -1
- package/src/utils/cache-directory.js +13 -6
- package/src/utils/get-package-name-from-import-path.d.ts +1 -0
- package/src/utils/get-package-name-from-import-path.js +18 -0
- package/src/utils/package-json.d.ts +1 -0
- package/src/utils/package-manager.js +42 -9
- package/src/utils/params.d.ts +1 -1
- package/src/utils/params.js +5 -1
package/src/daemon/tmp-dir.js
CHANGED
@@ -13,7 +13,7 @@ const cache_directory_1 = require("../utils/cache-directory");
|
|
13
13
|
const crypto_1 = require("crypto");
|
14
14
|
const tmp_1 = require("tmp");
|
15
15
|
const workspace_root_1 = require("../utils/workspace-root");
|
16
|
-
exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = (0, path_1.join)(cache_directory_1.
|
16
|
+
exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'd');
|
17
17
|
exports.DAEMON_OUTPUT_LOG_FILE = (0, path_1.join)(exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'daemon.log');
|
18
18
|
const getDaemonSocketDir = () => (0, path_1.join)(getSocketDir(),
|
19
19
|
// As per notes above on socket/named pipe length limitations, we keep this intentionally short
|
package/src/devkit-exports.d.ts
CHANGED
@@ -13,7 +13,7 @@ export type { WorkspaceJsonConfiguration, ProjectsConfigurations, TargetDependen
|
|
13
13
|
/**
|
14
14
|
* @category Workspace
|
15
15
|
*/
|
16
|
-
export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraphExecutor, GeneratorsJson, ExecutorsJson, MigrationsJson, CustomHasher, HasherContext, } from './config/misc-interfaces';
|
16
|
+
export type { Generator, GeneratorCallback, PromiseExecutor, AsyncIteratorExecutor, Executor, ExecutorContext, TaskGraphExecutor, GeneratorsJson, ExecutorsJson, MigrationsJson, CustomHasher, HasherContext, } from './config/misc-interfaces';
|
17
17
|
export { workspaceLayout } from './config/configuration';
|
18
18
|
export type { NxPlugin, NxPluginV2, CreateNodes, CreateNodesFunction, CreateNodesResult, CreateNodesContext, CreateNodesContextV2, CreateNodesFunctionV2, CreateNodesResultV2, CreateNodesV2, CreateDependencies, CreateDependenciesContext, CreateMetadata, CreateMetadataContext, ProjectsMetadata, } from './project-graph/plugins';
|
19
19
|
export { AggregateCreateNodesError } from './project-graph/error-types';
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.updateGitIgnore = exports.updatePrettierIgnore = void 0;
|
4
|
+
async function moveGraphCacheDirectory(tree) {
|
5
|
+
updateGitIgnore(tree);
|
6
|
+
updatePrettierIgnore(tree);
|
7
|
+
}
|
8
|
+
exports.default = moveGraphCacheDirectory;
|
9
|
+
function updatePrettierIgnore(tree) {
|
10
|
+
if (tree.exists('.prettierignore')) {
|
11
|
+
const ignored = tree.read('.prettierignore', 'utf-8');
|
12
|
+
if (!ignored?.includes('.nx/workspace-data')) {
|
13
|
+
tree.write('.prettierignore', [ignored, '/.nx/workspace-data'].join('\n'));
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
exports.updatePrettierIgnore = updatePrettierIgnore;
|
18
|
+
function updateGitIgnore(tree) {
|
19
|
+
const gitignore = tree.read('.gitignore', 'utf-8');
|
20
|
+
if (!gitignore) {
|
21
|
+
return;
|
22
|
+
}
|
23
|
+
const includesNxWorkspaceData = gitignore.includes('.nx/workspace-data');
|
24
|
+
if (includesNxWorkspaceData) {
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
const includesNxCache = gitignore.includes('.nx/cache');
|
28
|
+
if (!includesNxCache) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
const updatedGitignore = gitignore.replace('.nx/cache', ['.nx/cache', '.nx/workspace-data'].join('\n'));
|
32
|
+
tree.write('.gitignore', updatedGitignore);
|
33
|
+
}
|
34
|
+
exports.updateGitIgnore = updateGitIgnore;
|
package/src/plugins/js/index.js
CHANGED
@@ -101,5 +101,5 @@ function writeLastProcessedLockfileHash(hash, lockFile) {
|
|
101
101
|
function readCachedParsedLockFile() {
|
102
102
|
return JSON.parse((0, fs_1.readFileSync)(cachedParsedLockFile).toString());
|
103
103
|
}
|
104
|
-
const lockFileHashFile = (0, path_1.join)(cache_directory_1.
|
105
|
-
const cachedParsedLockFile = (0, path_1.join)(cache_directory_1.
|
104
|
+
const lockFileHashFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'lockfile.hash');
|
105
|
+
const cachedParsedLockFile = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'parsed-lock-file.json');
|
@@ -1,7 +1,18 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getTouchedProjectsFromLockFile = void 0;
|
4
|
+
const configuration_1 = require("../../../../config/configuration");
|
5
|
+
const config_1 = require("../../utils/config");
|
6
|
+
const find_matching_projects_1 = require("../../../../utils/find-matching-projects");
|
4
7
|
const getTouchedProjectsFromLockFile = (fileChanges, projectGraphNodes) => {
|
8
|
+
const nxJson = (0, configuration_1.readNxJson)();
|
9
|
+
const { projectsAffectedByDependencyUpdates } = (0, config_1.jsPluginConfig)(nxJson);
|
10
|
+
if (projectsAffectedByDependencyUpdates === 'auto') {
|
11
|
+
return [];
|
12
|
+
}
|
13
|
+
else if (Array.isArray(projectsAffectedByDependencyUpdates)) {
|
14
|
+
return (0, find_matching_projects_1.findMatchingProjects)(projectsAffectedByDependencyUpdates, projectGraphNodes);
|
15
|
+
}
|
5
16
|
const lockFiles = [
|
6
17
|
'package-lock.json',
|
7
18
|
'yarn.lock',
|
@@ -4,10 +4,12 @@ exports.getTouchedNpmPackages = void 0;
|
|
4
4
|
const file_utils_1 = require("../../../../project-graph/file-utils");
|
5
5
|
const json_diff_1 = require("../../../../utils/json-diff");
|
6
6
|
const logger_1 = require("../../../../utils/logger");
|
7
|
+
const get_package_name_from_import_path_1 = require("../../../../utils/get-package-name-from-import-path");
|
7
8
|
const getTouchedNpmPackages = (touchedFiles, _, nxJson, packageJson, projectGraph) => {
|
8
9
|
const packageJsonChange = touchedFiles.find((f) => f.file === 'package.json');
|
9
10
|
if (!packageJsonChange)
|
10
11
|
return [];
|
12
|
+
const globalPackages = new Set(getGlobalPackages(nxJson.plugins));
|
11
13
|
let touched = [];
|
12
14
|
const changes = packageJsonChange.getChanges();
|
13
15
|
const npmPackages = Object.values(projectGraph.externalNodes);
|
@@ -40,6 +42,11 @@ const getTouchedNpmPackages = (touchedFiles, _, nxJson, packageJson, projectGrap
|
|
40
42
|
touched.push(implementationNpmPackage.name);
|
41
43
|
}
|
42
44
|
}
|
45
|
+
if ('packageName' in npmPackage.data) {
|
46
|
+
if (globalPackages.has(npmPackage.data.packageName)) {
|
47
|
+
return Object.keys(projectGraph.nodes);
|
48
|
+
}
|
49
|
+
}
|
43
50
|
}
|
44
51
|
}
|
45
52
|
else if ((0, file_utils_1.isWholeFileChange)(c)) {
|
@@ -54,3 +61,8 @@ const getTouchedNpmPackages = (touchedFiles, _, nxJson, packageJson, projectGrap
|
|
54
61
|
return touched;
|
55
62
|
};
|
56
63
|
exports.getTouchedNpmPackages = getTouchedNpmPackages;
|
64
|
+
function getGlobalPackages(plugins) {
|
65
|
+
return (plugins ?? [])
|
66
|
+
.map((p) => (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(typeof p === 'string' ? p : p.plugin))
|
67
|
+
.concat('nx');
|
68
|
+
}
|
@@ -8,6 +8,7 @@ const fileutils_1 = require("../../../../utils/fileutils");
|
|
8
8
|
const workspace_root_1 = require("../../../../utils/workspace-root");
|
9
9
|
const resolve_relative_to_dir_1 = require("../../utils/resolve-relative-to-dir");
|
10
10
|
const typescript_1 = require("../../utils/typescript");
|
11
|
+
const get_package_name_from_import_path_1 = require("../../../../utils/get-package-name-from-import-path");
|
11
12
|
/**
|
12
13
|
* Use a shared cache to avoid repeated npm package resolution work within the TargetProjectLocator.
|
13
14
|
*/
|
@@ -17,7 +18,7 @@ const builtInModuleSet = new Set([
|
|
17
18
|
...node_module_1.builtinModules.map((x) => `node:${x}`),
|
18
19
|
]);
|
19
20
|
function isBuiltinModuleImport(importExpr) {
|
20
|
-
const packageName =
|
21
|
+
const packageName = (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(importExpr);
|
21
22
|
return builtInModuleSet.has(packageName);
|
22
23
|
}
|
23
24
|
exports.isBuiltinModuleImport = isBuiltinModuleImport;
|
@@ -111,7 +112,7 @@ class TargetProjectLocator {
|
|
111
112
|
* @param projectRoot
|
112
113
|
*/
|
113
114
|
findNpmProjectFromImport(importExpr, fromFilePath) {
|
114
|
-
const packageName =
|
115
|
+
const packageName = (0, get_package_name_from_import_path_1.getPackageNameFromImportPath)(importExpr);
|
115
116
|
let fullFilePath = fromFilePath;
|
116
117
|
let workspaceRelativeFilePath = fromFilePath;
|
117
118
|
if (fromFilePath.startsWith(workspace_root_1.workspaceRoot)) {
|
@@ -271,12 +272,3 @@ class TargetProjectLocator {
|
|
271
272
|
}
|
272
273
|
}
|
273
274
|
exports.TargetProjectLocator = TargetProjectLocator;
|
274
|
-
function parsePackageNameFromImportExpression(importExpression) {
|
275
|
-
// Check if the package is scoped
|
276
|
-
if (importExpression.startsWith('@')) {
|
277
|
-
// For scoped packages, the package name is up to the second '/'
|
278
|
-
return importExpression.split('/').slice(0, 2).join('/');
|
279
|
-
}
|
280
|
-
// For unscoped packages, the package name is up to the first '/'
|
281
|
-
return importExpression.split('/')[0];
|
282
|
-
}
|
@@ -19,6 +19,7 @@ function jsPluginConfig(nxJson) {
|
|
19
19
|
analyzePackageJson: true,
|
20
20
|
analyzeSourceFiles: true,
|
21
21
|
analyzeLockfile,
|
22
|
+
projectsAffectedByDependencyUpdates: 'all',
|
22
23
|
...nxJsonConfig,
|
23
24
|
};
|
24
25
|
}
|
@@ -27,6 +28,7 @@ function jsPluginConfig(nxJson) {
|
|
27
28
|
analyzeLockfile: false,
|
28
29
|
analyzePackageJson: false,
|
29
30
|
analyzeSourceFiles: false,
|
31
|
+
projectsAffectedByDependencyUpdates: 'all',
|
30
32
|
};
|
31
33
|
}
|
32
34
|
const packageJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspace_root_1.workspaceRoot, 'package.json'));
|
@@ -52,6 +54,7 @@ function jsPluginConfig(nxJson) {
|
|
52
54
|
analyzePackageJson: true,
|
53
55
|
analyzeLockfile,
|
54
56
|
analyzeSourceFiles: true,
|
57
|
+
projectsAffectedByDependencyUpdates: 'all',
|
55
58
|
};
|
56
59
|
}
|
57
60
|
else {
|
@@ -59,6 +62,7 @@ function jsPluginConfig(nxJson) {
|
|
59
62
|
analyzePackageJson: true,
|
60
63
|
analyzeLockfile,
|
61
64
|
analyzeSourceFiles: false,
|
65
|
+
projectsAffectedByDependencyUpdates: 'all',
|
62
66
|
};
|
63
67
|
}
|
64
68
|
}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { TsConfigOptions } from 'ts-node';
|
1
2
|
import type { CompilerOptions } from 'typescript';
|
2
3
|
/**
|
3
4
|
* Optionally, if swc-node and tsconfig-paths are available in the current workspace, apply the require
|
@@ -23,8 +24,8 @@ export declare function registerTsProject(tsConfigPath: string): () => void;
|
|
23
24
|
*/
|
24
25
|
export declare function registerTsProject(path: string, configFilename: string): any;
|
25
26
|
export declare function getSwcTranspiler(compilerOptions: CompilerOptions): (...args: unknown[]) => unknown;
|
26
|
-
export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions): (...args: unknown[]) => unknown;
|
27
|
-
export declare function getTranspiler(compilerOptions: CompilerOptions): () => (...args: unknown[]) => unknown;
|
27
|
+
export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions, tsNodeOptions?: TsConfigOptions): (...args: unknown[]) => unknown;
|
28
|
+
export declare function getTranspiler(compilerOptions: CompilerOptions, tsConfigRaw?: unknown): () => (...args: unknown[]) => unknown;
|
28
29
|
/**
|
29
30
|
* Register ts-node or swc-node given a set of compiler options.
|
30
31
|
*
|
@@ -33,7 +34,7 @@ export declare function getTranspiler(compilerOptions: CompilerOptions): () => (
|
|
33
34
|
*
|
34
35
|
* @returns cleanup method
|
35
36
|
*/
|
36
|
-
export declare function registerTranspiler(compilerOptions: CompilerOptions): () => void;
|
37
|
+
export declare function registerTranspiler(compilerOptions: CompilerOptions, tsConfigRaw?: unknown): () => void;
|
37
38
|
/**
|
38
39
|
* @param tsConfigPath Adds the paths from a tsconfig file into node resolutions
|
39
40
|
* @returns cleanup function
|
@@ -41,7 +41,7 @@ function getSwcTranspiler(compilerOptions) {
|
|
41
41
|
return typeof cleanupFn === 'function' ? cleanupFn : () => { };
|
42
42
|
}
|
43
43
|
exports.getSwcTranspiler = getSwcTranspiler;
|
44
|
-
function getTsNodeTranspiler(compilerOptions) {
|
44
|
+
function getTsNodeTranspiler(compilerOptions, tsNodeOptions) {
|
45
45
|
const { register } = require('ts-node');
|
46
46
|
// ts-node doesn't provide a cleanup method
|
47
47
|
const service = register({
|
@@ -60,7 +60,49 @@ function getTsNodeTranspiler(compilerOptions) {
|
|
60
60
|
};
|
61
61
|
}
|
62
62
|
exports.getTsNodeTranspiler = getTsNodeTranspiler;
|
63
|
-
|
63
|
+
/**
|
64
|
+
* Given the raw "ts-node" sub-object from a tsconfig, return an object with only the properties
|
65
|
+
* recognized by "ts-node"
|
66
|
+
*
|
67
|
+
* Adapted from the function of the same name in ts-node
|
68
|
+
*/
|
69
|
+
function filterRecognizedTsConfigTsNodeOptions(jsonObject) {
|
70
|
+
if (typeof jsonObject !== 'object' || jsonObject === null) {
|
71
|
+
return { recognized: {}, unrecognized: {} };
|
72
|
+
}
|
73
|
+
const { compiler, compilerHost, compilerOptions, emit, files, ignore, ignoreDiagnostics, logError, preferTsExts, pretty, require, skipIgnore, transpileOnly, typeCheck, transpiler, scope, scopeDir, moduleTypes, experimentalReplAwait, swc, experimentalResolver, esm, experimentalSpecifierResolution, experimentalTsImportSpecifiers, ...unrecognized } = jsonObject;
|
74
|
+
const filteredTsConfigOptions = {
|
75
|
+
compiler,
|
76
|
+
compilerHost,
|
77
|
+
compilerOptions,
|
78
|
+
emit,
|
79
|
+
experimentalReplAwait,
|
80
|
+
files,
|
81
|
+
ignore,
|
82
|
+
ignoreDiagnostics,
|
83
|
+
logError,
|
84
|
+
preferTsExts,
|
85
|
+
pretty,
|
86
|
+
require,
|
87
|
+
skipIgnore,
|
88
|
+
transpileOnly,
|
89
|
+
typeCheck,
|
90
|
+
transpiler,
|
91
|
+
scope,
|
92
|
+
scopeDir,
|
93
|
+
moduleTypes,
|
94
|
+
swc,
|
95
|
+
experimentalResolver,
|
96
|
+
esm,
|
97
|
+
experimentalSpecifierResolution,
|
98
|
+
experimentalTsImportSpecifiers,
|
99
|
+
};
|
100
|
+
// Use the typechecker to make sure this implementation has the correct set of properties
|
101
|
+
const catchExtraneousProps = null;
|
102
|
+
const catchMissingProps = null;
|
103
|
+
return { recognized: filteredTsConfigOptions, unrecognized };
|
104
|
+
}
|
105
|
+
function getTranspiler(compilerOptions, tsConfigRaw) {
|
64
106
|
const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';
|
65
107
|
if (!ts) {
|
66
108
|
ts = require('typescript');
|
@@ -78,7 +120,8 @@ function getTranspiler(compilerOptions) {
|
|
78
120
|
}
|
79
121
|
// We can fall back on ts-node if it's available
|
80
122
|
if (tsNodeInstalled) {
|
81
|
-
|
123
|
+
const tsNodeOptions = filterRecognizedTsConfigTsNodeOptions(tsConfigRaw).recognized;
|
124
|
+
return () => getTsNodeTranspiler(compilerOptions, tsNodeOptions);
|
82
125
|
}
|
83
126
|
}
|
84
127
|
exports.getTranspiler = getTranspiler;
|
@@ -90,7 +133,7 @@ exports.getTranspiler = getTranspiler;
|
|
90
133
|
*
|
91
134
|
* @returns cleanup method
|
92
135
|
*/
|
93
|
-
function registerTranspiler(compilerOptions) {
|
136
|
+
function registerTranspiler(compilerOptions, tsConfigRaw) {
|
94
137
|
// Function to register transpiler that returns cleanup function
|
95
138
|
const transpiler = getTranspiler(compilerOptions);
|
96
139
|
if (!transpiler) {
|
@@ -36,22 +36,22 @@ function filterAffectedProjects(graph, ctx) {
|
|
36
36
|
};
|
37
37
|
const reversed = (0, operators_1.reverse)(graph);
|
38
38
|
ctx.touchedProjects.forEach((p) => {
|
39
|
-
addAffectedNodes(p, reversed, result,
|
39
|
+
addAffectedNodes(p, reversed, result, new Set());
|
40
40
|
});
|
41
41
|
ctx.touchedProjects.forEach((p) => {
|
42
|
-
addAffectedDependencies(p, reversed, result,
|
42
|
+
addAffectedDependencies(p, reversed, result, new Set());
|
43
43
|
});
|
44
44
|
return result;
|
45
45
|
}
|
46
46
|
function addAffectedNodes(startingProject, reversed, result, visited) {
|
47
|
-
if (visited.
|
47
|
+
if (visited.has(startingProject))
|
48
48
|
return;
|
49
49
|
const reversedNode = reversed.nodes[startingProject];
|
50
50
|
const reversedExternalNode = reversed.externalNodes[startingProject];
|
51
51
|
if (!reversedNode && !reversedExternalNode) {
|
52
52
|
throw new Error(`Invalid project name is detected: "${startingProject}"`);
|
53
53
|
}
|
54
|
-
visited.
|
54
|
+
visited.add(startingProject);
|
55
55
|
if (reversedNode) {
|
56
56
|
result.nodes[startingProject] = reversedNode;
|
57
57
|
result.dependencies[startingProject] = [];
|
@@ -62,9 +62,9 @@ function addAffectedNodes(startingProject, reversed, result, visited) {
|
|
62
62
|
reversed.dependencies[startingProject]?.forEach(({ target }) => addAffectedNodes(target, reversed, result, visited));
|
63
63
|
}
|
64
64
|
function addAffectedDependencies(startingProject, reversed, result, visited) {
|
65
|
-
if (visited.
|
65
|
+
if (visited.has(startingProject))
|
66
66
|
return;
|
67
|
-
visited.
|
67
|
+
visited.add(startingProject);
|
68
68
|
if (reversed.dependencies[startingProject]) {
|
69
69
|
reversed.dependencies[startingProject].forEach(({ target }) => addAffectedDependencies(target, reversed, result, visited));
|
70
70
|
reversed.dependencies[startingProject].forEach(({ type, source, target }) => {
|
@@ -8,12 +8,12 @@ const perf_hooks_1 = require("perf_hooks");
|
|
8
8
|
const cache_directory_1 = require("../utils/cache-directory");
|
9
9
|
const fileutils_1 = require("../utils/fileutils");
|
10
10
|
const versions_1 = require("../utils/versions");
|
11
|
-
exports.nxProjectGraph = (0, path_1.join)(cache_directory_1.
|
12
|
-
exports.nxFileMap = (0, path_1.join)(cache_directory_1.
|
11
|
+
exports.nxProjectGraph = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'project-graph.json');
|
12
|
+
exports.nxFileMap = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'file-map.json');
|
13
13
|
function ensureCacheDirectory() {
|
14
14
|
try {
|
15
|
-
if (!(0, fs_1.existsSync)(cache_directory_1.
|
16
|
-
(0, fs_extra_1.ensureDirSync)(cache_directory_1.
|
15
|
+
if (!(0, fs_1.existsSync)(cache_directory_1.workspaceDataDirectory)) {
|
16
|
+
(0, fs_extra_1.ensureDirSync)(cache_directory_1.workspaceDataDirectory);
|
17
17
|
}
|
18
18
|
}
|
19
19
|
catch (e) {
|
@@ -27,8 +27,8 @@ function ensureCacheDirectory() {
|
|
27
27
|
* In this case, we're creating the directory. If the operation failed, we ensure that the directory
|
28
28
|
* exists before continuing (or raise an exception).
|
29
29
|
*/
|
30
|
-
if (!(0, fileutils_1.directoryExists)(cache_directory_1.
|
31
|
-
throw new Error(`Failed to create directory: ${cache_directory_1.
|
30
|
+
if (!(0, fileutils_1.directoryExists)(cache_directory_1.workspaceDataDirectory)) {
|
31
|
+
throw new Error(`Failed to create directory: ${cache_directory_1.workspaceDataDirectory}`);
|
32
32
|
}
|
33
33
|
}
|
34
34
|
}
|
@@ -9,12 +9,12 @@ import { LoadedNxPlugin } from '../plugins/internal-api';
|
|
9
9
|
* @param nxJson
|
10
10
|
*/
|
11
11
|
export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRootMap: Record<string, string>): Promise<{
|
12
|
-
allWorkspaceFiles: import("
|
12
|
+
allWorkspaceFiles: import("../file-utils").FileData[];
|
13
13
|
fileMap: {
|
14
14
|
projectFileMap: ProjectFiles;
|
15
|
-
nonProjectFiles: import("
|
15
|
+
nonProjectFiles: import("../../native").FileData[];
|
16
16
|
};
|
17
|
-
rustReferences: import("
|
17
|
+
rustReferences: import("../../native").NxWorkspaceFilesExternals;
|
18
18
|
}>;
|
19
19
|
/**
|
20
20
|
* Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
|
@@ -81,14 +81,20 @@ function loadDotEnvFilesForTask(task, environmentVariables) {
|
|
81
81
|
// Load DotEnv Files for a configuration in the project root
|
82
82
|
...(task.target.configuration
|
83
83
|
? [
|
84
|
+
`${task.projectRoot}/.env.${task.target.target}.${task.target.configuration}.local`,
|
84
85
|
`${task.projectRoot}/.env.${task.target.target}.${task.target.configuration}`,
|
86
|
+
`${task.projectRoot}/.env.${task.target.configuration}.local`,
|
85
87
|
`${task.projectRoot}/.env.${task.target.configuration}`,
|
88
|
+
`${task.projectRoot}/.${task.target.target}.${task.target.configuration}.local.env`,
|
86
89
|
`${task.projectRoot}/.${task.target.target}.${task.target.configuration}.env`,
|
90
|
+
`${task.projectRoot}/.${task.target.configuration}.local.env`,
|
87
91
|
`${task.projectRoot}/.${task.target.configuration}.env`,
|
88
92
|
]
|
89
93
|
: []),
|
90
94
|
// Load DotEnv Files for a target in the project root
|
95
|
+
`${task.projectRoot}/.env.${task.target.target}.local`,
|
91
96
|
`${task.projectRoot}/.env.${task.target.target}`,
|
97
|
+
`${task.projectRoot}/.${task.target.target}.local.env`,
|
92
98
|
`${task.projectRoot}/.${task.target.target}.env`,
|
93
99
|
`${task.projectRoot}/.env.local`,
|
94
100
|
`${task.projectRoot}/.local.env`,
|
@@ -96,14 +102,20 @@ function loadDotEnvFilesForTask(task, environmentVariables) {
|
|
96
102
|
// Load DotEnv Files for a configuration in the workspace root
|
97
103
|
...(task.target.configuration
|
98
104
|
? [
|
105
|
+
`.env.${task.target.target}.${task.target.configuration}.local`,
|
99
106
|
`.env.${task.target.target}.${task.target.configuration}`,
|
107
|
+
`.env.${task.target.configuration}.local`,
|
100
108
|
`.env.${task.target.configuration}`,
|
109
|
+
`.${task.target.target}.${task.target.configuration}.local.env`,
|
101
110
|
`.${task.target.target}.${task.target.configuration}.env`,
|
111
|
+
`.${task.target.configuration}.local.env`,
|
102
112
|
`.${task.target.configuration}.env`,
|
103
113
|
]
|
104
114
|
: []),
|
105
115
|
// Load DotEnv Files for a target in the workspace root
|
116
|
+
`.env.${task.target.target}.local`,
|
106
117
|
`.env.${task.target.target}`,
|
118
|
+
`.${task.target.target}.local.env`,
|
107
119
|
`.${task.target.target}.env`,
|
108
120
|
// Load base DotEnv Files at workspace root
|
109
121
|
`.local.env`,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.workspaceDataDirectory = exports.cacheDirectoryForWorkspace = exports.cacheDir = void 0;
|
4
4
|
const fs_1 = require("fs");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const fileutils_1 = require("./fileutils");
|
@@ -35,7 +35,7 @@ function cacheDirectory(root, cacheDirectory) {
|
|
35
35
|
return defaultCacheDirectory(root);
|
36
36
|
}
|
37
37
|
}
|
38
|
-
function
|
38
|
+
function pickCacheDirectory(root, nonNxCacheDirectory, nxCacheDirectory) {
|
39
39
|
// If nx.json doesn't exist the repo can't utilize
|
40
40
|
// caching, so .nx/cache is less relevant. Lerna users
|
41
41
|
// that don't want to fully opt in to Nx at this time
|
@@ -44,9 +44,15 @@ function defaultCacheDirectory(root) {
|
|
44
44
|
// this for the time being.
|
45
45
|
if ((0, fs_1.existsSync)((0, path_1.join)(root, 'lerna.json')) &&
|
46
46
|
!(0, fs_1.existsSync)((0, path_1.join)(root, 'nx.json'))) {
|
47
|
-
return (0, path_1.join)(root, 'node_modules', '.cache',
|
47
|
+
return (0, path_1.join)(root, 'node_modules', '.cache', nonNxCacheDirectory);
|
48
48
|
}
|
49
|
-
return (0, path_1.join)(root, '.nx',
|
49
|
+
return (0, path_1.join)(root, '.nx', nxCacheDirectory);
|
50
|
+
}
|
51
|
+
function defaultCacheDirectory(root) {
|
52
|
+
return pickCacheDirectory(root, 'nx', 'cache');
|
53
|
+
}
|
54
|
+
function defaultWorkspaceDataDirectory(root) {
|
55
|
+
return pickCacheDirectory(root, 'nx-workspace-data', 'workspace-data');
|
50
56
|
}
|
51
57
|
/**
|
52
58
|
* Path to the directory where Nx stores its cache and daemon-related files.
|
@@ -56,5 +62,6 @@ function cacheDirectoryForWorkspace(workspaceRoot) {
|
|
56
62
|
return cacheDirectory(workspaceRoot, readCacheDirectoryProperty(workspaceRoot));
|
57
63
|
}
|
58
64
|
exports.cacheDirectoryForWorkspace = cacheDirectoryForWorkspace;
|
59
|
-
exports.
|
60
|
-
|
65
|
+
exports.workspaceDataDirectory = absolutePath(workspace_root_1.workspaceRoot, process.env.NX_WORKSPACE_DATA_DIRECTORY ??
|
66
|
+
process.env.NX_PROJECT_GRAPH_CACHE_DIRECTORY ??
|
67
|
+
defaultWorkspaceDataDirectory(workspace_root_1.workspaceRoot));
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function getPackageNameFromImportPath(importExpression: string): string;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getPackageNameFromImportPath = void 0;
|
4
|
+
//# Converts import paths to package names.
|
5
|
+
//# e.g. - `@nx/workspace` -> `@nx/workspace`
|
6
|
+
//# - `@nx/workspace/plugin` -> `@nx/workspace`
|
7
|
+
//# - `@nx/workspace/other` -> `@nx/workspace`
|
8
|
+
//# - `nx/plugin` -> `nx`
|
9
|
+
function getPackageNameFromImportPath(importExpression) {
|
10
|
+
// Check if the package is scoped
|
11
|
+
if (importExpression.startsWith('@')) {
|
12
|
+
// For scoped packages, the package name is up to the second '/'
|
13
|
+
return importExpression.split('/').slice(0, 2).join('/');
|
14
|
+
}
|
15
|
+
// For unscoped packages, the package name is up to the first '/'
|
16
|
+
return importExpression.split('/')[0];
|
17
|
+
}
|
18
|
+
exports.getPackageNameFromImportPath = getPackageNameFromImportPath;
|
@@ -61,6 +61,7 @@ export interface PackageJson {
|
|
61
61
|
executors?: string;
|
62
62
|
'nx-migrations'?: string | NxMigrationsConfiguration;
|
63
63
|
'ng-update'?: string | NxMigrationsConfiguration;
|
64
|
+
packageManager?: string;
|
64
65
|
}
|
65
66
|
export declare function normalizePackageGroup(packageGroup: PackageGroup): ArrayPackageGroup;
|
66
67
|
export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigrationsConfiguration & {
|
@@ -60,8 +60,15 @@ exports.isWorkspacesEnabled = isWorkspacesEnabled;
|
|
60
60
|
function getPackageManagerCommand(packageManager = detectPackageManager(), root = workspace_root_1.workspaceRoot) {
|
61
61
|
const commands = {
|
62
62
|
yarn: () => {
|
63
|
-
|
64
|
-
|
63
|
+
let yarnVersion, useBerry;
|
64
|
+
try {
|
65
|
+
yarnVersion = getPackageManagerVersion('yarn', root);
|
66
|
+
useBerry = (0, semver_1.gte)(yarnVersion, '2.0.0');
|
67
|
+
}
|
68
|
+
catch {
|
69
|
+
yarnVersion = 'latest';
|
70
|
+
useBerry = true;
|
71
|
+
}
|
65
72
|
return {
|
66
73
|
preInstall: `yarn set version ${yarnVersion}`,
|
67
74
|
install: 'yarn',
|
@@ -84,9 +91,16 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
84
91
|
};
|
85
92
|
},
|
86
93
|
pnpm: () => {
|
87
|
-
|
88
|
-
|
89
|
-
|
94
|
+
let modernPnpm, includeDoubleDashBeforeArgs;
|
95
|
+
try {
|
96
|
+
const pnpmVersion = getPackageManagerVersion('pnpm', root);
|
97
|
+
modernPnpm = (0, semver_1.gte)(pnpmVersion, '6.13.0');
|
98
|
+
includeDoubleDashBeforeArgs = (0, semver_1.lt)(pnpmVersion, '7.0.0');
|
99
|
+
}
|
100
|
+
catch {
|
101
|
+
modernPnpm = true;
|
102
|
+
includeDoubleDashBeforeArgs = true;
|
103
|
+
}
|
90
104
|
const isPnpmWorkspace = (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
|
91
105
|
return {
|
92
106
|
install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
|
@@ -148,10 +162,29 @@ exports.getPackageManagerCommand = getPackageManagerCommand;
|
|
148
162
|
* but it can also be passed in explicitly.
|
149
163
|
*/
|
150
164
|
function getPackageManagerVersion(packageManager = detectPackageManager(), cwd = process.cwd()) {
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
165
|
+
let version;
|
166
|
+
try {
|
167
|
+
version = (0, child_process_1.execSync)(`${packageManager} --version`, {
|
168
|
+
cwd,
|
169
|
+
encoding: 'utf-8',
|
170
|
+
}).trim();
|
171
|
+
}
|
172
|
+
catch {
|
173
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(cwd, 'package.json'))) {
|
174
|
+
const packageVersion = (0, fileutils_1.readJsonFile)((0, path_1.join)(cwd, 'package.json'))?.packageManager;
|
175
|
+
if (packageVersion) {
|
176
|
+
const [packageManagerFromPackageJson, versionFromPackageJson] = packageVersion.split('@');
|
177
|
+
if (packageManagerFromPackageJson === packageManager &&
|
178
|
+
versionFromPackageJson) {
|
179
|
+
version = versionFromPackageJson;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
if (!version) {
|
185
|
+
throw new Error(`Cannot determine the version of ${packageManager}.`);
|
186
|
+
}
|
187
|
+
return version;
|
155
188
|
}
|
156
189
|
exports.getPackageManagerVersion = getPackageManagerVersion;
|
157
190
|
/**
|
package/src/utils/params.d.ts
CHANGED
@@ -79,7 +79,7 @@ export type Options = {
|
|
79
79
|
'--'?: Unmatched[];
|
80
80
|
[k: string]: string | number | boolean | string[] | Unmatched[] | undefined;
|
81
81
|
};
|
82
|
-
export declare function handleErrors(isVerbose: boolean, fn: Function): Promise<
|
82
|
+
export declare function handleErrors(isVerbose: boolean, fn: Function): Promise<number>;
|
83
83
|
export declare function convertToCamelCase(parsed: {
|
84
84
|
[k: string]: any;
|
85
85
|
}, schema: Schema): Options;
|
package/src/utils/params.js
CHANGED
@@ -6,7 +6,11 @@ const output_1 = require("./output");
|
|
6
6
|
const client_1 = require("../daemon/client/client");
|
7
7
|
async function handleErrors(isVerbose, fn) {
|
8
8
|
try {
|
9
|
-
|
9
|
+
const result = await fn();
|
10
|
+
if (typeof result === 'number') {
|
11
|
+
return result;
|
12
|
+
}
|
13
|
+
return 0;
|
10
14
|
}
|
11
15
|
catch (err) {
|
12
16
|
err ||= new Error('Unknown error caught');
|