nx 21.2.0-beta.2 → 21.2.0-beta.3

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.
@@ -4,5 +4,5 @@ import { WorkspaceTypeAndRoot } from '../src/utils/find-workspace-root';
4
4
  *
5
5
  * @param workspace Relevant local workspace properties
6
6
  */
7
- export declare function initLocal(workspace: WorkspaceTypeAndRoot): void;
7
+ export declare function initLocal(workspace: WorkspaceTypeAndRoot): Promise<void>;
8
8
  export declare function rewriteTargetsAndProjects(args: string[]): string[];
package/bin/init-local.js CHANGED
@@ -5,12 +5,13 @@ exports.rewriteTargetsAndProjects = rewriteTargetsAndProjects;
5
5
  const perf_hooks_1 = require("perf_hooks");
6
6
  const nx_commands_1 = require("../src/command-line/nx-commands");
7
7
  const strip_indents_1 = require("../src/utils/strip-indents");
8
+ const nx_console_prompt_1 = require("../src/utils/nx-console-prompt");
8
9
  /**
9
10
  * Nx is being run inside a workspace.
10
11
  *
11
12
  * @param workspace Relevant local workspace properties
12
13
  */
13
- function initLocal(workspace) {
14
+ async function initLocal(workspace) {
14
15
  process.env.NX_CLI_SET = 'true';
15
16
  try {
16
17
  perf_hooks_1.performance.mark('init-local');
@@ -20,6 +21,11 @@ function initLocal(workspace) {
20
21
  handleAngularCLIFallbacks(workspace);
21
22
  return;
22
23
  }
24
+ // Ensure NxConsole is installed if the user has it configured.
25
+ try {
26
+ await (0, nx_console_prompt_1.ensureNxConsoleInstalled)();
27
+ }
28
+ catch { }
23
29
  const command = process.argv[2];
24
30
  if (command === 'run' || command === 'g' || command === 'generate') {
25
31
  nx_commands_1.commandsObject.parse(process.argv.slice(2));
package/bin/nx.js CHANGED
@@ -23,7 +23,7 @@ process.on('exit', (...args) => {
23
23
  globalThis.tuiOnProcessExit(...args);
24
24
  }
25
25
  });
26
- function main() {
26
+ async function main() {
27
27
  if (process.argv[2] !== 'report' &&
28
28
  process.argv[2] !== '--version' &&
29
29
  process.argv[2] !== '--help' &&
@@ -32,12 +32,12 @@ function main() {
32
32
  }
33
33
  require('nx/src/utils/perf-logging');
34
34
  const workspace = (0, find_workspace_root_1.findWorkspaceRoot)(process.cwd());
35
- perf_hooks_1.performance.mark('loading dotenv files:start');
36
35
  if (workspace) {
36
+ perf_hooks_1.performance.mark('loading dotenv files:start');
37
37
  (0, dotenv_1.loadRootEnvFiles)(workspace.dir);
38
+ perf_hooks_1.performance.mark('loading dotenv files:end');
39
+ perf_hooks_1.performance.measure('loading dotenv files', 'loading dotenv files:start', 'loading dotenv files:end');
38
40
  }
39
- perf_hooks_1.performance.mark('loading dotenv files:end');
40
- perf_hooks_1.performance.measure('loading dotenv files', 'loading dotenv files:start', 'loading dotenv files:end');
41
41
  // new is a special case because there is no local workspace to load
42
42
  if (process.argv[2] === 'new' ||
43
43
  process.argv[2] === '_migrate' ||
@@ -75,7 +75,7 @@ function main() {
75
75
  }
76
76
  // this file is already in the local workspace
77
77
  if (isLocalInstall) {
78
- (0, init_local_1.initLocal)(workspace);
78
+ await (0, init_local_1.initLocal)(workspace);
79
79
  }
80
80
  else {
81
81
  // Nx is being run from globally installed CLI - hand off to the local
@@ -223,4 +223,7 @@ const getLatestVersionOfNx = ((fn) => {
223
223
  process.on('exit', () => {
224
224
  (0, db_connection_1.removeDbConnections)();
225
225
  });
226
- main();
226
+ main().catch((error) => {
227
+ console.error(error);
228
+ process.exit(1);
229
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "21.2.0-beta.2",
3
+ "version": "21.2.0-beta.3",
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": {
@@ -83,16 +83,16 @@
83
83
  }
84
84
  },
85
85
  "optionalDependencies": {
86
- "@nx/nx-darwin-arm64": "21.2.0-beta.2",
87
- "@nx/nx-darwin-x64": "21.2.0-beta.2",
88
- "@nx/nx-freebsd-x64": "21.2.0-beta.2",
89
- "@nx/nx-linux-arm-gnueabihf": "21.2.0-beta.2",
90
- "@nx/nx-linux-arm64-gnu": "21.2.0-beta.2",
91
- "@nx/nx-linux-arm64-musl": "21.2.0-beta.2",
92
- "@nx/nx-linux-x64-gnu": "21.2.0-beta.2",
93
- "@nx/nx-linux-x64-musl": "21.2.0-beta.2",
94
- "@nx/nx-win32-arm64-msvc": "21.2.0-beta.2",
95
- "@nx/nx-win32-x64-msvc": "21.2.0-beta.2"
86
+ "@nx/nx-darwin-arm64": "21.2.0-beta.3",
87
+ "@nx/nx-darwin-x64": "21.2.0-beta.3",
88
+ "@nx/nx-freebsd-x64": "21.2.0-beta.3",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.2.0-beta.3",
90
+ "@nx/nx-linux-arm64-gnu": "21.2.0-beta.3",
91
+ "@nx/nx-linux-arm64-musl": "21.2.0-beta.3",
92
+ "@nx/nx-linux-x64-gnu": "21.2.0-beta.3",
93
+ "@nx/nx-linux-x64-musl": "21.2.0-beta.3",
94
+ "@nx/nx-win32-arm64-msvc": "21.2.0-beta.3",
95
+ "@nx/nx-win32-x64-msvc": "21.2.0-beta.3"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
@@ -330,19 +330,25 @@ function createAPI(overrideReleaseConfig) {
330
330
  }, releaseGroup.releaseTagPatternCheckAllBranchesWhen))?.tag;
331
331
  if (!fromRef && useAutomaticFromRef) {
332
332
  const firstCommit = await (0, git_1.getFirstGitCommit)();
333
- const allCommits = await getCommits(firstCommit, toSHA);
334
- const commitsForProject = allCommits.filter((c) => c.affectedFiles.find((f) => f.startsWith(project.data.root)));
335
- fromRef = commitsForProject[0]?.shortHash;
333
+ commits = await filterProjectCommits({
334
+ fromSHA: firstCommit,
335
+ toSHA,
336
+ projectPath: project.data.root,
337
+ });
338
+ fromRef = commits[0]?.shortHash;
336
339
  if (args.verbose) {
337
340
  console.log(`Determined --from ref for ${project.name} from the first commit in which it exists: ${fromRef}`);
338
341
  }
339
- commits = commitsForProject;
340
342
  }
341
343
  if (!fromRef && !commits) {
342
344
  throw new Error(`Unable to determine the previous git tag. If this is the first release of your workspace, use the --first-release option or set the "release.changelog.automaticFromRef" config property in nx.json to generate a changelog from the first commit. Otherwise, be sure to configure the "release.releaseTagPattern" property in nx.json to match the structure of your repository's git tags.`);
343
345
  }
344
346
  if (!commits) {
345
- commits = await getCommits(fromRef, toSHA);
347
+ commits = await filterProjectCommits({
348
+ fromSHA: fromRef,
349
+ toSHA,
350
+ projectPath: project.data.root,
351
+ });
346
352
  }
347
353
  const { fileMap } = await (0, file_map_utils_1.createFileMapUsingProjectGraph)(projectGraph);
348
354
  const fileToProjectMap = createFileToProjectMap(fileMap.projectFileMap);
@@ -903,6 +909,10 @@ async function getCommits(fromSHA, toSHA) {
903
909
  // Parse as conventional commits
904
910
  return (0, git_1.parseCommits)(rawCommits);
905
911
  }
912
+ async function filterProjectCommits({ fromSHA, toSHA, projectPath, }) {
913
+ const allCommits = await getCommits(fromSHA, toSHA);
914
+ return allCommits.filter((c) => c.affectedFiles.find((f) => f.startsWith(projectPath)));
915
+ }
906
916
  function filterHiddenChanges(changes, conventionalCommitsConfig) {
907
917
  return changes.filter((change) => {
908
918
  const type = change.type;
@@ -956,7 +956,7 @@ Valid values are: ${version_1.validReleaseVersionPrefixes
956
956
  let bumpType = 'none';
957
957
  if (releaseGroup.projectsRelationship === 'fixed') {
958
958
  // For fixed groups, we only need to check one project
959
- const project = releaseGroupFilteredProjects[0];
959
+ const project = releaseGroupFilteredProjects.values().next().value;
960
960
  const dependencies = this.projectGraph.dependencies[project] || [];
961
961
  const hasDependencyInChangedGroup = dependencies.some((dep) => this.getReleaseGroupNameForProject(dep.target) ===
962
962
  changedDependencyGroup);
@@ -37,5 +37,5 @@ function topologicalSort(nodes, getEdges) {
37
37
  visit(node);
38
38
  }
39
39
  }
40
- return result.reverse();
40
+ return result;
41
41
  }
@@ -123,7 +123,7 @@ async function reportHandler() {
123
123
  bodyLines.push(LINE_SEPARATOR);
124
124
  bodyLines.push('Local workspace plugins:');
125
125
  for (const plugin of localPlugins) {
126
- bodyLines.push(`\t ${chalk.green(plugin)}`);
126
+ bodyLines.push(`${chalk.green(plugin)}`);
127
127
  }
128
128
  }
129
129
  if (cache) {
@@ -1,3 +1,5 @@
1
+ import { ProjectGraph } from '../../config/project-graph';
2
+ import { NxJsonConfiguration } from '../../config/nx-json';
1
3
  import { TargetDependencyConfig } from '../../config/workspace-json-project-json';
2
4
  export declare function runOne(cwd: string, args: {
3
5
  [k: string]: any;
@@ -5,3 +7,11 @@ export declare function runOne(cwd: string, args: {
5
7
  excludeTaskDependencies: boolean;
6
8
  loadDotEnvFiles: boolean;
7
9
  }): Promise<void>;
10
+ export declare function parseRunOneOptions(cwd: string, parsedArgs: {
11
+ [k: string]: any;
12
+ }, projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): {
13
+ project: any;
14
+ target: any;
15
+ configuration: any;
16
+ parsedArgs: any;
17
+ };
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runOne = runOne;
4
+ exports.parseRunOneOptions = parseRunOneOptions;
4
5
  const run_command_1 = require("../../tasks-runner/run-command");
5
6
  const command_line_utils_1 = require("../../utils/command-line-utils");
6
7
  const connect_to_nx_cloud_1 = require("../connect/connect-to-nx-cloud");
7
- const perf_hooks_1 = require("perf_hooks");
8
8
  const project_graph_1 = require("../../project-graph/project-graph");
9
9
  const workspace_root_1 = require("../../utils/workspace-root");
10
10
  const split_target_1 = require("../../utils/split-target");
@@ -17,8 +17,8 @@ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
17
17
  excludeTaskDependencies: args.excludeTaskDependencies,
18
18
  loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
19
19
  }) {
20
- perf_hooks_1.performance.mark('code-loading:end');
21
- perf_hooks_1.performance.measure('code-loading', 'init-local', 'code-loading:end');
20
+ performance.mark('code-loading:end');
21
+ performance.measure('code-loading', 'init-local', 'code-loading:end');
22
22
  const nxJson = (0, configuration_1.readNxJson)();
23
23
  const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
24
24
  const opts = parseRunOneOptions(cwd, args, projectGraph, nxJson);
@@ -107,8 +107,19 @@ function parseRunOneOptions(cwd, parsedArgs, projectGraph, nxJson) {
107
107
  project = defaultProjectName;
108
108
  }
109
109
  }
110
- else {
111
- target = parsedArgs.target ?? parsedArgs['project:target:configuration'];
110
+ else if (parsedArgs.target) {
111
+ target = parsedArgs.target;
112
+ }
113
+ else if (parsedArgs['project:target:configuration']) {
114
+ // If project:target:configuration exists but has no colon, check if it's a project with run target
115
+ if (projectGraph.nodes[parsedArgs['project:target:configuration']]?.data
116
+ ?.targets?.run) {
117
+ target = 'run';
118
+ project = parsedArgs['project:target:configuration'];
119
+ }
120
+ else {
121
+ target = parsedArgs['project:target:configuration'];
122
+ }
112
123
  }
113
124
  if (parsedArgs.project) {
114
125
  project = parsedArgs.project;