nx 20.0.0-beta.5 → 20.0.0-beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/.eslintrc.json +12 -2
  2. package/migrations.json +0 -37
  3. package/package.json +11 -11
  4. package/src/command-line/release/index.d.ts +5 -2
  5. package/src/command-line/release/publish.d.ts +6 -1
  6. package/src/command-line/release/publish.js +31 -25
  7. package/src/command-line/release/utils/print-changes.js +6 -4
  8. package/src/command-line/release/utils/resolve-nx-json-error-message.js +4 -3
  9. package/src/command-line/release/version.d.ts +3 -3
  10. package/src/config/workspace-json-project-json.d.ts +14 -0
  11. package/src/core/graph/main.js +1 -1
  12. package/src/native/nx.wasm32-wasi.wasm +0 -0
  13. package/src/nx-cloud/utilities/axios.js +1 -2
  14. package/src/nx-cloud/utilities/onboarding.js +2 -2
  15. package/src/nx-cloud/utilities/url-shorten.js +5 -5
  16. package/src/project-graph/file-utils.d.ts +2 -2
  17. package/src/project-graph/file-utils.js +2 -2
  18. package/src/tasks-runner/cache.d.ts +1 -2
  19. package/src/tasks-runner/cache.js +4 -4
  20. package/src/tasks-runner/create-task-graph.d.ts +2 -0
  21. package/src/tasks-runner/create-task-graph.js +35 -1
  22. package/src/tasks-runner/task-orchestrator.js +1 -1
  23. package/src/utils/git-utils.js +2 -2
  24. package/src/migrations/update-15-0-0/prefix-outputs.d.ts +0 -2
  25. package/src/migrations/update-15-0-0/prefix-outputs.js +0 -49
  26. package/src/migrations/update-16-0-0/remove-nrwl-cli.d.ts +0 -2
  27. package/src/migrations/update-16-0-0/remove-nrwl-cli.js +0 -16
  28. package/src/migrations/update-16-0-0/update-depends-on-to-tokens.d.ts +0 -2
  29. package/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +0 -97
  30. package/src/migrations/update-16-0-0/update-nx-cloud-runner.d.ts +0 -2
  31. package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +0 -29
  32. package/src/migrations/update-16-2-0/remove-run-commands-output-path.d.ts +0 -2
  33. package/src/migrations/update-16-2-0/remove-run-commands-output-path.js +0 -45
  34. package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.d.ts +0 -12
  35. package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +0 -67
package/.eslintrc.json CHANGED
@@ -9,8 +9,18 @@
9
9
  "no-restricted-imports": [
10
10
  "error",
11
11
  {
12
- "name": "fs-extra",
13
- "message": "Please use equivalent utilities from `node:fs` instead."
12
+ "paths": [
13
+ {
14
+ "name": "fs-extra",
15
+ "message": "Please use equivalent utilities from `node:fs` instead."
16
+ }
17
+ ],
18
+ "patterns": [
19
+ {
20
+ "group": ["**/devkit-exports"],
21
+ "message": "Do not import from devkit-exports from the nx package"
22
+ }
23
+ ]
14
24
  }
15
25
  ]
16
26
  }
