nx 21.0.0-beta.10 → 21.0.0-beta.11

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.
Files changed (31) hide show
  1. package/migrations.json +10 -0
  2. package/package.json +11 -11
  3. package/schemas/nx-schema.json +5 -0
  4. package/src/adapter/angular-json.js +11 -0
  5. package/src/command-line/migrate/migrate-ui-api.js +1 -1
  6. package/src/command-line/migrate/migrate.d.ts +12 -6
  7. package/src/command-line/migrate/migrate.js +31 -9
  8. package/src/command-line/repair/repair.js +8 -2
  9. package/src/command-line/report/report.js +1 -1
  10. package/src/config/misc-interfaces.d.ts +9 -1
  11. package/src/config/nx-json.d.ts +0 -4
  12. package/src/core/graph/main.js +1 -1
  13. package/src/devkit-exports.d.ts +1 -1
  14. package/src/migrations/update-21-0-0/remove-custom-tasks-runner.d.ts +2 -0
  15. package/src/migrations/update-21-0-0/remove-custom-tasks-runner.js +38 -0
  16. package/src/migrations/update-21-0-0/remove-legacy-cache.d.ts +2 -0
  17. package/src/migrations/update-21-0-0/remove-legacy-cache.js +17 -0
  18. package/src/native/nx.wasm32-wasi.wasm +0 -0
  19. package/src/plugins/js/index.d.ts +2 -1
  20. package/src/plugins/js/index.js +8 -1
  21. package/src/project-graph/plugins/loaded-nx-plugin.js +1 -5
  22. package/src/tasks-runner/batch/run-batch.js +1 -1
  23. package/src/tasks-runner/cache.d.ts +1 -2
  24. package/src/tasks-runner/cache.js +2 -18
  25. package/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +8 -7
  26. package/src/tasks-runner/pseudo-terminal.d.ts +1 -0
  27. package/src/tasks-runner/pseudo-terminal.js +11 -1
  28. package/src/tasks-runner/run-command.js +2 -24
  29. package/src/tasks-runner/task-graph-utils.d.ts +3 -0
  30. package/src/tasks-runner/task-graph-utils.js +31 -2
  31. package/src/tasks-runner/task-orchestrator.js +10 -1
package/migrations.json CHANGED
@@ -33,6 +33,16 @@
33
33
  "version": "21.0.0-beta.1",
34
34
  "description": "Updates release version config based on the breaking changes in Nx v21",
35
35
  "implementation": "./src/migrations/update-21-0-0/release-version-config-changes"
36
+ },
37
+ "remove-legacy-cache": {
38
+ "version": "21.0.0-beta.8",
39
+ "description": "Removes the legacy cache configuration from nx.json",
40
+ "implementation": "./src/migrations/update-21-0-0/remove-legacy-cache"
41
+ },
42
+ "remove-custom-tasks-runner": {
43
+ "version": "21.0.0-beta.8",
44
+ "description": "Removes the legacy cache configuration from nx.json",
45
+ "implementation": "./src/migrations/update-21-0-0/remove-custom-tasks-runner"
36
46
  }
37
47
  }
38
48
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "21.0.0-beta.10",
3
+ "version": "21.0.0-beta.11",
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": {
@@ -83,16 +83,16 @@
83
83
  }
84
84
  },
85
85
  "optionalDependencies": {
86
- "@nx/nx-darwin-arm64": "21.0.0-beta.10",
87
- "@nx/nx-darwin-x64": "21.0.0-beta.10",
88
- "@nx/nx-freebsd-x64": "21.0.0-beta.10",
89
- "@nx/nx-linux-arm-gnueabihf": "21.0.0-beta.10",
90
- "@nx/nx-linux-arm64-gnu": "21.0.0-beta.10",
91
- "@nx/nx-linux-arm64-musl": "21.0.0-beta.10",
92
- "@nx/nx-linux-x64-gnu": "21.0.0-beta.10",
93
- "@nx/nx-linux-x64-musl": "21.0.0-beta.10",
94
- "@nx/nx-win32-arm64-msvc": "21.0.0-beta.10",
95
- "@nx/nx-win32-x64-msvc": "21.0.0-beta.10"
86
+ "@nx/nx-darwin-arm64": "21.0.0-beta.11",
87
+ "@nx/nx-darwin-x64": "21.0.0-beta.11",
88
+ "@nx/nx-freebsd-x64": "21.0.0-beta.11",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.0.0-beta.11",
90
+ "@nx/nx-linux-arm64-gnu": "21.0.0-beta.11",
91
+ "@nx/nx-linux-arm64-musl": "21.0.0-beta.11",
92
+ "@nx/nx-linux-x64-gnu": "21.0.0-beta.11",
93
+ "@nx/nx-linux-x64-musl": "21.0.0-beta.11",
94
+ "@nx/nx-win32-arm64-msvc": "21.0.0-beta.11",
95
+ "@nx/nx-win32-x64-msvc": "21.0.0-beta.11"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
@@ -543,6 +543,11 @@
543
543
  "type": "object"
544
544
  }
