nx 21.3.0-canary.20250717-8b4b3e9 → 21.3.0-rc.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "21.3.0-canary.20250717-8b4b3e9",
3
+ "version": "21.3.0-rc.0",
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.0-canary.20250717-8b4b3e9",
87
- "@nx/nx-darwin-x64": "21.3.0-canary.20250717-8b4b3e9",
88
- "@nx/nx-freebsd-x64": "21.3.0-canary.20250717-8b4b3e9",
89
- "@nx/nx-linux-arm-gnueabihf": "21.3.0-canary.20250717-8b4b3e9",
90
- "@nx/nx-linux-arm64-gnu": "21.3.0-canary.20250717-8b4b3e9",
91
- "@nx/nx-linux-arm64-musl": "21.3.0-canary.20250717-8b4b3e9",
92
- "@nx/nx-linux-x64-gnu": "21.3.0-canary.20250717-8b4b3e9",
93
- "@nx/nx-linux-x64-musl": "21.3.0-canary.20250717-8b4b3e9",
94
- "@nx/nx-win32-arm64-msvc": "21.3.0-canary.20250717-8b4b3e9",
95
- "@nx/nx-win32-x64-msvc": "21.3.0-canary.20250717-8b4b3e9"
86
+ "@nx/nx-darwin-arm64": "21.3.0-rc.0",
87
+ "@nx/nx-darwin-x64": "21.3.0-rc.0",
88
+ "@nx/nx-freebsd-x64": "21.3.0-rc.0",
89
+ "@nx/nx-linux-arm-gnueabihf": "21.3.0-rc.0",
90
+ "@nx/nx-linux-arm64-gnu": "21.3.0-rc.0",
91
+ "@nx/nx-linux-arm64-musl": "21.3.0-rc.0",
92
+ "@nx/nx-linux-x64-gnu": "21.3.0-rc.0",
93
+ "@nx/nx-linux-x64-musl": "21.3.0-rc.0",
94
+ "@nx/nx-win32-arm64-msvc": "21.3.0-rc.0",
95
+ "@nx/nx-win32-x64-msvc": "21.3.0-rc.0"
96
96
  },
97
97
  "nx-migrations": {
98
98
  "migrations": "./migrations.json",
@@ -23,8 +23,6 @@ const nx_json_1 = require("../../config/nx-json");
23
23
  const error_types_1 = require("../../project-graph/error-types");
24
24
  const nx_key_1 = require("../../utils/nx-key");
25
25
  const cache_1 = require("../../tasks-runner/cache");
26
- const native_1 = require("../../native");
27
- const cache_directory_1 = require("../../utils/cache-directory");
28
26
  const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '../../../package.json'));