package/migrations.json CHANGED
@@ -1,42 +1,5 @@
1
1
  {
2
2
  "generators": {
3
- "16.0.0-remove-nrwl-cli": {
4
- "cli": "nx",
5
- "version": "16.0.0-beta.0",
6
- "description": "Remove @nrwl/cli.",
7
- "implementation": "./src/migrations/update-16-0-0/remove-nrwl-cli"
8
- },
9
- "16.0.0-tokens-for-depends-on": {
10
- "cli": "nx",
11
- "version": "16.0.0-beta.9",
12
- "description": "Replace `dependsOn.projects` and `inputs` definitions with new configuration format.",
13
- "implementation": "./src/migrations/update-16-0-0/update-depends-on-to-tokens"
14
- },
15
- "16.0.0-update-nx-cloud-runner": {
16
- "cli": "nx",
17
- "version": "16.0.0-beta.0",
18
- "description": "Replace @nrwl/nx-cloud with nx-cloud",
19
- "implementation": "./src/migrations/update-16-0-0/update-nx-cloud-runner"
20
- },
21
- "16.2.0-remove-output-path-from-run-commands": {
22
- "cli": "nx",
23
- "version": "16.2.0-beta.0",
24
- "description": "Remove outputPath from run commands",
25
- "implementation": "./src/migrations/update-16-2-0/remove-run-commands-output-path"
26
- },
27
- "16.6.0-prefix-outputs": {
28
- "cli": "nx",
29
- "version": "16.6.0-beta.6",
30
- "description": "Prefix outputs with {workspaceRoot}/{projectRoot} if needed",
31
- "implementation": "./src/migrations/update-15-0-0/prefix-outputs"
32
- },
33
- "16.8.0-escape-dollar-sign-env": {
34
- "cli": "nx",
35
- "version": "16.8.0-beta.3",
36
- "description": "Escape $ in env variables",
37
- "implementation": "./src/migrations/update-16-8-0/escape-dollar-sign-env-variables",
38
- "x-repair-skip": true
39
- },
40
3
  "17.0.0-move-cache-directory": {
41
4
  "cli": "nx",
42
5
  "version": "17.0.0-beta.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "20.0.0-beta.5",
3
+ "version": "20.0.0-beta.6",
4
4
  "private": false,
5
5
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
6
6
  "repository": {
@@ -80,16 +80,16 @@
80
80
  }
81
81
  },
82
82
  "optionalDependencies": {
83
- "@nx/nx-darwin-x64": "20.0.0-beta.5",
84
- "@nx/nx-darwin-arm64": "20.0.0-beta.5",
85
- "@nx/nx-linux-x64-gnu": "20.0.0-beta.5",
86
- "@nx/nx-linux-x64-musl": "20.0.0-beta.5",
87
- "@nx/nx-win32-x64-msvc": "20.0.0-beta.5",
88
- "@nx/nx-linux-arm64-gnu": "20.0.0-beta.5",
89
- "@nx/nx-linux-arm64-musl": "20.0.0-beta.5",
90
- "@nx/nx-linux-arm-gnueabihf": "20.0.0-beta.5",
91
- "@nx/nx-win32-arm64-msvc": "20.0.0-beta.5",
92
- "@nx/nx-freebsd-x64": "20.0.0-beta.5"
83
+ "@nx/nx-darwin-x64": "20.0.0-beta.6",
84
+ "@nx/nx-darwin-arm64": "20.0.0-beta.6",
85
+ "@nx/nx-linux-x64-gnu": "20.0.0-beta.6",
86
+ "@nx/nx-linux-x64-musl": "20.0.0-beta.6",
87
+ "@nx/nx-win32-x64-msvc": "20.0.0-beta.6",
88
+ "@nx/nx-linux-arm64-gnu": "20.0.0-beta.6",
89
+ "@nx/nx-linux-arm64-musl": "20.0.0-beta.6",
90
+ "@nx/nx-linux-arm-gnueabihf": "20.0.0-beta.6",
91
+ "@nx/nx-win32-arm64-msvc": "20.0.0-beta.6",
92
+ "@nx/nx-freebsd-x64": "20.0.0-beta.6"
93
93
  },
94
94
  "nx-migrations": {
95
95
  "migrations": "./migrations.json",
@@ -5,7 +5,7 @@ import type { NxReleaseConfiguration } from '../../config/nx-json';
5
5
  export declare class ReleaseClient {
6
6
  private overrideReleaseConfig;
7
7
  releaseChangelog: (args: import("./command-object").ChangelogOptions) => Promise<import("./changelog").NxReleaseChangelogResult>;
8
- releasePublish: (args: import("./command-object").PublishOptions, isCLI?: boolean) => Promise<number>;
8
+ releasePublish: (args: import("./command-object").PublishOptions) => Promise<import("./publish").PublishProjectsResult>;
9
9
  releaseVersion: (args: import("./command-object").VersionOptions) => Promise<import("./version").NxReleaseVersionResult>;
10
10
  release: (args: import("./command-object").ReleaseOptions) => Promise<import("./version").NxReleaseVersionResult | number>;
11
11
  constructor(overrideReleaseConfig: NxReleaseConfiguration);
@@ -15,6 +15,10 @@ declare const defaultClient: ReleaseClient;
15
15
  * @public
16
16
  */
17
17
  export declare const releaseChangelog: typeof defaultClient.releaseChangelog;
18
+ /**
19
+ * @public
20
+ */
21
+ export { PublishProjectsResult } from './publish';
18
22
  /**
19
23
  * @public
20
24
  */
@@ -27,4 +31,3 @@ export declare const releaseVersion: typeof defaultClient.releaseVersion;
27
31
  * @public
28
32
  */
29
33
  export declare const release: typeof defaultClient.release;
30
- export {};
@@ -1,4 +1,9 @@
1
1
  import { NxReleaseConfiguration } from '../../config/nx-json';
2
2
  import { PublishOptions } from './command-object';
3
+ export interface PublishProjectsResult {
4
+ [projectName: string]: {
5
+ code: number;
6
+ };
7
+ }
3
8
  export declare const releasePublishCLIHandler: (args: PublishOptions) => Promise<number>;
4
- export declare function createAPI(overrideReleaseConfig: NxReleaseConfiguration): (args: PublishOptions, isCLI?: boolean) => Promise<number>;
9
+ export declare function createAPI(overrideReleaseConfig: NxReleaseConfiguration): (args: PublishOptions) => Promise<PublishProjectsResult>;
@@ -7,15 +7,21 @@ const file_map_utils_1 = require("../../project-graph/file-map-utils");
7
7
  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
- const output_1 = require("../../utils/output");
11
10
  const handle_errors_1 = require("../../utils/handle-errors");
11
+ const output_1 = require("../../utils/output");
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, handle_errors_1.handleErrors)(args.verbose, () => createAPI({})(args, true));
18
+ const releasePublishCLIHandler = (args) => (0, handle_errors_1.handleErrors)(args.verbose, async () => {
19
+ const publishProjectsResult = await createAPI({})(args);
20
+ // If all projects are published successfully, return 0, otherwise return 1
21
+ return Object.values(publishProjectsResult).every((result) => result.code === 0)
22
+ ? 0
23
+ : 1;
24
+ });
19
25
  exports.releasePublishCLIHandler = releasePublishCLIHandler;
20
26
  function createAPI(overrideReleaseConfig) {
21
27
  /**
@@ -23,7 +29,7 @@ function createAPI(overrideReleaseConfig) {
23
29
  * of Nx. We intentionally do not wrap the implementation with handleErrors because users need
24
30
  * to have control over their own error handling when using the API.
25
31
  */
26
- return async function releasePublish(args, isCLI = false) {
32
+ return async function releasePublish(args) {
27
33
  /**
28
34
  * When used via the CLI, the args object will contain a __overrides_unparsed__ property that is
29
35
  * important for invoking the relevant executor behind the scenes.
@@ -60,38 +66,40 @@ function createAPI(overrideReleaseConfig) {
60
66
  const shouldExcludeTaskDependencies = _args.projects?.length > 0 ||
61
67
  _args.groups?.length > 0 ||
62
68
  args.excludeTaskDependencies;
63
- let overallExitStatus = 0;
69
+ let overallPublishProjectsResult = {};
64
70
  if (args.projects?.length) {
65
71
  /**
66
72
  * Run publishing for all remaining release groups and filtered projects within them
67
73
  */
68
74
  for (const releaseGroup of releaseGroups) {
69
- const status = await runPublishOnProjects(_args, projectGraph, nxJson, Array.from(releaseGroupToFilteredProjects.get(releaseGroup)), isCLI, {
75
+ const publishProjectsResult = await runPublishOnProjects(_args, projectGraph, nxJson, Array.from(releaseGroupToFilteredProjects.get(releaseGroup)), {
70
76
  excludeTaskDependencies: shouldExcludeTaskDependencies,
71
77
  loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
72
78
  });
73
- if (status !== 0) {
74
- overallExitStatus = status || 1;
75
- }
79
+ overallPublishProjectsResult = {
80
+ ...overallPublishProjectsResult,
81
+ ...publishProjectsResult,
82
+ };
76
83
  }
77
- return overallExitStatus;
84
+ return overallPublishProjectsResult;
78
85
  }
79
86
  /**
80
87
  * Run publishing for all remaining release groups
81
88
  */
82
89
  for (const releaseGroup of releaseGroups) {
83
- const status = await runPublishOnProjects(_args, projectGraph, nxJson, releaseGroup.projects, isCLI, {
90
+ const publishProjectsResult = await runPublishOnProjects(_args, projectGraph, nxJson, releaseGroup.projects, {
84
91
  excludeTaskDependencies: shouldExcludeTaskDependencies,
85
92
  loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
86
93
  });
87
- if (status !== 0) {
88
- overallExitStatus = status || 1;
89
- }
94
+ overallPublishProjectsResult = {
95
+ ...overallPublishProjectsResult,
96
+ ...publishProjectsResult,
97
+ };
90
98
  }
91
- return overallExitStatus;
99
+ return overallPublishProjectsResult;
92
100
  };
93
101
  }
94
- async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, isCLI, extraOptions) {
102
+ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, extraOptions) {
95
103
  const projectsToRun = projectNames.map((projectName) => projectGraph.nodes[projectName]);
96
104
  const overrides = (0, command_line_utils_1.createOverrides)(args.__overrides_unparsed__);
97
105
  if (args.registry) {
@@ -132,7 +140,7 @@ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, is
132
140
  projects: projectNamesWithTarget,
133
141
  file,
134
142
  }, projectNamesWithTarget);
135
- return 0;
143
+ return {};
136
144
  }
137
145
  const projectsWithTarget = projectsToRun.filter((project) => (0, project_graph_utils_1.projectHasTarget)(project, requiredTargetName));
138
146
  if (projectsWithTarget.length === 0) {
@@ -145,20 +153,18 @@ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, is
145
153
  /**
146
154
  * Run the relevant nx-release-publish executor on each of the selected projects.
147
155
  */
148
- const status = await (0, run_command_1.runCommand)(projectsWithTarget, projectGraph, { nxJson }, {
156
+ const commandResults = await (0, run_command_1.runCommandForTasks)(projectsWithTarget, projectGraph, { nxJson }, {
149
157
  targets: [requiredTargetName],
150
158
  outputStyle: 'static',
151
159
  ...args,
152
160
  // It is possible for workspaces to have circular dependencies between packages and still release them to a registry
153
161
  nxIgnoreCycles: true,
154
162
  }, overrides, null, {}, extraOptions);
155
- if (status !== 0) {
156
- // In order to not add noise to the overall CLI output, do not throw an additional error
157
- if (isCLI) {
158
- return status;
159
- }
160
- // Throw an additional error for programmatic API usage
161
- throw new Error('One or more of the selected projects could not be published');
163
+ const publishProjectsResult = {};
164
+ for (const taskData of Object.values(commandResults)) {
165
+ publishProjectsResult[taskData.task.target.project] = {
166
+ code: taskData.code,
167
+ };
162
168
  }
163
- return 0;
169
+ return publishProjectsResult;
164
170
  }
@@ -5,8 +5,10 @@ exports.printAndFlushChanges = printAndFlushChanges;
5
5
  const chalk = require("chalk");
6
6
  const jest_diff_1 = require("jest-diff");
7
7
  const node_fs_1 = require("node:fs");
8
- const devkit_exports_1 = require("../../../devkit-exports");
9
8
  const tree_1 = require("../../../generators/tree");
9
+ const workspace_root_1 = require("../../../utils/workspace-root");
10
+ const path_1 = require("../../../utils/path");
11
+ const logger_1 = require("../../../utils/logger");
10
12
  // jest-diff does not export this constant
11
13
  const NO_DIFF_MESSAGE = 'Compared values have no visual difference.';
12
14
  function printDiff(before, after, contextLines = 1, noDiffMessage = NO_DIFF_MESSAGE) {
@@ -43,7 +45,7 @@ function printAndFlushChanges(tree, isDryRun, diffContextLines = 1, shouldPrintD
43
45
  }
44
46
  else if (f.type === 'UPDATE') {
45
47
  console.error(`${chalk.white('UPDATE')} ${f.path}${isDryRun ? chalk.keyword('orange')(' [dry-run]') : ''}`);
46
- const currentContentsOnDisk = (0, node_fs_1.readFileSync)((0, devkit_exports_1.joinPathFragments)(tree.root, f.path)).toString();
48
+ const currentContentsOnDisk = (0, node_fs_1.readFileSync)((0, path_1.joinPathFragments)(tree.root, f.path)).toString();
47
49
  printDiff(currentContentsOnDisk, f.content?.toString() || '', diffContextLines, noDiffMessage);
48
50
  }
49
51
  else if (f.type === 'DELETE') {
@@ -51,9 +53,9 @@ function printAndFlushChanges(tree, isDryRun, diffContextLines = 1, shouldPrintD
51
53
  }
52
54
  });
53
55
  if (!isDryRun) {
54
- (0, tree_1.flushChanges)(devkit_exports_1.workspaceRoot, changes);
56
+ (0, tree_1.flushChanges)(workspace_root_1.workspaceRoot, changes);
55
57
  }
56
58
  if (isDryRun && shouldPrintDryRunMessage) {
57
- devkit_exports_1.logger.warn(`\nNOTE: The "dryRun" flag means no changes were made.`);
59
+ logger_1.logger.warn(`\nNOTE: The "dryRun" flag means no changes were made.`);
58
60
  }
59
61
  }
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveNxJsonConfigErrorMessage = resolveNxJsonConfigErrorMessage;
4
4
  const node_fs_1 = require("node:fs");
5
5
  const node_path_1 = require("node:path");
6
- const devkit_exports_1 = require("../../../devkit-exports");
6
+ const path_1 = require("../../../utils/path");
7
+ const workspace_root_1 = require("../../../utils/workspace-root");
7
8
  async function resolveNxJsonConfigErrorMessage(propPath) {
8
- const errorLines = await getJsonConfigLinesForErrorMessage((0, node_fs_1.readFileSync)((0, devkit_exports_1.joinPathFragments)(devkit_exports_1.workspaceRoot, 'nx.json'), 'utf-8'), propPath);
9
- let nxJsonMessage = `The relevant config is defined here: ${(0, node_path_1.relative)(process.cwd(), (0, devkit_exports_1.joinPathFragments)(devkit_exports_1.workspaceRoot, 'nx.json'))}`;
9
+ const errorLines = await getJsonConfigLinesForErrorMessage((0, node_fs_1.readFileSync)((0, path_1.joinPathFragments)(workspace_root_1.workspaceRoot, 'nx.json'), 'utf-8'), propPath);
10
+ let nxJsonMessage = `The relevant config is defined here: ${(0, node_path_1.relative)(process.cwd(), (0, path_1.joinPathFragments)(workspace_root_1.workspaceRoot, 'nx.json'))}`;
10
11
  if (errorLines) {
11
12
  nxJsonMessage +=
12
13
  errorLines.startLine === errorLines.endLine
@@ -26,10 +26,10 @@ export interface ReleaseVersionGeneratorSchema {
26
26
  conventionalCommitsConfig?: NxReleaseConfig['conventionalCommits'];
27
27
  deleteVersionPlans?: boolean;
28
28
  /**
29
- * 'auto' allows users to opt into dependents being updated (a patch version bump) when a dependency is versioned.
30
- * This is only applicable to independently released projects.
29
+ * 'auto' is the default and will cause dependents to be updated (a patch version bump) when a dependency is versioned.
30
+ * This is only applicable to independently released projects. 'never' will cause dependents to not be updated.
31
31
  */
32
- updateDependents?: 'never' | 'auto';
32
+ updateDependents?: 'auto' | 'never';
33
33
  /**
34
34
  * Whether or not to completely omit project logs when that project has no applicable changes. This can be useful for
35
35
  * large monorepos which have a large number of projects, especially when only a subset are released together.
@@ -108,6 +108,20 @@ export interface ProjectMetadata {
108
108
  description?: string;
109
109
  technologies?: string[];
110
110
  targetGroups?: Record<string, string[]>;
111
+ owners?: {
112
+ [ownerId: string]: {
113
+ ownedFiles: {
114
+ files: ['*'] | string[];
115
+ fromConfig?: {
116
+ filePath: string;
117
+ location: {
118
+ startLine: number;
119
+ endLine: number;
120
+ };
121
+ };
122
+ }[];
123
+ };
124
+ };
111
125
  }
112
126
  export interface TargetMetadata {
113
127
  [k: string]: any;