nx 20.1.0-canary.20241109-77d6704 → 20.2.0-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +11 -11
- package/src/command-line/generate/command-object.js +1 -2
- package/src/command-line/generate/generate.d.ts +1 -1
- package/src/command-line/generate/generate.js +3 -1
- package/src/command-line/init/command-object.js +8 -4
- package/src/command-line/init/implementation/utils.js +11 -1
- package/src/command-line/migrate/command-object.js +2 -96
- package/src/command-line/migrate/migrate.d.ts +1 -0
- package/src/command-line/migrate/migrate.js +89 -0
- package/src/command-line/release/command-object.js +3 -5
- package/src/command-line/release/utils/git.js +25 -2
- package/src/command-line/yargs-utils/shared-options.d.ts +3 -0
- package/src/command-line/yargs-utils/shared-options.js +19 -0
- package/src/core/graph/main.js +1 -1
- package/src/daemon/tmp-dir.js +1 -1
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/project-graph/error-types.d.ts +1 -1
- package/src/tasks-runner/create-task-graph.js +5 -1
- package/src/utils/assert-workspace-validity.js +4 -0
- package/src/utils/command-line-utils.d.ts +0 -3
- package/src/utils/command-line-utils.js +2 -20
- package/src/utils/find-matching-projects.js +2 -1
- package/src/utils/handle-errors.js +3 -3
- package/src/utils/package-json.d.ts +1 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.2.0-beta.0",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -80,16 +80,16 @@
|
|
80
80
|
}
|
81
81
|
},
|
82
82
|
"optionalDependencies": {
|
83
|
-
"@nx/nx-darwin-x64": "20.
|
84
|
-
"@nx/nx-darwin-arm64": "20.
|
85
|
-
"@nx/nx-linux-x64-gnu": "20.
|
86
|
-
"@nx/nx-linux-x64-musl": "20.
|
87
|
-
"@nx/nx-win32-x64-msvc": "20.
|
88
|
-
"@nx/nx-linux-arm64-gnu": "20.
|
89
|
-
"@nx/nx-linux-arm64-musl": "20.
|
90
|
-
"@nx/nx-linux-arm-gnueabihf": "20.
|
91
|
-
"@nx/nx-win32-arm64-msvc": "20.
|
92
|
-
"@nx/nx-freebsd-x64": "20.
|
83
|
+
"@nx/nx-darwin-x64": "20.2.0-beta.0",
|
84
|
+
"@nx/nx-darwin-arm64": "20.2.0-beta.0",
|
85
|
+
"@nx/nx-linux-x64-gnu": "20.2.0-beta.0",
|
86
|
+
"@nx/nx-linux-x64-musl": "20.2.0-beta.0",
|
87
|
+
"@nx/nx-win32-x64-msvc": "20.2.0-beta.0",
|
88
|
+
"@nx/nx-linux-arm64-gnu": "20.2.0-beta.0",
|
89
|
+
"@nx/nx-linux-arm64-musl": "20.2.0-beta.0",
|
90
|
+
"@nx/nx-linux-arm-gnueabihf": "20.2.0-beta.0",
|
91
|
+
"@nx/nx-win32-arm64-msvc": "20.2.0-beta.0",
|
92
|
+
"@nx/nx-freebsd-x64": "20.2.0-beta.0"
|
93
93
|
},
|
94
94
|
"nx-migrations": {
|
95
95
|
"migrations": "./migrations.json",
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.yargsGenerateCommand = void 0;
|
4
|
-
const path_1 = require("../../utils/path");
|
5
4
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
6
5
|
exports.yargsGenerateCommand = {
|
7
6
|
command: 'generate <generator> [_..]',
|
@@ -11,7 +10,7 @@ exports.yargsGenerateCommand = {
|
|
11
10
|
handler: async (args) => {
|
12
11
|
// Remove the command from the args
|
13
12
|
args._ = args._.slice(1);
|
14
|
-
process.exit(await (await Promise.resolve().then(() => require('./generate'))).generate(
|
13
|
+
process.exit(await (await Promise.resolve().then(() => require('./generate'))).generate(args));
|
15
14
|
},
|
16
15
|
};
|
17
16
|
function withGenerateOptions(yargs) {
|
@@ -16,6 +16,6 @@ export declare function parseGeneratorString(value: string): {
|
|
16
16
|
generator: string;
|
17
17
|
};
|
18
18
|
export declare function printGenHelp(opts: GenerateOptions, schema: Schema, normalizedGeneratorName: string, aliases: string[]): void;
|
19
|
-
export declare function generate(
|
19
|
+
export declare function generate(args: {
|
20
20
|
[k: string]: any;
|
21
21
|
}): Promise<number>;
|
@@ -19,6 +19,7 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
19
19
|
const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
|
20
20
|
const installed_plugins_1 = require("../../utils/plugins/installed-plugins");
|
21
21
|
const generator_utils_1 = require("./generator-utils");
|
22
|
+
const path_2 = require("../../utils/path");
|
22
23
|
function printChanges(fileChanges) {
|
23
24
|
fileChanges.forEach((f) => {
|
24
25
|
if (f.type === 'CREATE') {
|
@@ -206,7 +207,7 @@ function printGenHelp(opts, schema, normalizedGeneratorName, aliases) {
|
|
206
207
|
aliases,
|
207
208
|
});
|
208
209
|
}
|
209
|
-
async function generate(
|
210
|
+
async function generate(args) {
|
210
211
|
return (0, handle_errors_1.handleErrors)(args.verbose, async () => {
|
211
212
|
const nxJsonConfiguration = (0, configuration_1.readNxJson)();
|
212
213
|
const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
|
@@ -226,6 +227,7 @@ async function generate(cwd, args) {
|
|
226
227
|
printGenHelp(opts, schema, normalizedGeneratorName, aliases);
|
227
228
|
return 0;
|
228
229
|
}
|
230
|
+
const cwd = (0, path_2.getCwd)();
|
229
231
|
const combinedOpts = await (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, projectsConfigurations, nxJsonConfiguration), (0, path_1.relative)(workspace_root_1.workspaceRoot, cwd), args.verbose);
|
230
232
|
if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot, projectsConfigurations.projects).isNxGenerator) {
|
231
233
|
const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
|
@@ -2,14 +2,12 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.yargsInitCommand = void 0;
|
4
4
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
5
|
-
const nx_json_1 = require("../../config/nx-json");
|
6
|
-
const useV2 = process.env['NX_ADD_PLUGINS'] !== 'false' &&
|
7
|
-
(0, nx_json_1.readNxJson)().useInferencePlugins !== false;
|
8
5
|
exports.yargsInitCommand = {
|
9
6
|
command: 'init',
|
10
7
|
describe: 'Adds Nx to any type of workspace. It installs nx, creates an nx.json configuration file and optionally sets up remote caching. For more info, check https://nx.dev/recipes/adopting-nx.',
|
11
8
|
builder: (yargs) => withInitOptions(yargs),
|
12
9
|
handler: async (args) => {
|
10
|
+
const useV2 = await isInitV2();
|
13
11
|
if (useV2) {
|
14
12
|
await require('./init-v2').initHandler(args);
|
15
13
|
}
|
@@ -19,7 +17,13 @@ exports.yargsInitCommand = {
|
|
19
17
|
process.exit(0);
|
20
18
|
},
|
21
19
|
};
|
22
|
-
function
|
20
|
+
async function isInitV2() {
|
21
|
+
return (process.env['NX_ADD_PLUGINS'] !== 'false' &&
|
22
|
+
(await Promise.resolve().then(() => require('../../config/nx-json'))).readNxJson().useInferencePlugins !==
|
23
|
+
false);
|
24
|
+
}
|
25
|
+
async function withInitOptions(yargs) {
|
26
|
+
const useV2 = await isInitV2();
|
23
27
|
if (useV2) {
|
24
28
|
return yargs
|
25
29
|
.option('nxCloud', {
|
@@ -21,6 +21,7 @@ const fs_1 = require("fs");
|
|
21
21
|
const connect_to_nx_cloud_1 = require("../../../nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud");
|
22
22
|
const url_shorten_1 = require("../../../nx-cloud/utilities/url-shorten");
|
23
23
|
const connect_to_nx_cloud_2 = require("../../connect/connect-to-nx-cloud");
|
24
|
+
const default_base_1 = require("../../../utils/default-base");
|
24
25
|
function createNxJsonFile(repoRoot, topologicalTargets, cacheableOperations, scriptOutputs) {
|
25
26
|
const nxJsonPath = (0, path_2.joinPathFragments)(repoRoot, 'nx.json');
|
26
27
|
let nxJson = {};
|
@@ -88,7 +89,16 @@ function deduceDefaultBase() {
|
|
88
89
|
return 'next';
|
89
90
|
}
|
90
91
|
catch {
|
91
|
-
|
92
|
+
try {
|
93
|
+
(0, child_process_1.execSync)(`git rev-parse --verify master`, {
|
94
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
95
|
+
windowsHide: false,
|
96
|
+
});
|
97
|
+
return 'master';
|
98
|
+
}
|
99
|
+
catch {
|
100
|
+
return (0, default_base_1.deduceDefaultBase)();
|
101
|
+
}
|
92
102
|
}
|
93
103
|
}
|
94
104
|
}
|
@@ -1,13 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.yargsInternalMigrateCommand = exports.yargsMigrateCommand = void 0;
|
4
|
-
const path = require("path");
|
5
|
-
const child_process_1 = require("../../utils/child-process");
|
6
4
|
const documentation_1 = require("../yargs-utils/documentation");
|
7
|
-
const child_process_2 = require("child_process");
|
8
|
-
const package_manager_1 = require("../../utils/package-manager");
|
9
|
-
const fileutils_1 = require("../../utils/fileutils");
|
10
|
-
const workspace_root_1 = require("../../utils/workspace-root");
|
11
5
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
12
6
|
exports.yargsMigrateCommand = {
|
13
7
|
command: 'migrate [packageAndVersion]',
|
@@ -15,8 +9,8 @@ exports.yargsMigrateCommand = {
|
|
15
9
|
- Migrate packages and create migrations.json (e.g., nx migrate @nx/workspace@latest)
|
16
10
|
- Run migrations (e.g., nx migrate --run-migrations=migrations.json). Use flag --if-exists to run migrations only if the migrations file exists.`,
|
17
11
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)(withMigrationOptions(yargs), 'migrate'),
|
18
|
-
handler: () => {
|
19
|
-
runMigration();
|
12
|
+
handler: async () => {
|
13
|
+
(await Promise.resolve().then(() => require('./migrate'))).runMigration();
|
20
14
|
process.exit(0);
|
21
15
|
},
|
22
16
|
};
|
@@ -81,91 +75,3 @@ function withMigrationOptions(yargs) {
|
|
81
75
|
return true;
|
82
76
|
});
|
83
77
|
}
|
84
|
-
function runMigration() {
|
85
|
-
const runLocalMigrate = () => {
|
86
|
-
(0, child_process_1.runNxSync)(`_migrate ${process.argv.slice(3).join(' ')}`, {
|
87
|
-
stdio: ['inherit', 'inherit', 'inherit'],
|
88
|
-
});
|
89
|
-
};
|
90
|
-
if (process.env.NX_MIGRATE_USE_LOCAL === undefined) {
|
91
|
-
const p = nxCliPath();
|
92
|
-
if (p === null) {
|
93
|
-
runLocalMigrate();
|
94
|
-
}
|
95
|
-
else {
|
96
|
-
// ensure local registry from process is not interfering with the install
|
97
|
-
// when we start the process from temp folder the local registry would override the custom registry
|
98
|
-
if (process.env.npm_config_registry &&
|
99
|
-
process.env.npm_config_registry.match(/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/)) {
|
100
|
-
delete process.env.npm_config_registry;
|
101
|
-
}
|
102
|
-
(0, child_process_2.execSync)(`${p} _migrate ${process.argv.slice(3).join(' ')}`, {
|
103
|
-
stdio: ['inherit', 'inherit', 'inherit'],
|
104
|
-
windowsHide: false,
|
105
|
-
});
|
106
|
-
}
|
107
|
-
}
|
108
|
-
else {
|
109
|
-
runLocalMigrate();
|
110
|
-
}
|
111
|
-
}
|
112
|
-
function nxCliPath() {
|
113
|
-
const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
|
114
|
-
try {
|
115
|
-
const packageManager = (0, package_manager_1.detectPackageManager)();
|
116
|
-
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
117
|
-
const { dirSync } = require('tmp');
|
118
|
-
const tmpDir = dirSync().name;
|
119
|
-
(0, fileutils_1.writeJsonFile)(path.join(tmpDir, 'package.json'), {
|
120
|
-
dependencies: {
|
121
|
-
nx: version,
|
122
|
-
},
|
123
|
-
license: 'MIT',
|
124
|
-
});
|
125
|
-
(0, package_manager_1.copyPackageManagerConfigurationFiles)(workspace_root_1.workspaceRoot, tmpDir);
|
126
|
-
if (pmc.preInstall) {
|
127
|
-
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
128
|
-
(0, child_process_2.execSync)(pmc.preInstall, {
|
129
|
-
cwd: tmpDir,
|
130
|
-
stdio: ['ignore', 'ignore', 'ignore'],
|
131
|
-
windowsHide: false,
|
132
|
-
});
|
133
|
-
// if it's berry ensure we set the node_linker to node-modules
|
134
|
-
if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) {
|
135
|
-
(0, child_process_2.execSync)('yarn config set nodeLinker node-modules', {
|
136
|
-
cwd: tmpDir,
|
137
|
-
stdio: ['ignore', 'ignore', 'ignore'],
|
138
|
-
windowsHide: false,
|
139
|
-
});
|
140
|
-
}
|
141
|
-
}
|
142
|
-
(0, child_process_2.execSync)(pmc.install, {
|
143
|
-
cwd: tmpDir,
|
144
|
-
stdio: ['ignore', 'ignore', 'ignore'],
|
145
|
-
windowsHide: false,
|
146
|
-
});
|
147
|
-
// Set NODE_PATH so that these modules can be used for module resolution
|
148
|
-
addToNodePath(path.join(tmpDir, 'node_modules'));
|
149
|
-
addToNodePath(path.join(workspace_root_1.workspaceRoot, 'node_modules'));
|
150
|
-
return path.join(tmpDir, `node_modules`, '.bin', 'nx');
|
151
|
-
}
|
152
|
-
catch (e) {
|
153
|
-
console.error(`Failed to install the ${version} version of the migration script. Using the current version.`);
|
154
|
-
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
155
|
-
console.error(e);
|
156
|
-
}
|
157
|
-
return null;
|
158
|
-
}
|
159
|
-
}
|
160
|
-
function addToNodePath(dir) {
|
161
|
-
// NODE_PATH is a delimited list of paths.
|
162
|
-
// The delimiter is different for windows.
|
163
|
-
const delimiter = require('os').platform() === 'win32' ? ';' : ':';
|
164
|
-
const paths = process.env.NODE_PATH
|
165
|
-
? process.env.NODE_PATH.split(delimiter)
|
166
|
-
: [];
|
167
|
-
// Add the tmp path
|
168
|
-
paths.push(dir);
|
169
|
-
// Update the env variable.
|
170
|
-
process.env.NODE_PATH = paths.join(delimiter);
|
171
|
-
}
|
@@ -5,6 +5,7 @@ exports.normalizeVersion = normalizeVersion;
|
|
5
5
|
exports.parseMigrationsOptions = parseMigrationsOptions;
|
6
6
|
exports.executeMigrations = executeMigrations;
|
7
7
|
exports.migrate = migrate;
|
8
|
+
exports.runMigration = runMigration;
|
8
9
|
const chalk = require("chalk");
|
9
10
|
const child_process_1 = require("child_process");
|
10
11
|
const enquirer_1 = require("enquirer");
|
@@ -1051,6 +1052,34 @@ async function migrate(root, args, rawArgs) {
|
|
1051
1052
|
}
|
1052
1053
|
});
|
1053
1054
|
}
|
1055
|
+
function runMigration() {
|
1056
|
+
const runLocalMigrate = () => {
|
1057
|
+
(0, child_process_2.runNxSync)(`_migrate ${process.argv.slice(3).join(' ')}`, {
|
1058
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
1059
|
+
});
|
1060
|
+
};
|
1061
|
+
if (process.env.NX_MIGRATE_USE_LOCAL === undefined) {
|
1062
|
+
const p = nxCliPath();
|
1063
|
+
if (p === null) {
|
1064
|
+
runLocalMigrate();
|
1065
|
+
}
|
1066
|
+
else {
|
1067
|
+
// ensure local registry from process is not interfering with the install
|
1068
|
+
// when we start the process from temp folder the local registry would override the custom registry
|
1069
|
+
if (process.env.npm_config_registry &&
|
1070
|
+
process.env.npm_config_registry.match(/^https:\/\/registry\.(npmjs\.org|yarnpkg\.com)/)) {
|
1071
|
+
delete process.env.npm_config_registry;
|
1072
|
+
}
|
1073
|
+
(0, child_process_1.execSync)(`${p} _migrate ${process.argv.slice(3).join(' ')}`, {
|
1074
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
1075
|
+
windowsHide: false,
|
1076
|
+
});
|
1077
|
+
}
|
1078
|
+
}
|
1079
|
+
else {
|
1080
|
+
runLocalMigrate();
|
1081
|
+
}
|
1082
|
+
}
|
1054
1083
|
function readMigrationCollection(packageName, root) {
|
1055
1084
|
const collectionPath = readPackageMigrationConfig(packageName, root).migrations;
|
1056
1085
|
const collection = (0, fileutils_1.readJsonFile)(collectionPath);
|
@@ -1079,6 +1108,66 @@ function getImplementationPath(collection, collectionPath, name) {
|
|
1079
1108
|
}
|
1080
1109
|
return { path: implPath, fnSymbol };
|
1081
1110
|
}
|
1111
|
+
function nxCliPath() {
|
1112
|
+
const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
|
1113
|
+
try {
|
1114
|
+
const packageManager = (0, package_manager_1.detectPackageManager)();
|
1115
|
+
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
1116
|
+
const { dirSync } = require('tmp');
|
1117
|
+
const tmpDir = dirSync().name;
|
1118
|
+
(0, fileutils_1.writeJsonFile)((0, path_1.join)(tmpDir, 'package.json'), {
|
1119
|
+
dependencies: {
|
1120
|
+
nx: version,
|
1121
|
+
},
|
1122
|
+
license: 'MIT',
|
1123
|
+
});
|
1124
|
+
(0, package_manager_1.copyPackageManagerConfigurationFiles)(workspace_root_1.workspaceRoot, tmpDir);
|
1125
|
+
if (pmc.preInstall) {
|
1126
|
+
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
1127
|
+
(0, child_process_1.execSync)(pmc.preInstall, {
|
1128
|
+
cwd: tmpDir,
|
1129
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
1130
|
+
windowsHide: false,
|
1131
|
+
});
|
1132
|
+
// if it's berry ensure we set the node_linker to node-modules
|
1133
|
+
if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) {
|
1134
|
+
(0, child_process_1.execSync)('yarn config set nodeLinker node-modules', {
|
1135
|
+
cwd: tmpDir,
|
1136
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
1137
|
+
windowsHide: false,
|
1138
|
+
});
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
(0, child_process_1.execSync)(pmc.install, {
|
1142
|
+
cwd: tmpDir,
|
1143
|
+
stdio: ['ignore', 'ignore', 'ignore'],
|
1144
|
+
windowsHide: false,
|
1145
|
+
});
|
1146
|
+
// Set NODE_PATH so that these modules can be used for module resolution
|
1147
|
+
addToNodePath((0, path_1.join)(tmpDir, 'node_modules'));
|
1148
|
+
addToNodePath((0, path_1.join)(workspace_root_1.workspaceRoot, 'node_modules'));
|
1149
|
+
return (0, path_1.join)(tmpDir, `node_modules`, '.bin', 'nx');
|
1150
|
+
}
|
1151
|
+
catch (e) {
|
1152
|
+
console.error(`Failed to install the ${version} version of the migration script. Using the current version.`);
|
1153
|
+
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
1154
|
+
console.error(e);
|
1155
|
+
}
|
1156
|
+
return null;
|
1157
|
+
}
|
1158
|
+
}
|
1159
|
+
function addToNodePath(dir) {
|
1160
|
+
// NODE_PATH is a delimited list of paths.
|
1161
|
+
// The delimiter is different for windows.
|
1162
|
+
const delimiter = require('os').platform() === 'win32' ? ';' : ':';
|
1163
|
+
const paths = process.env.NODE_PATH
|
1164
|
+
? process.env.NODE_PATH.split(delimiter)
|
1165
|
+
: [];
|
1166
|
+
// Add the tmp path
|
1167
|
+
paths.push(dir);
|
1168
|
+
// Update the env variable.
|
1169
|
+
process.env.NODE_PATH = paths.join(delimiter);
|
1170
|
+
}
|
1082
1171
|
// TODO (v21): Remove CLI determination of Angular Migration
|
1083
1172
|
function isAngularMigration(collection, collectionPath, name) {
|
1084
1173
|
const entry = collection.generators?.[name] || collection.schematics?.[name];
|
@@ -2,8 +2,6 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.yargsReleaseCommand = void 0;
|
4
4
|
const yargs_1 = require("yargs");
|
5
|
-
const nx_json_1 = require("../../config/nx-json");
|
6
|
-
const command_line_utils_1 = require("../../utils/command-line-utils");
|
7
5
|
const logger_1 = require("../../utils/logger");
|
8
6
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
9
7
|
exports.yargsReleaseCommand = {
|
@@ -51,11 +49,11 @@ exports.yargsReleaseCommand = {
|
|
51
49
|
return val;
|
52
50
|
},
|
53
51
|
})
|
54
|
-
.check((argv) => {
|
52
|
+
.check(async (argv) => {
|
55
53
|
if (argv.groups && argv.projects) {
|
56
54
|
throw new Error('The --projects and --groups options are mutually exclusive, please use one or the other.');
|
57
55
|
}
|
58
|
-
const nxJson = (
|
56
|
+
const nxJson = (await Promise.resolve().then(() => require('../../config/nx-json'))).readNxJson();
|
59
57
|
if (argv.groups?.length) {
|
60
58
|
for (const group of argv.groups) {
|
61
59
|
if (!nxJson.release?.groups?.[group]) {
|
@@ -255,7 +253,7 @@ const planCheckCommand = {
|
|
255
253
|
function coerceParallelOption(args) {
|
256
254
|
return {
|
257
255
|
...args,
|
258
|
-
parallel: (0,
|
256
|
+
parallel: (0, shared_options_1.readParallelFromArgsAndEnv)(args),
|
259
257
|
};
|
260
258
|
}
|
261
259
|
function withGitCommitAndGitTagOptions(yargs) {
|
@@ -15,6 +15,7 @@ exports.getFirstGitCommit = getFirstGitCommit;
|
|
15
15
|
* Special thanks to changelogen for the original inspiration for many of these utilities:
|
16
16
|
* https://github.com/unjs/changelogen
|
17
17
|
*/
|
18
|
+
const node_path_1 = require("node:path");
|
18
19
|
const utils_1 = require("../../../tasks-runner/utils");
|
19
20
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
20
21
|
const exec_command_1 = require("./exec-command");
|
@@ -86,13 +87,19 @@ async function getGitDiff(from, to = 'HEAD') {
|
|
86
87
|
// Use a unique enough separator that we can be relatively certain will not occur within the commit message itself
|
87
88
|
const separator = '§§§';
|
88
89
|
// https://git-scm.com/docs/pretty-formats
|
89
|
-
const
|
90
|
+
const args = [
|
90
91
|
'--no-pager',
|
91
92
|
'log',
|
92
93
|
range,
|
93
94
|
`--pretty="----%n%s${separator}%h${separator}%an${separator}%ae%n%b"`,
|
94
95
|
'--name-status',
|
95
|
-
]
|
96
|
+
];
|
97
|
+
// Support cases where the nx workspace root is located at a nested path within the git repo
|
98
|
+
const relativePath = await getGitRootRelativePath();
|
99
|
+
if (relativePath) {
|
100
|
+
args.push(`--relative=${relativePath}`);
|
101
|
+
}
|
102
|
+
const r = await (0, exec_command_1.execCommand)('git', args);
|
96
103
|
return r
|
97
104
|
.split('----\n')
|
98
105
|
.splice(1)
|
@@ -405,3 +412,19 @@ async function getFirstGitCommit() {
|
|
405
412
|
throw new Error(`Unable to find first commit in git history`);
|
406
413
|
}
|
407
414
|
}
|
415
|
+
async function getGitRoot() {
|
416
|
+
try {
|
417
|
+
return (await (0, exec_command_1.execCommand)('git', ['rev-parse', '--show-toplevel'])).trim();
|
418
|
+
}
|
419
|
+
catch (e) {
|
420
|
+
throw new Error('Unable to find git root');
|
421
|
+
}
|
422
|
+
}
|
423
|
+
let gitRootRelativePath;
|
424
|
+
async function getGitRootRelativePath() {
|
425
|
+
if (!gitRootRelativePath) {
|
426
|
+
const gitRoot = await getGitRoot();
|
427
|
+
gitRootRelativePath = (0, node_path_1.relative)(gitRoot, workspace_root_1.workspaceRoot);
|
428
|
+
}
|
429
|
+
return gitRootRelativePath;
|
430
|
+
}
|
@@ -72,4 +72,7 @@ export declare function withRunOneOptions(yargs: Argv): Argv<{
|
|
72
72
|
help: boolean;
|
73
73
|
}>;
|
74
74
|
export declare function parseCSV(args: string[] | string): string[];
|
75
|
+
export declare function readParallelFromArgsAndEnv(args: {
|
76
|
+
[k: string]: any;
|
77
|
+
}): number;
|
75
78
|
export {};
|
@@ -13,6 +13,7 @@ exports.withOverrides = withOverrides;
|
|
13
13
|
exports.withOutputStyleOption = withOutputStyleOption;
|
14
14
|
exports.withRunOneOptions = withRunOneOptions;
|
15
15
|
exports.parseCSV = parseCSV;
|
16
|
+
exports.readParallelFromArgsAndEnv = readParallelFromArgsAndEnv;
|
16
17
|
exports.defaultYargsParserConfiguration = {
|
17
18
|
'strip-dashed': true,
|
18
19
|
'unknown-options-as-args': true,
|
@@ -251,3 +252,21 @@ function parseCSV(args) {
|
|
251
252
|
const items = args.split(',');
|
252
253
|
return items.map((i) => i.startsWith('"') && i.endsWith('"') ? i.slice(1, -1) : i);
|
253
254
|
}
|
255
|
+
function readParallelFromArgsAndEnv(args) {
|
256
|
+
if (args['parallel'] === 'false' || args['parallel'] === false) {
|
257
|
+
return 1;
|
258
|
+
}
|
259
|
+
else if (args['parallel'] === 'true' ||
|
260
|
+
args['parallel'] === true ||
|
261
|
+
args['parallel'] === '' ||
|
262
|
+
// dont require passing --parallel if NX_PARALLEL is set, but allow overriding it
|
263
|
+
(process.env.NX_PARALLEL && args['parallel'] === undefined)) {
|
264
|
+
return Number(args['maxParallel'] ||
|
265
|
+
args['max-parallel'] ||
|
266
|
+
process.env.NX_PARALLEL ||
|
267
|
+
3);
|
268
|
+
}
|
269
|
+
else if (args['parallel'] !== undefined) {
|
270
|
+
return Number(args['parallel']);
|
271
|
+
}
|
272
|
+
}
|