nx 24.0.0-beta.3 → 24.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/command-line/migrate/execute-migration.d.ts +4 -4
- package/dist/src/command-line/migrate/execute-migration.js +7 -5
- package/dist/src/command-line/migrate/migrate.d.ts +3 -0
- package/dist/src/command-line/migrate/migrate.js +61 -17
- package/dist/src/config/misc-interfaces.d.ts +6 -0
- package/dist/src/config/workspace-json-project-json.d.ts +12 -4
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/runtime.js +1 -1
- package/dist/src/core/graph/styles.css +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/devkit-exports.d.ts +4 -0
- package/dist/src/devkit-exports.js +7 -1
- package/dist/src/devkit-internals.d.ts +1 -0
- package/dist/src/devkit-internals.js +3 -0
- package/dist/src/native/index.d.ts +8 -2
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +49 -6
- package/dist/src/tasks-runner/pseudo-ipc.d.ts +1 -0
- package/dist/src/tasks-runner/pseudo-ipc.js +4 -0
- package/dist/src/tasks-runner/readiness/probes.d.ts +6 -1
- package/dist/src/tasks-runner/readiness/probes.js +40 -30
- package/dist/src/tasks-runner/readiness/ready-signal-server.d.ts +18 -0
- package/dist/src/tasks-runner/readiness/ready-signal-server.js +71 -0
- package/dist/src/tasks-runner/readiness/ready-signal.d.ts +25 -0
- package/dist/src/tasks-runner/readiness/ready-signal.js +70 -0
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +4 -0
- package/dist/src/tasks-runner/readiness/ready-when.js +37 -19
- package/dist/src/tasks-runner/readiness/startup-host.d.ts +1 -0
- package/dist/src/tasks-runner/readiness/startup-host.js +32 -0
- package/dist/src/tasks-runner/task-env.js +11 -0
- package/dist/src/tasks-runner/task-orchestrator.d.ts +4 -0
- package/dist/src/tasks-runner/task-orchestrator.js +41 -6
- package/dist/src/ultracache/config.d.ts +3 -3
- package/dist/src/ultracache/config.js +4 -4
- package/package.json +11 -11
- package/schemas/migrations-schema.json +11 -0
- package/schemas/nx-schema.json +8 -3
- package/schemas/project-schema.json +8 -3
|
@@ -59,10 +59,10 @@ export declare function runNxOrAngularMigration(root: string, migration: {
|
|
|
59
59
|
madeChanges: boolean;
|
|
60
60
|
}>;
|
|
61
61
|
/**
|
|
62
|
-
* The workspace's declared dependencies, serialized for
|
|
63
|
-
* or `null` when package.json could not be read or
|
|
64
|
-
* persist the value across processes need that
|
|
65
|
-
* package.json is not an empty dependency set.
|
|
62
|
+
* The workspace's declared dependencies, catalogs included, serialized for
|
|
63
|
+
* equality comparison, or `null` when package.json could not be read or
|
|
64
|
+
* parsed. Callers that persist the value across processes need that
|
|
65
|
+
* distinction: an unreadable package.json is not an empty dependency set.
|
|
66
66
|
*/
|
|
67
67
|
export declare function readPackageJsonDeps(root: string): string | null;
|
|
68
68
|
export declare function getStringifiedPackageJsonDeps(root: string): string;
|
|
@@ -25,6 +25,7 @@ const path_1 = require("path");
|
|
|
25
25
|
const semver_1 = require("semver");
|
|
26
26
|
const handle_import_1 = require("../../utils/handle-import");
|
|
27
27
|
const tree_1 = require("../../generators/tree");
|
|
28
|
+
const catalog_1 = require("../../utils/catalog");
|
|
28
29
|
const fileutils_1 = require("../../utils/fileutils");
|
|
29
30
|
const logger_1 = require("../../utils/logger");
|
|
30
31
|
const text_1 = require("./text");
|
|
@@ -342,15 +343,16 @@ async function runNxOrAngularMigration(root, migration, isVerbose, captureGenera
|
|
|
342
343
|
return { changes, nextSteps, agentContext, skipAgentic, logs, madeChanges };
|
|
343
344
|
}
|
|
344
345
|
/**
|
|
345
|
-
* The workspace's declared dependencies, serialized for
|
|
346
|
-
* or `null` when package.json could not be read or
|
|
347
|
-
* persist the value across processes need that
|
|
348
|
-
* package.json is not an empty dependency set.
|
|
346
|
+
* The workspace's declared dependencies, catalogs included, serialized for
|
|
347
|
+
* equality comparison, or `null` when package.json could not be read or
|
|
348
|
+
* parsed. Callers that persist the value across processes need that
|
|
349
|
+
* distinction: an unreadable package.json is not an empty dependency set.
|
|
349
350
|
*/
|
|
350
351
|
function readPackageJsonDeps(root) {
|
|
351
352
|
try {
|
|
352
353
|
const { dependencies, devDependencies } = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, 'package.json'));
|
|
353
|
-
|
|
354
|
+
const catalogs = (0, catalog_1.getCatalogManager)(root)?.getCatalogDefinitions(root);
|
|
355
|
+
return JSON.stringify([dependencies, devDependencies, catalogs]);
|
|
354
356
|
}
|
|
355
357
|
catch {
|
|
356
358
|
return null;
|
|
@@ -81,6 +81,7 @@ export declare class Migrator {
|
|
|
81
81
|
prompt?: string;
|
|
82
82
|
requires?: Record<string, string>;
|
|
83
83
|
documentation?: string;
|
|
84
|
+
optionalUpdate?: boolean;
|
|
84
85
|
package: string;
|
|
85
86
|
name: string;
|
|
86
87
|
}[];
|
|
@@ -111,6 +112,8 @@ export declare class Migrator {
|
|
|
111
112
|
private addPackageUpdate;
|
|
112
113
|
private areRequirementsMet;
|
|
113
114
|
private areIncompatiblePackagesPresent;
|
|
115
|
+
private shouldCollectMigration;
|
|
116
|
+
private areRequirementsMetAfterUpdates;
|
|
114
117
|
private areMigrationRequirementsMet;
|
|
115
118
|
private isMigrationForHigherVersionThanWhatIsInstalled;
|
|
116
119
|
private wasMigrationSkipped;
|
|
@@ -153,8 +153,8 @@ class Migrator {
|
|
|
153
153
|
addToPackageJson: false,
|
|
154
154
|
});
|
|
155
155
|
await this.applyPendingPackageJsonUpdates();
|
|
156
|
-
this.applyIncludeFilter();
|
|
157
|
-
const { migrations, promptContents } = await this.createMigrateJson();
|
|
156
|
+
const requiredPackageUpdates = this.applyIncludeFilter();
|
|
157
|
+
const { migrations, promptContents } = await this.createMigrateJson(requiredPackageUpdates);
|
|
158
158
|
return {
|
|
159
159
|
packageUpdates: this.packageUpdates,
|
|
160
160
|
migrations,
|
|
@@ -162,17 +162,10 @@ class Migrator {
|
|
|
162
162
|
minVersionWithSkippedUpdates: this.minVersionWithSkippedUpdates,
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
|
-
async createMigrateJson() {
|
|
165
|
+
async createMigrateJson(requiredPackageUpdates) {
|
|
166
166
|
const promptContents = {};
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
return [];
|
|
170
|
-
}
|
|
171
|
-
const currentVersion = this.getPkgVersion(packageName);
|
|
172
|
-
if (currentVersion === null)
|
|
173
|
-
return [];
|
|
174
|
-
const { version } = this.packageUpdates[packageName];
|
|
175
|
-
const { generators: migrationEntries, resolvedPromptFiles } = await this.fetchMigrationConfig(packageName, version);
|
|
167
|
+
const collect = async (packageName, metadataVersion, fromVersion, toVersion) => {
|
|
168
|
+
const { generators: migrationEntries, resolvedPromptFiles } = await this.fetchMigrationConfig(packageName, metadataVersion);
|
|
176
169
|
if (!migrationEntries)
|
|
177
170
|
return [];
|
|
178
171
|
if (resolvedPromptFiles) {
|
|
@@ -182,15 +175,34 @@ class Migrator {
|
|
|
182
175
|
}
|
|
183
176
|
return Object.entries(migrationEntries)
|
|
184
177
|
.filter(([, migration]) => migration.version &&
|
|
185
|
-
this.gt(migration.version,
|
|
186
|
-
this.lte(migration.version,
|
|
187
|
-
this.
|
|
178
|
+
this.gt(migration.version, fromVersion) &&
|
|
179
|
+
this.lte(migration.version, toVersion) &&
|
|
180
|
+
this.shouldCollectMigration(packageName, migration))
|
|
188
181
|
.map(([migrationName, migration]) => ({
|
|
189
182
|
...migration,
|
|
190
183
|
package: packageName,
|
|
191
184
|
name: migrationName,
|
|
192
185
|
}));
|
|
193
|
-
}
|
|
186
|
+
};
|
|
187
|
+
const migrations = await Promise.all([
|
|
188
|
+
...Object.entries(this.packageUpdates).map(async ([packageName, { version, ignoreMigrations }]) => {
|
|
189
|
+
if (ignoreMigrations)
|
|
190
|
+
return [];
|
|
191
|
+
const currentVersion = this.getPkgVersion(packageName);
|
|
192
|
+
if (currentVersion === null)
|
|
193
|
+
return [];
|
|
194
|
+
return collect(packageName, version, currentVersion, version);
|
|
195
|
+
}),
|
|
196
|
+
// The optional pass keeps required packages at their installed version,
|
|
197
|
+
// and the runner resolves migrations from there. An older target caps the
|
|
198
|
+
// range.
|
|
199
|
+
...Object.entries(requiredPackageUpdates).map(async ([packageName, { version, ignoreMigrations }]) => {
|
|
200
|
+
const installedVersion = this.getInstalledPackageVersion(packageName);
|
|
201
|
+
if (ignoreMigrations || !installedVersion)
|
|
202
|
+
return [];
|
|
203
|
+
return collect(packageName, installedVersion, '0.0.0', this.lt(version, installedVersion) ? version : installedVersion);
|
|
204
|
+
}),
|
|
205
|
+
]);
|
|
194
206
|
return { migrations: migrations.flat(), promptContents };
|
|
195
207
|
}
|
|
196
208
|
async buildPackageJsonUpdates(targetPackage, target) {
|
|
@@ -432,8 +444,9 @@ class Migrator {
|
|
|
432
444
|
return false;
|
|
433
445
|
}
|
|
434
446
|
applyIncludeFilter() {
|
|
447
|
+
const requiredPackageUpdates = {};
|
|
435
448
|
if (this.include !== 'optional') {
|
|
436
|
-
return;
|
|
449
|
+
return requiredPackageUpdates;
|
|
437
450
|
}
|
|
438
451
|
// Cascade walks through the required packages so cross-plugin optional
|
|
439
452
|
// deps (e.g. typescript managed by @nx/js but used by @nx/angular) get
|
|
@@ -441,9 +454,11 @@ class Migrator {
|
|
|
441
454
|
// optional updates land in package.json.
|
|
442
455
|
for (const name of Object.keys(this.packageUpdates)) {
|
|
443
456
|
if (this.requiredPackages.has(name)) {
|
|
457
|
+
requiredPackageUpdates[name] = this.packageUpdates[name];
|
|
444
458
|
delete this.packageUpdates[name];
|
|
445
459
|
}
|
|
446
460
|
}
|
|
461
|
+
return requiredPackageUpdates;
|
|
447
462
|
}
|
|
448
463
|
shouldApplyPackageUpdate(packageUpdate, packageName, dependencies) {
|
|
449
464
|
return ((!packageUpdate.ifPackageInstalled ||
|
|
@@ -493,6 +508,35 @@ class Migrator {
|
|
|
493
508
|
}));
|
|
494
509
|
});
|
|
495
510
|
}
|
|
511
|
+
shouldCollectMigration(packageName, migration) {
|
|
512
|
+
if (this.include === 'required') {
|
|
513
|
+
return (migration.optionalUpdate !== true &&
|
|
514
|
+
this.areMigrationRequirementsMet(packageName, migration));
|
|
515
|
+
}
|
|
516
|
+
if (this.include === 'optional' &&
|
|
517
|
+
this.requiredPackages.has(packageName)) {
|
|
518
|
+
// Every past migration of a required package is in range here. Collect
|
|
519
|
+
// only those that apply an optional update or were skipped.
|
|
520
|
+
return ((migration.optionalUpdate === true ||
|
|
521
|
+
this.wasMigrationSkipped(migration.requires)) &&
|
|
522
|
+
this.areRequirementsMetAfterUpdates(migration.requires));
|
|
523
|
+
}
|
|
524
|
+
return this.areMigrationRequirementsMet(packageName, migration);
|
|
525
|
+
}
|
|
526
|
+
// Counts only updates above the installed version. The optional walk also
|
|
527
|
+
// collects stale pins below it, which are never written.
|
|
528
|
+
areRequirementsMetAfterUpdates(requirements) {
|
|
529
|
+
return Object.entries(requirements ?? {}).every(([pkgName, versionRange]) => {
|
|
530
|
+
const installedVersion = this.getInstalledPackageVersion(pkgName);
|
|
531
|
+
const update = this.packageUpdates[pkgName];
|
|
532
|
+
const version = update &&
|
|
533
|
+
(!installedVersion || this.gt(update.version, installedVersion))
|
|
534
|
+
? cleanSemver(update.version)
|
|
535
|
+
: installedVersion;
|
|
536
|
+
return (!!version &&
|
|
537
|
+
(0, semver_1.satisfies)(version, versionRange, { includePrerelease: true }));
|
|
538
|
+
});
|
|
539
|
+
}
|
|
496
540
|
areMigrationRequirementsMet(packageName, migration) {
|
|
497
541
|
if (!this.excludeAppliedMigrations) {
|
|
498
542
|
return this.areRequirementsMet(migration.requires);
|
|
@@ -106,6 +106,12 @@ export interface MigrationsJsonEntry {
|
|
|
106
106
|
* an outer agent or to the user.
|
|
107
107
|
*/
|
|
108
108
|
documentation?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Marks a migration that applies an optional dependency update.
|
|
111
|
+
* `nx migrate --include=required` skips it, and `--include=optional` runs it
|
|
112
|
+
* whenever `requires` is met, so it must set `requires`.
|
|
113
|
+
*/
|
|
114
|
+
optionalUpdate?: boolean;
|
|
109
115
|
}
|
|
110
116
|
export type MigrationDetailsWithId = GeneratedMigrationDetails & {
|
|
111
117
|
id: string;
|
|
@@ -171,13 +171,13 @@ export interface ReadyWhenOptions {
|
|
|
171
171
|
timeout?: number;
|
|
172
172
|
/**
|
|
173
173
|
* Milliseconds between probe attempts. Default is 250. Unused by
|
|
174
|
-
* `logMatches`.
|
|
174
|
+
* `logMatches` and `signal`.
|
|
175
175
|
*/
|
|
176
176
|
interval?: number;
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
179
|
* Readiness probe of a continuous target. Exactly one of `url`, `port`,
|
|
180
|
-
* `command` or `
|
|
180
|
+
* `command`, `logMatches` or `signal` must be set. Strings may use the `{workspaceRoot}`,
|
|
181
181
|
* `{projectRoot}`, `{projectName}`, `{options.*}` and `{env.*}` placeholders,
|
|
182
182
|
* resolved against the options and environment the task runs with. A
|
|
183
183
|
* placeholder can list fallbacks, as in `{options.port ?? env.PORT ?? 4200}`.
|
|
@@ -203,7 +203,8 @@ export type ReadyWhen = ({
|
|
|
203
203
|
} & ReadyWhenOptions) | ({
|
|
204
204
|
/**
|
|
205
205
|
* Ready when the command, run through the shell at the workspace root,
|
|
206
|
-
* exits with code 0.
|
|
206
|
+
* exits with code 0. It runs with the env the task runs with, and the
|
|
207
|
+
* task's options as JSON in `NX_TASK_OPTIONS`.
|
|
207
208
|
*/
|
|
208
209
|
command: string;
|
|
209
210
|
} & ReadyWhenOptions) | ({
|
|
@@ -212,7 +213,14 @@ export type ReadyWhen = ({
|
|
|
212
213
|
* output.
|
|
213
214
|
*/
|
|
214
215
|
logMatches: string | string[];
|
|
215
|
-
} & ReadyWhenOptions)
|
|
216
|
+
} & ReadyWhenOptions) | {
|
|
217
|
+
/**
|
|
218
|
+
* Ready when the task reports it with `signalTaskReady` from
|
|
219
|
+
* `@nx/devkit`.
|
|
220
|
+
*/
|
|
221
|
+
signal: true;
|
|
222
|
+
timeout?: number;
|
|
223
|
+
};
|
|
216
224
|
export interface TargetDependencyConfig {
|
|
217
225
|
/**
|
|
218
226
|
* A list of projects that have `target`.
|