nx 19.3.0-beta.0 → 19.3.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/bin/post-install.js +1 -3
  2. package/migrations.json +12 -0
  3. package/package.json +12 -12
  4. package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +38 -13
  5. package/src/command-line/init/implementation/utils.js +15 -2
  6. package/src/command-line/release/command-object.js +1 -1
  7. package/src/command-line/release/utils/git.d.ts +2 -2
  8. package/src/command-line/release/utils/git.js +19 -11
  9. package/src/command-line/release/version.d.ts +1 -1
  10. package/src/command-line/release/version.js +1 -1
  11. package/src/command-line/yargs-utils/shared-options.d.ts +1 -1
  12. package/src/core/graph/main.js +1 -1
  13. package/src/daemon/client/client.js +0 -2
  14. package/src/executors/run-commands/run-commands.impl.d.ts +6 -2
  15. package/src/executors/run-commands/run-commands.impl.js +52 -25
  16. package/src/executors/run-commands/schema.json +5 -2
  17. package/src/generators/utils/project-configuration.js +1 -1
  18. package/src/hasher/file-hasher.js +1 -1
  19. package/src/migrations/update-19-2-4/set-project-name.d.ts +2 -0
  20. package/src/migrations/update-19-2-4/set-project-name.js +34 -0
  21. package/src/plugins/js/package-json/create-package-json.js +3 -0
  22. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +9 -4
  23. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  24. package/src/plugins/package-json-workspaces/create-nodes.js +34 -11
  25. package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -0
  26. package/src/plugins/project-json/build-nodes/project-json.js +16 -4
  27. package/src/project-graph/error-types.js +10 -0
  28. package/src/project-graph/file-utils.js +1 -1
  29. package/src/project-graph/plugins/internal-api.js +1 -1
  30. package/src/project-graph/utils/normalize-project-nodes.js +24 -6
  31. package/src/project-graph/utils/project-configuration-utils.js +9 -1
  32. package/src/tasks-runner/create-task-graph.js +32 -33
  33. package/src/utils/ab-testing.d.ts +1 -1
  34. package/src/utils/find-matching-projects.js +13 -1
  35. package/src/utils/package-json.d.ts +1 -0
@@ -14,7 +14,6 @@ const workspace_context_1 = require("../src/utils/workspace-context");
14
14
  const logger_1 = require("../src/utils/logger");
15
15
  (async () => {
16
16
  const start = new Date();
17
- let errored = false;
18
17
  try {
19
18
  (0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
20
19
  if (isMainNxPackage() && (0, fileutils_1.fileExists)((0, path_1.join)(workspace_root_1.workspaceRoot, 'nx.json'))) {
@@ -39,13 +38,12 @@ const logger_1 = require("../src/utils/logger");
39
38
  }
40
39
  }
41
40
  catch (e) {
42
- errored = true;
43
41
  logger_1.logger.verbose(e);
44
42
  }
45
43
  finally {
46
44
  const end = new Date();
47
45
  logger_1.logger.verbose(`Nx postinstall steps took ${end.getTime() - start.getTime()}ms`);
48
- process.exit(errored ? 1 : 0);
46
+ process.exit(0);
49
47
  }
50
48
  })();
51
49
  function isMainNxPackage() {
package/migrations.json CHANGED
@@ -77,6 +77,18 @@
77
77
  "version": "19.2.0-beta.2",
78
78
  "description": "Updates the default workspace data directory to .nx/workspace-data",
79
79
  "implementation": "./src/migrations/update-19-2-0/move-workspace-data-directory"
80
+ },
81
+ "19-2-2-update-nx-wrapper": {
82
+ "cli": "nx",
83
+ "version": "19.2.2-beta.0",
84
+ "description": "Updates the nx wrapper.",
85
+ "implementation": "./src/migrations/update-17-3-0/update-nxw"
86
+ },
87
+ "19-2-4-set-project-name": {
88
+ "version": "19.2.4-beta.0",
89
+ "description": "Set project name in nx.json explicitly",
90
+ "implementation": "./src/migrations/update-19-2-4/set-project-name",
91
+ "x-repair-skip": true
80
92
  }
81
93
  }