29
27
  exports.packagesWeCareAbout = [
30
28
  'lerna',
@@ -184,9 +182,7 @@ async function getReportData() {
184
182
  }
185
183
  let cache = (0, cache_1.dbCacheEnabled)()
186
184
  ? {
187
- max: nxJson.maxCacheSize !== undefined
188
- ? (0, cache_1.parseMaxCacheSize)(nxJson.maxCacheSize)
189
- : (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir),
185
+ max: (0, cache_1.resolveMaxCacheSize)(nxJson),
190
186
  used: new cache_1.DbCache({ nxCloudRemoteCache: null }).getUsedCacheSpace(),
191
187
  }
192
188
  : null;
@@ -42,6 +42,12 @@ function withWatchOptions(yargs) {
42
42
  .option('verbose', {
43
43
  type: 'boolean',
44
44
  description: 'Run watch mode in verbose mode, where commands are logged before execution.',
45
+ })
46
+ .option('initialRun', {
47
+ type: 'boolean',
48
+ description: 'Run the command once before watching for changes.',
49
+ alias: 'i',
50
+ default: false,
45
51
  })
46
52
  .conflicts({
47
53
  all: 'projects',
@@ -6,6 +6,7 @@ export interface WatchArguments {
6
6
  includeGlobalWorkspaceFiles?: boolean;
7
7
  verbose?: boolean;
8
8
  command?: string;
9
+ initialRun?: boolean;
9
10
  projectNameEnvName?: string;
10
11
  fileChangesEnvName?: string;
11
12
  }
@@ -137,6 +137,15 @@ async function watch(args) {
137
137
  args.verbose && output_1.output.logSingleLine('starting watch process');
138
138
  const whatToWatch = args.all ? 'all' : args.projects;
139
139
  const batchQueue = new BatchCommandRunner(args.command ?? '', args.projectNameEnvName, args.fileChangesEnvName);
140
+ // Run the command initially if requested
141
+ if (args.initialRun) {
142
+ args.verbose && output_1.output.logSingleLine('running command initially...');
143
+ const initialProjects = args.all
144
+ ? [] // When using --all, we don't need to pass specific projects
145
+ : args.projects || [];
146
+ // Execute the initial run
147
+ await batchQueue.enqueue(initialProjects, []);
148
+ }
140
149
  await client_1.daemonClient.registerFileWatcher({
141
150
  watchProjects: whatToWatch,
142
151
  includeDependentProjects: args.includeDependentProjects,
@@ -35,6 +35,9 @@ const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-executio
35
35
  const DAEMON_ENV_SETTINGS = {
36
36
  NX_PROJECT_GLOB_CACHE: 'false',
37
37
  NX_CACHE_PROJECTS_CONFIG: 'false',
38
+ NX_VERBOSE_LOGGING: 'true',
39
+ NX_PERF_LOGGING: 'true',
40
+ NX_NATIVE_LOGGING: 'nx=debug',
38
41
  };
39
42
  var DaemonStatus;
40
43
  (function (DaemonStatus) {
@@ -43,9 +43,14 @@ async function getCachedSerializedProjectGraphPromise() {
43
43
  if (!cachedSerializedProjectGraphPromise) {
44
44
  cachedSerializedProjectGraphPromise =
45
45
  processFilesAndCreateAndSerializeProjectGraph(plugins);
46
+ logger_1.serverLogger.log('No files changed, but no in-memory cached project graph found. Recomputing it...');
47
+ }
48
+ else {
49
+ logger_1.serverLogger.log('Reusing in-memory cached project graph because no files changed.');
46
50
  }
47
51
  }
48
52
  else {
53
+ logger_1.serverLogger.log(`Recomputing project graph because of ${collectedUpdatedFiles.size} updated and ${collectedDeletedFiles.size} deleted files.`);
49
54
  cachedSerializedProjectGraphPromise =
50
55
  processFilesAndCreateAndSerializeProjectGraph(plugins);
51
56
  }
@@ -294,6 +294,25 @@ class RunningNodeProcess {
294
294
  }
295
295
  }
296
296
  });
297
+ // Terminate any task processes on exit
298
+ process.on('exit', () => {
299
+ this.childProcess.kill();
300
+ });
301
+ process.on('SIGINT', () => {
302
+ this.childProcess.kill('SIGTERM');
303
+ // we exit here because we don't need to write anything to cache.
304
+ process.exit((0, exit_codes_1.signalToCode)('SIGINT'));
305
+ });
306
+ process.on('SIGTERM', () => {
307
+ this.childProcess.kill('SIGTERM');
308
+ // no exit here because we expect child processes to terminate which
309
+ // will store results to the cache and will terminate this process
310
+ });
311
+ process.on('SIGHUP', () => {
312
+ this.childProcess.kill('SIGTERM');
313
+ // no exit here because we expect child processes to terminate which
314
+ // will store results to the cache and will terminate this process
315
+ });
297
316
  }
298
317
  }
299
318
  async function runSingleCommandWithPseudoTerminal(normalized, context) {
Binary file
@@ -4,7 +4,3 @@
4
4
  export declare function createNxCloudOnboardingURL(onboardingSource: string, accessToken?: string, usesGithub?: boolean, meta?: string): Promise<string>;
5
5
  export declare function repoUsesGithub(github?: boolean, githubSlug?: string, apiUrl?: string): Promise<boolean>;
6
6
  export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string | null, apiUrl: string, source: string, accessToken?: string): string;
7
- export declare function getNxCloudVersion(apiUrl: string): Promise<string | null>;
8
- export declare function removeVersionModifier(versionString: string): string;
9
- export declare function versionIsValid(version: string): boolean;
10
- export declare function isOldNxCloudVersion(version: string): boolean;
@@ -3,10 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNxCloudOnboardingURL = createNxCloudOnboardingURL;
4
4
  exports.repoUsesGithub = repoUsesGithub;
5
5
  exports.getURLifShortenFailed = getURLifShortenFailed;
6
- exports.getNxCloudVersion = getNxCloudVersion;
7
- exports.removeVersionModifier = removeVersionModifier;
8
- exports.versionIsValid = versionIsValid;
9
- exports.isOldNxCloudVersion = isOldNxCloudVersion;
10
6
  const logger_1 = require("../../utils/logger");
11
7
  const git_utils_1 = require("../../utils/git-utils");
12
8
  const get_cloud_options_1 = require("./get-cloud-options");
@@ -19,17 +15,6 @@ async function createNxCloudOnboardingURL(onboardingSource, accessToken, usesGit
19
15
  if (usesGithub === undefined || usesGithub === null) {
20
16
  usesGithub = await repoUsesGithub(undefined, githubSlug, apiUrl);
21
17
  }
22
- try {
23
- const version = await getNxCloudVersion(apiUrl);
24
- if (!version || isOldNxCloudVersion(version)) {
25
- return apiUrl;
26
- }
27
- }
28
- catch (e) {
29
- logger_1.logger.verbose(`Failed to get Nx Cloud version.
30
- ${e}`);
31
- return apiUrl;
32
- }
33
18
  const source = getSource(onboardingSource);
34
19
  try {
35
20
  const response = await require('axios').post(`${apiUrl}/nx-cloud/onboarding`, {
@@ -80,7 +65,7 @@ function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessTok
80
65
  return `${apiUrl}/setup/connect-workspace/github/connect?name=${encodeURIComponent(githubSlug)}&source=${source}`;
81
66
  }
82
67
  else {
83
- return `${apiUrl}/setup/connect-workspace/github/select&source=${source}`;
68
+ return `${apiUrl}/setup/connect-workspace/github/select?source=${source}`;
84
69
  }
85
70
  }
86
71
  return `${apiUrl}/setup/connect-workspace/manual?accessToken=${accessToken}&source=${source}`;
@@ -101,57 +86,3 @@ async function getInstallationSupportsGitHub(apiUrl) {
101
86
  return false;
102
87
  }
103
88
  }
104
- async function getNxCloudVersion(apiUrl) {
105
- try {
106
- const response = await require('axios').get(`${apiUrl}/nx-cloud/system/version`);
107
- const version = removeVersionModifier(response.data.version);
108
- const isValid = versionIsValid(version);
109
- if (!version) {
110
- throw new Error('Failed to extract version from response.');
111
- }
112
- if (!isValid) {
113
- throw new Error(`Invalid version format: ${version}`);
114
- }
115
- return version;
116
- }
117
- catch (e) {
118
- logger_1.logger.verbose(`Failed to get version of Nx Cloud.
119
- ${e}`);
120
- return null;
121
- }
122
- }
123
- function removeVersionModifier(versionString) {
124
- // Cloud version string is in the format of YYMM.DD.BuildNumber-Modifier
125
- return versionString.split(/[\.-]/).slice(0, 3).join('.');
126
- }
127
- function versionIsValid(version) {
128
- // Updated Regex pattern to require YYMM.DD.BuildNumber format
129
- // All parts are required, including the BuildNumber.
130
- const pattern = /^\d{4}\.\d{2}\.\d+$/;
131
- return pattern.test(version);
132
- }
133
- function isOldNxCloudVersion(version) {
134
- const [major, minor, buildNumber] = version
135
- .split('.')
136
- .map((part) => parseInt(part, 10));
137
- // for on-prem images we are using YYYY.MM.BuildNumber format
138
- // the first year is 2025
139
- if (major >= 2025 && major < 2300) {
140
- return false;
141
- }
142
- // Previously we used YYMM.DD.BuildNumber
143
- // All versions before '2406.11.5' had different URL shortening logic
144
- const newVersionMajor = 2406;
145
- const newVersionMinor = 11;
146
- const newVersionBuildNumber = 5;
147
- if (major !== newVersionMajor) {
148
- return major < newVersionMajor;
149
- }
150
- if (minor !== newVersionMinor) {
151
- return minor < newVersionMinor;
152
- }
153
- if (buildNumber !== newVersionBuildNumber) {
154
- return buildNumber < newVersionBuildNumber;
155
- }
156
- return false;
157
- }
@@ -17,8 +17,8 @@ function pruneProjectGraph(graph, prunedPackageJson) {
17
17
  const workspacePackages = (0, get_workspace_packages_from_graph_1.getWorkspacePackagesFromGraph)(graph);
18
18
  const combinedDependencies = normalizeDependencies(prunedPackageJson, graph, workspacePackages);
19
19
  addNodesAndDependencies(graph, combinedDependencies, workspacePackages, builder);
20
- for (const nodeName of workspacePackages.keys()) {
21
- const node = graph.nodes[nodeName];
20
+ for (const project of workspacePackages.values()) {
21
+ const node = graph.nodes[project.name];
22
22
  builder.addNode(node);
23
23
  }
24
24
  // for NPM (as well as the graph consistency)
@@ -16,6 +16,8 @@ const cache_directory_1 = require("../utils/cache-directory");
16
16
  const fileutils_1 = require("../utils/fileutils");
17
17
  const versions_1 = require("../utils/versions");
18
18
  const error_types_1 = require("./error-types");
19
+ const is_on_daemon_1 = require("../daemon/is-on-daemon");
20
+ const logger_1 = require("../daemon/server/logger");
19
21
  exports.nxProjectGraph = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'project-graph.json');
20
22
  exports.nxFileMap = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'file-map.json');
21
23
  exports.nxSourceMaps = (0, path_1.join)(cache_directory_1.workspaceDataDirectory, 'source-maps.json');
@@ -159,6 +161,9 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
159
161
  (0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
160
162
  (0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
161
163
  }
164
+ if ((0, is_on_daemon_1.isOnDaemon)()) {
165
+ logger_1.serverLogger.log(`Wrote project graph cache to ${exports.nxProjectGraph}${errors.length > 0 ? ' with errors' : ''}`);
166
+ }
162
167
  done = true;
163
168
  }
164
169
  catch (err) {
@@ -171,6 +176,9 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
171
176
  ++retry;
172
177
  }
173
178
  } while (!done && retry < 5);
179
+ if (!done) {
180
+ throw new Error(`Failed to write project graph cache to ${exports.nxProjectGraph} and ${exports.nxFileMap} after 5 attempts.`);
181
+ }
174
182
  perf_hooks_1.performance.mark('write cache:end');
175
183
  perf_hooks_1.performance.measure('write cache', 'write cache:start', 'write cache:end');
176
184
  }
@@ -1,5 +1,6 @@
1
1
  import { DefaultTasksRunnerOptions, RemoteCache } from './default-tasks-runner';
2
2
  import { Task } from '../config/task-graph';
3
+ import { NxJsonConfiguration } from '../config/nx-json';
3
4
  export type CachedResult = {
4
5
  terminalOutput: string;
5
6
  outputsPath: string;
@@ -68,6 +69,14 @@ export declare class Cache {
68
69
  private createCacheDir;
69
70
  private createTerminalOutputsDir;
70
71
  }
72
+ /**
73
+ * Resolves the max cache size from environment variable or nx.json configuration
74
+ * and converts it to a number of bytes.
75
+ *
76
+ * @param nxJson The nx.json configuration object
77
+ * @returns The resolved max cache size in bytes
78
+ */
79
+ export declare function resolveMaxCacheSize(nxJson: NxJsonConfiguration): number;
71
80
  /**
72
81
  * Converts a string representation of a max cache size to a number.
73
82
  *
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cache = exports.DbCache = void 0;
4
4
  exports.dbCacheEnabled = dbCacheEnabled;
5
5
  exports.getCache = getCache;
6
+ exports.resolveMaxCacheSize = resolveMaxCacheSize;
6
7
  exports.parseMaxCacheSize = parseMaxCacheSize;
7
8
  exports.formatCacheSize = formatCacheSize;
8
9
  const workspace_root_1 = require("../utils/workspace-root");
@@ -55,9 +56,7 @@ class DbCache {
55
56
  constructor(options) {
56
57
  this.options = options;
57
58
  this.nxJson = (0, nx_json_1.readNxJson)();
58
- this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined, this.nxJson.maxCacheSize !== undefined
59
- ? parseMaxCacheSize(this.nxJson.maxCacheSize)
60
- : (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir));
59
+ this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined, resolveMaxCacheSize(this.nxJson));
61
60
  this.isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
62
61
  }
63
62
  async init() {
@@ -472,6 +471,19 @@ function tryAndRetry(fn) {
472
471
  };
473
472
  return _try();
474
473
  }
474
+ /**
475
+ * Resolves the max cache size from environment variable or nx.json configuration
476
+ * and converts it to a number of bytes.
477
+ *
478
+ * @param nxJson The nx.json configuration object
479
+ * @returns The resolved max cache size in bytes
480
+ */
481
+ function resolveMaxCacheSize(nxJson) {
482
+ const rawMaxCacheSize = process.env.NX_MAX_CACHE_SIZE ?? nxJson.maxCacheSize;
483
+ return rawMaxCacheSize !== undefined
484
+ ? parseMaxCacheSize(rawMaxCacheSize)
485
+ : (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir);
486
+ }
475
487
  /**
476
488
  * Converts a string representation of a max cache size to a number.
477
489
  *