nx 21.3.5 → 21.3.7

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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "21.3.5",
3
+ "version": "21.3.7",
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.5",
87
- "@nx/nx-darwin-x64": "21.3.5",
88
- "@nx/nx-freebsd-x64": "21.3.5",
89
- "@nx/nx-linux-arm-gnueabihf": "21.3.5",
90
- "@nx/nx-linux-arm64-gnu": "21.3.5",
91
- "@nx/nx-linux-arm64-musl": "21.3.5",
92
- "@nx/nx-linux-x64-gnu": "21.3.5",
93
- "@nx/nx-linux-x64-musl": "21.3.5",
94
- "@nx/nx-win32-arm64-msvc": "21.3.5",
95
- "@nx/nx-win32-x64-msvc": "21.3.5"
86
+ "@nx/nx-darwin-arm64": "21.3.7",
87
+ "@nx/nx-darwin-x64": "21.3.7",
88
+ "@nx/nx-freebsd-x64": "21.3.7",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.3.7",
90
+ "@nx/nx-linux-arm64-gnu": "21.3.7",
91
+ "@nx/nx-linux-arm64-musl": "21.3.7",
92
+ "@nx/nx-linux-x64-gnu": "21.3.7",
93
+ "@nx/nx-linux-x64-musl": "21.3.7",
94
+ "@nx/nx-win32-arm64-msvc": "21.3.7",
95
+ "@nx/nx-win32-x64-msvc": "21.3.7"
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 ||
@@ -252,6 +252,9 @@ export declare export declare function installNxConsole(): void
252
252
 
253
253
  export const IS_WASM: boolean
254
254
 
255
+ /** Detects if the current process is being run by an AI agent */
256
+ export declare export declare function isAiAgent(): boolean
257
+
255
258
  export declare export declare function logDebug(message: string): void
256
259
 
257
260
  /** Stripped version of the NxJson interface for use in rust */
@@ -392,6 +392,7 @@ module.exports.hashArray = nativeBinding.hashArray
392
392
  module.exports.hashFile = nativeBinding.hashFile
393
393
  module.exports.installNxConsole = nativeBinding.installNxConsole
394
394
  module.exports.IS_WASM = nativeBinding.IS_WASM
395
+ module.exports.isAiAgent = nativeBinding.isAiAgent
395
396
  module.exports.logDebug = nativeBinding.logDebug
396
397
  module.exports.parseTaskStatus = nativeBinding.parseTaskStatus
397
398
  module.exports.remove = nativeBinding.remove
@@ -124,16 +124,17 @@ function __napi_rs_initialize_modules(__napiInstance) {
124
124
  __napiInstance.exports['__napi_register__ExternalDependenciesInput_struct_49']?.()
125
125
  __napiInstance.exports['__napi_register__DepsOutputsInput_struct_50']?.()
126
126
  __napiInstance.exports['__napi_register__NxJson_struct_51']?.()
127
- __napiInstance.exports['__napi_register__FileLock_struct_52']?.()
128
- __napiInstance.exports['__napi_register__FileLock_impl_54']?.()
129
- __napiInstance.exports['__napi_register__WorkspaceContext_struct_55']?.()
130
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_66']?.()
131
- __napiInstance.exports['__napi_register__WorkspaceErrors_67']?.()
132
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_68']?.()
133
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_69']?.()
134
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_70']?.()
135
- __napiInstance.exports['__napi_register__FileMap_struct_71']?.()
136
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_72']?.()
127
+ __napiInstance.exports['__napi_register__is_ai_agent_52']?.()
128
+ __napiInstance.exports['__napi_register__FileLock_struct_53']?.()
129
+ __napiInstance.exports['__napi_register__FileLock_impl_55']?.()
130
+ __napiInstance.exports['__napi_register__WorkspaceContext_struct_56']?.()
131
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_67']?.()
132
+ __napiInstance.exports['__napi_register__WorkspaceErrors_68']?.()
133
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_69']?.()
134
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_70']?.()
135
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_71']?.()
136
+ __napiInstance.exports['__napi_register__FileMap_struct_72']?.()
137
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_73']?.()
137
138
  }
138
139
  module.exports.FileLock = __napiModule.exports.FileLock
139
140
  module.exports.HashPlanInspector = __napiModule.exports.HashPlanInspector
@@ -153,6 +154,7 @@ module.exports.hashArray = __napiModule.exports.hashArray
153
154
  module.exports.hashFile = __napiModule.exports.hashFile
154
155
  module.exports.installNxConsole = __napiModule.exports.installNxConsole
155
156
  module.exports.IS_WASM = __napiModule.exports.IS_WASM
157
+ module.exports.isAiAgent = __napiModule.exports.isAiAgent
156
158
  module.exports.logDebug = __napiModule.exports.logDebug
157
159
  module.exports.remove = __napiModule.exports.remove
158
160
  module.exports.testOnlyTransferFileMap = __napiModule.exports.testOnlyTransferFileMap
Binary file
@@ -292,9 +292,13 @@ class TargetProjectLocator {
292
292
  resolvedModule.includes('/node_modules/')) {
293
293
  return undefined;
294
294
  }
