nx 19.2.0-canary.20240604-0594deb → 19.2.0-rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. package/migrations.json +6 -0
  2. package/package.json +13 -12
  3. package/release/changelog-renderer/index.d.ts +6 -3
  4. package/release/changelog-renderer/index.js +53 -50
  5. package/schemas/nx-schema.json +8 -0
  6. package/src/command-line/add/add.d.ts +1 -1
  7. package/src/command-line/add/command-object.js +3 -1
  8. package/src/command-line/affected/command-object.js +10 -5
  9. package/src/command-line/deprecated/command-objects.js +12 -6
  10. package/src/command-line/examples.js +18 -0
  11. package/src/command-line/generate/generate.d.ts +1 -1
  12. package/src/command-line/migrate/migrate.d.ts +1 -1
  13. package/src/command-line/new/new.d.ts +1 -1
  14. package/src/command-line/release/changelog.d.ts +17 -1
  15. package/src/command-line/release/changelog.js +305 -76
  16. package/src/command-line/release/command-object.d.ts +14 -5
  17. package/src/command-line/release/command-object.js +52 -24
  18. package/src/command-line/release/config/config.js +38 -6
  19. package/src/command-line/release/config/filter-release-groups.d.ts +3 -1
  20. package/src/command-line/release/config/filter-release-groups.js +1 -0
  21. package/src/command-line/release/config/version-plans.d.ts +24 -0
  22. package/src/command-line/release/config/version-plans.js +184 -0
  23. package/src/command-line/release/plan.d.ts +3 -0
  24. package/src/command-line/release/plan.js +184 -0
  25. package/src/command-line/release/publish.d.ts +1 -1
  26. package/src/command-line/release/release.d.ts +1 -1
  27. package/src/command-line/release/release.js +40 -0
  28. package/src/command-line/release/utils/git.d.ts +10 -2
  29. package/src/command-line/release/utils/git.js +45 -10
  30. package/src/command-line/release/utils/shared.d.ts +12 -2
  31. package/src/command-line/release/utils/shared.js +3 -2
  32. package/src/command-line/release/version.d.ts +3 -2
  33. package/src/command-line/release/version.js +43 -5
  34. package/src/command-line/repair/repair.d.ts +1 -1
  35. package/src/command-line/reset/command-object.d.ts +6 -1
  36. package/src/command-line/reset/command-object.js +15 -2
  37. package/src/command-line/reset/reset.d.ts +2 -1
  38. package/src/command-line/reset/reset.js +98 -16
  39. package/src/command-line/run/command-object.js +6 -3
  40. package/src/command-line/run/run.d.ts +2 -2
  41. package/src/command-line/run-many/command-object.js +6 -3
  42. package/src/command-line/show/command-object.js +6 -6
  43. package/src/config/misc-interfaces.d.ts +15 -3
  44. package/src/config/nx-json.d.ts +11 -0
  45. package/src/daemon/tmp-dir.js +1 -1
  46. package/src/devkit-exports.d.ts +1 -1
  47. package/src/migrations/update-19-2-0/move-workspace-data-directory.d.ts +4 -0
  48. package/src/migrations/update-19-2-0/move-workspace-data-directory.js +34 -0
  49. package/src/plugins/js/index.js +2 -2
  50. package/src/plugins/js/project-graph/affected/lock-file-changes.js +11 -0
  51. package/src/plugins/js/project-graph/affected/npm-packages.js +12 -0
  52. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +3 -11
  53. package/src/plugins/js/utils/config.js +4 -0
  54. package/src/plugins/js/utils/register.d.ts +4 -3
  55. package/src/plugins/js/utils/register.js +47 -4
  56. package/src/project-graph/affected/affected-project-graph.js +6 -6
  57. package/src/project-graph/nx-deps-cache.js +6 -6
  58. package/src/project-graph/plugins/loader.js +1 -1
  59. package/src/tasks-runner/task-env.js +12 -0
  60. package/src/utils/cache-directory.d.ts +1 -1
  61. package/src/utils/cache-directory.js +13 -6
  62. package/src/utils/get-package-name-from-import-path.d.ts +1 -0
  63. package/src/utils/get-package-name-from-import-path.js +18 -0
  64. package/src/utils/package-json.d.ts +1 -0
  65. package/src/utils/package-manager.js +42 -9
  66. package/src/utils/params.d.ts +1 -1
  67. package/src/utils/params.js +5 -1
