nx 19.7.2 → 19.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/package.json +12 -12
  2. package/schemas/nx-schema.json +2 -2
  3. package/src/command-line/add/add.js +2 -2
  4. package/src/command-line/affected/command-object.js +6 -6
  5. package/src/command-line/deprecated/command-objects.js +3 -3
  6. package/src/command-line/generate/generate.js +2 -1
  7. package/src/command-line/import/command-object.js +8 -6
  8. package/src/command-line/import/import.d.ts +1 -1
  9. package/src/command-line/import/import.js +45 -29
  10. package/src/command-line/import/utils/prepare-source-repo.js +7 -35
  11. package/src/command-line/init/init-v2.js +6 -2
  12. package/src/command-line/login/login.js +2 -2
  13. package/src/command-line/logout/logout.js +2 -2
  14. package/src/command-line/migrate/migrate.js +2 -2
  15. package/src/command-line/new/new.js +2 -1
  16. package/src/command-line/release/changelog.js +2 -2
  17. package/src/command-line/release/command-object.d.ts +2 -2
  18. package/src/command-line/release/config/config.js +10 -3
  19. package/src/command-line/release/plan-check.js +2 -2
  20. package/src/command-line/release/plan.js +2 -2
  21. package/src/command-line/release/publish.js +2 -2
  22. package/src/command-line/release/release.js +2 -2
  23. package/src/command-line/release/utils/git.d.ts +2 -2
  24. package/src/command-line/release/utils/git.js +12 -2
  25. package/src/command-line/release/utils/shared.d.ts +1 -1
  26. package/src/command-line/release/version.js +6 -1
  27. package/src/command-line/repair/repair.js +2 -2
  28. package/src/command-line/run/command-object.js +3 -3
  29. package/src/command-line/run/run.js +3 -2
  30. package/src/command-line/run-many/command-object.js +2 -2
  31. package/src/command-line/show/command-object.js +3 -3
  32. package/src/command-line/sync/sync.js +69 -11
  33. package/src/config/nx-json.d.ts +13 -5
  34. package/src/daemon/client/client.d.ts +3 -3
  35. package/src/daemon/server/handle-flush-sync-generator-changes-to-disk.js +2 -2
  36. package/src/daemon/server/handle-get-sync-generator-changes.js +8 -6
  37. package/src/daemon/server/sync-generators.d.ts +4 -4
  38. package/src/daemon/server/sync-generators.js +11 -2
  39. package/src/hasher/hash-task.js +2 -2
  40. package/src/native/nx.wasi-browser.js +42 -54
  41. package/src/native/nx.wasi.cjs +42 -54
  42. package/src/native/nx.wasm32-wasi.wasm +0 -0
  43. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +0 -1
  44. package/src/nx-cloud/utilities/get-cloud-options.d.ts +1 -0
  45. package/src/nx-cloud/utilities/get-cloud-options.js +4 -0
  46. package/src/nx-cloud/utilities/is-workspace-claimed.d.ts +1 -1
  47. package/src/nx-cloud/utilities/is-workspace-claimed.js +6 -5
  48. package/src/nx-cloud/utilities/onboarding.js +2 -2
  49. package/src/plugins/js/utils/register.js +7 -0
  50. package/src/project-graph/error-types.d.ts +1 -1
  51. package/src/project-graph/error-types.js +19 -5
  52. package/src/tasks-runner/cache.js +2 -1
  53. package/src/tasks-runner/run-command.js +142 -30
  54. package/src/tasks-runner/task-orchestrator.d.ts +0 -1
  55. package/src/tasks-runner/task-orchestrator.js +3 -6
  56. package/src/utils/git-utils.d.ts +3 -2
  57. package/src/utils/git-utils.index-filter.d.ts +0 -0
  58. package/src/utils/git-utils.index-filter.js +20 -0
  59. package/src/utils/git-utils.js +44 -13
  60. package/src/utils/git-utils.tree-filter.d.ts +11 -0
  61. package/src/utils/git-utils.tree-filter.js +43 -0
  62. package/src/utils/handle-errors.d.ts +1 -0
  63. package/src/utils/handle-errors.js +71 -0
  64. package/src/utils/nx-cloud-utils.d.ts +0 -1
  65. package/src/utils/nx-cloud-utils.js +0 -10
  66. package/src/utils/params.d.ts +0 -1
  67. package/src/utils/params.js +0 -50
  68. package/src/utils/plugins/plugin-capabilities.js +4 -1
  69. package/src/utils/sync-generators.d.ts +35 -6
  70. package/src/utils/sync-generators.js +144 -47
