nx 21.3.6 → 21.3.8

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.
package/bin/nx.js CHANGED
@@ -68,7 +68,12 @@ async function main() {
68
68
  handleMissingLocalInstallation(workspace ? workspace.dir : null);
69
69
  }
70
70
  // this file is already in the local workspace
71
- if (isLocalInstall) {
71
+ if (isNxCloudCommand(process.argv[2])) {
72
+ // nx-cloud commands can run without local Nx installation
73
+ process.env.NX_DAEMON = 'false';
74
+ require('nx/src/command-line/nx-commands').commandsObject.argv;
75
+ }
76
+ else if (isLocalInstall) {
72
77
  await (0, init_local_1.initLocal)(workspace);
73
78
  }
74
79
  else if (localNx) {
@@ -82,11 +87,6 @@ async function main() {
82
87
  require(localNx);
83
88
  }
84
89
  }
85
- else if (isNxCloudCommand(process.argv[2])) {
86
- // nx-cloud commands can run without local Nx installation
87
- process.env.NX_DAEMON = 'false';
88
- require('nx/src/command-line/nx-commands').commandsObject.argv;
89
- }
90
90
  }
91
91
  }
92
92
  function handleNoWorkspace(globalNxVersion) {
@@ -1,43 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const project_graph_1 = require("../src/project-graph/project-graph");
4
3
  const workspace_root_1 = require("../src/utils/workspace-root");
5
4
  const fileutils_1 = require("../src/utils/fileutils");
6
5
  const path_1 = require("path");
7
- const client_1 = require("../src/daemon/client/client");
8
6
  const assert_supported_platform_1 = require("../src/native/assert-supported-platform");
9
7
  const update_manager_1 = require("../src/nx-cloud/update-manager");
10
8
  const get_cloud_options_1 = require("../src/nx-cloud/utilities/get-cloud-options");
11
9
  const nx_cloud_utils_1 = require("../src/utils/nx-cloud-utils");
12
10
  const nx_json_1 = require("../src/config/nx-json");
13
11
  const logger_1 = require("../src/utils/logger");
14
- const workspace_context_1 = require("../src/utils/workspace-context");
12
+ // The post install is not critical, to avoid any chance that it may hang
13
+ // we will kill this process after 30 seconds.
14
+ const postinstallTimeout = setTimeout(() => {
15
+ logger_1.logger.verbose('Nx post-install timed out.');
16
+ process.exit(0);
17
+ }, 30_000);
15
18
  (async () => {
16
19
  const start = new Date();
17
20
  try {
18
21
  if (isMainNxPackage() && (0, fileutils_1.fileExists)((0, path_1.join)(workspace_root_1.workspaceRoot, 'nx.json'))) {
19
22
  (0, assert_supported_platform_1.assertSupportedPlatform)();
20
- (0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
21
- if (client_1.daemonClient.enabled()) {
22
- try {
23
- await client_1.daemonClient.stop();
24
- }
25
- catch (e) { }
26
- }
27
- const tasks = [
28
- (0, project_graph_1.buildProjectGraphAndSourceMapsWithoutDaemon)(),
29
- ];
30
23
  if ((0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())) {
31
- tasks.push((0, update_manager_1.verifyOrUpdateNxCloudClient)((0, get_cloud_options_1.getCloudOptions)()));
24
+ await (0, update_manager_1.verifyOrUpdateNxCloudClient)((0, get_cloud_options_1.getCloudOptions)());
32
25
  }
33
- process.env.NX_DAEMON = 'false';
34
- await Promise.all(tasks.map((promise) => {
35
- return promise.catch((e) => {
36
- if (process.env.NX_VERBOSE_LOGGING === 'true') {
37
- console.warn(e);
38
- }
39
- });
40
- }));
41
26
  }
42
27
  }
43
28
  catch (e) {
@@ -46,6 +31,7 @@ const workspace_context_1 = require("../src/utils/workspace-context");
46
31
  finally {
47
32
  const end = new Date();
48
33
  logger_1.logger.verbose(`Nx postinstall steps took ${end.getTime() - start.getTime()}ms`);
34
+ clearTimeout(postinstallTimeout);
49
35
  process.exit(0);
50
36
  }
51
37
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "21.3.6",
3
+ "version": "21.3.8",
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.3.6",
87
- "@nx/nx-darwin-x64": "21.3.6",
88
- "@nx/nx-freebsd-x64": "21.3.6",
89
- "@nx/nx-linux-arm-gnueabihf": "21.3.6",
90
- "@nx/nx-linux-arm64-gnu": "21.3.6",
91
- "@nx/nx-linux-arm64-musl": "21.3.6",
92
- "@nx/nx-linux-x64-gnu": "21.3.6",
93
- "@nx/nx-linux-x64-musl": "21.3.6",
94
- "@nx/nx-win32-arm64-msvc": "21.3.6",
95
- "@nx/nx-win32-x64-msvc": "21.3.6"
86
+ "@nx/nx-darwin-arm64": "21.3.8",
87
+ "@nx/nx-darwin-x64": "21.3.8",
88
+ "@nx/nx-freebsd-x64": "21.3.8",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.3.8",
90
+ "@nx/nx-linux-arm64-gnu": "21.3.8",
91
+ "@nx/nx-linux-arm64-musl": "21.3.8",
92
+ "@nx/nx-linux-x64-gnu": "21.3.8",
93
+ "@nx/nx-linux-x64-musl": "21.3.8",
94
+ "@nx/nx-win32-arm64-msvc": "21.3.8",
95
+ "@nx/nx-win32-x64-msvc": "21.3.8"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
@@ -10,7 +10,8 @@ exports.yargsConnectCommand = {
10
10
  describe: `Connect workspace to Nx Cloud.`,
11
11
  builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)(withConnectOptions(yargs), 'connect-to-nx-cloud'),
12
12
  handler: async (args) => {
13
- await (await Promise.resolve().then(() => require('./connect-to-nx-cloud'))).connectToNxCloudCommand(args);
13
+ const checkRemote = process.env.NX_SKIP_CHECK_REMOTE !== 'true';
14
+ await (await Promise.resolve().then(() => require('./connect-to-nx-cloud'))).connectToNxCloudCommand({ ...args, checkRemote });
14
15
  await (await Promise.resolve().then(() => require('../../../utils/ab-testing'))).recordStat({
15
16
  command: 'connect',
16
17
  nxVersion: versions_1.nxVersion,
@@ -7,6 +7,7 @@ export declare function connectToNxCloudIfExplicitlyAsked(opts: NxArgs): Promise
7
7
  export declare function connectWorkspaceToCloud(options: ConnectToNxCloudOptions, directory?: string): Promise<string>;
8
8
  export declare function connectToNxCloudCommand(options: {
9
9
  generateToken?: boolean;
10
+ checkRemote?: boolean;
10
11
  }, command?: string): Promise<boolean>;
11
12
  export declare function connectExistingRepoToNxCloudPrompt(command?: string, key?: MessageKey): Promise<boolean>;
12
13
  export declare function connectToNxCloudWithPrompt(command: string): Promise<void>;
@@ -17,8 +17,9 @@ const ab_testing_1 = require("../../../utils/ab-testing");
17
17
  const versions_1 = require("../../../utils/versions");
18
18
  const workspace_root_1 = require("../../../utils/workspace-root");
19
19
  const chalk = require("chalk");
20
- const ora = require("ora");
21
- const open = require("open");
20
+ const git_utils_1 = require("../../../utils/git-utils");
21
+ const ora = require('ora');
22
+ const open = require('open');
22
23
  function onlyDefaultRunnerIsUsed(nxJson) {
23
24
  const defaultRunner = nxJson.tasksRunnerOptions?.default?.runner;
24
25
  if (!defaultRunner) {
@@ -59,6 +60,17 @@ async function connectToNxCloudCommand(options, command) {
59
60
  const installationSource = process.env.NX_CONSOLE
60
61
  ? 'nx-console'
61
62
  : 'nx-connect';
63
+ const hasRemote = !!(0, git_utils_1.getGitRemote)();
64
+ if (!hasRemote && options.checkRemote) {
65
+ output_1.output.error({
66
+ title: 'Missing VCS provider',
67
+ bodyLines: [
68
+ 'Push this repository to a VCS provider (e.g., GitHub) and try again.',
69
+ 'Go to https://github.com/new to create a repository on GitHub.',
70
+ ],
71
+ });
72
+ return false;
73
+ }
62
74
  if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
63
75
  const token = process.env.NX_CLOUD_ACCESS_TOKEN ||
64
76
  nxJson.nxCloudAccessToken ||
@@ -32,6 +32,7 @@ export declare class GitRepository {
32
32
  private quotePath;
33
33
  private quoteArg;
34
34
  }
35
+ export declare function getGitRemote(): string;
35
36
  /**
36
37
  * This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
37
38
  */
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GitRepository = void 0;
4
4
  exports.cloneFromUpstream = cloneFromUpstream;
5
+ exports.getGitRemote = getGitRemote;
5
6
  exports.getGithubSlugOrNull = getGithubSlugOrNull;
6
7
  exports.extractUserAndRepoFromGitHubUrl = extractUserAndRepoFromGitHubUrl;
7
8
  exports.commitChanges = commitChanges;
@@ -170,15 +171,21 @@ class GitRepository {
170
171
  }
171
172
  }
172
173
  exports.GitRepository = GitRepository;
174
+ function getGitRemote() {
175
+ const res = (0, child_process_1.execSync)('git remote -v', {
176
+ stdio: 'pipe',
177
+ windowsHide: false,
178
+ })
179
+ .toString()
180
+ .trim();
181
+ return res;
182
+ }
173
183
  /**
174
184
  * This is currently duplicated in Nx Console. Please let @MaxKless know if you make changes here.
175
185
  */
176
186
  function getGithubSlugOrNull() {
177
187
  try {
178
- const gitRemote = (0, child_process_1.execSync)('git remote -v', {
179
- stdio: 'pipe',
180
- windowsHide: false,
181
- }).toString();
188
+ const gitRemote = getGitRemote();
182
189
  // If there are no remotes, we default to github
183
190
  if (!gitRemote || gitRemote.length === 0) {
184
191
  return 'github';