82
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.3.0-beta.0",
3
+ "version": "19.3.0-beta.1",
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": {
@@ -70,7 +70,7 @@
70
70
  "yargs-parser": "21.1.1",
71
71
  "node-machine-id": "1.1.12",
72
72
  "ora": "5.3.0",
73
- "@nrwl/tao": "19.3.0-beta.0"
73
+ "@nrwl/tao": "19.3.0-beta.1"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "@swc-node/register": "^1.8.0",
@@ -85,16 +85,16 @@
85
85
  }
86
86
  },
87
87
  "optionalDependencies": {
88
- "@nx/nx-darwin-x64": "19.3.0-beta.0",
89
- "@nx/nx-darwin-arm64": "19.3.0-beta.0",
90
- "@nx/nx-linux-x64-gnu": "19.3.0-beta.0",
91
- "@nx/nx-linux-x64-musl": "19.3.0-beta.0",
92
- "@nx/nx-win32-x64-msvc": "19.3.0-beta.0",
93
- "@nx/nx-linux-arm64-gnu": "19.3.0-beta.0",
94
- "@nx/nx-linux-arm64-musl": "19.3.0-beta.0",
95
- "@nx/nx-linux-arm-gnueabihf": "19.3.0-beta.0",
96
- "@nx/nx-win32-arm64-msvc": "19.3.0-beta.0",
97
- "@nx/nx-freebsd-x64": "19.3.0-beta.0"
88
+ "@nx/nx-darwin-x64": "19.3.0-beta.1",
89
+ "@nx/nx-darwin-arm64": "19.3.0-beta.1",
90
+ "@nx/nx-linux-x64-gnu": "19.3.0-beta.1",
91
+ "@nx/nx-linux-x64-musl": "19.3.0-beta.1",
92
+ "@nx/nx-win32-x64-msvc": "19.3.0-beta.1",
93
+ "@nx/nx-linux-arm64-gnu": "19.3.0-beta.1",
94
+ "@nx/nx-linux-arm64-musl": "19.3.0-beta.1",
95
+ "@nx/nx-linux-arm-gnueabihf": "19.3.0-beta.1",
96
+ "@nx/nx-win32-arm64-msvc": "19.3.0-beta.1",
97
+ "@nx/nx-freebsd-x64": "19.3.0-beta.1"
98
98
  },