@@ -8,14 +8,14 @@ const project_graph_1 = require("../../project-graph/project-graph");
8
8
  const all_file_data_1 = require("../../utils/all-file-data");
9
9
  const command_line_utils_1 = require("../../utils/command-line-utils");
10
10
  const output_1 = require("../../utils/output");
11
- const params_1 = require("../../utils/params");
11
+ const handle_errors_1 = require("../../utils/handle-errors");
12
12
  const config_1 = require("./config/config");
13
13
  const deep_merge_json_1 = require("./config/deep-merge-json");
14
14
  const filter_release_groups_1 = require("./config/filter-release-groups");
15
15
  const version_plans_1 = require("./config/version-plans");
16
16
  const get_touched_projects_for_group_1 = require("./utils/get-touched-projects-for-group");
17
17
  const print_config_1 = require("./utils/print-config");
18
- const releasePlanCheckCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args));
18
+ const releasePlanCheckCLIHandler = (args) => (0, handle_errors_1.handleErrors)(args.verbose, () => createAPI({})(args));
19
19
  exports.releasePlanCheckCLIHandler = releasePlanCheckCLIHandler;
20
20
  function createAPI(overrideReleaseConfig) {
21
21
  return async function releasePlanCheck(args) {
@@ -13,7 +13,7 @@ const project_graph_1 = require("../../project-graph/project-graph");
13
13
  const all_file_data_1 = require("../../utils/all-file-data");
14
14
  const command_line_utils_1 = require("../../utils/command-line-utils");
15
15
  const output_1 = require("../../utils/output");
16
- const params_1 = require("../../utils/params");
16
+ const handle_errors_1 = require("../../utils/handle-errors");
17
17
  const config_1 = require("./config/config");
18
18
  const deep_merge_json_1 = require("./config/deep-merge-json");
19
19
  const filter_release_groups_1 = require("./config/filter-release-groups");
@@ -23,7 +23,7 @@ const get_touched_projects_for_group_1 = require("./utils/get-touched-projects-f
23
23
  const launch_editor_1 = require("./utils/launch-editor");
24
24
  const print_changes_1 = require("./utils/print-changes");
25
25
  const print_config_1 = require("./utils/print-config");
26
- const releasePlanCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args));
26
+ const releasePlanCLIHandler = (args) => (0, handle_errors_1.handleErrors)(args.verbose, () => createAPI({})(args));
27
27
  exports.releasePlanCLIHandler = releasePlanCLIHandler;
28
28
  function createAPI(overrideReleaseConfig) {
29
29
  return async function releasePlan(args) {
@@ -8,14 +8,14 @@ const project_graph_1 = require("../../project-graph/project-graph");
8
8
  const run_command_1 = require("../../tasks-runner/run-command");
9
9
  const command_line_utils_1 = require("../../utils/command-line-utils");
10
10
  const output_1 = require("../../utils/output");
11
- const params_1 = require("../../utils/params");
11
+ const handle_errors_1 = require("../../utils/handle-errors");
12
12
  const project_graph_utils_1 = require("../../utils/project-graph-utils");
13
13
  const graph_1 = require("../graph/graph");
14
14
  const config_1 = require("./config/config");
15
15
  const deep_merge_json_1 = require("./config/deep-merge-json");
16
16
  const filter_release_groups_1 = require("./config/filter-release-groups");
17
17
  const print_config_1 = require("./utils/print-config");
18
- const releasePublishCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args, true));
18
+ const releasePublishCLIHandler = (args) => (0, handle_errors_1.handleErrors)(args.verbose, () => createAPI({})(args, true));
19
19
  exports.releasePublishCLIHandler = releasePublishCLIHandler;
20
20
  function createAPI(overrideReleaseConfig) {
21
21
  /**
@@ -8,7 +8,7 @@ const nx_json_1 = require("../../config/nx-json");
8
8
  const file_map_utils_1 = require("../../project-graph/file-map-utils");
9
9
  const project_graph_1 = require("../../project-graph/project-graph");
10
10
  const output_1 = require("../../utils/output");
11
- const params_1 = require("../../utils/params");
11
+ const handle_errors_1 = require("../../utils/handle-errors");
12
12
  const changelog_1 = require("./changelog");
13
13
  const config_1 = require("./config/config");
14
14
  const deep_merge_json_1 = require("./config/deep-merge-json");
@@ -21,7 +21,7 @@ const print_config_1 = require("./utils/print-config");
21
21
  const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
22
22
  const shared_1 = require("./utils/shared");
23
23
  const version_1 = require("./version");
24
- const releaseCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args));
24
+ const releaseCLIHandler = (args) => (0, handle_errors_1.handleErrors)(args.verbose, () => createAPI({})(args));
25
25
  exports.releaseCLIHandler = releaseCLIHandler;
26
26
  function createAPI(overrideReleaseConfig) {
27
27
  const releaseVersion = (0, version_1.createAPI)(overrideReleaseConfig);
@@ -37,7 +37,7 @@ export declare function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, lo
37
37
  }): Promise<string>;
38
38
  export declare function gitCommit({ messages, additionalArgs, dryRun, verbose, logFn, }: {
39
39
  messages: string[];
40
- additionalArgs?: string;
40
+ additionalArgs?: string | string[];
41
41
  dryRun?: boolean;
42
42
  verbose?: boolean;
43
43
  logFn?: (message: string) => void;
@@ -45,7 +45,7 @@ export declare function gitCommit({ messages, additionalArgs, dryRun, verbose, l
45
45
  export declare function gitTag({ tag, message, additionalArgs, dryRun, verbose, logFn, }: {
46
46
  tag: string;
47
47
  message?: string;
48
- additionalArgs?: string;
48
+ additionalArgs?: string | string[];
49
49
  dryRun?: boolean;
50
50
  verbose?: boolean;
51
51
  logFn?: (message: string) => void;
@@ -188,7 +188,12 @@ async function gitCommit({ messages, additionalArgs, dryRun, verbose, logFn, })
188
188
  commandArgs.push('--message', message);
189
189
  }
190
190
  if (additionalArgs) {
191
- commandArgs.push(...additionalArgs.split(' '));
191
+ if (Array.isArray(additionalArgs)) {
192
+ commandArgs.push(...additionalArgs);
193
+ }
194
+ else {
195
+ commandArgs.push(...additionalArgs.split(' '));
196
+ }
192
197
  }
193
198
  if (verbose) {
194
199
  logFn(dryRun
@@ -224,7 +229,12 @@ async function gitTag({ tag, message, additionalArgs, dryRun, verbose, logFn, })
224
229
  message || tag,
225
230
  ];
226
231
  if (additionalArgs) {
227
- commandArgs.push(...additionalArgs.split(' '));
232
+ if (Array.isArray(additionalArgs)) {
233
+ commandArgs.push(...additionalArgs);
234
+ }
235
+ else {
236
+ commandArgs.push(...additionalArgs.split(' '));
237
+ }
228
238
  }
229
239
  if (verbose) {
230
240
  logFn(dryRun
@@ -45,7 +45,7 @@ export declare function commitChanges({ changedFiles, deletedFiles, isDryRun, is
45
45
  isDryRun?: boolean;
46
46
  isVerbose?: boolean;
47
47
  gitCommitMessages?: string[];
48
- gitCommitArgs?: string;
48
+ gitCommitArgs?: string | string[];
49
49
  }): Promise<void>;
50
50
  export declare function createCommitMessageValues(releaseGroups: ReleaseGroupWithName[], releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>, versionData: VersionData, commitMessage: string): string[];
51
51
  export declare function createGitTagValues(releaseGroups: ReleaseGroupWithName[], releaseGroupToFilteredProjects: Map<ReleaseGroupWithName, Set<string>>, versionData: VersionData): string[];
@@ -26,12 +26,13 @@ const print_changes_1 = require("./utils/print-changes");
26
26
  const print_config_1 = require("./utils/print-config");
27
27
  const resolve_nx_json_error_message_1 = require("./utils/resolve-nx-json-error-message");
28
28
  const shared_1 = require("./utils/shared");
29
+ const handle_errors_1 = require("../../utils/handle-errors");
29
30
  const LARGE_BUFFER = 1024 * 1000000;
30
31
  // Reexport some utils for use in plugin release-version generator implementations
31
32
  var semver_1 = require("./utils/semver");
32
33
  Object.defineProperty(exports, "deriveNewSemverVersion", { enumerable: true, get: function () { return semver_1.deriveNewSemverVersion; } });
33
34
  exports.validReleaseVersionPrefixes = ['auto', '', '~', '^', '='];
34
- const releaseVersionCLIHandler = (args) => (0, params_1.handleErrors)(args.verbose, () => createAPI({})(args));
35
+ const releaseVersionCLIHandler = (args) => (0, handle_errors_1.handleErrors)(args.verbose, () => createAPI({})(args));
35
36
  exports.releaseVersionCLIHandler = releaseVersionCLIHandler;
36
37
  function createAPI(overrideReleaseConfig) {
37
38
  /**
@@ -206,6 +207,10 @@ function createAPI(overrideReleaseConfig) {
206
207
  */
207
208
  for (const releaseGroup of releaseGroups) {
208
209
  const releaseGroupName = releaseGroup.name;
210
+ runPreVersionCommand(releaseGroup.version.groupPreVersionCommand, {
211
+ dryRun: args.dryRun,
212
+ verbose: args.verbose,
213
+ });
209
214
  const projectBatches = (0, batch_projects_by_generator_config_1.batchProjectsByGeneratorConfig)(projectGraph, releaseGroup,
210
215
  // Batch based on all projects within the release group
211
216
  releaseGroup.projects);
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.repair = repair;
4
- const params_1 = require("../../utils/params");
4
+ const handle_errors_1 = require("../../utils/handle-errors");
5
5
  const migrationsJson = require("../../../migrations.json");
6
6
  const migrate_1 = require("../migrate/migrate");
7
7
  const output_1 = require("../../utils/output");
8
8
  async function repair(args, extraMigrations = []) {
9
- return (0, params_1.handleErrors)(args.verbose, async () => {
9
+ return (0, handle_errors_1.handleErrors)(args.verbose, async () => {
10
10
  const nxMigrations = Object.entries(migrationsJson.generators).reduce((agg, [name, migration]) => {
11
11
  const skip = migration['x-repair-skip'];
12
12
  if (!skip) {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsNxInfixCommand = exports.yargsRunCommand = void 0;
4
4
  const yargs_1 = require("yargs");
5
5
  const shared_options_1 = require("../yargs-utils/shared-options");
6
- const params_1 = require("../../utils/params");
6
+ const handle_errors_1 = require("../../utils/handle-errors");
7
7
  exports.yargsRunCommand = {
8
8
  command: 'run [project][:target][:configuration] [_..]',
9
9
  describe: `Run a target for a project
@@ -15,7 +15,7 @@ exports.yargsRunCommand = {
15
15
  You can skip the use of Nx cache by using the --skip-nx-cache option.`,
16
16
  builder: (yargs) => (0, shared_options_1.withRunOneOptions)((0, shared_options_1.withBatch)(yargs)),
17
17
  handler: async (args) => {
18
- const exitCode = await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
18
+ const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
19
19
  await Promise.resolve().then(() => require('./run-one')).then((m) => m.runOne(process.cwd(), (0, shared_options_1.withOverrides)(args)));
20
20
  });
21
21
  process.exit(exitCode);
@@ -29,7 +29,7 @@ exports.yargsNxInfixCommand = {
29
29
  command: '$0 <target> [project] [_..]',
30
30
  describe: 'Run a target for a project.',
31
31
  handler: async (args) => {
32
- const exitCode = await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
32
+ const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
33
33
  // Yargs parses <target> as 'undefined' if running just 'nx'
34
34
  if (!args.target || args.target === 'undefined') {
35
35
  (0, yargs_1.showHelp)();
@@ -7,6 +7,7 @@ exports.printTargetRunHelp = printTargetRunHelp;
7
7
  exports.run = run;
8
8
  const npm_run_path_1 = require("npm-run-path");
9
9
  const params_1 = require("../../utils/params");
10
+ const handle_errors_1 = require("../../utils/handle-errors");
10
11
  const print_help_1 = require("../../utils/print-help");
11
12
  const path_1 = require("path");
12
13
  const serialize_overrides_into_command_line_1 = require("../../utils/serialize-overrides-into-command-line");
@@ -163,14 +164,14 @@ async function runExecutor(targetDescription, overrides, context) {
163
164
  }
164
165
  function printTargetRunHelp(targetDescription, root) {
165
166
  const projectGraph = (0, project_graph_1.readCachedProjectGraph)();
166
- return (0, params_1.handleErrors)(false, async () => {
167
+ return (0, handle_errors_1.handleErrors)(false, async () => {
167
168
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
168
169
  await printTargetRunHelpInternal(targetDescription, root, projectsConfigurations);
169
170
  });
170
171
  }
171
172
  function run(cwd, root, targetDescription, overrides, isVerbose, taskGraph) {
172
173
  const projectGraph = (0, project_graph_1.readCachedProjectGraph)();
173
- return (0, params_1.handleErrors)(isVerbose, async () => {
174
+ return (0, handle_errors_1.handleErrors)(isVerbose, async () => {
174
175
  const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
175
176
  return iteratorToProcessStatusCode(await runExecutorInternal(targetDescription, overrides, root, cwd, projectsConfigurations, (0, configuration_1.readNxJson)(), projectGraph, taskGraph, isVerbose));
176
177
  });
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsRunManyCommand = void 0;
4
4
  const documentation_1 = require("../yargs-utils/documentation");
5
5
  const shared_options_1 = require("../yargs-utils/shared-options");
6
- const params_1 = require("../../utils/params");
6
+ const handle_errors_1 = require("../../utils/handle-errors");
7
7
  exports.yargsRunManyCommand = {
8
8
  command: 'run-many',
9
9
  describe: 'Run target for multiple listed projects.',
10
10
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)((0, shared_options_1.withRunManyOptions)((0, shared_options_1.withOutputStyleOption)((0, shared_options_1.withTargetAndConfigurationOption)((0, shared_options_1.withBatch)(yargs)))), 'run-many'),
11
11
  handler: async (args) => {
12
- const exitCode = await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
12
+ const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
13
13
  await Promise.resolve().then(() => require('./run-many')).then((m) => m.runMany((0, shared_options_1.withOverrides)(args)));
14
14
  });
15
15
  process.exit(exitCode);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.yargsShowCommand = void 0;
4
4
  const yargs_1 = require("yargs");
5
5
  const shared_options_1 = require("../yargs-utils/shared-options");
6
- const params_1 = require("../../utils/params");
6
+ const handle_errors_1 = require("../../utils/handle-errors");
7
7
  exports.yargsShowCommand = {
8
8
  command: 'show',
9
9
  describe: 'Show information about the workspace (e.g., list of projects).',
@@ -65,7 +65,7 @@ const showProjectsCommand = {
65
65
  .example('$0 show projects --type app --affected', 'Show affected apps in the workspace')
66
66
  .example('$0 show projects --affected --exclude=*-e2e', 'Show affected projects in the workspace, excluding end-to-end projects'),
67
67
  handler: async (args) => {
68
- const exitCode = await (0, params_1.handleErrors)(args.verbose, async () => {
68
+ const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose, async () => {
69
69
  const { showProjectsHandler } = await Promise.resolve().then(() => require('./projects'));
70
70
  await showProjectsHandler(args);
71
71
  });
@@ -106,7 +106,7 @@ const showProjectCommand = {
106
106
  .example('$0 show project my-app', 'View project information for my-app in JSON format')
107
107
  .example('$0 show project my-app --web', 'View project information for my-app in the browser'),
108
108
  handler: async (args) => {
109
- const exitCode = await (0, params_1.handleErrors)(args.verbose, async () => {
109
+ const exitCode = await (0, handle_errors_1.handleErrors)(args.verbose, async () => {
110
110
  const { showProjectHandler } = await Promise.resolve().then(() => require('./project'));
111
111
  await showProjectHandler(args);
112
112
  });
@@ -5,11 +5,11 @@ const ora = require("ora");
5
5
  const nx_json_1 = require("../../config/nx-json");
6
6
  const project_graph_1 = require("../../project-graph/project-graph");
7
7
  const output_1 = require("../../utils/output");
8
- const params_1 = require("../../utils/params");
8
+ const handle_errors_1 = require("../../utils/handle-errors");
9
9
  const sync_generators_1 = require("../../utils/sync-generators");
10
10
  const chalk = require("chalk");
11
11
  function syncHandler(options) {
12
- return (0, params_1.handleErrors)(options.verbose, async () => {
12
+ return (0, handle_errors_1.handleErrors)(options.verbose, async () => {
13
13
  const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
14
14
  const nxJson = (0, nx_json_1.readNxJson)();
15
15
  const syncGenerators = await (0, sync_generators_1.collectAllRegisteredSyncGenerators)(projectGraph, nxJson);
@@ -32,24 +32,82 @@ function syncHandler(options) {
32
32
  });
33
33
  return 0;
34
34
  }
35
+ const { failedGeneratorsCount, areAllResultsFailures, anySyncGeneratorsFailed, } = (0, sync_generators_1.processSyncGeneratorResultErrors)(results);
36
+ const failedSyncGeneratorsFixMessageLines = (0, sync_generators_1.getFailedSyncGeneratorsFixMessageLines)(results, options.verbose);
37
+ if (areAllResultsFailures) {
38
+ output_1.output.error({
39
+ title: `The workspace is probably out of sync because ${failedGeneratorsCount === 1
40
+ ? 'a sync generator'
41
+ : 'some sync generators'} failed to run`,
42
+ bodyLines: failedSyncGeneratorsFixMessageLines,
43
+ });
44
+ return 1;
45
+ }
46
+ const resultBodyLines = (0, sync_generators_1.getSyncGeneratorSuccessResultsMessageLines)(results);
35
47
  if (options.check) {
36
48
  output_1.output.error({
37
- title: `The workspace is out of sync`,
38
- bodyLines: (0, sync_generators_1.syncGeneratorResultsToMessageLines)(results),
49
+ title: 'The workspace is out of sync',
50
+ bodyLines: resultBodyLines,
39
51
  });
52
+ if (anySyncGeneratorsFailed) {
53
+ output_1.output.error({
54
+ title: failedGeneratorsCount === 1
55
+ ? 'A sync generator failed to run'
56
+ : 'Some sync generators failed to run',
57
+ bodyLines: failedSyncGeneratorsFixMessageLines,
58
+ });
59
+ }
40
60
  return 1;
41
61
  }
42
62
  output_1.output.warn({
43
- title: `The workspace is out of sync`,
44
- bodyLines: (0, sync_generators_1.syncGeneratorResultsToMessageLines)(results),
63
+ title: 'The workspace is out of sync',
64
+ bodyLines: resultBodyLines,
45
65
  });
46
66
  const spinner = ora('Syncing the workspace...');
47
67
  spinner.start();
48
- await (0, sync_generators_1.flushSyncGeneratorChanges)(results);
49
- spinner.succeed(`The workspace was synced successfully!
50
-
51
- Please make sure to commit the changes to your repository.
52
- `);
68
+ try {
69
+ const flushResult = await (0, sync_generators_1.flushSyncGeneratorChanges)(results);
70
+ if ('generatorFailures' in flushResult) {
71
+ spinner.fail();
72
+ output_1.output.error({
73
+ title: 'Failed to sync the workspace',
74
+ bodyLines: (0, sync_generators_1.getFlushFailureMessageLines)(flushResult, options.verbose),
75
+ });
76
+ return 1;
77
+ }
78
+ }
79
+ catch (e) {
80
+ spinner.fail();
81
+ output_1.output.error({
82
+ title: 'Failed to sync the workspace',
83
+ bodyLines: [
84
+ 'Syncing the workspace failed with the following error:',
85
+ '',
86
+ e.message,
87
+ ...(options.verbose && !!e.stack ? [`\n${e.stack}`] : []),
88
+ '',
89
+ 'Please rerun with `--verbose` and report the error at: https://github.com/nrwl/nx/issues/new/choose',
90
+ ],
91
+ });
92
+ return 1;
93
+ }
94
+ const successTitle = anySyncGeneratorsFailed
95
+ ? // the identified changes were synced successfully, but the workspace
96
+ // is still not up to date, which we'll mention next
97
+ 'The identified changes were synced successfully!'
98
+ : // the workspace is fully up to date
99
+ 'The workspace was synced successfully!';
100
+ const successSubtitle = 'Please make sure to commit the changes to your repository.';
101
+ spinner.succeed(`${successTitle}\n\n${successSubtitle}`);
102
+ if (anySyncGeneratorsFailed) {
103
+ output_1.output.error({
104
+ title: `The workspace is probably still out of sync because ${failedGeneratorsCount === 1
105
+ ? 'a sync generator'
106
+ : 'some sync generators'} failed to run`,
107
+ bodyLines: failedSyncGeneratorsFixMessageLines,
108
+ });
109
+ return 1;
110
+ }
53
111
  return 0;
54
112
  });
55
113
  }
@@ -101,9 +101,9 @@ export interface NxReleaseGitConfiguration {
101
101
  */
102
102
  commitMessage?: string;
103
103
  /**
104
- * Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes
104
+ * Additional arguments (added after the --message argument, which may or may not be customized with --git-commit-message) to pass to the `git commit` command invoked behind the scenes. May be a string or array of strings.
105
105
  */
106
- commitArgs?: string;
106
+ commitArgs?: string | string[];
107
107
  /**
108
108
  * Whether or not to stage the changes made by this command. Always treated as true if commit is true.
109
109
  */
@@ -117,9 +117,9 @@ export interface NxReleaseGitConfiguration {
117
117
  */
118
118
  tagMessage?: string;
119
119
  /**
120
- * Additional arguments to pass to the `git tag` command invoked behind the scenes
120
+ * Additional arguments to pass to the `git tag` command invoked behind the scenes. . May be a string or array of strings.
121
121
  */
122
- tagArgs?: string;
122
+ tagArgs?: string | string[];
123
123
  }
124
124
  export interface NxReleaseConventionalCommitsConfiguration {
125
125
  types?: Record<string,
@@ -179,7 +179,15 @@ export interface NxReleaseConfiguration {
179
179
  *
180
180
  * NOTE: git configuration is not supported at the group level, only the root/command level
181
181
  */
182
- version?: NxReleaseVersionConfiguration;
182
+ version?: NxReleaseVersionConfiguration & {
183
+ /**
184
+ * A command to run after validation of nx release configuration, but before versioning begins.
185
+ * Used for preparing build artifacts. If --dry-run is passed, the command is still executed, but
186
+ * with the NX_DRY_RUN environment variable set to 'true'.
187
+ * It will run in addition to the global `preVersionCommand`
188
+ */
189
+ groupPreVersionCommand?: string;
190
+ };
183
191
  /**
184
192
  * Project changelogs are disabled by default.
185
193
  *
@@ -4,7 +4,7 @@ import { Hash } from '../../hasher/task-hasher';
4
4
  import { Task, TaskGraph } from '../../config/task-graph';
5
5
  import { ConfigurationSourceMaps } from '../../project-graph/utils/project-configuration-utils';
6
6
  import { NxWorkspaceFiles, TaskRun } from '../../native';
7
- import type { SyncGeneratorChangesResult } from '../../utils/sync-generators';
7
+ import type { FlushSyncGeneratorChangesResult, SyncGeneratorRunResult } from '../../utils/sync-generators';
8
8
  export type UnregisterCallback = () => void;
9
9
  export type ChangedFile = {
10
10
  path: string;
@@ -52,8 +52,8 @@ export declare class DaemonClient {
52
52
  hashGlob(globs: string[], exclude?: string[]): Promise<string>;
53
53
  getFlakyTasks(hashes: string[]): Promise<string[]>;
54
54
  recordTaskRuns(taskRuns: TaskRun[]): Promise<void>;
55
- getSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorChangesResult[]>;
56
- flushSyncGeneratorChangesToDisk(generators: string[]): Promise<void>;
55
+ getSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorRunResult[]>;
56
+ flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
57
57
  getRegisteredSyncGenerators(): Promise<string[]>;
58
58
  updateWorkspaceContext(createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
59
59
  isServerAvailable(): Promise<boolean>;
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleFlushSyncGeneratorChangesToDisk = handleFlushSyncGeneratorChangesToDisk;
4
4
  const sync_generators_1 = require("./sync-generators");
5
5
  async function handleFlushSyncGeneratorChangesToDisk(generators) {
6
- await (0, sync_generators_1.flushSyncGeneratorChangesToDisk)(generators);
6
+ const result = await (0, sync_generators_1.flushSyncGeneratorChangesToDisk)(generators);
7
7
  return {
8
- response: '{}',
8
+ response: JSON.stringify(result),
9
9
  description: 'handleFlushSyncGeneratorChangesToDisk',
10
10
  };
11
11
  }
@@ -4,12 +4,14 @@ exports.handleGetSyncGeneratorChanges = handleGetSyncGeneratorChanges;
4
4
  const sync_generators_1 = require("./sync-generators");
5
5
  async function handleGetSyncGeneratorChanges(generators) {
6
6
  const changes = await (0, sync_generators_1.getCachedSyncGeneratorChanges)(generators);
7
- // strip out the content of the changes and any potential callback
8
- const result = changes.map((change) => ({
9
- generatorName: change.generatorName,
10
- changes: change.changes.map((c) => ({ ...c, content: null })),
11
- outOfSyncMessage: change.outOfSyncMessage,
12
- }));
7
+ const result = changes.map((change) => 'error' in change
8
+ ? change
9
+ : // strip out the content of the changes and any potential callback
10
+ {
11
+ generatorName: change.generatorName,
12
+ changes: change.changes.map((c) => ({ ...c, content: null })),
13
+ outOfSyncMessage: change.outOfSyncMessage,
14
+ });
13
15
  return {
14
16
  response: JSON.stringify(result),
15
17
  description: 'handleGetSyncGeneratorChanges',
@@ -1,10 +1,10 @@
1
1
  import type { ProjectGraph } from '../../config/project-graph';
2
- import { type SyncGeneratorChangesResult } from '../../utils/sync-generators';
3
- export declare function getCachedSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorChangesResult[]>;
4
- export declare function flushSyncGeneratorChangesToDisk(generators: string[]): Promise<void>;
2
+ import { type FlushSyncGeneratorChangesResult, type SyncGeneratorRunResult } from '../../utils/sync-generators';
3
+ export declare function getCachedSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorRunResult[]>;
4
+ export declare function flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
5
5
  export declare function collectAndScheduleSyncGenerators(projectGraph: ProjectGraph): void;
6
6
  export declare function getCachedRegisteredSyncGenerators(): Promise<string[]>;
7
7
  /**
8
8
  * @internal
9
9
  */
10
- export declare function _getConflictingGeneratorGroups(results: SyncGeneratorChangesResult[]): string[][];
10
+ export declare function _getConflictingGeneratorGroups(results: SyncGeneratorRunResult[]): string[][];
@@ -59,7 +59,7 @@ async function flushSyncGeneratorChangesToDisk(generators) {
59
59
  for (const generator of generators) {
60
60
  syncGeneratorsCacheResultPromises.delete(generator);
61
61
  }
62
- await (0, sync_generators_1.flushSyncGeneratorChanges)(results);
62
+ return await (0, sync_generators_1.flushSyncGeneratorChanges)(results);
63
63
  }
64
64
  function collectAndScheduleSyncGenerators(projectGraph) {
65
65
  if (!projectGraph) {
@@ -191,6 +191,7 @@ async function processConflictingGenerators(conflicts, initialResults) {
191
191
  const conflictRunResults = (await Promise.all(conflicts.map((generators) => {
192
192
  const [firstGenerator, ...generatorsToRun] = generators;
193
193
  // it must exists because the conflicts were identified from the initial results
194
+ // and it's guaranteed to be a success result
194
195
  const firstGeneratorResult = initialResults.find((r) => r.generatorName === firstGenerator);
195
196
  const tree = new tree_1.FsTree(workspace_root_1.workspaceRoot, false, `running sync generators ${generators.join(',')}`);
196
197
  // pre-apply the changes from the first generator to avoid running it
@@ -234,6 +235,9 @@ async function processConflictingGenerators(conflicts, initialResults) {
234
235
  function _getConflictingGeneratorGroups(results) {
235
236
  const changedFileToGeneratorMap = new Map();
236
237
  for (const result of results) {
238
+ if ('error' in result) {
239
+ continue;
240
+ }
237
241
  for (const change of result.changes) {
238
242
  if (!changedFileToGeneratorMap.has(change.path)) {
239
243
  changedFileToGeneratorMap.set(change.path, new Set());
@@ -318,7 +322,12 @@ function runGenerator(generator, projects, tree) {
318
322
  scheduledGenerators.delete(generator);
319
323
  tree ??= new tree_1.FsTree(workspace_root_1.workspaceRoot, false, `running sync generator ${generator}`);
320
324
  return (0, sync_generators_1.runSyncGenerator)(tree, generator, projects).then((result) => {
321
- log(generator, 'changes:', result.changes.map((c) => c.path).join(', '));
325
+ if ('error' in result) {
326
+ log(generator, 'error:', result.error.message);
327
+ }
328
+ else {
329
+ log(generator, 'changes:', result.changes.map((c) => c.path).join(', '));
330
+ }
322
331
  return result;
323
332
  });
324
333
  }
@@ -11,7 +11,7 @@ const db_connection_1 = require("../utils/db-connection");
11
11
  let taskDetails;
12
12
  function getTaskDetails() {
13
13
  // TODO: Remove when wasm supports sqlite
14
- if (native_1.IS_WASM) {
14
+ if (process.env.NX_DISABLE_DB === 'true' || native_1.IS_WASM) {
15
15
  return null;
16
16
  }
17
17
  if (!taskDetails) {
@@ -42,7 +42,7 @@ async function hashTasksThatDoNotDependOnOutputsOfOtherTasks(hasher, projectGrap
42
42
  tasksToHash[i].hash = hashes[i].value;
43
43
  tasksToHash[i].hashDetails = hashes[i].details;
44
44
  }
45
- // TODO: Remove if when wasm supports sqlite
45
+ // TODO: Remove if when sqlite is always on
46
46
  if (taskDetails) {
47
47
  taskDetails.recordTaskDetails(tasksToHash.map((task) => ({
48
48
  hash: task.hash,