nx 21.0.0-beta.8 → 21.0.0-beta.9

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 (43) hide show
  1. package/migrations.json +5 -35
  2. package/package.json +11 -11
  3. package/schemas/nx-schema.json +34 -38
  4. package/src/command-line/migrate/migrate-ui-api.d.ts +2 -0
  5. package/src/command-line/migrate/migrate-ui-api.js +39 -0
  6. package/src/command-line/migrate/migrate.d.ts +0 -4
  7. package/src/command-line/migrate/migrate.js +8 -21
  8. package/src/command-line/release/command-object.d.ts +6 -0
  9. package/src/command-line/release/config/config.js +15 -8
  10. package/src/command-line/release/config/use-legacy-versioning.js +4 -4
  11. package/src/command-line/release/version/release-group-processor.d.ts +10 -9
  12. package/src/command-line/release/version/release-group-processor.js +25 -8
  13. package/src/command-line/release/version/test-utils.d.ts +2 -4
  14. package/src/command-line/release/version/test-utils.js +13 -14
  15. package/src/command-line/release/version/version-actions.d.ts +9 -8
  16. package/src/command-line/release/version/version-actions.js +21 -9
  17. package/src/command-line/release/version.js +6 -2
  18. package/src/command-line/repair/repair.js +0 -1
  19. package/src/config/misc-interfaces.d.ts +0 -1
  20. package/src/config/nx-json.d.ts +15 -9
  21. package/src/config/workspace-json-project-json.d.ts +2 -2
  22. package/src/core/graph/main.js +1 -1
  23. package/src/migrations/{update-17-0-0/rm-default-collection-npm-scope.d.ts → update-21-0-0/release-version-config-changes.d.ts} +1 -1
  24. package/src/migrations/update-21-0-0/release-version-config-changes.js +111 -0
  25. package/src/native/index.d.ts +2 -0
  26. package/src/native/native-bindings.js +1 -0
  27. package/src/native/nx.wasm32-wasi.wasm +0 -0
  28. package/src/plugins/js/lock-file/utils/package-json.js +6 -5
  29. package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
  30. package/src/project-graph/file-utils.d.ts +1 -10
  31. package/src/project-graph/file-utils.js +2 -77
  32. package/src/tasks-runner/task-orchestrator.js +3 -0
  33. package/src/migrations/update-17-0-0/move-cache-directory.d.ts +0 -2
  34. package/src/migrations/update-17-0-0/move-cache-directory.js +0 -35
  35. package/src/migrations/update-17-0-0/rm-default-collection-npm-scope.js +0 -72
  36. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.d.ts +0 -2
  37. package/src/migrations/update-17-0-0/use-minimal-config-for-tasks-runner-options.js +0 -122
  38. package/src/migrations/update-17-2-0/move-default-base.d.ts +0 -5
  39. package/src/migrations/update-17-2-0/move-default-base.js +0 -21
  40. package/src/migrations/update-17-3-0/nx-release-path.d.ts +0 -3
  41. package/src/migrations/update-17-3-0/nx-release-path.js +0 -47
  42. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +0 -2
  43. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +0 -11
@@ -1,5 +1,5 @@
1
1
  import { ReleaseType } from 'semver';
2
- import { NxReleaseVersionV2Configuration } from '../../../config/nx-json';
2
+ import { NxReleaseVersionConfiguration } from '../../../config/nx-json';
3
3
  import type { ProjectGraph, ProjectGraphDependency, ProjectGraphProjectNode } from '../../../config/project-graph';
4
4
  import type { Tree } from '../../../generators/tree';
5
5
  import { ReleaseGroupWithName } from '../config/filter-release-groups';
