nx 24.0.5 → 24.1.0-beta.0
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/dist/bin/nx.js +2 -8
- package/dist/bin/workspace-env.d.ts +7 -0
- package/dist/bin/workspace-env.js +20 -0
- package/dist/src/adapter/ngcli-adapter.js +7 -20
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +0 -1
- package/dist/src/command-line/generate/generate.js +12 -23
- package/dist/src/command-line/graph/graph.js +1 -7
- package/dist/src/command-line/import/utils/prepare-source-repo.js +0 -3
- package/dist/src/command-line/init/implementation/angular/standalone-workspace.js +2 -2
- package/dist/src/command-line/init/init-v2.js +2 -2
- package/dist/src/command-line/migrate/migrate.js +4 -6
- package/dist/src/command-line/migrate/prompt-files.js +5 -5
- package/dist/src/command-line/migrate/run/orchestrator.js +2 -3
- package/dist/src/command-line/migrate/run/worker.js +7 -5
- package/dist/src/command-line/migrate/run-migration-process.js +3 -2
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +1 -1
- package/dist/src/command-line/release/changelog.js +8 -39
- package/dist/src/command-line/release/config/use-legacy-versioning.js +1 -1
- package/dist/src/command-line/release/utils/diff.js +0 -14
- package/dist/src/command-line/release/utils/git.js +1 -1
- package/dist/src/command-line/reset/reset.js +13 -1
- package/dist/src/command-line/run/executor-utils.js +1 -1
- package/dist/src/command-line/show/show-target/utils.js +1 -1
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/commands-runner/get-command-projects.js +0 -3
- package/dist/src/config/misc-interfaces.d.ts +0 -1
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.css +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/daemon-environment.d.ts +5 -3
- package/dist/src/daemon/client/daemon-environment.js +15 -3
- package/dist/src/devkit-internals.js +1 -1
- package/dist/src/executors/run-commands/running-tasks.d.ts +1 -0
- package/dist/src/executors/run-commands/running-tasks.js +69 -17
- package/dist/src/executors/run-script/run-script.impl.js +11 -3
- package/dist/src/hasher/hash-task.js +4 -4
- package/dist/src/hasher/task-hasher.js +2 -2
- package/dist/src/native/index.js +31 -3
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/native/transform-objects.js +5 -1
- package/dist/src/nx-cloud/update-manager.d.ts +6 -1
- package/dist/src/nx-cloud/update-manager.js +39 -12
- package/dist/src/nx-cloud/utilities/environment.js +0 -17
- package/dist/src/plugins/js/lock-file/bun-parser.js +0 -2
- package/dist/src/plugins/js/lock-file/npm-parser.js +1 -2
- package/dist/src/plugins/js/package-json/create-package-json.d.ts +1 -1
- package/dist/src/plugins/js/package-json/create-package-json.js +31 -13
- package/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +7 -1
- package/dist/src/plugins/js/utils/get-workspace-packages-from-graph.js +1 -1
- package/dist/src/plugins/js/utils/register.js +1 -1
- package/dist/src/project-graph/affected/affected-tasks.js +1 -1
- package/dist/src/tasks-runner/run-command.js +6 -7
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +3 -2
- package/dist/src/tasks-runner/running-tasks/batch-process.js +7 -3
- package/dist/src/tasks-runner/task-orchestrator.js +1 -1
- package/dist/src/tasks-runner/utils.js +1 -12
- package/dist/src/ultracache/overrides.js +1 -1
- package/dist/src/utils/cache-directory.d.ts +3 -0
- package/dist/src/utils/cache-directory.js +105 -25
- package/dist/src/utils/child-process.d.ts +8 -1
- package/dist/src/utils/child-process.js +24 -0
- package/dist/src/utils/code-frames.js +0 -1
- package/dist/src/utils/compile-cache.d.ts +6 -8
- package/dist/src/utils/compile-cache.js +23 -16
- package/dist/src/utils/db-connection.js +6 -4
- package/dist/src/utils/min-release-age/behavior/pnpm.js +9 -9
- package/dist/src/utils/min-release-age/behavior/yarn.js +2 -2
- package/dist/src/utils/nx-tmp-dir.d.ts +14 -2
- package/dist/src/utils/nx-tmp-dir.js +26 -2
- package/dist/src/utils/package-json.js +40 -20
- package/dist/src/utils/package-manager.d.ts +15 -0
- package/dist/src/utils/package-manager.js +184 -2
- package/dist/src/utils/plugins/output.js +0 -2
- package/package.json +12 -12
package/dist/bin/nx.js
CHANGED
|
@@ -17,6 +17,7 @@ const output_1 = require("../src/utils/output");
|
|
|
17
17
|
const installation_directory_1 = require("../src/utils/installation-directory");
|
|
18
18
|
const semver_1 = require("semver");
|
|
19
19
|
const strip_indents_1 = require("../src/utils/strip-indents");
|
|
20
|
+
const workspace_env_1 = require("./workspace-env");
|
|
20
21
|
const child_process_1 = require("child_process");
|
|
21
22
|
const module_1 = require("module");
|
|
22
23
|
const path_1 = require("path");
|
|
@@ -63,14 +64,7 @@ async function main() {
|
|
|
63
64
|
// --version doesn't need any env / daemon / analytics state — skip dotenv
|
|
64
65
|
// loading (and the heavy modules it would pull in).
|
|
65
66
|
if (workspace && process.argv[2] !== '--version') {
|
|
66
|
-
|
|
67
|
-
process.report.reportOnFatalError = true;
|
|
68
|
-
process.report.directory = workspaceDataDirectoryForWorkspace(workspace.dir);
|
|
69
|
-
const { loadRootEnvFiles } = await import('../src/utils/dotenv.js');
|
|
70
|
-
perf_hooks_1.performance.mark('loading dotenv files:start');
|
|
71
|
-
loadRootEnvFiles(workspace.dir);
|
|
72
|
-
perf_hooks_1.performance.mark('loading dotenv files:end');
|
|
73
|
-
perf_hooks_1.performance.measure('loading dotenv files', 'loading dotenv files:start', 'loading dotenv files:end');
|
|
67
|
+
await (0, workspace_env_1.loadWorkspaceEnv)(workspace.dir);
|
|
74
68
|
}
|
|
75
69
|
// new is a special case because there is no local workspace to load
|
|
76
70
|
if (process.argv[2] === 'new' ||
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads the workspace's root `.env` files, then sends Node's fatal error
|
|
3
|
+
* reports to its workspace data directory. The `.env` files load first because
|
|
4
|
+
* importing `cache-directory` resolves and checks the configured directories,
|
|
5
|
+
* which read `NX_*` variables those files can set.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadWorkspaceEnv(workspaceDir: string): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadWorkspaceEnv = loadWorkspaceEnv;
|
|
4
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
5
|
+
/**
|
|
6
|
+
* Loads the workspace's root `.env` files, then sends Node's fatal error
|
|
7
|
+
* reports to its workspace data directory. The `.env` files load first because
|
|
8
|
+
* importing `cache-directory` resolves and checks the configured directories,
|
|
9
|
+
* which read `NX_*` variables those files can set.
|
|
10
|
+
*/
|
|
11
|
+
async function loadWorkspaceEnv(workspaceDir) {
|
|
12
|
+
const { loadRootEnvFiles } = await import('../src/utils/dotenv.js');
|
|
13
|
+
perf_hooks_1.performance.mark('loading dotenv files:start');
|
|
14
|
+
loadRootEnvFiles(workspaceDir);
|
|
15
|
+
perf_hooks_1.performance.mark('loading dotenv files:end');
|
|
16
|
+
perf_hooks_1.performance.measure('loading dotenv files', 'loading dotenv files:start', 'loading dotenv files:end');
|
|
17
|
+
const { workspaceDataDirectoryForWorkspace } = await import('../src/utils/cache-directory.js');
|
|
18
|
+
process.report.reportOnFatalError = true;
|
|
19
|
+
process.report.directory = workspaceDataDirectoryForWorkspace(workspaceDir);
|
|
20
|
+
}
|
|
@@ -227,7 +227,7 @@ function getCollection(workflow, name) {
|
|
|
227
227
|
throw new Error(`Cannot find collection '${name}'`);
|
|
228
228
|
return collection;
|
|
229
229
|
}
|
|
230
|
-
async function createRecorder(
|
|
230
|
+
async function createRecorder(record, logger) {
|
|
231
231
|
return (event) => {
|
|
232
232
|
let eventPath = event.path.startsWith('/')
|
|
233
233
|
? event.path.slice(1)
|
|
@@ -266,12 +266,12 @@ async function createRecorder(host, record, logger) {
|
|
|
266
266
|
function emptyFileChange(type, path) {
|
|
267
267
|
return { type, path, content: Buffer.alloc(0) };
|
|
268
268
|
}
|
|
269
|
-
async function runSchematic(
|
|
269
|
+
async function runSchematic(root, workflow, logger, opts, schematic, printDryRunMessage = true, recorder = null) {
|
|
270
270
|
const record = {
|
|
271
271
|
loggingQueue: [],
|
|
272
272
|
error: false,
|
|
273
273
|
};
|
|
274
|
-
workflow.reporter.subscribe(recorder || (await createRecorder(
|
|
274
|
+
workflow.reporter.subscribe(recorder || (await createRecorder(record, logger)));
|
|
275
275
|
try {
|
|
276
276
|
await workflow
|
|
277
277
|
.execute({
|
|
@@ -605,7 +605,7 @@ async function generate(root, opts, projects, verbose, projectGraph) {
|
|
|
605
605
|
const workflow = createWorkflow(fsHost, root, opts, projects);
|
|
606
606
|
const collection = getCollection(workflow, opts.collectionName);
|
|
607
607
|
const schematic = collection.createSchematic(opts.generatorName, true);
|
|
608
|
-
return (await runSchematic(
|
|
608
|
+
return (await runSchematic(root, workflow, logger, { ...opts, generatorName: schematic.description.name }, schematic)).status;
|
|
609
609
|
}
|
|
610
610
|
function createPromptProvider() {
|
|
611
611
|
return (definitions) => {
|
|
@@ -724,7 +724,7 @@ async function runMigration(root, packageName, migrationName, projects, isVerbos
|
|
|
724
724
|
changes: [],
|
|
725
725
|
error: false,
|
|
726
726
|
};
|
|
727
|
-
workflow.reporter.subscribe(await createRecorder(
|
|
727
|
+
workflow.reporter.subscribe(await createRecorder(record, logger));
|
|
728
728
|
await workflow
|
|
729
729
|
.execute({
|
|
730
730
|
collection,
|
|
@@ -772,7 +772,6 @@ function resolveMigrationsCollection(name) {
|
|
|
772
772
|
}
|
|
773
773
|
throw new Error(`Collection cannot be resolved: "${name}"`);
|
|
774
774
|
}
|
|
775
|
-
let collectionResolutionOverrides = null;
|
|
776
775
|
let mockedSchematics = null;
|
|
777
776
|
/**
|
|
778
777
|
* If you have an Nx Devkit generator invoking the wrapped Angular Devkit schematic,
|
|
@@ -855,21 +854,9 @@ function wrapAngularDevkitSchematic(collectionName, generatorName) {
|
|
|
855
854
|
quiet: false,
|
|
856
855
|
};
|
|
857
856
|
const workflow = createWorkflow(fsHost, host.root, options, projects);
|
|
858
|
-
// used for testing
|
|
859
|
-
if (collectionResolutionOverrides) {
|
|
860
|
-
const r = workflow.engineHost.resolve;
|
|
861
|
-
workflow.engineHost.resolve = (collection, b, c) => {
|
|
862
|
-
if (collectionResolutionOverrides[collection]) {
|
|
863
|
-
return collectionResolutionOverrides[collection];
|
|
864
|
-
}
|
|
865
|
-
else {
|
|
866
|
-
return r.apply(workflow.engineHost, [collection, b, c]);
|
|
867
|
-
}
|
|
868
|
-
};
|
|
869
|
-
}
|
|
870
857
|
const collection = getCollection(workflow, collectionName);
|
|
871
858
|
const schematic = collection.createSchematic(generatorName, true);
|
|
872
|
-
const res = await runSchematic(
|
|
859
|
+
const res = await runSchematic(host.root, workflow, logger, options, schematic, false, recorder);
|
|
873
860
|
if (res.status !== 0) {
|
|
874
861
|
throw new Error(res.loggingQueue.join('\n'));
|
|
875
862
|
}
|
|
@@ -990,7 +977,7 @@ async function getWrappedWorkspaceNodeModulesArchitectHost(workspace, root, proj
|
|
|
990
977
|
const batchImplementationFactory = executorConfig.batchImplementation
|
|
991
978
|
? this.getImplementationFactory(executorConfig.batchImplementation, executorsDir, nodeModule)
|
|
992
979
|
: null;
|
|
993
|
-
// TODO(v25): remove custom hasher support.
|
|
980
|
+
// TODO(v25): remove custom hasher support (NXC-5052).
|
|
994
981
|
const hasherFactory = executorConfig.hasher
|
|
995
982
|
? this.getImplementationFactory(executorConfig.hasher, executorsDir, nodeModule)
|
|
996
983
|
: null;
|
|
@@ -152,27 +152,21 @@ function parseGeneratorString(value) {
|
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
async function convertToGenerateOptions(generatorOptions,
|
|
155
|
+
async function convertToGenerateOptions(generatorOptions, projectsConfiguration) {
|
|
156
156
|
let collectionName = null;
|
|
157
157
|
let generatorName = null;
|
|
158
158
|
const interactive = generatorOptions.interactive;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
generatorName = generator;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
const generatorString = await promptForCollection(generatorDescriptor, interactive, projectsConfiguration);
|
|
168
|
-
const parsedGeneratorString = parseGeneratorString(generatorString);
|
|
169
|
-
collectionName = parsedGeneratorString.collection;
|
|
170
|
-
generatorName = parsedGeneratorString.generator;
|
|
171
|
-
}
|
|
159
|
+
const generatorDescriptor = generatorOptions['generator'];
|
|
160
|
+
const { collection, generator } = parseGeneratorString(generatorDescriptor);
|
|
161
|
+
if (collection) {
|
|
162
|
+
collectionName = collection;
|
|
163
|
+
generatorName = generator;
|
|
172
164
|
}
|
|
173
165
|
else {
|
|
174
|
-
|
|
175
|
-
|
|
166
|
+
const generatorString = await promptForCollection(generatorDescriptor, interactive, projectsConfiguration);
|
|
167
|
+
const parsedGeneratorString = parseGeneratorString(generatorString);
|
|
168
|
+
collectionName = parsedGeneratorString.collection;
|
|
169
|
+
generatorName = parsedGeneratorString.generator;
|
|
176
170
|
}
|
|
177
171
|
const res = {
|
|
178
172
|
collectionName,
|
|
@@ -225,8 +219,8 @@ async function generate(args) {
|
|
|
225
219
|
projectsConfigurations =
|
|
226
220
|
(0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
227
221
|
}
|
|
228
|
-
const opts = await convertToGenerateOptions(args,
|
|
229
|
-
const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases,
|
|
222
|
+
const opts = await convertToGenerateOptions(args, projectsConfigurations);
|
|
223
|
+
const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, ['x-deprecated']: deprecated }, } = (0, generator_utils_1.getGeneratorInformation)(opts.collectionName, opts.generatorName, workspace_root_1.workspaceRoot, projectsConfigurations.projects);
|
|
230
224
|
if (deprecated) {
|
|
231
225
|
logger_1.logger.warn([
|
|
232
226
|
`${logger_1.NX_PREFIX}: ${opts.collectionName}:${normalizedGeneratorName} is deprecated`,
|
|
@@ -246,11 +240,6 @@ async function generate(args) {
|
|
|
246
240
|
if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot, projectsConfigurations.projects).isNxGenerator) {
|
|
247
241
|
const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, args.verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
|
|
248
242
|
const implementation = implementationFactory();
|
|
249
|
-
// @todo(v17): Remove this, isStandalonePreset property is defunct.
|
|
250
|
-
if (normalizedGeneratorName === 'preset' && !isStandalonePreset) {
|
|
251
|
-
host.write('apps/.gitkeep', '');
|
|
252
|
-
host.write('libs/.gitkeep', '');
|
|
253
|
-
}
|
|
254
243
|
const task = await implementation(host, combinedOpts);
|
|
255
244
|
host.lock();
|
|
256
245
|
const changes = host.listChanges();
|
|
@@ -808,7 +808,7 @@ async function createProjectGraphAndSourceMapClientResponse(affected = [], focus
|
|
|
808
808
|
sourceMapResponse,
|
|
809
809
|
};
|
|
810
810
|
}
|
|
811
|
-
async function createTaskGraphClientResponse(
|
|
811
|
+
async function createTaskGraphClientResponse() {
|
|
812
812
|
let graph;
|
|
813
813
|
try {
|
|
814
814
|
graph = await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: false });
|
|
@@ -818,9 +818,6 @@ async function createTaskGraphClientResponse(pruneExternal = false) {
|
|
|
818
818
|
graph = e.getPartialProjectGraph();
|
|
819
819
|
}
|
|
820
820
|
}
|
|
821
|
-
if (pruneExternal) {
|
|
822
|
-
graph = (0, operators_1.pruneExternalNodes)(graph);
|
|
823
|
-
}
|
|
824
821
|
const nxJson = (0, configuration_1.readNxJson)();
|
|
825
822
|
node_perf_hooks_1.performance.mark('task graph generation:start');
|
|
826
823
|
const projects = Object.keys(graph.nodes);
|
|
@@ -873,13 +870,10 @@ async function createExpandedTaskInputResponse(taskGraphClientResponse, depGraph
|
|
|
873
870
|
return response;
|
|
874
871
|
}
|
|
875
872
|
// Performance optimized functions for lazy loading task graphs
|
|
876
|
-
// In-memory cache for task graphs to avoid regeneration
|
|
877
|
-
const taskGraphCache = new Map();
|
|
878
873
|
// In-memory cache for expanded task inputs to avoid regeneration
|
|
879
874
|
const expandedTaskInputsCache = new Map();
|
|
880
875
|
// Clear cache when project graph changes
|
|
881
876
|
function clearTaskGraphCache() {
|
|
882
|
-
taskGraphCache.clear();
|
|
883
877
|
expandedTaskInputsCache.clear();
|
|
884
878
|
}
|
|
885
879
|
/**
|
|
@@ -22,6 +22,3 @@ async function prepareSourceRepo(gitClient, ref, source, relativeDestination, te
|
|
|
22
22
|
: `Filtered git history`);
|
|
23
23
|
spinner.succeed(`${sourceRemoteUrl} has been prepared to be imported into this workspace on a temporary branch: ${tempImportBranch} in ${gitClient.root}`);
|
|
24
24
|
}
|
|
25
|
-
function wait(ms) {
|
|
26
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
|
-
}
|
|
@@ -12,7 +12,7 @@ async function setupStandaloneWorkspace(repoRoot, cacheableOperations, workspace
|
|
|
12
12
|
const angularJsonPath = (0, node_path_1.join)(repoRoot, 'angular.json');
|
|
13
13
|
const angularJson = (0, fileutils_1.readJsonFile)(angularJsonPath);
|
|
14
14
|
const workspaceCapabilities = getWorkspaceCapabilities(angularJson.projects);
|
|
15
|
-
createNxJson(repoRoot,
|
|
15
|
+
createNxJson(repoRoot, cacheableOperations, workspaceCapabilities, workspaceTargets);
|
|
16
16
|
(0, utils_1.addVsCodeRecommendedExtensions)(repoRoot, [
|
|
17
17
|
'nrwl.angular-console',
|
|
18
18
|
'angular.ng-template',
|
|
@@ -37,7 +37,7 @@ async function setupStandaloneWorkspace(repoRoot, cacheableOperations, workspace
|
|
|
37
37
|
}
|
|
38
38
|
(0, fs_1.unlinkSync)(angularJsonPath);
|
|
39
39
|
}
|
|
40
|
-
function createNxJson(repoRoot,
|
|
40
|
+
function createNxJson(repoRoot, cacheableOperations, { eslintProjectConfigFile, test, karmaProjectConfigFile, }, workspaceTargets) {
|
|
41
41
|
(0, utils_1.createNxJsonFile)(repoRoot, [], cacheableOperations, {});
|
|
42
42
|
const nxJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(repoRoot, 'nx.json'));
|
|
43
43
|
nxJson.namedInputs = {
|
|
@@ -108,13 +108,13 @@ async function initHandlerImpl(options) {
|
|
|
108
108
|
meta: { type: 'start', ...baseMeta },
|
|
109
109
|
});
|
|
110
110
|
try {
|
|
111
|
-
return await runInit(options
|
|
111
|
+
return await runInit(options);
|
|
112
112
|
}
|
|
113
113
|
catch (error) {
|
|
114
114
|
await recordInitError(error, baseMeta);
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
async function runInit(options
|
|
117
|
+
async function runInit(options) {
|
|
118
118
|
// Resolving `latest` here would install a version nothing has verified.
|
|
119
119
|
const version = process.env.NX_VERSION ?? versions_1.nxVersion;
|
|
120
120
|
if (process.env.NX_VERSION) {
|
|
@@ -1237,7 +1237,6 @@ function createFetcher(pmc) {
|
|
|
1237
1237
|
if (migrationsCache[`${packageName}-${packageVersion}`]) {
|
|
1238
1238
|
return migrationsCache[`${packageName}-${packageVersion}`];
|
|
1239
1239
|
}
|
|
1240
|
-
let resolvedVersion = packageVersion;
|
|
1241
1240
|
let migrations;
|
|
1242
1241
|
function setCache(packageName, packageVersion) {
|
|
1243
1242
|
migrationsCache[packageName + '-' + packageVersion] = migrations;
|
|
@@ -1256,7 +1255,6 @@ function createFetcher(pmc) {
|
|
|
1256
1255
|
result.generators = { ...result.schematics, ...result.generators };
|
|
1257
1256
|
delete result.schematics;
|
|
1258
1257
|
}
|
|
1259
|
-
resolvedVersion = result.version;
|
|
1260
1258
|
return result;
|
|
1261
1259
|
});
|
|
1262
1260
|
setCache(packageName, packageVersion);
|
|
@@ -1589,7 +1587,7 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts, fetch) {
|
|
|
1589
1587
|
let phase = 'fetch_migrations';
|
|
1590
1588
|
try {
|
|
1591
1589
|
const rootPkgJsonPath = (0, path_1.join)(root, 'package.json');
|
|
1592
|
-
|
|
1590
|
+
const originalPackageJson = (0, fs_1.existsSync)(rootPkgJsonPath)
|
|
1593
1591
|
? (0, fileutils_1.readJsonFile)(rootPkgJsonPath)
|
|
1594
1592
|
: null;
|
|
1595
1593
|
const originalNxJson = (0, configuration_1.readNxJson)();
|
|
@@ -1744,7 +1742,6 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts, fetch) {
|
|
|
1744
1742
|
],
|
|
1745
1743
|
});
|
|
1746
1744
|
await (0, connect_to_nx_cloud_1.connectToNxCloudWithPrompt)('migrate');
|
|
1747
|
-
originalPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
|
|
1748
1745
|
}
|
|
1749
1746
|
}
|
|
1750
1747
|
catch {
|
|
@@ -2912,11 +2909,12 @@ async function nxCliPath(nxWorkspaceRoot) {
|
|
|
2912
2909
|
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
2913
2910
|
const root = nxWorkspaceRoot ?? workspace_root_1.workspaceRoot;
|
|
2914
2911
|
const version = await (0, provenance_1.resolveVersionWithProvenance)('nx', process.env.NX_MIGRATE_CLI_VERSION || 'latest', root);
|
|
2912
|
+
// Outside the try, so a missing private install root is reported rather than
|
|
2913
|
+
// hidden behind the fallback to the workspace's nx.
|
|
2914
|
+
const tmpDir = (0, package_manager_1.createTempInstallDirectory)();
|
|
2915
2915
|
try {
|
|
2916
2916
|
const packageManager = (0, package_manager_1.detectPackageManager)();
|
|
2917
2917
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
2918
|
-
const { dirSync } = require('tmp');
|
|
2919
|
-
const tmpDir = dirSync().name;
|
|
2920
2918
|
(0, fileutils_1.writeJsonFile)((0, path_1.join)(tmpDir, 'package.json'), {
|
|
2921
2919
|
dependencies: {
|
|
2922
2920
|
nx: version,
|
|
@@ -26,13 +26,13 @@ function validateMigrationEntries(packageName, packageVersion, migrations) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
async function resolvePromptFiles(packageName, packageVersion, migrations,
|
|
29
|
+
async function resolvePromptFiles(packageName, packageVersion, migrations, resolveContent) {
|
|
30
30
|
const resolvedPromptFiles = {};
|
|
31
31
|
for (const [migrationName, entry] of iterateMigrationEntries(migrations)) {
|
|
32
32
|
if (!entry.prompt || resolvedPromptFiles[entry.prompt] !== undefined) {
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
|
-
assertPromptPathWithinMigrationsDir(
|
|
35
|
+
assertPromptPathWithinMigrationsDir(entry.prompt, packageName, packageVersion);
|
|
36
36
|
if (!isPortableMarkdownPath(entry.prompt)) {
|
|
37
37
|
throw new Error(`Invalid prompt path "${entry.prompt}" in package "${packageName}@${packageVersion}": prompt files must be markdown (.md) files whose path has no characters reserved on Windows (<>:"|?*).`);
|
|
38
38
|
}
|
|
@@ -47,7 +47,7 @@ async function resolvePromptFiles(packageName, packageVersion, migrations, migra
|
|
|
47
47
|
? resolvedPromptFiles
|
|
48
48
|
: undefined;
|
|
49
49
|
}
|
|
50
|
-
function assertPromptPathWithinMigrationsDir(
|
|
50
|
+
function assertPromptPathWithinMigrationsDir(promptRelPath, packageName, packageVersion) {
|
|
51
51
|
if (!(0, path_2.isContainedRelativePath)(promptRelPath)) {
|
|
52
52
|
throw new Error(`Invalid prompt path "${promptRelPath}" in package "${packageName}@${packageVersion}": prompt paths must be relative and resolve within the package's migrations directory.`);
|
|
53
53
|
}
|
|
@@ -102,7 +102,7 @@ function resolvePrompt(promptPath, migrationsDir) {
|
|
|
102
102
|
}
|
|
103
103
|
function extractPromptFilesFromTarball(packageName, packageVersion, migrations, migrationsFilePath, fullTarballPath, destDir) {
|
|
104
104
|
const migrationsDir = (0, path_1.dirname)(migrationsFilePath);
|
|
105
|
-
return resolvePromptFiles(packageName, packageVersion, migrations,
|
|
105
|
+
return resolvePromptFiles(packageName, packageVersion, migrations, async (promptRelPath) => {
|
|
106
106
|
const promptInTarball = (0, path_2.joinPathFragments)('package', migrationsDir, promptRelPath);
|
|
107
107
|
const promptDest = (0, path_1.join)(destDir, migrationsDir, promptRelPath);
|
|
108
108
|
await (0, tar_1.extractFileFromTarball)(fullTarballPath, promptInTarball, promptDest);
|
|
@@ -111,7 +111,7 @@ function extractPromptFilesFromTarball(packageName, packageVersion, migrations,
|
|
|
111
111
|
}
|
|
112
112
|
function readPromptFilesFromInstall(packageName, packageVersion, migrations, migrationsFilePath) {
|
|
113
113
|
const migrationsDir = (0, path_1.dirname)(migrationsFilePath);
|
|
114
|
-
return resolvePromptFiles(packageName, packageVersion, migrations,
|
|
114
|
+
return resolvePromptFiles(packageName, packageVersion, migrations, (promptRelPath) => (0, fs_1.readFileSync)(resolvePrompt(promptRelPath, migrationsDir), 'utf-8'));
|
|
115
115
|
}
|
|
116
116
|
function writePromptMigrationFiles(root, migrations, promptContents, targetVersion) {
|
|
117
117
|
const sourceToChosen = new Map();
|
|
@@ -1042,7 +1042,6 @@ async function runOrchestratorReconcile(input) {
|
|
|
1042
1042
|
written.steps.find((s) => s.id === target.id)?.installFailed === true) {
|
|
1043
1043
|
warnInstallLeftToUser(root, target);
|
|
1044
1044
|
}
|
|
1045
|
-
state = written;
|
|
1046
1045
|
}
|
|
1047
1046
|
finally {
|
|
1048
1047
|
scope.lease?.release();
|
|
@@ -1609,7 +1608,7 @@ function advanceAndDispense(root, dir, runId) {
|
|
|
1609
1608
|
}
|
|
1610
1609
|
switch (step.status) {
|
|
1611
1610
|
case 'pending':
|
|
1612
|
-
dispenseNextStep(root, dir, runId,
|
|
1611
|
+
dispenseNextStep(root, dir, runId, step, noProgress);
|
|
1613
1612
|
break;
|
|
1614
1613
|
case 'dispensed':
|
|
1615
1614
|
// Re-entry before the worker advanced the step; re-emit its command.
|
|
@@ -1687,7 +1686,7 @@ function trackNoProgress(dir, step) {
|
|
|
1687
1686
|
});
|
|
1688
1687
|
return streak.consecutiveCount >= NO_PROGRESS_THRESHOLD ? streak : null;
|
|
1689
1688
|
}
|
|
1690
|
-
function dispenseNextStep(root, dir, runId,
|
|
1689
|
+
function dispenseNextStep(root, dir, runId, step, noProgress) {
|
|
1691
1690
|
// Read the pre-step baselines (git and package.json reads) before the
|
|
1692
1691
|
// lock; the dispense transition and the baselines then apply to the fresh
|
|
1693
1692
|
// state in one write.
|
|
@@ -464,7 +464,7 @@ async function runRecorded(root, runId, migration, skipInstall, isVerbose, calle
|
|
|
464
464
|
awaitingKind = 'generator-validation';
|
|
465
465
|
}
|
|
466
466
|
else if (generatorAlreadyCompleted) {
|
|
467
|
-
|
|
467
|
+
await finishCompletedGenerator(dir, root, state, startedStep, migration, effectiveSkipInstall, rerunCommand, scope);
|
|
468
468
|
outcome = buildOutcome([], [], 'The generator ran in an earlier attempt; this attempt completed its install and commit.', root);
|
|
469
469
|
}
|
|
470
470
|
else {
|
|
@@ -508,7 +508,7 @@ async function runRecorded(root, runId, migration, skipInstall, isVerbose, calle
|
|
|
508
508
|
madeChanges &&
|
|
509
509
|
!validationOwed &&
|
|
510
510
|
!promptOwed) {
|
|
511
|
-
|
|
511
|
+
await commitStepChanges(dir, root, state, startedStep, migration, install, scope);
|
|
512
512
|
}
|
|
513
513
|
else {
|
|
514
514
|
await (0, broker_1.installStepTree)(dir, startedStep, 'install', install, scope);
|
|
@@ -610,7 +610,7 @@ async function finishCompletedGenerator(dir, root, state, step, migration, skipI
|
|
|
610
610
|
// answer, and the commit is kept as that version's retries did.
|
|
611
611
|
if (!state.createCommits || step.generatorMadeChanges === false) {
|
|
612
612
|
await (0, broker_1.installStepTree)(dir, step, 'install', installDeps, scope);
|
|
613
|
-
return
|
|
613
|
+
return;
|
|
614
614
|
}
|
|
615
615
|
return commitStepChanges(dir, root, state, step, migration, installDeps, scope);
|
|
616
616
|
}
|
|
@@ -641,14 +641,16 @@ async function commitStepChanges(dir, root, state, step, migration, installDeps,
|
|
|
641
641
|
}
|
|
642
642
|
const entry = (0, state_machine_1.commitResultToLedgerEntry)(commit.result, step.id, commit.absorbedStepIds);
|
|
643
643
|
// A session's parent records what it commits itself, receipt included.
|
|
644
|
-
|
|
644
|
+
if (entry && !commit.recorded) {
|
|
645
|
+
recordCommitEntry(dir, entry);
|
|
646
|
+
}
|
|
645
647
|
}
|
|
646
648
|
// The git commit itself already ran outside the lock; only this pure append is
|
|
647
649
|
// locked. A landed entry carries the resolved issues of every step it names,
|
|
648
650
|
// same as the orchestrator's fold and adopt appends: an absorbed step's
|
|
649
651
|
// resolutions would otherwise land unattached.
|
|
650
652
|
function recordCommitEntry(dir, entry) {
|
|
651
|
-
|
|
653
|
+
(0, state_lock_1.updateRunState)(dir, (fresh) => (0, state_machine_1.appendCommit)(fresh, (0, issues_1.attachIssueIdsToCommitEntry)(fresh, entry)));
|
|
652
654
|
}
|
|
653
655
|
function buildOutcome(changes, nextSteps, description, root) {
|
|
654
656
|
const outcome = {};
|
|
@@ -28,11 +28,12 @@ async function runMigrationProcess() {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
try {
|
|
31
|
-
|
|
31
|
+
// Validate HEAD before the migration can change the working tree.
|
|
32
|
+
execSync('git rev-parse HEAD', {
|
|
32
33
|
cwd: workspacePath,
|
|
33
34
|
encoding: 'utf-8',
|
|
34
35
|
windowsHide: true,
|
|
35
|
-
})
|
|
36
|
+
});
|
|
36
37
|
|
|
37
38
|
// Snapshot package.json deps now so we can detect post-migration drift
|
|
38
39
|
// and run a single install, whether commits are on or off.
|
|
@@ -5,7 +5,7 @@ const handle_import_1 = require("../../../utils/handle-import");
|
|
|
5
5
|
const shared_options_1 = require("../../yargs-utils/shared-options");
|
|
6
6
|
exports.yargsStartNxAgentsCommand = {
|
|
7
7
|
command: 'start-nx-agents [options]',
|
|
8
|
-
describe: '
|
|
8
|
+
describe: 'Starts workers for distributed task execution, reading configuration from `.nx/pipelines/ci.yaml`. This command is an alias for [`nx-cloud start-workers`](/docs/reference/nx-cloud-cli#nx-cloud-start-workers).',
|
|
9
9
|
builder: (yargs) => (0, shared_options_1.withVerbose)(yargs)
|
|
10
10
|
.help(false)
|
|
11
11
|
.showHelpOnFail(false)
|
|
@@ -213,10 +213,6 @@ function createAPI(overrideReleaseConfig, ignoreNxJsonConfig) {
|
|
|
213
213
|
resolveChanges: () => resolveWorkspaceChangelogChanges({
|
|
214
214
|
releaseGraph,
|
|
215
215
|
nxReleaseConfig,
|
|
216
|
-
args,
|
|
217
|
-
workspacePreid,
|
|
218
|
-
projectsPreid,
|
|
219
|
-
useAutomaticFromRef,
|
|
220
216
|
toSHA,
|
|
221
217
|
fromSHA,
|
|
222
218
|
}),
|
|
@@ -229,10 +225,6 @@ function createAPI(overrideReleaseConfig, ignoreNxJsonConfig) {
|
|
|
229
225
|
* Create a cache for from SHA resolution to avoid duplicate git operations
|
|
230
226
|
*/
|
|
231
227
|
const fromSHACache = new Map();
|
|
232
|
-
// Cache the workspace from SHA if available
|
|
233
|
-
if (fromSHA) {
|
|
234
|
-
fromSHACache.set('workspace', fromSHA);
|
|
235
|
-
}
|
|
236
228
|
// Helper function to get cached from SHA or resolve and cache it
|
|
237
229
|
const getCachedFromSHA = async (cacheKey, pattern, templateValues, preid, checkAllBranchesWhen, requireSemver, strictPreid, projectRoot) => {
|
|
238
230
|
if (fromSHACache.has(cacheKey)) {
|
|
@@ -323,33 +315,14 @@ function createAPI(overrideReleaseConfig, ignoreNxJsonConfig) {
|
|
|
323
315
|
projectName: project.name,
|
|
324
316
|
releaseGroupName: releaseGroup.name,
|
|
325
317
|
}, projectsPreid[project.name], releaseGroup.releaseTag.checkAllBranchesWhen, releaseGroup.releaseTag.requireSemver, releaseGroup.releaseTag.strictPreid, project.data.root);
|
|
326
|
-
|
|
327
|
-
let fromRef = fromSHA;
|
|
328
|
-
if (!fromRef && useAutomaticFromRef) {
|
|
329
|
-
// For automatic from ref, we already have it cached
|
|
330
|
-
fromRef = fromSHACache.get(projectCacheKey);
|
|
331
|
-
if (fromRef) {
|
|
332
|
-
commits = await filterProjectCommits({
|
|
333
|
-
fromSHA: fromRef,
|
|
334
|
-
toSHA,
|
|
335
|
-
projectPath: project.data.root,
|
|
336
|
-
});
|
|
337
|
-
fromRef = commits[0]?.shortHash;
|
|
338
|
-
if (args.verbose) {
|
|
339
|
-
console.log(`Determined --from ref for ${project.name} from the first commit in which it exists: ${fromRef}`);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
if (!fromRef && !commits) {
|
|
318
|
+
if (!fromSHA) {
|
|
344
319
|
throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTag.pattern" property in nx.json to match the structure of your repository's git tags.`);
|
|
345
320
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
});
|
|
352
|
-
}
|
|
321
|
+
const commits = await filterProjectCommits({
|
|
322
|
+
fromSHA,
|
|
323
|
+
toSHA,
|
|
324
|
+
projectPath: project.data.root,
|
|
325
|
+
});
|
|
353
326
|
const { fileMap } = await (0, file_map_utils_1.createFileMapUsingProjectGraph)(projectGraph);
|
|
354
327
|
const fileToProjectMap = (0, commit_utils_1.createFileToProjectMap)(fileMap.projectFileMap);
|
|
355
328
|
changes = (0, commit_utils_1.createChangesFromCommits)(commits, fileMap, fileToProjectMap, nxReleaseConfig.conventionalCommits);
|
|
@@ -862,7 +835,7 @@ async function promptForRemoteRelease() {
|
|
|
862
835
|
onCancel: () => false,
|
|
863
836
|
});
|
|
864
837
|
}
|
|
865
|
-
async function resolveWorkspaceChangelogChanges({ releaseGraph, nxReleaseConfig,
|
|
838
|
+
async function resolveWorkspaceChangelogChanges({ releaseGraph, nxReleaseConfig, toSHA, fromSHA, }) {
|
|
866
839
|
// NOTE: If there are multiple release groups, we'll just skip the workspace changelog anyway.
|
|
867
840
|
const versionPlansEnabledForWorkspaceChangelog = releaseGraph.releaseGroups[0]?.resolvedVersionPlans;
|
|
868
841
|
// Derive changes from version plan files
|
|
@@ -872,10 +845,6 @@ async function resolveWorkspaceChangelogChanges({ releaseGraph, nxReleaseConfig,
|
|
|
872
845
|
// Derive changes from commits
|
|
873
846
|
return resolveWorkspaceChangelogFromCommits({
|
|
874
847
|
nxReleaseConfig,
|
|
875
|
-
args,
|
|
876
|
-
workspacePreid,
|
|
877
|
-
projectsPreid,
|
|
878
|
-
useAutomaticFromRef,
|
|
879
848
|
toSHA,
|
|
880
849
|
fromSHA,
|
|
881
850
|
});
|
|
@@ -890,7 +859,7 @@ function resolveWorkspaceChangelogFromVersionPlans(releaseGraph) {
|
|
|
890
859
|
const versionPlans = firstReleaseGroup.resolvedVersionPlans;
|
|
891
860
|
return (0, version_plan_utils_1.createChangesFromGroupVersionPlans)(versionPlans);
|
|
892
861
|
}
|
|
893
|
-
async function resolveWorkspaceChangelogFromCommits({ nxReleaseConfig,
|
|
862
|
+
async function resolveWorkspaceChangelogFromCommits({ nxReleaseConfig, toSHA, fromSHA, }) {
|
|
894
863
|
// Use the cached fromSHA if available, otherwise throw an error
|
|
895
864
|
if (!fromSHA) {
|
|
896
865
|
throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTag.pattern" property in nx.json to match the structure of your repository's git tags.`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.shouldUseLegacyVersioning = shouldUseLegacyVersioning;
|
|
4
|
-
// TODO(
|
|
4
|
+
// TODO(v25): remove - kept only so `@nx/js@21`'s library generator can load via `ensurePackage` (NXC-5163).
|
|
5
5
|
/** @deprecated Compat shim for `@nx/js@21`. */
|
|
6
6
|
function shouldUseLegacyVersioning(releaseConfig) {
|
|
7
7
|
return releaseConfig?.version?.useLegacyVersioning ?? false;
|
|
@@ -47,8 +47,6 @@ function diffLinesRaw(aLines, bLines) {
|
|
|
47
47
|
}
|
|
48
48
|
function formatNoExpand(diffs, contextLines, aColor, bColor, patchColor) {
|
|
49
49
|
const lines = [];
|
|
50
|
-
let aLine = 0;
|
|
51
|
-
let bLine = 0;
|
|
52
50
|
// Group diffs into hunks with context
|
|
53
51
|
const hunks = [];
|
|
54
52
|
let currentHunk = null;
|
|
@@ -61,8 +59,6 @@ function formatNoExpand(diffs, contextLines, aColor, bColor, patchColor) {
|
|
|
61
59
|
if (!currentHunk) {
|
|
62
60
|
const contextStart = Math.max(0, i - contextLines);
|
|
63
61
|
currentHunk = {
|
|
64
|
-
aStart: aLine - (i - contextStart),
|
|
65
|
-
bStart: bLine - (i - contextStart),
|
|
66
62
|
lines: [],
|
|
67
63
|
};
|
|
68
64
|
// Add leading context
|
|
@@ -104,16 +100,6 @@ function formatNoExpand(diffs, contextLines, aColor, bColor, patchColor) {
|
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
102
|
}
|
|
107
|
-
if (type === DIFF_DELETE) {
|
|
108
|
-
aLine++;
|
|
109
|
-
}
|
|
110
|
-
else if (type === DIFF_INSERT) {
|
|
111
|
-
bLine++;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
aLine++;
|
|
115
|
-
bLine++;
|
|
116
|
-
}
|
|
117
103
|
}
|
|
118
104
|
if (currentHunk) {
|
|
119
105
|
hunks.push(currentHunk);
|
|
@@ -534,7 +534,7 @@ function parseGitCommit(commit) {
|
|
|
534
534
|
}
|
|
535
535
|
// Find all authors
|
|
536
536
|
const authors = getAllAuthorsForCommit(commit);
|
|
537
|
-
const affectedFiles = Array.from((commit.nameStatus ?? '').matchAll(ChangedFileRegex)).reduce((prev, [
|
|
537
|
+
const affectedFiles = Array.from((commit.nameStatus ?? '').matchAll(ChangedFileRegex)).reduce((prev, [, , file1, file2]) =>
|
|
538
538
|
// file2 only exists for some change types, such as renames
|
|
539
539
|
file2 ? [...prev, file1, file2] : [...prev, file1], []);
|
|
540
540
|
return {
|