nx 24.0.2 → 24.0.4
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/dist/bin/nx-cloud.js +9 -0
- package/dist/release/changelog-renderer/index.js +12 -5
- package/dist/src/ai/clone-ai-config-repo.d.ts +2 -1
- package/dist/src/ai/clone-ai-config-repo.js +48 -11
- package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +37 -8
- package/dist/src/analytics/analytics.js +7 -2
- package/dist/src/command-line/ai/ai-output.js +3 -3
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +2 -2
- package/dist/src/command-line/graph/graph.d.ts +10 -0
- package/dist/src/command-line/graph/graph.js +61 -2
- package/dist/src/command-line/import/import.js +18 -30
- package/dist/src/command-line/import/utils/merge-remote-source.d.ts +1 -0
- package/dist/src/command-line/import/utils/merge-remote-source.js +10 -1
- package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +17 -5
- package/dist/src/command-line/init/init-v1.js +2 -2
- package/dist/src/command-line/init/init-v2.js +4 -4
- package/dist/src/command-line/migrate/migrate-analytics.js +2 -2
- package/dist/src/command-line/migrate/migrate.d.ts +3 -0
- package/dist/src/command-line/migrate/migrate.js +40 -22
- package/dist/src/command-line/migrate/workspace-installation.d.ts +15 -0
- package/dist/src/command-line/migrate/workspace-installation.js +73 -0
- package/dist/src/command-line/nx-cloud/complete-run/command-object.js +1 -1
- package/dist/src/command-line/nx-cloud/fix-ci/command-object.js +1 -1
- package/dist/src/command-line/nx-cloud/logout/command-object.js +11 -2
- package/dist/src/command-line/nx-cloud/record/command-object.js +1 -1
- package/dist/src/command-line/nx-cloud/record/record.js +3 -2
- package/dist/src/command-line/nx-cloud/start-ci-run/command-object.js +1 -1
- package/dist/src/command-line/nx-cloud/start-nx-agents/command-object.js +1 -1
- package/dist/src/command-line/nx-commands.js +3 -1
- package/dist/src/command-line/release/changelog/version-plan-filtering.js +4 -1
- package/dist/src/command-line/release/changelog.js +8 -3
- package/dist/src/command-line/release/config/version-plans.js +29 -29
- package/dist/src/command-line/release/utils/git.d.ts +2 -0
- package/dist/src/command-line/release/utils/git.js +49 -26
- package/dist/src/command-line/release/utils/markdown.js +4 -1
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +18 -7
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -1
- package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.js +1 -1
- package/dist/src/command-line/release/version/version-actions.js +2 -1
- package/dist/src/command-line/release/version.js +2 -1
- package/dist/src/command-line/show/show-target/info.d.ts +1 -1
- package/dist/src/command-line/show/show-target/info.js +4 -4
- package/dist/src/core/graph/favicon.ico +0 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/server/latest-nx.js +2 -2
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +3 -1
- package/dist/src/executors/run-commands/running-tasks.js +7 -0
- package/dist/src/executors/run-commands/schema.json +1 -1
- package/dist/src/hasher/native-task-hasher-impl.js +5 -2
- package/dist/src/native/index.d.ts +11 -1
- package/dist/src/native/index.js +12 -17
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +5 -6
- package/dist/src/nx-cloud/update-manager.d.ts +2 -0
- package/dist/src/nx-cloud/utilities/client.d.ts +1 -0
- package/dist/src/nx-cloud/utilities/client.js +5 -0
- package/dist/src/nx-cloud/utilities/get-cloud-options.d.ts +1 -1
- package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
- package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +1 -1
- package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -1
- package/dist/src/nx-cloud/utilities/url-shorten.js +4 -4
- package/dist/src/plugins/js/lock-file/yarn-parser.js +49 -2
- package/dist/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +2 -1
- package/dist/src/plugins/js/utils/register.js +3 -2
- package/dist/src/plugins/js/utils/typescript.js +3 -2
- package/dist/src/project-graph/utils/retrieve-workspace-files.js +2 -2
- package/dist/src/tasks-runner/cache.js +24 -8
- package/dist/src/tasks-runner/default-tasks-runner.js +21 -13
- package/dist/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +34 -13
- package/dist/src/tasks-runner/life-cycles/dynamic-run-one-terminal-output-life-cycle.js +26 -5
- package/dist/src/tasks-runner/life-cycles/performance-report.js +2 -2
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +1 -1
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +1 -1
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +3 -3
- package/dist/src/tasks-runner/life-cycles/tui-summary-life-cycle.js +76 -39
- package/dist/src/tasks-runner/running-tasks/batch-process.d.ts +2 -2
- package/dist/src/tasks-runner/running-tasks/batch-process.js +1 -1
- package/dist/src/tasks-runner/task-orchestrator.d.ts +6 -3
- package/dist/src/tasks-runner/task-orchestrator.js +61 -29
- package/dist/src/utils/git-utils.js +3 -3
- package/dist/src/utils/git-utils.tree-filter.js +102 -24
- package/dist/src/utils/installation-directory.d.ts +8 -0
- package/dist/src/utils/installation-directory.js +13 -0
- package/dist/src/utils/package-manager.d.ts +9 -3
- package/dist/src/utils/package-manager.js +64 -34
- package/dist/src/utils/provenance.d.ts +14 -1
- package/dist/src/utils/provenance.js +44 -13
- package/dist/src/utils/redact-url-credentials.d.ts +1 -0
- package/dist/src/utils/redact-url-credentials.js +7 -0
- package/dist/src/utils/workspace-id.d.ts +4 -3
- package/dist/src/utils/workspace-id.js +4 -3
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_nx_graph_client=self.webpackChunk_nx_graph_client||[]).push([[869],{
|
|
1
|
+
"use strict";(self.webpackChunk_nx_graph_client=self.webpackChunk_nx_graph_client||[]).push([[869],{8516(){}},e=>{e(8516)}]);
|
|
@@ -30,8 +30,8 @@ async function getLatestNxTmpPath() {
|
|
|
30
30
|
installPromise = (async () => {
|
|
31
31
|
try {
|
|
32
32
|
logger_1.serverLogger.log('[LATEST-NX]: Pulling latest Nx...');
|
|
33
|
-
await (0, provenance_1.
|
|
34
|
-
const result = await (0, package_json_1.installPackageToTmpAsync)('nx',
|
|
33
|
+
const version = await (0, provenance_1.resolveVersionWithProvenance)('nx', 'latest');
|
|
34
|
+
const result = await (0, package_json_1.installPackageToTmpAsync)('nx', version, (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot));
|
|
35
35
|
latestNxTmpPath = result.tempDir;
|
|
36
36
|
cleanupFn = result.cleanup;
|
|
37
37
|
logger_1.serverLogger.log('[LATEST-NX]: Successfully pulled latest Nx to', latestNxTmpPath);
|
|
@@ -88,6 +88,9 @@ function kickOffRecompute() {
|
|
|
88
88
|
return chainToSuccessor(myPromise);
|
|
89
89
|
if (cachedSerializedProjectGraphPromise === myPromise &&
|
|
90
90
|
result.projectGraph) {
|
|
91
|
+
if (result.projectFileMapCache) {
|
|
92
|
+
exports.currentProjectFileMapCache = result.projectFileMapCache;
|
|
93
|
+
}
|
|
91
94
|
// The graph identity ties the candidate's generation to exactly this
|
|
92
95
|
// result; a chained result never matches (its computation's kickoff
|
|
93
96
|
// replaced the cached pointer, failing the identity check above).
|
|
@@ -606,7 +609,6 @@ async function createAndSerializeProjectGraph({ projects, externalNodes, sourceM
|
|
|
606
609
|
const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
|
|
607
610
|
const rustReferences = exports.fileMapWithFiles.rustReferences;
|
|
608
611
|
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot)), sourceMaps);
|
|
609
|
-
exports.currentProjectFileMapCache = projectFileMapCache;
|
|
610
612
|
exports.currentProjectGraph = projectGraph;
|
|
611
613
|
exports.currentSourceMaps = sourceMaps;
|
|
612
614
|
perf_hooks_1.performance.mark('create-project-graph-end');
|
|
@@ -195,6 +195,13 @@ class SeriallyRunningTasks {
|
|
|
195
195
|
this.run(options, context)
|
|
196
196
|
.catch((e) => {
|
|
197
197
|
this.error = e;
|
|
198
|
+
this.code = 1;
|
|
199
|
+
const message = e?.message ?? String(e);
|
|
200
|
+
this.terminalOutputChunks.push(message);
|
|
201
|
+
for (const cb of this.outputCallbacks) {
|
|
202
|
+
cb(message);
|
|
203
|
+
}
|
|
204
|
+
streamChunk(message, options.streamOutput, process.stderr);
|
|
198
205
|
})
|
|
199
206
|
.finally(() => {
|
|
200
207
|
const terminalOutput = this.terminalOutputChunks.join('');
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"type": "string"
|
|
142
142
|
}
|
|
143
143
|
],
|
|
144
|
-
"description": "Extra arguments. You can pass them as follows: nx run project:target --args='--wait=100'. You can then use {args.wait} syntax to interpolate them in the workspace config file. See example [above](#
|
|
144
|
+
"description": "Extra arguments. You can pass them as follows: nx run project:target --args='--wait=100'. You can then use {args.wait} syntax to interpolate them in the workspace config file. See example [above](#interpolating-args)"
|
|
145
145
|
},
|
|
146
146
|
"envFile": {
|
|
147
147
|
"type": "string",
|
|
@@ -4,6 +4,7 @@ exports.NativeTaskHasherImpl = void 0;
|
|
|
4
4
|
const native_1 = require("../native");
|
|
5
5
|
const transform_objects_1 = require("../native/transform-objects");
|
|
6
6
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
|
7
|
+
const prune_task_graph_1 = require("../tasks-runner/prune-task-graph");
|
|
7
8
|
const task_io_service_1 = require("../tasks-runner/task-io-service");
|
|
8
9
|
const fileutils_1 = require("../utils/fileutils");
|
|
9
10
|
const overrides_1 = require("../ultracache/overrides");
|
|
@@ -65,10 +66,12 @@ class NativeTaskHasherImpl {
|
|
|
65
66
|
* planner's eligibility walk withholds their entries.
|
|
66
67
|
*/
|
|
67
68
|
plan(taskIds, taskGraph, ultracacheConfigurations) {
|
|
69
|
+
// N-API converts each task's result fields too, which the planner never reads.
|
|
70
|
+
const prunedGraph = (0, prune_task_graph_1.pruneTaskGraph)(taskGraph);
|
|
68
71
|
if (!ultracacheConfigurations) {
|
|
69
|
-
return this.planner.getPlansReference(taskIds,
|
|
72
|
+
return this.planner.getPlansReference(taskIds, prunedGraph);
|
|
70
73
|
}
|
|
71
|
-
return this.planner.getPlansReference(taskIds,
|
|
74
|
+
return this.planner.getPlansReference(taskIds, prunedGraph, ultracacheConfigurations, (0, overrides_1.ultracacheEligibilityOptions)(this.projectGraph, taskGraph));
|
|
72
75
|
}
|
|
73
76
|
async hashTasksUpfront(tasks, taskGraph, perTaskEnvs, cwd, collectInputs, ultracacheConfigurations) {
|
|
74
77
|
const plans = this.plan(tasks.map((t) => t.id), taskGraph, ultracacheConfigurations);
|
|
@@ -148,7 +148,12 @@ export declare class NxCache {
|
|
|
148
148
|
*/
|
|
149
149
|
getBatch(hashes: Array<string>): Array<CachedResult | undefined | null>
|
|
150
150
|
put(hash: string, terminalOutput: string, outputs: Array<string>, code: number): CachedOutputs
|
|
151
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Restores and records a result fetched from a remote cache. Returns
|
|
153
|
+
* false, discarding the artifact, when it holds a link that leaves the
|
|
154
|
+
* output it sits in.
|
|
155
|
+
*/
|
|
156
|
+
applyRemoteCacheResults(hash: string, result: CachedResult, outputs?: Array<string> | undefined | null): boolean
|
|
152
157
|
/**
|
|
153
158
|
* Register terminal outputs that were written without a cache entry —
|
|
154
159
|
* uncacheable tasks, and cacheable ones run with `--skip-nx-cache`.
|
|
@@ -614,6 +619,11 @@ export interface CachedOutputs {
|
|
|
614
619
|
expandedOutputs: Array<string>
|
|
615
620
|
/** Each file copied, stamped as it is in the workspace. */
|
|
616
621
|
files: Array<OutputFile>
|
|
622
|
+
/**
|
|
623
|
+
* Outputs that exist only through a linked directory. When there are
|
|
624
|
+
* any, nothing is stored and the task is not cached.
|
|
625
|
+
*/
|
|
626
|
+
outputsBelowALink: Array<string>
|
|
617
627
|
}
|
|
618
628
|
|
|
619
629
|
export interface CachedPluginCapabilities {
|
package/dist/src/native/index.js
CHANGED
|
@@ -77,10 +77,6 @@ function removeIfPresent(path) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function isNoExecError(e) {
|
|
81
|
-
return e.code === 'EACCES' || e.code === 'EPERM';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
80
|
// We override the _load function so that when a native file is required,
|
|
85
81
|
// we copy it to a cache directory and require it from there.
|
|
86
82
|
// This prevents the file being loaded from node_modules and causing file locking issues.
|
|
@@ -135,17 +131,24 @@ Module._load = function (request, parent, isMain) {
|
|
|
135
131
|
existingFileStats?.size === expectedFileSize &&
|
|
136
132
|
existingFileStats.mtimeMs >= sourceStats.mtimeMs;
|
|
137
133
|
|
|
138
|
-
|
|
139
|
-
if (isFresh) {
|
|
134
|
+
const loadFromCache = () => {
|
|
140
135
|
try {
|
|
141
136
|
return originalLoad.apply(this, [tmpFile, parent, isMain]);
|
|
142
137
|
} catch (e) {
|
|
143
|
-
|
|
144
|
-
|
|
138
|
+
if (
|
|
139
|
+
e.code === 'EACCES' ||
|
|
140
|
+
e.code === 'EPERM' ||
|
|
141
|
+
e.code === 'MODULE_NOT_FOUND' ||
|
|
142
|
+
e.code === 'ERR_DLOPEN_FAILED'
|
|
143
|
+
) {
|
|
145
144
|
return originalLoad.apply(this, [nativeLocation, parent, isMain]);
|
|
146
145
|
}
|
|
147
146
|
throw e;
|
|
148
147
|
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
if (isFresh) {
|
|
151
|
+
return loadFromCache();
|
|
149
152
|
}
|
|
150
153
|
|
|
151
154
|
// Retry copying up to 3 times, validating after each copy
|
|
@@ -177,15 +180,7 @@ Module._load = function (request, parent, isMain) {
|
|
|
177
180
|
removeIfPresent(tmpTmpFile);
|
|
178
181
|
break;
|
|
179
182
|
}
|
|
180
|
-
|
|
181
|
-
return originalLoad.apply(this, [tmpFile, parent, isMain]);
|
|
182
|
-
} catch (e) {
|
|
183
|
-
// If loading from cache fails due to noexec, fall back to original location
|
|
184
|
-
if (isNoExecError(e)) {
|
|
185
|
-
return originalLoad.apply(this, [nativeLocation, parent, isMain]);
|
|
186
|
-
}
|
|
187
|
-
throw e;
|
|
188
|
-
}
|
|
183
|
+
return loadFromCache();
|
|
189
184
|
}
|
|
190
185
|
|
|
191
186
|
// Copy failed validation, clean up the malformed file
|
|
Binary file
|
|
Binary file
|
|
@@ -45,8 +45,7 @@ function getNxInitDate() {
|
|
|
45
45
|
return new Date().toISOString();
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
async function createNxCloudWorkspaceV1(workspaceName, installationSource, nxInitDate) {
|
|
49
|
-
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
|
48
|
+
async function createNxCloudWorkspaceV1(apiUrl, workspaceName, installationSource, nxInitDate) {
|
|
50
49
|
const response = await (0, http_client_1.httpRequest)(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
|
|
51
50
|
method: 'POST',
|
|
52
51
|
data: {
|
|
@@ -60,8 +59,7 @@ async function createNxCloudWorkspaceV1(workspaceName, installationSource, nxIni
|
|
|
60
59
|
}
|
|
61
60
|
return response.data;
|
|
62
61
|
}
|
|
63
|
-
async function createNxCloudWorkspaceV2(workspaceName, installationSource, nxInitDate) {
|
|
64
|
-
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
|
62
|
+
async function createNxCloudWorkspaceV2(apiUrl, workspaceName, installationSource, nxInitDate) {
|
|
65
63
|
const response = await (0, http_client_1.httpRequest)(`${apiUrl}/nx-cloud/v2/create-org-and-workspace`, {
|
|
66
64
|
method: 'POST',
|
|
67
65
|
data: {
|
|
@@ -131,12 +129,13 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
|
|
|
131
129
|
(schema.installationSource === 'nx-connect' ||
|
|
132
130
|
schema.installationSource === 'nx-console'))
|
|
133
131
|
return null;
|
|
132
|
+
const apiUrl = (0, get_cloud_options_1.getCloudUrl)((0, path_1.join)(tree.root, schema.directory ?? ''));
|
|
134
133
|
try {
|
|
135
|
-
responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(getRootPackageName(tree, schema.directory), schema.installationSource, getNxInitDate());
|
|
134
|
+
responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(apiUrl, getRootPackageName(tree, schema.directory), schema.installationSource, getNxInitDate());
|
|
136
135
|
}
|
|
137
136
|
catch (e) {
|
|
138
137
|
if (e.response?.status === 404) {
|
|
139
|
-
responseFromCreateNxCloudWorkspaceV1 = await createNxCloudWorkspaceV1(getRootPackageName(tree, schema.directory), schema.installationSource, getNxInitDate());
|
|
138
|
+
responseFromCreateNxCloudWorkspaceV1 = await createNxCloudWorkspaceV1(apiUrl, getRootPackageName(tree, schema.directory), schema.installationSource, getNxInitDate());
|
|
140
139
|
}
|
|
141
140
|
else {
|
|
142
141
|
throw e;
|
|
@@ -27,6 +27,8 @@ export interface NxCloudClient {
|
|
|
27
27
|
}) => Promise<{
|
|
28
28
|
enabled: boolean;
|
|
29
29
|
}>;
|
|
30
|
+
/** Clients that dispatch a whole `nx-cloud` command line; resolves to the exit code. */
|
|
31
|
+
runCLI?: (args: string[]) => Promise<number>;
|
|
30
32
|
}
|
|
31
33
|
export declare function verifyOrUpdateNxCloudClient(options?: {
|
|
32
34
|
url?: string;
|
|
@@ -7,4 +7,5 @@ export declare class UnknownCommandError extends Error {
|
|
|
7
7
|
export declare function getCloudClient(options: CloudTaskRunnerOptions): Promise<{
|
|
8
8
|
invoke: (command: string, exit?: boolean) => Promise<void>;
|
|
9
9
|
availableCommands: string[];
|
|
10
|
+
runCLI: (args: string[]) => Promise<number>;
|
|
10
11
|
}>;
|
|
@@ -38,5 +38,10 @@ async function getCloudClient(options) {
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
availableCommands: Object.keys(nxCloudClient.commands),
|
|
41
|
+
// Bundles that export runCLI own dispatch, help, output and the exit code.
|
|
42
|
+
// Older bundles only export `commands`.
|
|
43
|
+
runCLI: typeof nxCloudClient.runCLI === 'function'
|
|
44
|
+
? (args) => nxCloudClient.runCLI(args)
|
|
45
|
+
: undefined,
|
|
41
46
|
};
|
|
42
47
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CloudTaskRunnerOptions } from '../nx-cloud-tasks-runner-shell';
|
|
2
2
|
export declare function getCloudOptions(directory?: string): CloudTaskRunnerOptions;
|
|
3
|
-
export declare function getCloudUrl(): string;
|
|
3
|
+
export declare function getCloudUrl(directory?: string): string;
|
|
4
4
|
export declare function removeTrailingSlash(apiUrl: string): string;
|
|
5
5
|
export declare function isNxCloudId(token: string): boolean;
|
|
@@ -15,8 +15,11 @@ function getCloudOptions(directory = workspace_root_1.workspaceRoot) {
|
|
|
15
15
|
// TODO: The default is not always cloud? But it's not handled at the moment
|
|
16
16
|
return getRunnerOptions('default', nxJson, {}, true);
|
|
17
17
|
}
|
|
18
|
-
function getCloudUrl() {
|
|
19
|
-
return removeTrailingSlash(process.env.NX_CLOUD_API ||
|
|
18
|
+
function getCloudUrl(directory = workspace_root_1.workspaceRoot) {
|
|
19
|
+
return removeTrailingSlash(process.env.NX_CLOUD_API ||
|
|
20
|
+
process.env.NRWL_API ||
|
|
21
|
+
getCloudOptions(directory).url ||
|
|
22
|
+
`https://cloud.nx.app`);
|
|
20
23
|
}
|
|
21
24
|
function removeTrailingSlash(apiUrl) {
|
|
22
25
|
return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl;
|
|
@@ -6,8 +6,8 @@ const http_client_1 = require("../../utils/http-client");
|
|
|
6
6
|
async function isWorkspaceClaimed(accessToken) {
|
|
7
7
|
if (!accessToken)
|
|
8
8
|
return false;
|
|
9
|
-
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
|
10
9
|
try {
|
|
10
|
+
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
|
11
11
|
const requestData = (0, get_cloud_options_1.isNxCloudId)(accessToken)
|
|
12
12
|
? { nxCloudId: accessToken }
|
|
13
13
|
: { nxCloudAccessToken: accessToken };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare function createNxCloudOnboardingURL(onboardingSource: string, accessToken?: string, meta?: string, forceManual?: boolean, forceGithub?: boolean, directory?: string, signal?: AbortSignal): Promise<string>;
|
|
2
|
-
export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string | null, apiUrl: string, source: string
|
|
2
|
+
export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string | null, apiUrl: string, source: string): string;
|
|
@@ -12,7 +12,7 @@ async function createNxCloudOnboardingURL(onboardingSource, accessToken, meta, f
|
|
|
12
12
|
// the event loop open, since these requests have no timeout.
|
|
13
13
|
signal) {
|
|
14
14
|
const remoteInfo = (0, git_utils_1.getVcsRemoteInfo)(directory);
|
|
15
|
-
const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
|
|
15
|
+
const apiUrl = (0, get_cloud_options_1.getCloudUrl)(directory);
|
|
16
16
|
const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl, signal);
|
|
17
17
|
let usesGithub = false;
|
|
18
18
|
if (forceGithub) {
|
|
@@ -47,7 +47,7 @@ signal) {
|
|
|
47
47
|
catch (e) {
|
|
48
48
|
logger_1.logger.verbose(`Failed to shorten Nx Cloud URL.
|
|
49
49
|
${e}`);
|
|
50
|
-
return getURLifShortenFailed(usesGithub, usesGithub ? remoteInfo?.slug : null, apiUrl, source
|
|
50
|
+
return getURLifShortenFailed(usesGithub, usesGithub ? remoteInfo?.slug : null, apiUrl, source);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
function getSource(installationSource) {
|
|
@@ -61,7 +61,7 @@ function getSource(installationSource) {
|
|
|
61
61
|
return installationSource;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source
|
|
64
|
+
function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source) {
|
|
65
65
|
if (usesGithub) {
|
|
66
66
|
if (githubSlug) {
|
|
67
67
|
return `${apiUrl}/setup/connect-workspace/github/connect?name=${encodeURIComponent(githubSlug)}&source=${source}`;
|
|
@@ -70,7 +70,7 @@ function getURLifShortenFailed(usesGithub, githubSlug, apiUrl, source, accessTok
|
|
|
70
70
|
return `${apiUrl}/setup/connect-workspace/github/select?source=${source}`;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
return `${apiUrl}/setup/connect-workspace/manual?
|
|
73
|
+
return `${apiUrl}/setup/connect-workspace/manual?source=${source}`;
|
|
74
74
|
}
|
|
75
75
|
async function getInstallationSupportsGitHub(apiUrl, signal) {
|
|
76
76
|
try {
|
|
@@ -58,9 +58,23 @@ function getNodes(dependencies, packageJson, isBerry) {
|
|
|
58
58
|
...packageJson.peerDependencies,
|
|
59
59
|
...packageJson.optionalDependencies,
|
|
60
60
|
};
|
|
61
|
+
// @patch: descriptors are not their own nodes. Their checksum and resolution
|
|
62
|
+
// are folded into the matching package node so a patch changes its hash.
|
|
63
|
+
const patchesByPackage = new Map();
|
|
61
64
|
Object.entries(dependencies).forEach(([keys, snapshot]) => {
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
if (snapshot.linkType === 'soft') {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (keys.includes('@patch:')) {
|
|
69
|
+
for (const packageName of getPackageNameKeyPairs(keys).keys()) {
|
|
70
|
+
const patches = patchesByPackage.get(packageName);
|
|
71
|
+
if (patches) {
|
|
72
|
+
patches.push(snapshot);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
patchesByPackage.set(packageName, [snapshot]);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
64
78
|
return;
|
|
65
79
|
}
|
|
66
80
|
const nameKeyPairs = getPackageNameKeyPairs(keys);
|
|
@@ -103,6 +117,7 @@ function getNodes(dependencies, packageJson, isBerry) {
|
|
|
103
117
|
});
|
|
104
118
|
});
|
|
105
119
|
});
|
|
120
|
+
foldPatchIntoExternalNodeHashes(nodes, patchesByPackage);
|
|
106
121
|
const externalNodes = {};
|
|
107
122
|
for (const [packageName, versionMap] of nodes.entries()) {
|
|
108
123
|
// If there's only one version of a package, treat it as hoisted
|
|
@@ -120,6 +135,38 @@ function getNodes(dependencies, packageJson, isBerry) {
|
|
|
120
135
|
}
|
|
121
136
|
return { nodes: externalNodes, keyMap };
|
|
122
137
|
}
|
|
138
|
+
function foldPatchIntoExternalNodeHashes(nodes, patchesByPackage) {
|
|
139
|
+
for (const [packageName, patches] of patchesByPackage) {
|
|
140
|
+
const versionMap = nodes.get(packageName);
|
|
141
|
+
if (!versionMap) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
for (const [versionKey, node] of versionMap) {
|
|
145
|
+
const seen = new Set();
|
|
146
|
+
const parts = [];
|
|
147
|
+
const matching = patches
|
|
148
|
+
.filter((patch) => !!patch.version &&
|
|
149
|
+
(patch.version === versionKey ||
|
|
150
|
+
patch.version === node.data.version))
|
|
151
|
+
.sort((a, b) => patchSortKey(a).localeCompare(patchSortKey(b)));
|
|
152
|
+
for (const patch of matching) {
|
|
153
|
+
const patchParts = [patch.checksum, patch.resolution].filter((part) => !!part);
|
|
154
|
+
const id = patchParts.join('\0');
|
|
155
|
+
if (!id || seen.has(id)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
seen.add(id);
|
|
159
|
+
parts.push(...patchParts);
|
|
160
|
+
}
|
|
161
|
+
if (parts.length > 0) {
|
|
162
|
+
node.data.hash = (0, file_hasher_1.hashArray)([node.data.hash, ...parts]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function patchSortKey(snapshot) {
|
|
168
|
+
return `${snapshot.resolution ?? ''}\0${snapshot.checksum ?? ''}`;
|
|
169
|
+
}
|
|
123
170
|
function findHoistedNode(packageName, versionMap, combinedDeps) {
|
|
124
171
|
const hoistedVersion = getHoistedVersion(packageName);
|
|
125
172
|
if (hoistedVersion) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildExplicitDependencies = buildExplicitDependencies;
|
|
4
|
+
const installation_directory_1 = require("../../../../utils/installation-directory");
|
|
4
5
|
const explicit_package_json_dependencies_1 = require("./explicit-package-json-dependencies");
|
|
5
6
|
const explicit_project_dependencies_1 = require("./explicit-project-dependencies");
|
|
6
7
|
const target_project_locator_1 = require("./target-project-locator");
|
|
@@ -24,7 +25,7 @@ function buildExplicitDependencies(jsPluginConfig, ctx) {
|
|
|
24
25
|
jsPluginConfig.analyzeSourceFiles === true) {
|
|
25
26
|
let tsExists = false;
|
|
26
27
|
try {
|
|
27
|
-
|
|
28
|
+
(0, installation_directory_1.resolveFromWorkspace)('typescript');
|
|
28
29
|
tsExists = true;
|
|
29
30
|
}
|
|
30
31
|
catch { }
|
|
@@ -25,6 +25,7 @@ exports.getTsNodeCompilerOptions = getTsNodeCompilerOptions;
|
|
|
25
25
|
const path_1 = require("path");
|
|
26
26
|
const fs_1 = require("fs");
|
|
27
27
|
const fileutils_1 = require("../../../utils/fileutils");
|
|
28
|
+
const installation_directory_1 = require("../../../utils/installation-directory");
|
|
28
29
|
const logger_1 = require("../../../utils/logger");
|
|
29
30
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
30
31
|
const typescript_1 = require("./typescript");
|
|
@@ -664,7 +665,7 @@ const registered = new Map();
|
|
|
664
665
|
function getTranspiler(compilerOptions, tsConfigRaw) {
|
|
665
666
|
const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';
|
|
666
667
|
if (!ts) {
|
|
667
|
-
ts = require('typescript');
|
|
668
|
+
ts = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
|
|
668
669
|
}
|
|
669
670
|
compilerOptions.lib = ['es2021'];
|
|
670
671
|
compilerOptions.module = ts.ModuleKind.CommonJS;
|
|
@@ -1181,7 +1182,7 @@ function packageIsInstalled(m) {
|
|
|
1181
1182
|
*/
|
|
1182
1183
|
function getTsNodeCompilerOptions(compilerOptions) {
|
|
1183
1184
|
if (!ts) {
|
|
1184
|
-
ts = require('typescript');
|
|
1185
|
+
ts = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
|
|
1185
1186
|
}
|
|
1186
1187
|
const flagMap = {
|
|
1187
1188
|
module: 'ModuleKind',
|
|
@@ -10,6 +10,7 @@ exports.getRootTsConfigCustomConditions = getRootTsConfigCustomConditions;
|
|
|
10
10
|
exports.getRootTsConfigResolveExportsConditions = getRootTsConfigResolveExportsConditions;
|
|
11
11
|
exports.getPluginResolveConditionNodeArgs = getPluginResolveConditionNodeArgs;
|
|
12
12
|
exports.findNodes = findNodes;
|
|
13
|
+
const installation_directory_1 = require("../../../utils/installation-directory");
|
|
13
14
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
|
14
15
|
const fs_1 = require("fs");
|
|
15
16
|
const path_1 = require("path");
|
|
@@ -17,7 +18,7 @@ const normalizedAppRoot = workspace_root_1.workspaceRoot.replace(/\\/g, '/');
|
|
|
17
18
|
let tsModule;
|
|
18
19
|
function readTsConfig(tsConfigPath, sys) {
|
|
19
20
|
if (!tsModule) {
|
|
20
|
-
tsModule = require('typescript');
|
|
21
|
+
tsModule = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
|
|
21
22
|
}
|
|
22
23
|
sys ??= tsModule.sys;
|
|
23
24
|
const readResult = tsModule.readConfigFile(tsConfigPath, sys.readFile);
|
|
@@ -25,7 +26,7 @@ function readTsConfig(tsConfigPath, sys) {
|
|
|
25
26
|
}
|
|
26
27
|
function readTsConfigWithoutFiles(tsConfigPath) {
|
|
27
28
|
if (!tsModule) {
|
|
28
|
-
tsModule = require('typescript');
|
|
29
|
+
tsModule = require((0, installation_directory_1.resolveFromWorkspace)('typescript'));
|
|
29
30
|
}
|
|
30
31
|
// We only care about options, so we don't need to scan source files, and thus
|
|
31
32
|
// `readDirectory` is stubbed for performance.
|
|
@@ -59,13 +59,13 @@ async function retrieveProjectConfigurations(separatedPlugins, workspaceRoot, nx
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
|
|
62
|
-
const pluginsToLoad = nxJson?.plugins ?? [];
|
|
62
|
+
const pluginsToLoad = [...(nxJson?.plugins ?? [])];
|
|
63
63
|
if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, true) &&
|
|
64
64
|
!pluginsToLoad.some((p) => p === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME ||
|
|
65
65
|
(typeof p === 'object' && p.plugin === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME))) {
|
|
66
66
|
pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
|
|
67
67
|
}
|
|
68
|
-
const separatedPlugins = await (0, get_plugins_1.getPluginsSeparated)(nxJson, workspaceRoot);
|
|
68
|
+
const separatedPlugins = await (0, get_plugins_1.getPluginsSeparated)({ ...nxJson, plugins: pluginsToLoad }, workspaceRoot);
|
|
69
69
|
const res = await retrieveProjectConfigurations(separatedPlugins, workspaceRoot, nxJson);
|
|
70
70
|
return res;
|
|
71
71
|
}
|
|
@@ -107,8 +107,7 @@ class DbCache {
|
|
|
107
107
|
// didn't find it locally but we have a remote cache
|
|
108
108
|
// attempt remote cache
|
|
109
109
|
const res = await this.remoteCache.retrieve(task.hash, this.cache.cacheDirectory);
|
|
110
|
-
if (res) {
|
|
111
|
-
this.applyRemoteCacheResults(task.hash, res, task.outputs);
|
|
110
|
+
if (res && this.applyRemoteCacheResults(task, res)) {
|
|
112
111
|
return {
|
|
113
112
|
...res,
|
|
114
113
|
terminalOutput: res.terminalOutput ?? '',
|
|
@@ -159,8 +158,7 @@ class DbCache {
|
|
|
159
158
|
if (remoteMisses.length > 0) {
|
|
160
159
|
await Promise.all(remoteMisses.map(async (task) => {
|
|
161
160
|
const res = await this.remoteCache.retrieve(task.hash, this.cache.cacheDirectory);
|
|
162
|
-
if (res) {
|
|
163
|
-
this.applyRemoteCacheResults(task.hash, res, task.outputs);
|
|
161
|
+
if (res && this.applyRemoteCacheResults(task, res)) {
|
|
164
162
|
results.set(task.hash, {
|
|
165
163
|
...res,
|
|
166
164
|
terminalOutput: res.terminalOutput ?? '',
|
|
@@ -174,15 +172,33 @@ class DbCache {
|
|
|
174
172
|
getUsedCacheSpace() {
|
|
175
173
|
return this.cache.getCacheSize();
|
|
176
174
|
}
|
|
177
|
-
applyRemoteCacheResults(
|
|
178
|
-
|
|
175
|
+
applyRemoteCacheResults(task, res) {
|
|
176
|
+
const applied = this.cache.applyRemoteCacheResults(task.hash, res, task.outputs);
|
|
177
|
+
if (!applied) {
|
|
178
|
+
output_1.output.warn({
|
|
179
|
+
title: `Ignoring the remote cache result for ${task.id}`,
|
|
180
|
+
bodyLines: [
|
|
181
|
+
'Its outputs contain a symlink that points outside the output it is in.',
|
|
182
|
+
],
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return applied;
|
|
179
186
|
}
|
|
180
187
|
async put(task, terminalOutput, outputs, code) {
|
|
181
188
|
return tryAndRetry(async () => {
|
|
182
|
-
const { expandedOutputs, files } = this.cache.put(task.hash, terminalOutput, outputs, code);
|
|
189
|
+
const { expandedOutputs, files, outputsBelowALink } = this.cache.put(task.hash, terminalOutput, outputs, code);
|
|
183
190
|
// Notify TaskIOService of actual output files
|
|
184
191
|
(0, task_io_service_1.getTaskIOService)().notifyTaskOutputs(task.id, expandedOutputs);
|
|
185
|
-
if (
|
|
192
|
+
if (outputsBelowALink.length > 0) {
|
|
193
|
+
output_1.output.warn({
|
|
194
|
+
title: `Not caching ${task.id}`,
|
|
195
|
+
bodyLines: [
|
|
196
|
+
'These outputs are inside a symlinked directory, so they cannot be cached:',
|
|
197
|
+
...outputsBelowALink.map((o) => `- ${o}`),
|
|
198
|
+
],
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
else if (this.remoteCache) {
|
|
186
202
|
await this.remoteCache.store(task.hash, this.cache.cacheDirectory, terminalOutput, code);
|
|
187
203
|
}
|
|
188
204
|
return files;
|
|
@@ -6,27 +6,35 @@ const performance_life_cycle_1 = require("./life-cycles/performance-life-cycle")
|
|
|
6
6
|
const cache_directory_1 = require("../utils/cache-directory");
|
|
7
7
|
const promises_1 = require("fs/promises");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
async function readRegularFile(path) {
|
|
10
|
+
const stats = await (0, promises_1.lstat)(path).catch(() => null);
|
|
11
|
+
return stats?.isFile() ? (0, promises_1.readFile)(path, 'utf-8').catch(() => null) : null;
|
|
12
|
+
}
|
|
9
13
|
class RemoteCacheV2 {
|
|
10
14
|
static async fromCacheV1(cache) {
|
|
11
15
|
await (0, promises_1.mkdir)((0, path_1.join)(cache_directory_1.cacheDir, 'terminalOutputs'), { recursive: true });
|
|
12
16
|
return {
|
|
13
17
|
retrieve: async (hash, cacheDirectory) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const [terminalOutput, oldTerminalOutput, code] = await Promise.all([
|
|
17
|
-
(0, promises_1.readFile)((0, path_1.join)(cacheDirectory, hash, 'terminalOutputs'), 'utf-8').catch(() => null),
|
|
18
|
-
(0, promises_1.readFile)((0, path_1.join)(cache_directory_1.cacheDir, 'terminalOutputs', hash), 'utf-8').catch(() => null),
|
|
19
|
-
(0, promises_1.readFile)((0, path_1.join)(cacheDirectory, hash, 'code'), 'utf-8').then((s) => +s),
|
|
20
|
-
]);
|
|
21
|
-
return {
|
|
22
|
-
outputsPath: (0, path_1.join)(cacheDirectory, hash, 'outputs'),
|
|
23
|
-
terminalOutput: terminalOutput ?? oldTerminalOutput,
|
|
24
|
-
code,
|
|
25
|
-
};
|
|
18
|
+
if (!(await cache.retrieve(hash, cacheDirectory))) {
|
|
19
|
+
return null;
|
|
26
20
|
}
|
|
27
|
-
|
|
21
|
+
const entry = (0, path_1.join)(cacheDirectory, hash);
|
|
22
|
+
const [outputs, terminalOutputs, code] = await Promise.all(['outputs', 'terminalOutputs', 'code'].map((name) => (0, promises_1.lstat)((0, path_1.join)(entry, name)).catch(() => null)));
|
|
23
|
+
if ((outputs && !outputs.isDirectory()) ||
|
|
24
|
+
(terminalOutputs && !terminalOutputs.isFile()) ||
|
|
25
|
+
!code?.isFile()) {
|
|
28
26
|
return null;
|
|
29
27
|
}
|
|
28
|
+
const [terminalOutput, oldTerminalOutput, exitCode] = await Promise.all([
|
|
29
|
+
readRegularFile((0, path_1.join)(entry, 'terminalOutputs')),
|
|
30
|
+
readRegularFile((0, path_1.join)(cache_directory_1.cacheDir, 'terminalOutputs', hash)),
|
|
31
|
+
(0, promises_1.readFile)((0, path_1.join)(entry, 'code'), 'utf-8'),
|
|
32
|
+
]);
|
|
33
|
+
return {
|
|
34
|
+
outputsPath: (0, path_1.join)(entry, 'outputs'),
|
|
35
|
+
terminalOutput: terminalOutput ?? oldTerminalOutput,
|
|
36
|
+
code: +exitCode,
|
|
37
|
+
};
|
|
30
38
|
},
|
|
31
39
|
store: async (hash, cacheDirectory, terminalOutput, code) => {
|
|
32
40
|
// The new db cache places the outputs directly into the cacheDirectory + hash.
|