545
545
  },
546
+ "continuous": {
547
+ "type": "boolean",
548
+ "default": false,
549
+ "description": "Whether this target runs continuously until stopped"
550
+ },
546
551
  "parallelism": {
547
552
  "type": "boolean",
548
553
  "default": true,
@@ -18,6 +18,17 @@ exports.NxAngularJsonPlugin = {
18
18
  projects: readAngularJson(ctx.workspaceRoot),
19
19
  }),
20
20
  ],
21
+ createNodesV2: [
22
+ 'angular.json',
23
+ (f, _, ctx) => [
24
+ [
25
+ 'angular.json',
26
+ {
27
+ projects: readAngularJson(ctx.workspaceRoot),
28
+ },
29
+ ],
30
+ ],
31
+ ],
21
32
  };
22
33
  exports.default = exports.NxAngularJsonPlugin;
23
34
  function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
@@ -72,7 +72,7 @@ async function runSingleMigration(workspacePath, migration, configuration) {
72
72
  // 1. The CLI path to the migrated modules. The version of Nx is of the user's choosing. This may or may not have the new migrate API, so Console will check that `runSingleMigration` exists before using it.
73
73
  // 2. Bundled into Console, so the version is fixed to what we build Console with.
74
74
  const updatedMigrateModule = await Promise.resolve().then(() => require('./migrate.js'));
75
- const fileChanges = await updatedMigrateModule.runNxOrAngularMigration(workspacePath, migration, false, configuration.createCommits, configuration.commitPrefix || 'chore: [nx migration] ', undefined, true);
75
+ const { changes: fileChanges } = await updatedMigrateModule.runNxOrAngularMigration(workspacePath, migration, false, configuration.createCommits, configuration.commitPrefix || 'chore: [nx migration] ', undefined, true);
76
76
  const gitRefAfter = (0, child_process_1.execSync)('git rev-parse HEAD', {
77
77
  cwd: workspacePath,
78
78
  encoding: 'utf-8',
@@ -101,17 +101,23 @@ export declare function executeMigrations(root: string, migrations: {
101
101
  description?: string;
102
102
  version: string;
103
103
  }[], isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string): Promise<{
104
- package: string;
105
- name: string;
106
- description?: string;
107
- version: string;
108
- }[]>;
104
+ migrationsWithNoChanges: {
105
+ package: string;
106
+ name: string;
107
+ description?: string;
108
+ version: string;
109
+ }[];
110
+ nextSteps: string[];
111
+ }>;
109
112
  export declare function runNxOrAngularMigration(root: string, migration: {
110
113
  package: string;
111
114
  name: string;
112
115
  description?: string;
113
116
  version: string;
114
- }, isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string, installDepsIfChanged?: () => void, handleInstallDeps?: boolean): Promise<FileChange[]>;
117
+ }, isVerbose: boolean, shouldCreateCommits: boolean, commitPrefix: string, installDepsIfChanged?: () => void, handleInstallDeps?: boolean): Promise<{
118
+ changes: FileChange[];
119
+ nextSteps: string[];
120
+ }>;
115
121
  export declare function migrate(root: string, args: {
116
122
  [k: string]: any;
117
123
  }, rawArgs: string[]): Promise<number>;
@@ -935,10 +935,12 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
935
935
  logger_1.logger.info(`Running the following migrations:`);
936
936
  sortedMigrations.forEach((m) => logger_1.logger.info(`- ${m.package}: ${m.name} (${m.description})`));
937
937
  logger_1.logger.info(`---------------------------------------------------------\n`);