99
99
  "nx-migrations": {
100
100
  "migrations": "./migrations.json",
@@ -11,17 +11,36 @@ const nxWrapperPath = (p = path) => p.join('.nx', 'nxw.js');
11
11
  exports.nxWrapperPath = nxWrapperPath;
12
12
  const NODE_MISSING_ERR = 'Nx requires NodeJS to be available. To install NodeJS and NPM, see: https://nodejs.org/en/download/ .';
13
13
  const NPM_MISSING_ERR = 'Nx requires npm to be available. To install NodeJS and NPM, see: https://nodejs.org/en/download/ .';
14
- const BATCH_SCRIPT_CONTENTS = `set path_to_root=%~dp0
15
- WHERE node >nul 2>nul
16
- IF %ERRORLEVEL% NEQ 0 (ECHO ${NODE_MISSING_ERR}; EXIT 1)
17
- WHERE npm >nul 2>nul
18
- IF %ERRORLEVEL% NEQ 0 (ECHO ${NPM_MISSING_ERR}; EXIT 1)
19
- node ${path.win32.join('%path_to_root%', (0, exports.nxWrapperPath)(path.win32))} %*`;
20
- const SHELL_SCRIPT_CONTENTS = `#!/bin/bash
21
- command -v node >/dev/null 2>&1 || { echo >&2 "${NODE_MISSING_ERR}"; exit 1; }
22
- command -v npm >/dev/null 2>&1 || { echo >&2 "${NPM_MISSING_ERR}"; exit 1; }
23
- path_to_root=$(dirname $BASH_SOURCE)
24
- node ${path.posix.join('$path_to_root', (0, exports.nxWrapperPath)(path.posix))} $@`;
14
+ const BATCH_SCRIPT_CONTENTS = [
15
+ // don't log command to console
16
+ `@ECHO OFF`,
17
+ // Prevents path_to_root from being inherited by child processes
18
+ `SETLOCAL`,
19
+ `SET path_to_root=%~dp0`,
20
+ // Checks if node is available
21
+ `WHERE node >nul 2>nul`,
22
+ `IF %ERRORLEVEL% NEQ 0 (ECHO ${NODE_MISSING_ERR} & GOTO exit)`,
23
+ // Checks if npm is available
24
+ `WHERE npm >nul 2>nul`,
25
+ `IF %ERRORLEVEL% NEQ 0 (ECHO ${NPM_MISSING_ERR} & GOTO exit)`,
26
+ // Executes the nx wrapper script
27
+ `node ${path.win32.join('%path_to_root%', (0, exports.nxWrapperPath)(path.win32))} %*`,
28
+ // Exits with the same error code as the previous command
29
+ `:exit`,
30
+ ` cmd /c exit /b %ERRORLEVEL%`,
31
+ ].join('\r\n');
32
+ const SHELL_SCRIPT_CONTENTS = [
33
+ // Execute in bash
34
+ `#!/bin/bash`,
35
+ // Checks if node is available
36
+ `command -v node >/dev/null 2>&1 || { echo >&2 "${NODE_MISSING_ERR}"; exit 1; }`,
37
+ // Checks if npm is available
38
+ `command -v npm >/dev/null 2>&1 || { echo >&2 "${NPM_MISSING_ERR}"; exit 1; }`,
39
+ // Gets the path to the root of the project
40
+ `path_to_root=$(dirname $BASH_SOURCE)`,
41
+ // Executes the nx wrapper script
42
+ `node ${path.posix.join('$path_to_root', (0, exports.nxWrapperPath)(path.posix))} $@`,
43
+ ].join('\n');
25
44
  function generateDotNxSetup(version) {
26
45
  const host = new tree_1.FsTree(process.cwd(), false, '.nx setup');
27
46
  writeMinimalNxJson(host, version);
@@ -54,8 +73,14 @@ function writeMinimalNxJson(host, version) {
54
73
  }
55
74
  exports.writeMinimalNxJson = writeMinimalNxJson;
56
75
  function updateGitIgnore(host) {
57
- const contents = host.read('.gitignore', 'utf-8') ?? '';
58
- host.write('.gitignore', [contents, '.nx/installation', '.nx/cache'].join('\n'));
76
+ let contents = host.read('.gitignore', 'utf-8') ?? '';
77
+ if (!contents.includes('.nx/installation')) {
78
+ contents = [contents, '.nx/installation'].join('\n');
79
+ }
80
+ if (!contents.includes('.nx/cache')) {
81
+ contents = [contents, '.nx/cache'].join('\n');
82
+ }
83
+ host.write('.gitignore', contents);
59
84
  }
60
85
  exports.updateGitIgnore = updateGitIgnore;
61
86
  // Gets the sanitized contents for nxw.js
@@ -98,10 +98,23 @@ function updateGitIgnore(root) {
98
98
  const ignorePath = (0, path_1.join)(root, '.gitignore');
99
99
  try {
100
100
  let contents = (0, fs_1.readFileSync)(ignorePath, 'utf-8');
101
+ const lines = contents.split('\n');
102
+ let sepIncluded = false;
101
103
  if (!contents.includes('.nx/cache')) {
102
- contents = [contents, '', '.nx/cache'].join('\n');
103
- (0, fs_1.writeFileSync)(ignorePath, contents, 'utf-8');
104
+ if (!sepIncluded) {
105
+ lines.push('\n');
106
+ sepIncluded = true;
107
+ }
108
+ lines.push('.nx/cache');
109
+ }
110
+ if (!contents.includes('.nx/workspace-data')) {
111
+ if (!sepIncluded) {
112
+ lines.push('\n');
113
+ sepIncluded = true;
114
+ }
115
+ lines.push('.nx/workspace-data');
104
116
  }
117
+ (0, fs_1.writeFileSync)(ignorePath, lines.join('\n'), 'utf-8');
105
118
  }
106
119
  catch { }
107
120
  }
@@ -101,7 +101,7 @@ const versionCommand = {
101
101
  })
102
102
  .option('preid', {
103
103
  type: 'string',
104
- describe: 'The optional prerelease identifier to apply to the version, in the case that the specifier argument has been set to `prerelease`.',
104
+ describe: 'The optional prerelease identifier to apply to the version. This will only be applied in the case that the specifier argument has been set to `prerelease` OR when conventional commits are enabled, in which case it will modify the resolved specifier from conventional commits to be its prerelease equivalent. E.g. minor -> preminor',
105
105
  default: '',
106
106
  })
107
107
  .option('stage-changes', {
@@ -27,12 +27,12 @@ export declare function getLatestGitTagForPattern(releaseTagPattern: string, add
27
27
  extractedVersion: string;
28
28
  } | null>;
29
29
  export declare function getGitDiff(from: string | undefined, to?: string): Promise<RawGitCommit[]>;
30
- export declare function getChangedTrackedFiles(): Promise<Set<string>>;
31
- export declare function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }: {
30
+ export declare function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, cwd, }: {
32
31
  changedFiles?: string[];
33
32
  deletedFiles?: string[];
34
33
  dryRun?: boolean;
35
34
  verbose?: boolean;
35
+ cwd?: string;
36
36
  logFn?: (...messages: string[]) => void;
37
37
  }): Promise<string>;
38
38
  export declare function gitCommit({ messages, additionalArgs, dryRun, verbose, logFn, }: {
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getFirstGitCommit = exports.getCommitHash = exports.parseGitCommit = exports.parseConventionalCommitsMessage = exports.parseCommits = exports.gitPush = exports.gitTag = exports.gitCommit = exports.gitAdd = exports.getChangedTrackedFiles = exports.getGitDiff = exports.getLatestGitTagForPattern = void 0;
3
+ exports.getFirstGitCommit = exports.getCommitHash = exports.parseGitCommit = exports.parseConventionalCommitsMessage = exports.parseCommits = exports.gitPush = exports.gitTag = exports.gitCommit = exports.gitAdd = exports.getGitDiff = exports.getLatestGitTagForPattern = void 0;
4
4
  /**
5
5
  * Special thanks to changelogen for the original inspiration for many of these utilities:
6
6
  * https://github.com/unjs/changelogen
7
7
  */
8
8
  const utils_1 = require("../../../tasks-runner/utils");
9
+ const app_root_1 = require("../../../utils/app-root");
9
10
  const exec_command_1 = require("./exec-command");
10
11
  function escapeRegExp(string) {
11
12
  return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&');
@@ -97,18 +98,21 @@ async function getGitDiff(from, to = 'HEAD') {
97
98
  });
98
99
  }
99
100
  exports.getGitDiff = getGitDiff;
100
- async function getChangedTrackedFiles() {
101
- const result = await (0, exec_command_1.execCommand)('git', ['status', '--porcelain']);
101
+ async function getChangedTrackedFiles(cwd) {
102
+ const result = await (0, exec_command_1.execCommand)('git', ['status', '--porcelain'], {
103
+ cwd,
104
+ });
102
105
  const lines = result.split('\n').filter((l) => l.trim().length > 0);
103
106
  return new Set(lines.map((l) => l.substring(3)));
104
107
  }
105
- exports.getChangedTrackedFiles = getChangedTrackedFiles;
106
- async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }) {
108
+ async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, cwd, }) {
107
109
  logFn = logFn || console.log;
110
+ // Default to running git add related commands from the workspace root
111
+ cwd = cwd || app_root_1.workspaceRoot;
108
112
  let ignoredFiles = [];
109
113
  let filesToAdd = [];
110
114
  for (const f of changedFiles ?? []) {
111
- const isFileIgnored = await isIgnored(f);
115
+ const isFileIgnored = await isIgnored(f, cwd);
112
116
  if (isFileIgnored) {
113
117
  ignoredFiles.push(f);
114
118
  }
@@ -117,9 +121,9 @@ async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }) {
117
121
  }