@@ -81,14 +81,20 @@ function loadDotEnvFilesForTask(task, environmentVariables) {
81
81
  // Load DotEnv Files for a configuration in the project root
82
82
  ...(task.target.configuration
83
83
  ? [
84
+ `${task.projectRoot}/.env.${task.target.target}.${task.target.configuration}.local`,
84
85
  `${task.projectRoot}/.env.${task.target.target}.${task.target.configuration}`,
86
+ `${task.projectRoot}/.env.${task.target.configuration}.local`,
85
87
  `${task.projectRoot}/.env.${task.target.configuration}`,
88
+ `${task.projectRoot}/.${task.target.target}.${task.target.configuration}.local.env`,
86
89
  `${task.projectRoot}/.${task.target.target}.${task.target.configuration}.env`,
90
+ `${task.projectRoot}/.${task.target.configuration}.local.env`,
87
91
  `${task.projectRoot}/.${task.target.configuration}.env`,
88
92
  ]
89
93
  : []),
90
94
  // Load DotEnv Files for a target in the project root
95
+ `${task.projectRoot}/.env.${task.target.target}.local`,
91
96
  `${task.projectRoot}/.env.${task.target.target}`,
97
+ `${task.projectRoot}/.${task.target.target}.local.env`,
92
98
  `${task.projectRoot}/.${task.target.target}.env`,
93
99
  `${task.projectRoot}/.env.local`,
94
100
  `${task.projectRoot}/.local.env`,
@@ -96,14 +102,20 @@ function loadDotEnvFilesForTask(task, environmentVariables) {
96
102
  // Load DotEnv Files for a configuration in the workspace root
97
103
  ...(task.target.configuration
98
104
  ? [
105
+ `.env.${task.target.target}.${task.target.configuration}.local`,
99
106
  `.env.${task.target.target}.${task.target.configuration}`,
107
+ `.env.${task.target.configuration}.local`,
100
108
  `.env.${task.target.configuration}`,
109
+ `.${task.target.target}.${task.target.configuration}.local.env`,
101
110
  `.${task.target.target}.${task.target.configuration}.env`,
111
+ `.${task.target.configuration}.local.env`,
102
112
  `.${task.target.configuration}.env`,
103
113
  ]
104
114
  : []),
105
115
  // Load DotEnv Files for a target in the workspace root
116
+ `.env.${task.target.target}.local`,
106
117
  `.env.${task.target.target}`,
118
+ `.${task.target.target}.local.env`,
107
119
  `.${task.target.target}.env`,
108
120
  // Load base DotEnv Files at workspace root
109
121
  `.local.env`,
@@ -3,4 +3,4 @@
3
3
  */
4
4
  export declare const cacheDir: string;
5
5
  export declare function cacheDirectoryForWorkspace(workspaceRoot: string): string;
6
- export declare const projectGraphCacheDirectory: string;
6
+ export declare const workspaceDataDirectory: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projectGraphCacheDirectory = exports.cacheDirectoryForWorkspace = exports.cacheDir = void 0;
3
+ exports.workspaceDataDirectory = exports.cacheDirectoryForWorkspace = exports.cacheDir = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const fileutils_1 = require("./fileutils");
@@ -35,7 +35,7 @@ function cacheDirectory(root, cacheDirectory) {
35
35
  return defaultCacheDirectory(root);
36
36
  }
37
37
  }
38
- function defaultCacheDirectory(root) {
38
+ function pickCacheDirectory(root, nonNxCacheDirectory, nxCacheDirectory) {
39
39
  // If nx.json doesn't exist the repo can't utilize
40
40
  // caching, so .nx/cache is less relevant. Lerna users
41
41
  // that don't want to fully opt in to Nx at this time
@@ -44,9 +44,15 @@ function defaultCacheDirectory(root) {
44
44
  // this for the time being.
45
45
  if ((0, fs_1.existsSync)((0, path_1.join)(root, 'lerna.json')) &&
46
46
  !(0, fs_1.existsSync)((0, path_1.join)(root, 'nx.json'))) {
47
- return (0, path_1.join)(root, 'node_modules', '.cache', 'nx');
47
+ return (0, path_1.join)(root, 'node_modules', '.cache', nonNxCacheDirectory);
48
48
  }
49
- return (0, path_1.join)(root, '.nx', 'cache');
49
+ return (0, path_1.join)(root, '.nx', nxCacheDirectory);
50
+ }
51
+ function defaultCacheDirectory(root) {
52
+ return pickCacheDirectory(root, 'nx', 'cache');
53
+ }
54
+ function defaultWorkspaceDataDirectory(root) {
55
+ return pickCacheDirectory(root, 'nx-workspace-data', 'workspace-data');
50
56
  }
51
57
  /**
52
58
  * Path to the directory where Nx stores its cache and daemon-related files.
@@ -56,5 +62,6 @@ function cacheDirectoryForWorkspace(workspaceRoot) {
56
62
  return cacheDirectory(workspaceRoot, readCacheDirectoryProperty(workspaceRoot));
57
63
  }
58
64
  exports.cacheDirectoryForWorkspace = cacheDirectoryForWorkspace;
59
- exports.projectGraphCacheDirectory = absolutePath(workspace_root_1.workspaceRoot, process.env.NX_PROJECT_GRAPH_CACHE_DIRECTORY ??
60
- defaultCacheDirectory(workspace_root_1.workspaceRoot));
65
+ exports.workspaceDataDirectory = absolutePath(workspace_root_1.workspaceRoot, process.env.NX_WORKSPACE_DATA_DIRECTORY ??
66
+ process.env.NX_PROJECT_GRAPH_CACHE_DIRECTORY ??
67
+ defaultWorkspaceDataDirectory(workspace_root_1.workspaceRoot));
@@ -0,0 +1 @@
1
+ export declare function getPackageNameFromImportPath(importExpression: string): string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPackageNameFromImportPath = void 0;
4
+ //# Converts import paths to package names.
5
+ //# e.g. - `@nx/workspace` -> `@nx/workspace`
6
+ //# - `@nx/workspace/plugin` -> `@nx/workspace`
7
+ //# - `@nx/workspace/other` -> `@nx/workspace`
8
+ //# - `nx/plugin` -> `nx`
9
+ function getPackageNameFromImportPath(importExpression) {
10
+ // Check if the package is scoped
11
+ if (importExpression.startsWith('@')) {
12
+ // For scoped packages, the package name is up to the second '/'
13
+ return importExpression.split('/').slice(0, 2).join('/');
14
+ }
15
+ // For unscoped packages, the package name is up to the first '/'
16
+ return importExpression.split('/')[0];
17
+ }
18
+ exports.getPackageNameFromImportPath = getPackageNameFromImportPath;
@@ -61,6 +61,7 @@ export interface PackageJson {
61
61
  executors?: string;
62
62
  'nx-migrations'?: string | NxMigrationsConfiguration;
63
63
  'ng-update'?: string | NxMigrationsConfiguration;
64
+ packageManager?: string;
64
65
  }
65
66
  export declare function normalizePackageGroup(packageGroup: PackageGroup): ArrayPackageGroup;
66
67
  export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigrationsConfiguration & {
@@ -60,8 +60,15 @@ exports.isWorkspacesEnabled = isWorkspacesEnabled;
60
60
  function getPackageManagerCommand(packageManager = detectPackageManager(), root = workspace_root_1.workspaceRoot) {
61
61
  const commands = {
62
62
  yarn: () => {
63
- const yarnVersion = getPackageManagerVersion('yarn', root);
64
- const useBerry = (0, semver_1.gte)(yarnVersion, '2.0.0');
63
+ let yarnVersion, useBerry;
64
+ try {
65
+ yarnVersion = getPackageManagerVersion('yarn', root);
66
+ useBerry = (0, semver_1.gte)(yarnVersion, '2.0.0');
67
+ }
68
+ catch {
69
+ yarnVersion = 'latest';
70
+ useBerry = true;
71
+ }
65
72
  return {
66
73
  preInstall: `yarn set version ${yarnVersion}`,
67
74
  install: 'yarn',
@@ -84,9 +91,16 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
84
91
  };
85
92
  },
86
93
  pnpm: () => {
87
- const pnpmVersion = getPackageManagerVersion('pnpm', root);
88
- const modernPnpm = (0, semver_1.gte)(pnpmVersion, '6.13.0');
89
- const includeDoubleDashBeforeArgs = (0, semver_1.lt)(pnpmVersion, '7.0.0');
94
+ let modernPnpm, includeDoubleDashBeforeArgs;
95
+ try {
96
+ const pnpmVersion = getPackageManagerVersion('pnpm', root);
97
+ modernPnpm = (0, semver_1.gte)(pnpmVersion, '6.13.0');
98
+ includeDoubleDashBeforeArgs = (0, semver_1.lt)(pnpmVersion, '7.0.0');
99
+ }
100
+ catch {
101
+ modernPnpm = true;
102
+ includeDoubleDashBeforeArgs = true;
103
+ }
90
104
  const isPnpmWorkspace = (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
91
105
  return {
92
106
  install: 'pnpm install --no-frozen-lockfile', // explicitly disable in case of CI
@@ -148,10 +162,29 @@ exports.getPackageManagerCommand = getPackageManagerCommand;
148
162
  * but it can also be passed in explicitly.
149
163
  */
150
164
  function getPackageManagerVersion(packageManager = detectPackageManager(), cwd = process.cwd()) {
151
- return (0, child_process_1.execSync)(`${packageManager} --version`, {
152
- cwd,
153
- encoding: 'utf-8',
154
- }).trim();
165
+ let version;
166
+ try {
167
+ version = (0, child_process_1.execSync)(`${packageManager} --version`, {
168
+ cwd,
169
+ encoding: 'utf-8',
170
+ }).trim();
171
+ }
172
+ catch {
173
+ if ((0, fs_1.existsSync)((0, path_1.join)(cwd, 'package.json'))) {
174
+ const packageVersion = (0, fileutils_1.readJsonFile)((0, path_1.join)(cwd, 'package.json'))?.packageManager;
175
+ if (packageVersion) {
176
+ const [packageManagerFromPackageJson, versionFromPackageJson] = packageVersion.split('@');
177
+ if (packageManagerFromPackageJson === packageManager &&
178
+ versionFromPackageJson) {
179
+ version = versionFromPackageJson;
180
+ }
181
+ }
182
+ }
183
+ }
184
+ if (!version) {
185
+ throw new Error(`Cannot determine the version of ${packageManager}.`);
186
+ }
187
+ return version;
155
188
  }
156
189
  exports.getPackageManagerVersion = getPackageManagerVersion;
157
190
  /**
@@ -79,7 +79,7 @@ export type Options = {
79
79
  '--'?: Unmatched[];
80
80
  [k: string]: string | number | boolean | string[] | Unmatched[] | undefined;
81
81
  };
82
- export declare function handleErrors(isVerbose: boolean, fn: Function): Promise<any>;
82
+ export declare function handleErrors(isVerbose: boolean, fn: Function): Promise<number>;
83
83
  export declare function convertToCamelCase(parsed: {
84
84
  [k: string]: any;
85
85
  }, schema: Schema): Options;
@@ -6,7 +6,11 @@ const output_1 = require("./output");
6
6
  const client_1 = require("../daemon/client/client");
7
7
  async function handleErrors(isVerbose, fn) {
8
8
  try {
9
- return await fn();
9
+ const result = await fn();
10
+ if (typeof result === 'number') {
11
+ return result;
12
+ }
13
+ return 0;
10
14
  }
11
15
  catch (err) {
12
16
  err ||= new Error('Unknown error caught');