@@ -49,8 +49,14 @@ export declare abstract class VersionActions {
49
49
  * The interpolated manifest paths to update, if applicable based on the user's configuration, when new
50
50
  * versions and dependencies are determined. If no manifest files should be updated based on the user's
51
51
  * configuration, this will be an empty array.
52
+ *
53
+ * The final value for preserveLocalDependencyProtocols will be based on the resolved config for the current
54
+ * project and any overrides from the user's configuration for the manifestRootsToUpdate.
52
55
  */
53
- manifestsToUpdate: string[];
56
+ manifestsToUpdate: {
57
+ manifestPath: string;
58
+ preserveLocalDependencyProtocols: boolean;
59
+ }[];
54
60
  constructor(releaseGroup: ReleaseGroupWithName, projectGraphNode: ProjectGraphProjectNode, finalConfigForProject: FinalConfigForProject);
55
61
  /**
56
62
  * Asynchronous initialization of the version actions and validation of certain configuration options.
@@ -106,7 +112,7 @@ export declare abstract class VersionActions {
106
112
  * NOTE: The version actions implementation does not need to provide the method for handling resolution
107
113
  * from git tags, this is done directly by nx release.
108
114
  */
109
- abstract readCurrentVersionFromRegistry(tree: Tree, currentVersionResolverMetadata: NxReleaseVersionV2Configuration['currentVersionResolverMetadata']): Promise<{
115
+ abstract readCurrentVersionFromRegistry(tree: Tree, currentVersionResolverMetadata: NxReleaseVersionConfiguration['currentVersionResolverMetadata']): Promise<{
110
116
  currentVersion: string | null;
111
117
  logText: string;
112
118
  } | null>;
@@ -138,11 +144,6 @@ export declare abstract class VersionActions {
138
144
  currentVersion: string | null;
139
145
  dependencyCollection: string | null;
140
146
  }>;
141
- /**
142
- * Implementation details of determining if a version specifier uses a local dependency protocol that is relevant to this
143
- * specific project. E.g. in a package.json context, `file:` and `workspace:` protocols should return true here.
144
- */
145
- abstract isLocalDependencyProtocol(versionSpecifier: string): Promise<boolean>;
146
147
  /**
147
148
  * Implementation details of updating a newly derived version in some source of truth.
148
149
  *
@@ -92,6 +92,9 @@ class VersionActions {
92
92
  * The interpolated manifest paths to update, if applicable based on the user's configuration, when new
93
93
  * versions and dependencies are determined. If no manifest files should be updated based on the user's
94
94
  * configuration, this will be an empty array.
95
+ *
96
+ * The final value for preserveLocalDependencyProtocols will be based on the resolved config for the current
97
+ * project and any overrides from the user's configuration for the manifestRootsToUpdate.
95
98
  */
96
99
  this.manifestsToUpdate = [];
97
100
  }
@@ -104,31 +107,40 @@ class VersionActions {
104
107
  this.finalConfigForProject.manifestRootsToUpdate.length === 0) {
105
108
  for (const manifestFilename of this.validManifestFilenames) {
106
109
  if (tree.exists((0, node_path_1.join)(this.projectGraphNode.data.root, manifestFilename))) {
107
- this.finalConfigForProject.manifestRootsToUpdate.push(this.projectGraphNode.data.root);
110
+ this.finalConfigForProject.manifestRootsToUpdate.push({
111
+ path: this.projectGraphNode.data.root,
112
+ preserveLocalDependencyProtocols: this.finalConfigForProject.preserveLocalDependencyProtocols,
113
+ });
108
114
  break;
109
115
  }
110
116
  }
111
117
  }
112
118
  const interpolatedManifestRoots = this.finalConfigForProject.manifestRootsToUpdate.map((manifestRoot) => {
113
- return (0, utils_1.interpolate)(manifestRoot, {
114
- workspaceRoot: '',
115
- projectRoot: this.projectGraphNode.data.root,
116
- projectName: this.projectGraphNode.name,
117
- });
119
+ return {
120
+ ...manifestRoot,
121
+ path: (0, utils_1.interpolate)(manifestRoot.path, {
122
+ workspaceRoot: '',
123
+ projectRoot: this.projectGraphNode.data.root,
124
+ projectName: this.projectGraphNode.name,
125
+ }),
126
+ };
118
127
  });
119
128
  for (const interpolatedManifestRoot of interpolatedManifestRoots) {
120
129
  let hasValidManifest = false;
121
130
  for (const manifestFilename of this.validManifestFilenames) {
122
- const manifestPath = (0, node_path_1.join)(interpolatedManifestRoot, manifestFilename);
131
+ const manifestPath = (0, node_path_1.join)(interpolatedManifestRoot.path, manifestFilename);
123
132
  if (tree.exists(manifestPath)) {
124
- this.manifestsToUpdate.push(manifestPath);
133
+ this.manifestsToUpdate.push({
134
+ ...interpolatedManifestRoot,
135
+ manifestPath,
136
+ });
125
137
  hasValidManifest = true;
126
138
  break;
127
139
  }
128
140
  }
129
141
  if (!hasValidManifest) {
130
142
  const validManifestFilenames = this.validManifestFilenames?.join(' or ');
131
- throw new Error(`The project "${this.projectGraphNode.name}" does not have a ${validManifestFilenames} file available in ./${interpolatedManifestRoot}.
143
+ throw new Error(`The project "${this.projectGraphNode.name}" does not have a ${validManifestFilenames} file available in ./${interpolatedManifestRoot.path}.
132
144
 
133
145
  To fix this you will either need to add a ${validManifestFilenames} file at that location, or configure "release" within your nx.json to exclude "${this.projectGraphNode.name}" from the current release group, or amend the "release.version.manifestRootsToUpdate" configuration to point to where the relevant manifest should be.`);
134
146
  }
@@ -133,6 +133,7 @@ function createAPI(overrideReleaseConfig) {
133
133
  projects: args.projects,
134
134
  groups: args.groups,
135
135
  },
136
+ versionActionsOptionsOverrides: args.versionActionsOptionsOverrides,
136
137
  });
137
138
  try {
138
139
  await processor.init();
@@ -160,8 +161,11 @@ function createAPI(overrideReleaseConfig) {
160
161
  : [];
161
162
  (0, shared_1.handleDuplicateGitTags)(gitTagValues);
162
163
  printAndFlushChanges(tree, !!args.dryRun);
163
- const { changedFiles: changed, deletedFiles: deleted } = await processor.afterAllProjectsVersioned(nxReleaseConfig.version
164
- .versionActionsOptions);
164
+ const { changedFiles: changed, deletedFiles: deleted } = await processor.afterAllProjectsVersioned({
165
+ ...nxReleaseConfig.version
166
+ .versionActionsOptions,
167
+ ...(args.versionActionsOptionsOverrides ?? {}),
168
+ });
165
169
  changed.forEach((f) => additionalChangedFiles.add(f));
166
170
  deleted.forEach((f) => additionalDeletedFiles.add(f));
167
171
  // Only applicable when there is a single release group with a fixed relationship
@@ -12,7 +12,6 @@ async function repair(args, extraMigrations = []) {
12
12
  if (!skip) {
13
13
  agg.push({
14
14
  package: 'nx',
15
- cli: 'nx',
16
15
  name,
17
16
  description: migration.description,
18
17
  version: migration.version,
@@ -53,7 +53,6 @@ export type PackageJsonUpdates = {
53
53
  export interface MigrationsJsonEntry {
54
54
  version: string;
55
55
  description?: string;
56
- cli?: string;
57
56
  implementation?: string;
58
57
  factory?: string;
59
58
  requires?: Record<string, string>;
@@ -37,12 +37,12 @@ interface NxInstallationConfiguration {
37
37
  plugins?: Record<string, string>;
38
38
  }
39
39
  /**
40
- * This named configuration interface will be changing in Nx v21. This interface will be made available
41
- * under LegacyNxReleaseVersionConfiguration, which is already available as an alias.
40
+ * This named configuration interface represents the options prior to Nx v21. This interface will be made available
41
+ * under LegacyNxReleaseVersionConfiguration throughout the lifetime of Nx v21.
42
42
  *
43
43
  * In Nx v22, this configuration interface will no longer be valid.
44
44
  */
45
- export interface NxReleaseVersionConfiguration {
45
+ export interface LegacyNxReleaseVersionConfiguration {
46
46
  generator?: string;
47
47
  generatorOptions?: Record<string, unknown>;
48
48
  /**
@@ -57,10 +57,13 @@ export interface NxReleaseVersionConfiguration {
57
57
  */
58
58
  conventionalCommits?: boolean;
59
59
  }
60
- export type LegacyNxReleaseVersionConfiguration = NxReleaseVersionConfiguration;
61
- export interface NxReleaseVersionV2Configuration {
60
+ export type ManifestRootToUpdate = string | {
61
+ path: string;
62
+ preserveLocalDependencyProtocols: boolean;
63
+ };
64
+ export interface NxReleaseVersionConfiguration {
62
65
  /**
63
- * Whether to use the legacy versioning strategy. This value will be true in Nx v20 and false in Nx v21.
66
+ * Whether to use the legacy versioning strategy. This value was true in Nx v20 and became false in Nx v21.
64
67
  * The legacy versioning implementation will be removed in Nx v22, as will this flag.
65
68
  */
66
69
  useLegacyVersioning?: boolean;
@@ -88,8 +91,11 @@ export interface NxReleaseVersionV2Configuration {
88
91
  *
89
92
  * By default, only the project root will be used, but you could customize this to only version a manifest in a
90
93
  * dist directory, or even version multiple manifests in different directories, such as both source and dist.
94
+ *
95
+ * For more advanced scenarios, the preserveLocalDependencyProtocols can be overridden per manifest by providing
96
+ * and object instead of a string.
91
97
  */
92
- manifestRootsToUpdate?: string[];
98
+ manifestRootsToUpdate?: ManifestRootToUpdate[];
93
99
  /**
94
100
  * The resolver to use for determining the current version of a project during versioning.
95
101
  * This is needed for versioning approaches which involve relatively modifying a current version
@@ -295,7 +301,7 @@ export interface NxReleaseConfiguration {
295
301
  *
296
302
  * NOTE: git configuration is not supported at the group level, only the root/command level
297
303
  */
298
- version?: (LegacyNxReleaseVersionConfiguration | NxReleaseVersionV2Configuration) & {
304
+ version?: (LegacyNxReleaseVersionConfiguration | NxReleaseVersionConfiguration) & {
299
305
  /**
300
306
  * A command to run after validation of nx release configuration, but before versioning begins.
301
307
  * Used for preparing build artifacts. If --dry-run is passed, the command is still executed, but
@@ -372,7 +378,7 @@ export interface NxReleaseConfiguration {
372
378
  * If no version configuration is provided, we will assume that TypeScript/JavaScript experience is what is desired,
373
379
  * allowing for terser release configuration for the common case.
374
380
  */
375
- version?: (LegacyNxReleaseVersionConfiguration | NxReleaseVersionV2Configuration) & {
381
+ version?: (LegacyNxReleaseVersionConfiguration | NxReleaseVersionConfiguration) & {
376
382
  useLegacyVersioning?: boolean;
377
383
  git?: NxReleaseGitConfiguration;
378
384
  preVersionCommand?: string;
@@ -1,5 +1,5 @@
1
1
  import type { PackageJson } from '../utils/package-json';
2
- import type { NxJsonConfiguration, NxReleaseVersionConfiguration, NxReleaseVersionV2Configuration } from './nx-json';
2
+ import type { LegacyNxReleaseVersionConfiguration, NxJsonConfiguration, NxReleaseVersionConfiguration } from './nx-json';
3
3
  /**
4
4
  * @deprecated use ProjectsConfigurations or NxJsonConfiguration
5
5
  */
@@ -98,7 +98,7 @@ export interface ProjectConfiguration {
98
98
  * Project specific configuration for `nx release`
99
99
  */
100
100
  release?: {
101
- version?: Pick<NxReleaseVersionConfiguration, 'generator' | 'generatorOptions'> | Pick<NxReleaseVersionV2Configuration, 'versionActions' | 'versionActionsOptions' | 'manifestRootsToUpdate' | 'currentVersionResolver' | 'currentVersionResolverMetadata' | 'fallbackCurrentVersionResolver' | 'versionPrefix' | 'preserveLocalDependencyProtocols'>;
101
+ version?: Pick<LegacyNxReleaseVersionConfiguration, 'generator' | 'generatorOptions'> | Pick<NxReleaseVersionConfiguration, 'versionActions' | 'versionActionsOptions' | 'manifestRootsToUpdate' | 'currentVersionResolver' | 'currentVersionResolverMetadata' | 'fallbackCurrentVersionResolver' | 'versionPrefix' | 'preserveLocalDependencyProtocols'>;
102
102
  };
103
103
  /**
104
104
  * Metadata about the project