118
122
  }
119
123
  if (deletedFiles?.length > 0) {
120
- const changedTrackedFiles = await getChangedTrackedFiles();
124
+ const changedTrackedFiles = await getChangedTrackedFiles(cwd);
121
125
  for (const f of deletedFiles ?? []) {
122
- const isFileIgnored = await isIgnored(f);
126
+ const isFileIgnored = await isIgnored(f, cwd);
123
127
  if (isFileIgnored) {
124
128
  ignoredFiles.push(f);
125
129
  // git add will fail if trying to add an untracked file that doesn't exist
@@ -151,13 +155,17 @@ async function gitAdd({ changedFiles, deletedFiles, dryRun, verbose, logFn, }) {
151
155
  if (dryRun) {
152
156
  return;
153
157
  }
154
- return (0, exec_command_1.execCommand)('git', commandArgs);
158
+ return (0, exec_command_1.execCommand)('git', commandArgs, {
159
+ cwd,
160
+ });
155
161
  }
156
162
  exports.gitAdd = gitAdd;
157
- async function isIgnored(filePath) {
163
+ async function isIgnored(filePath, cwd) {
158
164
  try {
159
165
  // This command will error if the file is not ignored
160
- await (0, exec_command_1.execCommand)('git', ['check-ignore', filePath]);
166
+ await (0, exec_command_1.execCommand)('git', ['check-ignore', filePath], {
167
+ cwd,
168
+ });
161
169
  return true;
162
170
  }
163
171
  catch {
@@ -18,7 +18,7 @@ export interface ReleaseVersionGeneratorSchema {
18
18
  currentVersionResolverMetadata?: Record<string, unknown>;
19
19
  fallbackCurrentVersionResolver?: 'disk';
20
20
  firstRelease?: boolean;
21
- versionPrefix?: typeof validReleaseVersionPrefixes[number];
21
+ versionPrefix?: (typeof validReleaseVersionPrefixes)[number];
22
22
  skipLockFileUpdate?: boolean;
23
23
  installArgs?: string;
24
24
  installIgnoreScripts?: boolean;
@@ -378,7 +378,7 @@ function resolveGeneratorData({ collectionName, generatorName, configGeneratorOp
378
378
  * the @nx/js generator config in their nx.json so we need to be clear about what the problem is)
379
379
  */
380
380
  if (collectionName === '@nx/js') {
381
- throw new Error('The @nx/js plugin is required in order to version your JavaScript packages. Please install it and try again.');
381
+ throw new Error('The @nx/js plugin is required in order to version your JavaScript packages. Run "nx add @nx/js" to add it to your workspace.');
382
382
  }
383
383
  throw new Error(`Unable to resolve the package ${collectionName} in order to load the generator called ${generatorName}. Is the package installed?`);
384
384
  }
@@ -57,7 +57,7 @@ export declare function withOverrides<T extends {
57
57
  __overrides_unparsed__: string[];
58
58
  };
59
59
  declare const allOutputStyles: readonly ["dynamic", "static", "stream", "stream-without-prefixes", "compact"];
60
- export type OutputStyle = typeof allOutputStyles[number];
60
+ export type OutputStyle = (typeof allOutputStyles)[number];
61
61
  export declare function withOutputStyleOption(yargs: Argv, choices?: ReadonlyArray<OutputStyle>): Argv<{
62
62
  "output-style": string;
63
63
  }>;