nx 20.6.0-canary.20250313-7f1e1cf → 20.6.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 +12 -12
- package/src/command-line/init/configure-plugins.js +9 -2
- package/src/command-line/init/init-v2.js +1 -0
- package/src/command-line/report/report.d.ts +4 -0
- package/src/command-line/report/report.js +17 -1
- package/src/native/index.d.ts +3 -0
- package/src/native/native-bindings.js +1 -0
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/tasks-runner/cache.d.ts +3 -1
- package/src/tasks-runner/cache.js +23 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "20.6.0
|
3
|
+
"version": "20.6.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": {
|
@@ -38,7 +38,7 @@
|
|
38
38
|
"@yarnpkg/lockfile": "^1.1.0",
|
39
39
|
"@yarnpkg/parsers": "3.0.2",
|
40
40
|
"@zkochan/js-yaml": "0.0.7",
|
41
|
-
"axios": "^1.
|
41
|
+
"axios": "^1.8.3",
|
42
42
|
"chalk": "^4.1.0",
|
43
43
|
"cli-cursor": "3.1.0",
|
44
44
|
"cli-spinners": "2.6.1",
|
@@ -82,16 +82,16 @@
|
|
82
82
|
}
|
83
83
|
},
|
84
84
|
"optionalDependencies": {
|
85
|
-
"@nx/nx-darwin-arm64": "20.6.0
|
86
|
-
"@nx/nx-darwin-x64": "20.6.0
|
87
|
-
"@nx/nx-freebsd-x64": "20.6.0
|
88
|
-
"@nx/nx-linux-arm-gnueabihf": "20.6.0
|
89
|
-
"@nx/nx-linux-arm64-gnu": "20.6.0
|
90
|
-
"@nx/nx-linux-arm64-musl": "20.6.0
|
91
|
-
"@nx/nx-linux-x64-gnu": "20.6.0
|
92
|
-
"@nx/nx-linux-x64-musl": "20.6.0
|
93
|
-
"@nx/nx-win32-arm64-msvc": "20.6.0
|
94
|
-
"@nx/nx-win32-x64-msvc": "20.6.0
|
85
|
+
"@nx/nx-darwin-arm64": "20.6.0",
|
86
|
+
"@nx/nx-darwin-x64": "20.6.0",
|
87
|
+
"@nx/nx-freebsd-x64": "20.6.0",
|
88
|
+
"@nx/nx-linux-arm-gnueabihf": "20.6.0",
|
89
|
+
"@nx/nx-linux-arm64-gnu": "20.6.0",
|
90
|
+
"@nx/nx-linux-arm64-musl": "20.6.0",
|
91
|
+
"@nx/nx-linux-x64-gnu": "20.6.0",
|
92
|
+
"@nx/nx-linux-x64-musl": "20.6.0",
|
93
|
+
"@nx/nx-win32-arm64-msvc": "20.6.0",
|
94
|
+
"@nx/nx-win32-x64-msvc": "20.6.0"
|
95
95
|
},
|
96
96
|
"nx-migrations": {
|
97
97
|
"migrations": "./migrations.json",
|
@@ -33,8 +33,15 @@ function runPackageManagerInstallPlugins(repoRoot, pmc = (0, package_manager_1.g
|
|
33
33
|
*/
|
34
34
|
async function installPlugin(plugin, repoRoot = workspace_root_1.workspaceRoot, updatePackageScripts = false, verbose = false, pmc = (0, package_manager_1.getPackageManagerCommand)()) {
|
35
35
|
try {
|
36
|
-
(0, generator_utils_1.getGeneratorInformation)(plugin, 'init', workspace_root_1.workspaceRoot, {});
|
37
|
-
|
36
|
+
const { schema } = (0, generator_utils_1.getGeneratorInformation)(plugin, 'init', workspace_root_1.workspaceRoot, {});
|
37
|
+
let command = `${pmc.exec} nx g ${plugin}:init ${verbose ? '--verbose' : ''}`;
|
38
|
+
if (!!schema.properties['keepExistingVersions']) {
|
39
|
+
command += ` --keepExistingVersions`;
|
40
|
+
}
|
41
|
+
if (updatePackageScripts && !!schema.properties['updatePackageScripts']) {
|
42
|
+
command += ` --updatePackageScripts`;
|
43
|
+
}
|
44
|
+
(0, child_process_1.execSync)(command, {
|
38
45
|
stdio: [0, 1, 2],
|
39
46
|
cwd: repoRoot,
|
40
47
|
windowsHide: false,
|
@@ -156,6 +156,7 @@ const npmPackageToPluginMap = {
|
|
156
156
|
'react-native': '@nx/react-native',
|
157
157
|
'@remix-run/dev': '@nx/remix',
|
158
158
|
'@rsbuild/core': '@nx/rsbuild',
|
159
|
+
'@react-router/dev': '@nx/react',
|
159
160
|
};
|
160
161
|
async function detectPlugins(nxJson, interactive, includeAngularCli) {
|
161
162
|
let files = ['package.json'].concat((0, workspace_context_1.globWithWorkspaceContextSync)(process.cwd(), ['**/*/package.json']));
|
@@ -36,6 +36,10 @@ export interface ReportData {
|
|
36
36
|
};
|
37
37
|
projectGraphError?: Error | null;
|
38
38
|
nativeTarget: string | null;
|
39
|
+
cache: {
|
40
|
+
max: number;
|
41
|
+
used: number;
|
42
|
+
} | null;
|
39
43
|
}
|
40
44
|
export declare function getReportData(): Promise<ReportData>;
|
41
45
|
interface OutOfSyncPackageGroup {
|
@@ -22,6 +22,9 @@ const installation_directory_1 = require("../../utils/installation-directory");
|
|
22
22
|
const nx_json_1 = require("../../config/nx-json");
|
23
23
|
const error_types_1 = require("../../project-graph/error-types");
|
24
24
|
const powerpack_1 = require("../../utils/powerpack");
|
25
|
+
const cache_1 = require("../../tasks-runner/cache");
|
26
|
+
const native_1 = require("../../native");
|
27
|
+
const cache_directory_1 = require("../../utils/cache-directory");
|
25
28
|
const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '../../../package.json'));
|
26
29
|
exports.packagesWeCareAbout = [
|
27
30
|
'lerna',
|
@@ -46,7 +49,7 @@ const LINE_SEPARATOR = '---------------------------------------';
|
|
46
49
|
*
|
47
50
|
*/
|
48
51
|
async function reportHandler() {
|
49
|
-
const { pm, pmVersion, powerpackLicense, powerpackError, localPlugins, powerpackPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, projectGraphError, nativeTarget, } = await getReportData();
|
52
|
+
const { pm, pmVersion, powerpackLicense, powerpackError, localPlugins, powerpackPlugins, communityPlugins, registeredPlugins, packageVersionsWeCareAbout, outOfSyncPackageGroup, projectGraphError, nativeTarget, cache, } = await getReportData();
|
50
53
|
const fields = [
|
51
54
|
['Node', process.versions.node],
|
52
55
|
['OS', `${process.platform}-${process.arch}`],
|
@@ -123,6 +126,10 @@ async function reportHandler() {
|
|
123
126
|
bodyLines.push(`\t ${chalk.green(plugin)}`);
|
124
127
|
}
|
125
128
|
}
|
129
|
+
if (cache) {
|
130
|
+
bodyLines.push(LINE_SEPARATOR);
|
131
|
+
bodyLines.push(`Cache Usage: ${(0, cache_1.formatCacheSize)(cache.used)} / ${cache.max === 0 ? '∞' : (0, cache_1.formatCacheSize)(cache.max)}`);
|
132
|
+
}
|
126
133
|
if (outOfSyncPackageGroup) {
|
127
134
|
bodyLines.push(LINE_SEPARATOR);
|
128
135
|
bodyLines.push(`The following packages should match the installed version of ${outOfSyncPackageGroup.basePackage}`);
|
@@ -175,6 +182,14 @@ async function getReportData() {
|
|
175
182
|
powerpackError = e;
|
176
183
|
}
|
177
184
|
}
|
185
|
+
let cache = (0, cache_1.dbCacheEnabled)(nxJson)
|
186
|
+
? {
|
187
|
+
max: nxJson.maxCacheSize !== undefined
|
188
|
+
? (0, cache_1.parseMaxCacheSize)(nxJson.maxCacheSize)
|
189
|
+
: (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir),
|
190
|
+
used: new cache_1.DbCache({ nxCloudRemoteCache: null }).getUsedCacheSpace(),
|
191
|
+
}
|
192
|
+
: null;
|
178
193
|
return {
|
179
194
|
pm,
|
180
195
|
powerpackLicense,
|
@@ -188,6 +203,7 @@ async function getReportData() {
|
|
188
203
|
outOfSyncPackageGroup,
|
189
204
|
projectGraphError,
|
190
205
|
nativeTarget: native ? native.getBinaryTarget() : null,
|
206
|
+
cache,
|
191
207
|
};
|
192
208
|
}
|
193
209
|
async function tryGetProjectGraph() {
|
package/src/native/index.d.ts
CHANGED
@@ -42,6 +42,7 @@ export declare class NxCache {
|
|
42
42
|
put(hash: string, terminalOutput: string, outputs: Array<string>, code: number): void
|
43
43
|
applyRemoteCacheResults(hash: string, result: CachedResult, outputs: Array<string>): void
|
44
44
|
getTaskOutputsPath(hash: string): string
|
45
|
+
getCacheSize(): number
|
45
46
|
copyFilesFromCache(cachedResult: CachedResult, outputs: Array<string>): number
|
46
47
|
removeOldCacheRecords(): void
|
47
48
|
checkCacheFsInSync(): boolean
|
@@ -166,6 +167,8 @@ export declare export function findImports(projectFileMap: Record<string, Array<
|
|
166
167
|
|
167
168
|
export declare export function getBinaryTarget(): string
|
168
169
|
|
170
|
+
export declare export function getDefaultMaxCacheSize(cachePath: string): number
|
171
|
+
|
169
172
|
/**
|
170
173
|
* Expands the given outputs into a list of existing files.
|
171
174
|
* This is used when hashing outputs
|
@@ -379,6 +379,7 @@ module.exports.EventType = nativeBinding.EventType
|
|
379
379
|
module.exports.expandOutputs = nativeBinding.expandOutputs
|
380
380
|
module.exports.findImports = nativeBinding.findImports
|
381
381
|
module.exports.getBinaryTarget = nativeBinding.getBinaryTarget
|
382
|
+
module.exports.getDefaultMaxCacheSize = nativeBinding.getDefaultMaxCacheSize
|
382
383
|
module.exports.getFilesForOutputs = nativeBinding.getFilesForOutputs
|
383
384
|
module.exports.getTransformableOutputs = nativeBinding.getTransformableOutputs
|
384
385
|
module.exports.hashArray = nativeBinding.hashArray
|
Binary file
|
@@ -26,6 +26,7 @@ export declare class DbCache {
|
|
26
26
|
});
|
27
27
|
init(): Promise<void>;
|
28
28
|
get(task: Task): Promise<CachedResult | null>;
|
29
|
+
getUsedCacheSpace(): number;
|
29
30
|
private applyRemoteCacheResults;
|
30
31
|
put(task: Task, terminalOutput: string | null, outputs: string[], code: number): Promise<void>;
|
31
32
|
copyFilesFromCache(_: string, cachedResult: CachedResult, outputs: string[]): Promise<number>;
|
@@ -76,4 +77,5 @@ export declare class Cache {
|
|
76
77
|
*
|
77
78
|
* @param maxCacheSize Max cache size as specified in nx.json
|
78
79
|
*/
|
79
|
-
export declare function parseMaxCacheSize(maxCacheSize: string): number | undefined;
|
80
|
+
export declare function parseMaxCacheSize(maxCacheSize: string | number): number | undefined;
|
81
|
+
export declare function formatCacheSize(maxCacheSize: number, decimals?: number): string;
|
@@ -4,6 +4,7 @@ exports.Cache = exports.DbCache = void 0;
|
|
4
4
|
exports.dbCacheEnabled = dbCacheEnabled;
|
5
5
|
exports.getCache = getCache;
|
6
6
|
exports.parseMaxCacheSize = parseMaxCacheSize;
|
7
|
+
exports.formatCacheSize = formatCacheSize;
|
7
8
|
const workspace_root_1 = require("../utils/workspace-root");
|
8
9
|
const path_1 = require("path");
|
9
10
|
const perf_hooks_1 = require("perf_hooks");
|
@@ -70,7 +71,9 @@ class DbCache {
|
|
70
71
|
constructor(options) {
|
71
72
|
this.options = options;
|
72
73
|
this.nxJson = (0, nx_json_1.readNxJson)();
|
73
|
-
this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined,
|
74
|
+
this.cache = new native_1.NxCache(workspace_root_1.workspaceRoot, cache_directory_1.cacheDir, (0, db_connection_1.getDbConnection)(), undefined, this.nxJson.maxCacheSize !== undefined
|
75
|
+
? parseMaxCacheSize(this.nxJson.maxCacheSize)
|
76
|
+
: (0, native_1.getDefaultMaxCacheSize)(cache_directory_1.cacheDir));
|
74
77
|
this.isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
75
78
|
}
|
76
79
|
async init() {
|
@@ -107,6 +110,9 @@ class DbCache {
|
|
107
110
|
return null;
|
108
111
|
}
|
109
112
|
}
|
113
|
+
getUsedCacheSpace() {
|
114
|
+
return this.cache.getCacheSize();
|
115
|
+
}
|
110
116
|
applyRemoteCacheResults(hash, res, outputs) {
|
111
117
|
return this.cache.applyRemoteCacheResults(hash, res, outputs);
|
112
118
|
}
|
@@ -467,10 +473,14 @@ function tryAndRetry(fn) {
|
|
467
473
|
* @param maxCacheSize Max cache size as specified in nx.json
|
468
474
|
*/
|
469
475
|
function parseMaxCacheSize(maxCacheSize) {
|
470
|
-
if (
|
476
|
+
if (maxCacheSize === null || maxCacheSize === undefined) {
|
471
477
|
return undefined;
|
472
478
|
}
|
473
|
-
let regexResult = maxCacheSize
|
479
|
+
let regexResult = maxCacheSize
|
480
|
+
// Covers folks who accidentally specify as a number rather than a string
|
481
|
+
.toString()
|
482
|
+
// Match a number followed by an optional unit (KB, MB, GB), with optional whitespace between the number and unit
|
483
|
+
.match(/^(?<size>[\d|.]+)\s?((?<unit>[KMG]?B)?)$/);
|
474
484
|
if (!regexResult) {
|
475
485
|
throw new Error(`Invalid max cache size specified in nx.json: ${maxCacheSize}. Must be a number followed by an optional unit (KB, MB, GB)`);
|
476
486
|
}
|
@@ -494,3 +504,13 @@ function parseMaxCacheSize(maxCacheSize) {
|
|
494
504
|
return size;
|
495
505
|
}
|
496
506
|
}
|
507
|
+
function formatCacheSize(maxCacheSize, decimals = 2) {
|
508
|
+
const exponents = ['B', 'KB', 'MB', 'GB'];
|
509
|
+
let exponent = 0;
|
510
|
+
let size = maxCacheSize;
|
511
|
+
while (size >= 1024 && exponent < exponents.length - 1) {
|
512
|
+
size /= 1024;
|
513
|
+
exponent++;
|
514
|
+
}
|
515
|
+
return `${size.toFixed(decimals)} ${exponents[exponent]}`;
|
516
|
+
}
|