938
+ const allNextSteps = [];
938
939
  for (const m of sortedMigrations) {
939
940
  logger_1.logger.info(`Running migration ${m.package}: ${m.name}`);
940
941
  try {
941
- const changes = await runNxOrAngularMigration(root, m, isVerbose, shouldCreateCommits, commitPrefix, () => changedDepInstaller.installDepsIfChanged());
942
+ const { changes, nextSteps } = await runNxOrAngularMigration(root, m, isVerbose, shouldCreateCommits, commitPrefix, () => changedDepInstaller.installDepsIfChanged());
943
+ allNextSteps.push(...nextSteps);
942
944
  if (changes.length === 0) {
943
945
  migrationsWithNoChanges.push(m);
944
946
  }
@@ -954,7 +956,7 @@ async function executeMigrations(root, migrations, isVerbose, shouldCreateCommit
954
956
  if (!shouldCreateCommits) {
955
957
  changedDepInstaller.installDepsIfChanged();
956
958
  }
957
- return migrationsWithNoChanges;
959
+ return { migrationsWithNoChanges, nextSteps: allNextSteps };
958
960
  }
959
961
  class ChangedDepInstaller {
960
962
  constructor(root) {
@@ -976,13 +978,14 @@ async function runNxOrAngularMigration(root, migration, isVerbose, shouldCreateC
976
978
  }
977
979
  const { collection, collectionPath } = readMigrationCollection(migration.package, root);
978
980
  let changes = [];
981
+ let nextSteps = [];
979
982
  if (!isAngularMigration(collection, migration.name)) {
980
- changes = await runNxMigration(root, collectionPath, collection, migration.name);
983
+ ({ nextSteps, changes } = await runNxMigration(root, collectionPath, collection, migration.name));
981
984
  logger_1.logger.info(`Ran ${migration.name} from ${migration.package}`);
982
985
  logger_1.logger.info(` ${migration.description}\n`);
983
986
  if (changes.length < 1) {
984
987
  logger_1.logger.info(`No changes were made\n`);
985
- return [];
988
+ return { changes, nextSteps };
986
989
  }
987
990
  logger_1.logger.info('Changes:');
988
991
  (0, tree_1.printChanges)(changes, ' ');
@@ -996,7 +999,7 @@ async function runNxOrAngularMigration(root, migration, isVerbose, shouldCreateC
996
999
  logger_1.logger.info(` ${migration.description}\n`);
997
1000
  if (!madeChanges) {
998
1001
  logger_1.logger.info(`No changes were made\n`);
999
- return [];
1002
+ return { changes, nextSteps };
1000
1003
  }
1001
1004
  logger_1.logger.info('Changes:');
1002
1005
  loggingQueue.forEach((log) => logger_1.logger.info(' ' + log));
@@ -1022,7 +1025,7 @@ async function runNxOrAngularMigration(root, migration, isVerbose, shouldCreateC
1022
1025
  else if (handleInstallDeps) {
1023
1026
  installDepsIfChanged();
1024
1027
  }
1025
- return changes;
1028
+ return { changes, nextSteps };
1026
1029
  }
1027
1030
  async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits = false, commitPrefix) {
1028
1031
  if (!process.env.NX_MIGRATE_SKIP_INSTALL) {
@@ -1056,7 +1059,7 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits =
1056
1059
  (shouldCreateCommits ? ', with each applied in a dedicated commit' : ''),
1057
1060
  });
1058
1061
  const migrations = (0, fileutils_1.readJsonFile)((0, path_1.join)(root, opts.runMigrations)).migrations;
1059
- const migrationsWithNoChanges = await executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix);
1062
+ const { migrationsWithNoChanges, nextSteps } = await executeMigrations(root, migrations, isVerbose, shouldCreateCommits, commitPrefix);
1060
1063
  if (migrationsWithNoChanges.length < migrations.length) {
1061
1064
  output_1.output.success({
1062
1065
  title: `Successfully finished running migrations from '${opts.runMigrations}'. This workspace is up to date!`,
@@ -1067,6 +1070,12 @@ async function runMigrations(root, opts, args, isVerbose, shouldCreateCommits =
1067
1070
  title: `No changes were made from running '${opts.runMigrations}'. This workspace is up to date!`,
1068
1071
  });
1069
1072
  }
1073
+ if (nextSteps.length > 0) {
1074
+ output_1.output.log({
1075
+ title: `Some migrations have additional information, see below.`,
1076
+ bodyLines: nextSteps.map((line) => `- ${line}`),
1077
+ });
1078
+ }
1070
1079
  }
1071
1080
  function getStringifiedPackageJsonDeps(root) {
1072
1081
  try {
@@ -1083,11 +1092,18 @@ async function runNxMigration(root, collectionPath, collection, name) {
1083
1092
  const { path: implPath, fnSymbol } = getImplementationPath(collection, collectionPath, name);
1084
1093
  const fn = require(implPath)[fnSymbol];
1085
1094
  const host = new tree_1.FsTree(root, process.env.NX_VERBOSE_LOGGING === 'true', `migration ${collection.name}:${name}`);
1086
- await fn(host, {});
1095
+ let nextSteps = await fn(host, {});
1096
+ // This accounts for migrations that mistakenly return a generator callback
1097
+ // from a migration. We've never executed these, so its not a breaking change that
1098
+ // we don't call them now... but currently shipping a migration with one wouldn't break
1099
+ // the migrate flow, so we are being cautious.
1100
+ if (!isStringArray(nextSteps)) {
1101
+ nextSteps = [];
1102
+ }
1087
1103
  host.lock();
1088
1104
  const changes = host.listChanges();
1089
1105
  (0, tree_1.flushChanges)(root, changes);
1090
- return changes;
1106
+ return { changes, nextSteps };
1091
1107
  }
1092
1108
  async function migrate(root, args, rawArgs) {
1093
1109
  await client_1.daemonClient.stop();
@@ -1230,3 +1246,9 @@ const getNgCompatLayer = (() => {
1230
1246
  return _ngCliAdapter;
1231
1247
  };
1232
1248
  })();
1249
+ function isStringArray(value) {
1250
+ if (!Array.isArray(value)) {
1251
+ return false;
1252
+ }
1253
+ return value.every((v) => typeof v === 'string');
1254
+ }
@@ -20,8 +20,8 @@ async function repair(args, extraMigrations = []) {
20
20
  return agg;
21
21
  }, []);
22
22
  const migrations = [...nxMigrations, ...extraMigrations];
23
- const migrationsThatMadeNoChanges = await (0, migrate_1.executeMigrations)(process.cwd(), migrations, args.verbose, false, '');
24
- if (migrationsThatMadeNoChanges.length < migrations.length) {
23
+ const { migrationsWithNoChanges, nextSteps } = await (0, migrate_1.executeMigrations)(process.cwd(), migrations, args.verbose, false, '');
24
+ if (migrationsWithNoChanges.length < migrations.length) {
25
25
  output_1.output.success({
26
26
  title: `Successfully repaired your configuration. This workspace is up to date!`,
27
27
  });
@@ -31,5 +31,11 @@ async function repair(args, extraMigrations = []) {
31
31
  title: `No changes were necessary. This workspace is up to date!`,
32
32
  });
33
33
  }
34
+ if (nextSteps.length) {
35
+ output_1.output.log({
36
+ title: 'Some repairs have additional information, see below.',
37
+ bodyLines: nextSteps.map((line) => ` - ${line}`),
38
+ });
39
+ }
34
40
  });
35
41
  }
@@ -182,7 +182,7 @@ async function getReportData() {
182
182
  nxKeyError = e;
183
183
  }
184
184
  }
185
- let cache = (0, cache_1.dbCacheEnabled)(nxJson)
185
+ let cache = (0, cache_1.dbCacheEnabled)()
186
186
  ? {
187
187
  max: nxJson.maxCacheSize !== undefined
188
188
  ? (0, cache_1.parseMaxCacheSize)(nxJson.maxCacheSize)
@@ -3,7 +3,8 @@ import { ProjectGraph } from './project-graph';
3
3
  import { Task, TaskGraph } from './task-graph';
4
4
  import { TargetConfiguration, ProjectsConfigurations } from './workspace-json-project-json';
5
5
  import type { NxJsonConfiguration } from './nx-json';
6
- import { Schema } from '../utils/params';
6
+ import type { Schema } from '../utils/params';
7
+ import type { Tree } from '../generators/tree';
7
8
  /**
8
9
  * A callback function that is executed after changes are made to the file system
9
10
  */
@@ -50,6 +51,13 @@ export type PackageJsonUpdates = {
50
51
  requires?: Record<string, string>;
51
52
  };
52
53
  };
54
+ /**
55
+ * Represents a migration that is executed when running `nx migrate`.
56
+ *
57
+ * Returning a string[] from the migration function will be interpreted as
58
+ * a list of next steps to be displayed to the user.
59
+ */
60
+ export type Migration = (tree: Tree) => void | Promise<void> | string[] | Promise<string[]>;
53
61
  export interface MigrationsJsonEntry {
54
62
  version: string;
55
63
  description?: string;
@@ -590,10 +590,6 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
590
590
  * Configuration for the `nx sync` command.
591
591
  */
592
592
  sync?: NxSyncConfiguration;
593
- /**
594
- * Use the legacy file system cache instead of the db cache
595
- */
596
- useLegacyCache?: boolean;
597
593
  /**
598
594
  * Sets the maximum size of the local cache. Accepts a number followed by a unit (e.g. 100MB). Accepted units are B, KB, MB, and GB.
599
595
  */