295
- const normalizedResolvedModule = resolvedModule.startsWith('./')
295
+ let normalizedResolvedModule = resolvedModule.startsWith('./')
296
296
  ? resolvedModule.substring(2)
297
297
  : resolvedModule;
298
+ // Remove trailing slash to ensure proper project matching
299
+ if (normalizedResolvedModule.endsWith('/')) {
300
+ normalizedResolvedModule = normalizedResolvedModule.slice(0, -1);
301
+ }
298
302
  const importedProject = this.findMatchingProjectFiles(normalizedResolvedModule);
299
303
  return importedProject ? importedProject.name : void 0;
300
304
  }
@@ -1,6 +1,6 @@
1
- import { ProjectGraphProjectNode } from '../../config/project-graph';
2
- import { ProjectGraphBuilder } from '../project-graph-builder';
3
- import { ProjectConfiguration } from '../../config/workspace-json-project-json';
4
- import { CreateDependenciesContext } from '../plugins';
5
- export declare function normalizeProjectNodes({ projects }: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
1
+ import type { ProjectGraphProjectNode } from '../../config/project-graph';
2
+ import type { ProjectConfiguration } from '../../config/workspace-json-project-json';
3
+ import type { CreateDependenciesContext } from '../plugins';
4
+ import type { ProjectGraphBuilder } from '../project-graph-builder';
5
+ export declare function normalizeProjectNodes({ projects, workspaceRoot }: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
6
6
  export declare function normalizeImplicitDependencies(source: string, implicitDependencies: ProjectConfiguration['implicitDependencies'], projects: Record<string, ProjectGraphProjectNode>): string[];
@@ -2,8 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeProjectNodes = normalizeProjectNodes;
4
4
  exports.normalizeImplicitDependencies = normalizeImplicitDependencies;
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const fileutils_1 = require("../../utils/fileutils");
5
8
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
6
- async function normalizeProjectNodes({ projects }, builder) {
9
+ async function normalizeProjectNodes({ projects, workspaceRoot }, builder) {
7
10
  // Sorting projects by name to make sure that the order of projects in the graph is deterministic.
8
11
  // This is important to ensure that expanded properties referencing projects (e.g. implicit dependencies)
9
12
  // are also deterministic, and thus don't cause the calculated project configuration hash to shift.
@@ -26,11 +29,7 @@ async function normalizeProjectNodes({ projects }, builder) {
26
29
  p.implicitDependencies = normalizeImplicitDependencies(key, p.implicitDependencies, partialProjectGraphNodes);
27
30
  p.targets ??= {};
28
31
  // TODO: remove in v16
29
- const projectType = p.projectType === 'application'
30
- ? key.endsWith('-e2e') || key === 'e2e'
31
- ? 'e2e'
32
- : 'app'
33
- : 'lib';
32
+ const projectType = getProjectType(key, p.projectType, workspaceRoot, p.root);
34
33
  const tags = p.tags || [];
35
34
  toAdd.push({
36
35
  name: key,
@@ -86,3 +85,33 @@ function normalizeImplicitDependencies(source, implicitDependencies, projects) {
86
85
  // detected by createDependencies.
87
86
  return deps.concat(alwaysIgnoredDeps.map((x) => '!' + x));
88
87
  }
88
+ function getProjectType(projectName, projectType, workspaceRoot, projectRoot) {
89
+ if (projectType) {
90
+ if (projectType === 'library') {
91
+ return 'lib';
92
+ }
93
+ if (projectName.endsWith('-e2e') || projectName === 'e2e') {
94
+ return 'e2e';
95
+ }
96
+ return 'app';
97
+ }
98
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(workspaceRoot, projectRoot, 'tsconfig.lib.json'))) {
99
+ return 'lib';
100
+ }
101
+ if ((0, node_fs_1.existsSync)((0, node_path_1.join)(workspaceRoot, projectRoot, 'tsconfig.app.json'))) {
102
+ return 'app';
103
+ }
104
+ // If it doesn't have any common library entry points, assume it is an application
105
+ const packageJsonPath = (0, node_path_1.join)(workspaceRoot, projectRoot, 'package.json');
106
+ try {
107
+ const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
108
+ if (!packageJson.exports &&
109
+ !packageJson.main &&
110
+ !packageJson.module &&
111
+ !packageJson.bin) {
112
+ return 'app';
113
+ }
114
+ }
115
+ catch { }
116
+ return 'lib';
117
+ }
@@ -56,6 +56,8 @@ function shouldUseTui(nxJson, nxArgs, skipCapabilityCheck = process.env.NX_TUI_S
56
56
  if (
57
57
  // Interactive TUI doesn't make sense on CI
58
58
  (0, is_ci_1.isCI)() ||
59
+ // Interactive TUI doesn't make sense in an AI agent context
60
+ (0, native_1.isAiAgent)() ||
59
61
  // TODO(@JamesHenry): Remove this check once Windows issues are fixed.
60
62
  // Windows is not working well right now, temporarily disable it on Windows even if it has been specified as enabled
61
63
  isWindows ||
@@ -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';