nx 16.8.1 → 16.9.0-beta.1
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/README.md +1 -1
- package/bin/nx.js +6 -1
- package/package.json +13 -14
- package/src/command-line/affected/print-affected.js +1 -2
- package/src/command-line/graph/graph.js +0 -2
- package/src/command-line/repair/command-object.js +10 -1
- package/src/daemon/server/handle-hash-tasks.js +1 -2
- package/src/daemon/server/handle-request-file-data.js +3 -2
- package/src/daemon/server/outputs-tracking.js +3 -18
- package/src/daemon/server/project-graph-incremental-recomputation.js +7 -5
- package/src/daemon/server/server.js +4 -2
- package/src/devkit-exports.d.ts +1 -1
- package/src/devkit-internals.d.ts +1 -0
- package/src/devkit-internals.js +3 -1
- package/src/hasher/file-hasher.d.ts +0 -13
- package/src/hasher/file-hasher.js +1 -63
- package/src/hasher/task-hasher.d.ts +1 -3
- package/src/hasher/task-hasher.js +12 -6
- package/src/native/index.d.ts +14 -14
- package/src/native/index.js +2 -4
- package/src/plugins/js/index.js +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +3 -2
- package/src/plugins/js/lock-file/lock-file.js +4 -4
- package/src/plugins/js/lock-file/npm-parser.d.ts +3 -2
- package/src/plugins/js/lock-file/npm-parser.js +12 -12
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +3 -2
- package/src/plugins/js/lock-file/pnpm-parser.js +7 -7
- package/src/plugins/js/lock-file/yarn-parser.d.ts +3 -2
- package/src/plugins/js/lock-file/yarn-parser.js +5 -5
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +2 -2
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +2 -2
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.js +16 -17
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +2 -2
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +47 -13
- package/src/project-graph/build-project-graph.js +9 -3
- package/src/project-graph/file-map-utils.js +3 -3
- package/src/project-graph/project-graph-builder.d.ts +50 -7
- package/src/project-graph/project-graph-builder.js +46 -30
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +4 -0
- package/src/project-graph/utils/retrieve-workspace-files.js +8 -11
- package/src/tasks-runner/run-command.js +1 -2
- package/src/utils/all-file-data.js +3 -3
- package/src/utils/ignore.d.ts +0 -1
- package/src/utils/ignore.js +0 -1
- package/src/utils/nx-plugin.d.ts +8 -7
- package/src/utils/workspace-context.d.ts +8 -0
- package/src/utils/workspace-context.js +46 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[]()
|
|
9
9
|
[](http://commitizen.github.io/cz-cli/)
|
|
10
10
|
[](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
11
|
-
[](https://go.nx.dev/community)
|
|
12
12
|
|
|
13
13
|
</div>
|
|
14
14
|
|
package/bin/nx.js
CHANGED
|
@@ -15,6 +15,8 @@ const child_process_1 = require("child_process");
|
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const assert_supported_platform_1 = require("../src/native/assert-supported-platform");
|
|
17
17
|
const perf_hooks_1 = require("perf_hooks");
|
|
18
|
+
const workspace_context_1 = require("../src/utils/workspace-context");
|
|
19
|
+
const client_1 = require("../src/daemon/client/client");
|
|
18
20
|
function main() {
|
|
19
21
|
if (process.argv[2] !== 'report' &&
|
|
20
22
|
process.argv[2] !== '--version' &&
|
|
@@ -42,9 +44,12 @@ function main() {
|
|
|
42
44
|
// Angular CLI, and prettier both use ESM so we need to disable it in these cases.
|
|
43
45
|
if (workspace &&
|
|
44
46
|
workspace.type === 'nx' &&
|
|
45
|
-
!['format', 'format:check', 'format:write', 'g', 'generate'].some((cmd) => process.argv[
|
|
47
|
+
!['format', 'format:check', 'format:write', 'g', 'generate'].some((cmd) => process.argv[2] === cmd)) {
|
|
46
48
|
require('v8-compile-cache');
|
|
47
49
|
}
|
|
50
|
+
if (!client_1.daemonClient.enabled() && workspace !== null) {
|
|
51
|
+
(0, workspace_context_1.setupWorkspaceContext)(workspace.dir);
|
|
52
|
+
}
|
|
48
53
|
// polyfill rxjs observable to avoid issues with multiple version of Observable installed in node_modules
|
|
49
54
|
// https://twitter.com/BenLesh/status/1192478226385428483?s=20
|
|
50
55
|
if (!Symbol.observable)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.9.0-beta.1",
|
|
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": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://nx.dev",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nrwl/tao": "16.
|
|
35
|
+
"@nrwl/tao": "16.9.0-beta.1",
|
|
36
36
|
"@parcel/watcher": "2.0.4",
|
|
37
37
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
38
38
|
"@yarnpkg/parsers": "3.0.0-rc.46",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"dotenv": "~16.3.1",
|
|
46
46
|
"dotenv-expand": "~10.0.0",
|
|
47
47
|
"enquirer": "~2.3.6",
|
|
48
|
-
"fast-glob": "3.2.7",
|
|
49
48
|
"figures": "3.2.0",
|
|
50
49
|
"flat": "^5.0.2",
|
|
51
50
|
"fs-extra": "^11.1.0",
|
|
@@ -82,16 +81,16 @@
|
|
|
82
81
|
}
|
|
83
82
|
},
|
|
84
83
|
"optionalDependencies": {
|
|
85
|
-
"@nx/nx-darwin-arm64": "16.
|
|
86
|
-
"@nx/nx-darwin-x64": "16.
|
|
87
|
-
"@nx/nx-freebsd-x64": "16.
|
|
88
|
-
"@nx/nx-linux-arm-gnueabihf": "16.
|
|
89
|
-
"@nx/nx-linux-arm64-gnu": "16.
|
|
90
|
-
"@nx/nx-linux-arm64-musl": "16.
|
|
91
|
-
"@nx/nx-linux-x64-gnu": "16.
|
|
92
|
-
"@nx/nx-linux-x64-musl": "16.
|
|
93
|
-
"@nx/nx-win32-arm64-msvc": "16.
|
|
94
|
-
"@nx/nx-win32-x64-msvc": "16.
|
|
84
|
+
"@nx/nx-darwin-arm64": "16.9.0-beta.1",
|
|
85
|
+
"@nx/nx-darwin-x64": "16.9.0-beta.1",
|
|
86
|
+
"@nx/nx-freebsd-x64": "16.9.0-beta.1",
|
|
87
|
+
"@nx/nx-linux-arm-gnueabihf": "16.9.0-beta.1",
|
|
88
|
+
"@nx/nx-linux-arm64-gnu": "16.9.0-beta.1",
|
|
89
|
+
"@nx/nx-linux-arm64-musl": "16.9.0-beta.1",
|
|
90
|
+
"@nx/nx-linux-x64-gnu": "16.9.0-beta.1",
|
|
91
|
+
"@nx/nx-linux-x64-musl": "16.9.0-beta.1",
|
|
92
|
+
"@nx/nx-win32-arm64-msvc": "16.9.0-beta.1",
|
|
93
|
+
"@nx/nx-win32-x64-msvc": "16.9.0-beta.1"
|
|
95
94
|
},
|
|
96
95
|
"nx-migrations": {
|
|
97
96
|
"migrations": "./migrations.json",
|
|
@@ -178,5 +177,5 @@
|
|
|
178
177
|
},
|
|
179
178
|
"main": "./bin/nx.js",
|
|
180
179
|
"type": "commonjs",
|
|
181
|
-
"gitHead": "
|
|
180
|
+
"gitHead": "5056d6cefb2949ba865019e8b71e633fba28c091"
|
|
182
181
|
}
|
|
@@ -6,7 +6,6 @@ const create_task_graph_1 = require("../../tasks-runner/create-task-graph");
|
|
|
6
6
|
const task_hasher_1 = require("../../hasher/task-hasher");
|
|
7
7
|
const hash_task_1 = require("../../hasher/hash-task");
|
|
8
8
|
const package_manager_1 = require("../../utils/package-manager");
|
|
9
|
-
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
10
9
|
const command_object_1 = require("./command-object");
|
|
11
10
|
const logger_1 = require("../../utils/logger");
|
|
12
11
|
/**
|
|
@@ -35,7 +34,7 @@ exports.printAffected = printAffected;
|
|
|
35
34
|
async function createTasks(affectedProjectsWithTargetAndConfig, projectGraph, nxArgs, nxJson, overrides) {
|
|
36
35
|
const defaultDependencyConfigs = (0, create_task_graph_1.mapTargetDefaultsToDependencies)(nxJson.targetDefaults);
|
|
37
36
|
const taskGraph = (0, create_task_graph_1.createTaskGraph)(projectGraph, defaultDependencyConfigs, affectedProjectsWithTargetAndConfig.map((p) => p.name), nxArgs.targets, nxArgs.configuration, overrides);
|
|
38
|
-
const hasher = new task_hasher_1.InProcessTaskHasher({}, [], projectGraph, nxJson, {}
|
|
37
|
+
const hasher = new task_hasher_1.InProcessTaskHasher({}, [], projectGraph, nxJson, {});
|
|
39
38
|
const execCommand = (0, package_manager_1.getPackageManagerCommand)().exec;
|
|
40
39
|
const tasks = Object.values(taskGraph.tasks);
|
|
41
40
|
await Promise.all(tasks.map((t) => (0, hash_task_1.hashTask)(hasher, projectGraph, taskGraph, t)));
|
|
@@ -18,7 +18,6 @@ const project_graph_1 = require("../../project-graph/project-graph");
|
|
|
18
18
|
const create_task_graph_1 = require("../../tasks-runner/create-task-graph");
|
|
19
19
|
const client_1 = require("../../daemon/client/client");
|
|
20
20
|
const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
|
|
21
|
-
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
22
21
|
const affected_1 = require("../affected/affected");
|
|
23
22
|
const command_line_utils_1 = require("../../utils/command-line-utils");
|
|
24
23
|
// maps file extention to MIME types
|
|
@@ -381,7 +380,6 @@ function createFileWatcher() {
|
|
|
381
380
|
}
|
|
382
381
|
async function createDepGraphClientResponse(affected = []) {
|
|
383
382
|
perf_hooks_1.performance.mark('project graph watch calculation:start');
|
|
384
|
-
await file_hasher_1.fileHasher.init();
|
|
385
383
|
let graph = (0, operators_1.pruneExternalNodes)(await (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true }));
|
|
386
384
|
let fileMap = (0, nx_deps_cache_1.readProjectFileMapCache)().projectFileMap;
|
|
387
385
|
perf_hooks_1.performance.mark('project graph watch calculation:end');
|
|
@@ -4,7 +4,16 @@ exports.yargsRepairCommand = void 0;
|
|
|
4
4
|
const documentation_1 = require("../yargs-utils/documentation");
|
|
5
5
|
exports.yargsRepairCommand = {
|
|
6
6
|
command: 'repair',
|
|
7
|
-
describe:
|
|
7
|
+
describe: `Repair any configuration that is no longer supported by Nx.
|
|
8
|
+
|
|
9
|
+
Specifically, this will run every migration within the \`nx\` package
|
|
10
|
+
against the current repository. Doing so should fix any configuration
|
|
11
|
+
details left behind if the repository was previously updated to a new
|
|
12
|
+
Nx version without using \`nx migrate\`.
|
|
13
|
+
|
|
14
|
+
If your repository has only ever updated to newer versions of Nx with
|
|
15
|
+
\`nx migrate\`, running \`nx repair\` should do nothing.
|
|
16
|
+
`,
|
|
8
17
|
builder: (yargs) => (0, documentation_1.linkToNxDevAndExamples)(yargs, 'repair').option('verbose', {
|
|
9
18
|
type: 'boolean',
|
|
10
19
|
describe: 'Prints additional information about the commands (e.g., stack traces)',
|
|
@@ -4,7 +4,6 @@ exports.handleHashTasks = void 0;
|
|
|
4
4
|
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
|
5
5
|
const task_hasher_1 = require("../../hasher/task-hasher");
|
|
6
6
|
const configuration_1 = require("../../config/configuration");
|
|
7
|
-
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
8
7
|
const set_hash_env_1 = require("../../hasher/set-hash-env");
|
|
9
8
|
/**
|
|
10
9
|
* We use this not to recreated hasher for every hash operation
|
|
@@ -18,7 +17,7 @@ async function handleHashTasks(payload) {
|
|
|
18
17
|
const nxJson = (0, configuration_1.readNxJson)();
|
|
19
18
|
if (projectGraph !== storedProjectGraph) {
|
|
20
19
|
storedProjectGraph = projectGraph;
|
|
21
|
-
storedHasher = new task_hasher_1.InProcessTaskHasher(projectFileMap, allWorkspaceFiles, projectGraph, nxJson, payload.runnerOptions
|
|
20
|
+
storedHasher = new task_hasher_1.InProcessTaskHasher(projectFileMap, allWorkspaceFiles, projectGraph, nxJson, payload.runnerOptions);
|
|
22
21
|
}
|
|
23
22
|
const response = JSON.stringify(await storedHasher.hashTasks(payload.tasks, payload.taskGraph));
|
|
24
23
|
return {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleRequestFileData = void 0;
|
|
4
|
-
const
|
|
4
|
+
const workspace_context_1 = require("../../utils/workspace-context");
|
|
5
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
|
5
6
|
async function handleRequestFileData() {
|
|
6
|
-
const response = JSON.stringify(
|
|
7
|
+
const response = JSON.stringify((0, workspace_context_1.getAllFileDataInContext)(workspace_root_1.workspaceRoot));
|
|
7
8
|
return {
|
|
8
9
|
response,
|
|
9
10
|
description: 'handleRequestFileData',
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.disableOutputsTracking = exports.processFileChangesInOutputs = exports.outputsHashesMatch = exports.recordOutputsHash = exports.recordedHash = exports._outputsHashesMatch = exports._recordOutputsHash = void 0;
|
|
4
|
-
const fs_extra_1 = require("fs-extra");
|
|
5
4
|
const path_1 = require("path");
|
|
6
|
-
const fastGlob = require("fast-glob");
|
|
7
5
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
8
6
|
const collapse_expanded_outputs_1 = require("../../utils/collapse-expanded-outputs");
|
|
7
|
+
const native_1 = require("../../native");
|
|
9
8
|
let disabled = false;
|
|
10
9
|
const dirsContainingOutputs = {};
|
|
11
10
|
const recordedHashes = {};
|
|
@@ -60,22 +59,8 @@ async function outputsHashesMatch(_outputs, hash) {
|
|
|
60
59
|
}
|
|
61
60
|
exports.outputsHashesMatch = outputsHashesMatch;
|
|
62
61
|
async function normalizeOutputs(outputs) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
async function normalizeOutput(output, expand) {
|
|
66
|
-
try {
|
|
67
|
-
await (0, fs_extra_1.lstat)((0, path_1.join)(workspace_root_1.workspaceRoot, output));
|
|
68
|
-
return [output];
|
|
69
|
-
}
|
|
70
|
-
catch (e) {
|
|
71
|
-
if (expand) {
|
|
72
|
-
const expanded = (0, collapse_expanded_outputs_1.collapseExpandedOutputs)(await fastGlob(output, { cwd: workspace_root_1.workspaceRoot, dot: true }));
|
|
73
|
-
return (await Promise.all(expanded.map((e) => normalizeOutput(e, false)))).flat();
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
62
|
+
let expandedOutputs = (0, collapse_expanded_outputs_1.collapseExpandedOutputs)((0, native_1.getFilesForOutputs)(workspace_root_1.workspaceRoot, outputs));
|
|
63
|
+
return expandedOutputs;
|
|
79
64
|
}
|
|
80
65
|
function processFileChangesInOutputs(changeEvents, now = undefined) {
|
|
81
66
|
if (!now) {
|
|
@@ -13,6 +13,7 @@ const child_process_1 = require("child_process");
|
|
|
13
13
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
14
14
|
const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
|
|
15
15
|
const nx_json_1 = require("../../config/nx-json");
|
|
16
|
+
const workspace_context_1 = require("../../utils/workspace-context");
|
|
16
17
|
let cachedSerializedProjectGraphPromise;
|
|
17
18
|
const collectedUpdatedFiles = new Set();
|
|
18
19
|
const collectedDeletedFiles = new Set();
|
|
@@ -117,11 +118,13 @@ function filterUpdatedFiles(files) {
|
|
|
117
118
|
async function processCollectedUpdatedAndDeletedFiles() {
|
|
118
119
|
try {
|
|
119
120
|
perf_hooks_1.performance.mark('hash-watched-changes-start');
|
|
120
|
-
const updatedFiles =
|
|
121
|
+
const updatedFiles = filterUpdatedFiles([
|
|
122
|
+
...collectedUpdatedFiles.values(),
|
|
123
|
+
]);
|
|
121
124
|
const deletedFiles = [...collectedDeletedFiles.values()];
|
|
125
|
+
let updatedFileHashes = (0, workspace_context_1.updateFilesInContext)(updatedFiles, deletedFiles);
|
|
122
126
|
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
123
127
|
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
124
|
-
file_hasher_1.fileHasher.incrementalUpdate(updatedFiles, deletedFiles);
|
|
125
128
|
const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
|
|
126
129
|
const { projectNodes } = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
|
|
127
130
|
const workspaceConfigHash = computeWorkspaceConfigHash(projectNodes);
|
|
@@ -136,7 +139,7 @@ async function processCollectedUpdatedAndDeletedFiles() {
|
|
|
136
139
|
}
|
|
137
140
|
else {
|
|
138
141
|
if (exports.projectFileMapWithFiles) {
|
|
139
|
-
exports.projectFileMapWithFiles = (0, file_map_utils_1.updateProjectFileMap)(projectNodes, exports.projectFileMapWithFiles.projectFileMap, exports.projectFileMapWithFiles.allWorkspaceFiles,
|
|
142
|
+
exports.projectFileMapWithFiles = (0, file_map_utils_1.updateProjectFileMap)(projectNodes, exports.projectFileMapWithFiles.projectFileMap, exports.projectFileMapWithFiles.allWorkspaceFiles, new Map(Object.entries(updatedFileHashes)), deletedFiles);
|
|
140
143
|
}
|
|
141
144
|
else {
|
|
142
145
|
exports.projectFileMapWithFiles = await (0, retrieve_workspace_files_1.retrieveWorkspaceFiles)(workspace_root_1.workspaceRoot, nxJson);
|
|
@@ -224,8 +227,7 @@ async function resetInternalState() {
|
|
|
224
227
|
exports.currentProjectGraph = undefined;
|
|
225
228
|
collectedUpdatedFiles.clear();
|
|
226
229
|
collectedDeletedFiles.clear();
|
|
227
|
-
|
|
228
|
-
await file_hasher_1.fileHasher.ensureInitialized();
|
|
230
|
+
(0, workspace_context_1.resetWorkspaceContext)();
|
|
229
231
|
waitPeriod = 100;
|
|
230
232
|
}
|
|
231
233
|
async function resetInternalStateIfNxDepsMissing() {
|
|
@@ -24,6 +24,8 @@ const cache_1 = require("../cache");
|
|
|
24
24
|
const handle_hash_tasks_1 = require("./handle-hash-tasks");
|
|
25
25
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
26
26
|
const handle_request_file_data_1 = require("./handle-request-file-data");
|
|
27
|
+
const workspace_context_1 = require("../../utils/workspace-context");
|
|
28
|
+
const native_1 = require("../../native");
|
|
27
29
|
let performanceObserver;
|
|
28
30
|
let workspaceWatcherError;
|
|
29
31
|
let outputsWatcherError;
|
|
@@ -183,7 +185,7 @@ function lockFileHashChanged() {
|
|
|
183
185
|
(0, path_1.join)(workspace_root_1.workspaceRoot, 'pnpm-lock.yaml'),
|
|
184
186
|
]
|
|
185
187
|
.filter((file) => (0, fs_1.existsSync)(file))
|
|
186
|
-
.map((file) =>
|
|
188
|
+
.map((file) => (0, native_1.hashFile)(file));
|
|
187
189
|
const newHash = (0, file_hasher_1.hashArray)(lockHashes);
|
|
188
190
|
if (existingLockHash && newHash != existingLockHash) {
|
|
189
191
|
existingLockHash = newHash;
|
|
@@ -277,6 +279,7 @@ const handleOutputsChanges = async (err, changeEvents) => {
|
|
|
277
279
|
}
|
|
278
280
|
};
|
|
279
281
|
async function startServer() {
|
|
282
|
+
(0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
|
|
280
283
|
// Persist metadata about the background process so that it can be cleaned up later if needed
|
|
281
284
|
await (0, cache_1.writeDaemonJsonProcessCache)({
|
|
282
285
|
processId: process.pid,
|
|
@@ -287,7 +290,6 @@ async function startServer() {
|
|
|
287
290
|
}
|
|
288
291
|
return new Promise(async (resolve, reject) => {
|
|
289
292
|
try {
|
|
290
|
-
await file_hasher_1.fileHasher.ensureInitialized();
|
|
291
293
|
server.listen(socket_utils_1.FULL_OS_SOCKET_PATH, async () => {
|
|
292
294
|
try {
|
|
293
295
|
logger_1.serverLogger.log(`Started listening on: ${socket_utils_1.FULL_OS_SOCKET_PATH}`);
|
package/src/devkit-exports.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export { DependencyType } from './config/project-graph';
|
|
|
72
72
|
/**
|
|
73
73
|
* @category Project Graph
|
|
74
74
|
*/
|
|
75
|
-
export { ProjectGraphBuilder,
|
|
75
|
+
export { ProjectGraphBuilder, RawProjectGraphDependency, DynamicDependency, ImplicitDependency, StaticDependency, validateDependency, } from './project-graph/project-graph-builder';
|
|
76
76
|
/**
|
|
77
77
|
* @category Utils
|
|
78
78
|
*/
|
|
@@ -13,3 +13,4 @@ export { combineOptionsForExecutor } from './utils/params';
|
|
|
13
13
|
export { sortObjectByKeys } from './utils/object-sort';
|
|
14
14
|
export { stripIndent } from './utils/logger';
|
|
15
15
|
export { readModulePackageJson } from './utils/package-json';
|
|
16
|
+
export { splitByColons } from './utils/split-target';
|
package/src/devkit-internals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
|
3
|
+
exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
|
|
6
6
|
*
|
|
@@ -26,3 +26,5 @@ var logger_1 = require("./utils/logger");
|
|
|
26
26
|
Object.defineProperty(exports, "stripIndent", { enumerable: true, get: function () { return logger_1.stripIndent; } });
|
|
27
27
|
var package_json_1 = require("./utils/package-json");
|
|
28
28
|
Object.defineProperty(exports, "readModulePackageJson", { enumerable: true, get: function () { return package_json_1.readModulePackageJson; } });
|
|
29
|
+
var split_target_2 = require("./utils/split-target");
|
|
30
|
+
Object.defineProperty(exports, "splitByColons", { enumerable: true, get: function () { return split_target_2.splitByColons; } });
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
import { FileData } from '../config/project-graph';
|
|
2
|
-
export declare class FileHasher {
|
|
3
|
-
private fileHashes;
|
|
4
|
-
private isInitialized;
|
|
5
|
-
init(): Promise<void>;
|
|
6
|
-
hashFile(path: string): string;
|
|
7
|
-
clear(): void;
|
|
8
|
-
ensureInitialized(): Promise<void>;
|
|
9
|
-
hashFiles(files: string[]): Promise<Map<string, string>>;
|
|
10
|
-
allFileData(): FileData[];
|
|
11
|
-
incrementalUpdate(updatedFiles: Map<string, string>, deletedFiles?: string[]): void;
|
|
12
|
-
}
|
|
13
|
-
export declare const fileHasher: FileHasher;
|
|
14
1
|
export declare function hashArray(content: string[]): string;
|
|
15
2
|
export declare function hashObject(obj: object): string;
|
|
@@ -1,68 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hashObject = exports.hashArray =
|
|
4
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
5
|
-
const workspace_root_1 = require("../utils/workspace-root");
|
|
6
|
-
class FileHasher {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.isInitialized = false;
|
|
9
|
-
}
|
|
10
|
-
async init() {
|
|
11
|
-
perf_hooks_1.performance.mark('init hashing:start');
|
|
12
|
-
// Import as needed. There is also an issue running unit tests in Nx repo if this is a top-level import.
|
|
13
|
-
const { hashFiles } = require('../native');
|
|
14
|
-
this.clear();
|
|
15
|
-
const filesObject = hashFiles(workspace_root_1.workspaceRoot);
|
|
16
|
-
this.fileHashes = new Map(Object.entries(filesObject));
|
|
17
|
-
perf_hooks_1.performance.mark('init hashing:end');
|
|
18
|
-
perf_hooks_1.performance.measure('init hashing', 'init hashing:start', 'init hashing:end');
|
|
19
|
-
}
|
|
20
|
-
hashFile(path) {
|
|
21
|
-
// Import as needed. There is also an issue running unit tests in Nx repo if this is a top-level import.
|
|
22
|
-
const { hashFile } = require('../native');
|
|
23
|
-
return hashFile(path).hash;
|
|
24
|
-
}
|
|
25
|
-
clear() {
|
|
26
|
-
this.fileHashes = new Map();
|
|
27
|
-
this.isInitialized = false;
|
|
28
|
-
}
|
|
29
|
-
async ensureInitialized() {
|
|
30
|
-
if (!this.isInitialized) {
|
|
31
|
-
await this.init();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async hashFiles(files) {
|
|
35
|
-
const r = new Map();
|
|
36
|
-
for (let f of files) {
|
|
37
|
-
r.set(f, this.hashFile(f));
|
|
38
|
-
}
|
|
39
|
-
return r;
|
|
40
|
-
}
|
|
41
|
-
allFileData() {
|
|
42
|
-
const res = [];
|
|
43
|
-
this.fileHashes.forEach((hash, file) => {
|
|
44
|
-
res.push({
|
|
45
|
-
file,
|
|
46
|
-
hash,
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
res.sort((x, y) => x.file.localeCompare(y.file));
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
incrementalUpdate(updatedFiles, deletedFiles = []) {
|
|
53
|
-
perf_hooks_1.performance.mark('incremental hashing:start');
|
|
54
|
-
updatedFiles.forEach((hash, filename) => {
|
|
55
|
-
this.fileHashes.set(filename, hash);
|
|
56
|
-
});
|
|
57
|
-
for (const deletedFile of deletedFiles) {
|
|
58
|
-
this.fileHashes.delete(deletedFile);
|
|
59
|
-
}
|
|
60
|
-
perf_hooks_1.performance.mark('incremental hashing:end');
|
|
61
|
-
perf_hooks_1.performance.measure('incremental hashing', 'incremental hashing:start', 'incremental hashing:end');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.FileHasher = FileHasher;
|
|
65
|
-
exports.fileHasher = new FileHasher();
|
|
3
|
+
exports.hashObject = exports.hashArray = void 0;
|
|
66
4
|
function hashArray(content) {
|
|
67
5
|
// Import as needed. There is also an issue running unit tests in Nx repo if this is a top-level import.
|
|
68
6
|
const { hashArray } = require('../native');
|
|
@@ -3,7 +3,6 @@ import { NxJsonConfiguration } from '../config/nx-json';
|
|
|
3
3
|
import { Task, TaskGraph } from '../config/task-graph';
|
|
4
4
|
import { InputDefinition } from '../config/workspace-json-project-json';
|
|
5
5
|
import { DaemonClient } from '../daemon/client/client';
|
|
6
|
-
import { FileHasher } from './file-hasher';
|
|
7
6
|
type ExpandedSelfInput = {
|
|
8
7
|
fileset: string;
|
|
9
8
|
} | {
|
|
@@ -73,10 +72,9 @@ export declare class InProcessTaskHasher implements TaskHasher {
|
|
|
73
72
|
private readonly projectGraph;
|
|
74
73
|
private readonly nxJson;
|
|
75
74
|
private readonly options;
|
|
76
|
-
private readonly fileHasher;
|
|
77
75
|
static version: string;
|
|
78
76
|
private taskHasher;
|
|
79
|
-
constructor(projectFileMap: ProjectFileMap, allWorkspaceFiles: FileData[], projectGraph: ProjectGraph, nxJson: NxJsonConfiguration, options: any
|
|
77
|
+
constructor(projectFileMap: ProjectFileMap, allWorkspaceFiles: FileData[], projectGraph: ProjectGraph, nxJson: NxJsonConfiguration, options: any);
|
|
80
78
|
hashTasks(tasks: Task[], taskGraph?: TaskGraph): Promise<Hash[]>;
|
|
81
79
|
hashTask(task: Task, taskGraph?: TaskGraph): Promise<Hash>;
|
|
82
80
|
private hashCommand;
|
|
@@ -13,6 +13,7 @@ const workspace_root_1 = require("../utils/workspace-root");
|
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const path_2 = require("../utils/path");
|
|
15
15
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
16
|
+
const native_1 = require("../native");
|
|
16
17
|
class DaemonBasedTaskHasher {
|
|
17
18
|
constructor(daemonClient, runnerOptions) {
|
|
18
19
|
this.daemonClient = daemonClient;
|
|
@@ -27,13 +28,12 @@ class DaemonBasedTaskHasher {
|
|
|
27
28
|
}
|
|
28
29
|
exports.DaemonBasedTaskHasher = DaemonBasedTaskHasher;
|
|
29
30
|
class InProcessTaskHasher {
|
|
30
|
-
constructor(projectFileMap, allWorkspaceFiles, projectGraph, nxJson, options
|
|
31
|
+
constructor(projectFileMap, allWorkspaceFiles, projectGraph, nxJson, options) {
|
|
31
32
|
this.projectFileMap = projectFileMap;
|
|
32
33
|
this.allWorkspaceFiles = allWorkspaceFiles;
|
|
33
34
|
this.projectGraph = projectGraph;
|
|
34
35
|
this.nxJson = nxJson;
|
|
35
36
|
this.options = options;
|
|
36
|
-
this.fileHasher = fileHasher;
|
|
37
37
|
const legacyRuntimeInputs = (this.options && this.options.runtimeCacheInputs
|
|
38
38
|
? this.options.runtimeCacheInputs
|
|
39
39
|
: []).map((r) => ({ runtime: r }));
|
|
@@ -46,7 +46,7 @@ class InProcessTaskHasher {
|
|
|
46
46
|
'.gitignore',
|
|
47
47
|
'.nxignore',
|
|
48
48
|
].map((d) => ({ fileset: `{workspaceRoot}/${d}` }));
|
|
49
|
-
this.taskHasher = new TaskHasherImpl(nxJson, legacyRuntimeInputs, legacyFilesetInputs, this.projectFileMap, this.allWorkspaceFiles, this.projectGraph,
|
|
49
|
+
this.taskHasher = new TaskHasherImpl(nxJson, legacyRuntimeInputs, legacyFilesetInputs, this.projectFileMap, this.allWorkspaceFiles, this.projectGraph, { selectivelyHashTsConfig: this.options.selectivelyHashTsConfig ?? false });
|
|
50
50
|
}
|
|
51
51
|
async hashTasks(tasks, taskGraph) {
|
|
52
52
|
return await Promise.all(tasks.map((t) => this.hashTask(t, taskGraph)));
|
|
@@ -93,14 +93,13 @@ const DEFAULT_INPUTS = [
|
|
|
93
93
|
},
|
|
94
94
|
];
|
|
95
95
|
class TaskHasherImpl {
|
|
96
|
-
constructor(nxJson, legacyRuntimeInputs, legacyFilesetInputs, projectFileMap, allWorkspaceFiles, projectGraph,
|
|
96
|
+
constructor(nxJson, legacyRuntimeInputs, legacyFilesetInputs, projectFileMap, allWorkspaceFiles, projectGraph, options) {
|
|
97
97
|
this.nxJson = nxJson;
|
|
98
98
|
this.legacyRuntimeInputs = legacyRuntimeInputs;
|
|
99
99
|
this.legacyFilesetInputs = legacyFilesetInputs;
|
|
100
100
|
this.projectFileMap = projectFileMap;
|
|
101
101
|
this.allWorkspaceFiles = allWorkspaceFiles;
|
|
102
102
|
this.projectGraph = projectGraph;
|
|
103
|
-
this.fileHasher = fileHasher;
|
|
104
103
|
this.options = options;
|
|
105
104
|
this.filesetHashes = {};
|
|
106
105
|
this.runtimeHashes = {};
|
|
@@ -206,7 +205,7 @@ class TaskHasherImpl {
|
|
|
206
205
|
minimatch(p, dependentTasksOutputFiles, { dot: true }));
|
|
207
206
|
const hashDetails = {};
|
|
208
207
|
const hashes = [];
|
|
209
|
-
for (const [file, hash] of
|
|
208
|
+
for (const [file, hash] of this.hashFiles(filteredFiles.map((p) => (0, path_1.join)(workspace_root_1.workspaceRoot, p)))) {
|
|
210
209
|
hashes.push(hash);
|
|
211
210
|
hashDetails[(0, path_2.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, file))] = hash;
|
|
212
211
|
}
|
|
@@ -220,6 +219,13 @@ class TaskHasherImpl {
|
|
|
220
219
|
}
|
|
221
220
|
return partialHashes;
|
|
222
221
|
}
|
|
222
|
+
hashFiles(files) {
|
|
223
|
+
const r = new Map();
|
|
224
|
+
for (let f of files) {
|
|
225
|
+
r.set(f, (0, native_1.hashFile)(f));
|
|
226
|
+
}
|
|
227
|
+
return r;
|
|
228
|
+
}
|
|
223
229
|
getExternalDependencyHash(externalNodeName) {
|
|
224
230
|
const combinedHash = this.combinePartialHashes(this.externalDependencyHashes.get(externalNodeName));
|
|
225
231
|
// Set the combined hash into the hashes so it's not recalculated next time
|
package/src/native/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export function getFilesForOutputs(directory: string, entries: Array<string>): A
|
|
|
16
16
|
export function remove(src: string): void
|
|
17
17
|
export function copy(src: string, dest: string): void
|
|
18
18
|
export function hashArray(input: Array<string>): string
|
|
19
|
-
export function hashFile(file: string):
|
|
19
|
+
export function hashFile(file: string): string | null
|
|
20
20
|
export function hashFiles(workspaceRoot: string): Record<string, string>
|
|
21
21
|
export function findImports(projectFileMap: Record<string, Array<string>>): Array<ImportResult>
|
|
22
22
|
export interface ExternalNodeData {
|
|
@@ -69,10 +69,6 @@ export interface FileData {
|
|
|
69
69
|
file: string
|
|
70
70
|
hash: string
|
|
71
71
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Newly created files will have the `update` EventType as well.
|
|
74
|
-
* This simplifies logic between OS's, IDEs and git operations
|
|
75
|
-
*/
|
|
76
72
|
export const enum EventType {
|
|
77
73
|
delete = 'delete',
|
|
78
74
|
update = 'update',
|
|
@@ -87,21 +83,16 @@ export const enum WorkspaceErrors {
|
|
|
87
83
|
ParseError = 'ParseError',
|
|
88
84
|
Generic = 'Generic'
|
|
89
85
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
export interface ConfigurationParserResult {
|
|
87
|
+
projectNodes: Record<string, object>
|
|
88
|
+
externalNodes: Record<string, object>
|
|
89
|
+
}
|
|
94
90
|
export interface NxWorkspaceFiles {
|
|
95
91
|
projectFileMap: Record<string, Array<FileData>>
|
|
96
92
|
globalFiles: Array<FileData>
|
|
97
93
|
projectConfigurations: Record<string, object>
|
|
98
94
|
externalNodes: Record<string, object>
|
|
99
95
|
}
|
|
100
|
-
export function getWorkspaceFilesNative(workspaceRoot: string, globs: Array<string>, parseConfigurations: (arg0: Array<string>) => ConfigurationParserResult): NxWorkspaceFiles
|
|
101
|
-
export interface ConfigurationParserResult {
|
|
102
|
-
projectNodes: Record<string, object>
|
|
103
|
-
externalNodes: Record<string, object>
|
|
104
|
-
}
|
|
105
96
|
export class ImportResult {
|
|
106
97
|
file: string
|
|
107
98
|
sourceProject: string
|
|
@@ -118,3 +109,12 @@ export class Watcher {
|
|
|
118
109
|
watch(callback: (err: string | null, events: WatchEvent[]) => void): void
|
|
119
110
|
stop(): Promise<void>
|
|
120
111
|
}
|
|
112
|
+
export class WorkspaceContext {
|
|
113
|
+
workspaceRoot: string
|
|
114
|
+
constructor(workspaceRoot: string)
|
|
115
|
+
getWorkspaceFiles(globs: Array<string>, parseConfigurations: (arg0: Array<string>) => ConfigurationParserResult): NxWorkspaceFiles
|
|
116
|
+
getProjectConfigurationFiles(globs: Array<string>): Array<string>
|
|
117
|
+
getProjectConfigurations(globs: Array<string>, parseConfigurations: (arg0: Array<string>) => ConfigurationParserResult): ConfigurationParserResult
|
|
118
|
+
incrementalUpdate(updatedFiles: Array<string>, deletedFiles: Array<string>): Record<string, string>
|
|
119
|
+
allFileData(): Array<FileData>
|
|
120
|
+
}
|
package/src/native/index.js
CHANGED
|
@@ -246,7 +246,7 @@ if (!nativeBinding) {
|
|
|
246
246
|
throw new Error(`Failed to load native binding`)
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
const { expandOutputs, getFilesForOutputs, remove, copy, hashArray, hashFile, hashFiles, ImportResult, findImports, EventType, Watcher,
|
|
249
|
+
const { expandOutputs, getFilesForOutputs, remove, copy, hashArray, hashFile, hashFiles, ImportResult, findImports, EventType, Watcher, WorkspaceContext, WorkspaceErrors } = nativeBinding
|
|
250
250
|
|
|
251
251
|
module.exports.expandOutputs = expandOutputs
|
|
252
252
|
module.exports.getFilesForOutputs = getFilesForOutputs
|
|
@@ -259,7 +259,5 @@ module.exports.ImportResult = ImportResult
|
|
|
259
259
|
module.exports.findImports = findImports
|
|
260
260
|
module.exports.EventType = EventType
|
|
261
261
|
module.exports.Watcher = Watcher
|
|
262
|
+
module.exports.WorkspaceContext = WorkspaceContext
|
|
262
263
|
module.exports.WorkspaceErrors = WorkspaceErrors
|
|
263
|
-
module.exports.getProjectConfigurationFiles = getProjectConfigurationFiles
|
|
264
|
-
module.exports.getProjectConfigurations = getProjectConfigurations
|
|
265
|
-
module.exports.getWorkspaceFilesNative = getWorkspaceFilesNative
|
package/src/plugins/js/index.js
CHANGED
|
@@ -61,7 +61,7 @@ const createDependencies = (ctx) => {
|
|
|
61
61
|
lockfileDependencies = readCachedParsedLockFile().dependencies ?? [];
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
-
lockfileDependencies = (0, lock_file_1.getLockFileDependencies)(packageManager, lockFileContents, lockFileHash, ctx
|
|
64
|
+
lockfileDependencies = (0, lock_file_1.getLockFileDependencies)(packageManager, lockFileContents, lockFileHash, ctx);
|
|
65
65
|
parsedLockFile.dependencies = lockfileDependencies;
|
|
66
66
|
writeLastProcessedLockfileHash(lockFileHash, parsedLockFile);
|
|
67
67
|
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { PackageManager } from '../../../utils/package-manager';
|
|
6
6
|
import { ProjectGraph, ProjectGraphExternalNode } from '../../../config/project-graph';
|
|
7
|
-
import {
|
|
7
|
+
import { RawProjectGraphDependency } from '../../../project-graph/project-graph-builder';
|
|
8
8
|
import { PackageJson } from '../../../utils/package-json';
|
|
9
|
+
import { CreateDependenciesContext } from '../../../utils/nx-plugin';
|
|
9
10
|
export declare const LOCKFILES: string[];
|
|
10
11
|
/**
|
|
11
12
|
* Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
|
|
@@ -14,7 +15,7 @@ export declare function getLockFileNodes(packageManager: PackageManager, content
|
|
|
14
15
|
/**
|
|
15
16
|
* Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
|
|
16
17
|
*/
|
|
17
|
-
export declare function getLockFileDependencies(packageManager: PackageManager, contents: string, lockFileHash: string,
|
|
18
|
+
export declare function getLockFileDependencies(packageManager: PackageManager, contents: string, lockFileHash: string, context: CreateDependenciesContext): RawProjectGraphDependency[];
|
|
18
19
|
export declare function lockFileExists(packageManager: PackageManager): boolean;
|
|
19
20
|
/**
|
|
20
21
|
* Returns lock file name based on the detected package manager in the root
|
|
@@ -54,16 +54,16 @@ exports.getLockFileNodes = getLockFileNodes;
|
|
|
54
54
|
/**
|
|
55
55
|
* Parses lock file and maps dependencies and metadata to {@link LockFileGraph}
|
|
56
56
|
*/
|
|
57
|
-
function getLockFileDependencies(packageManager, contents, lockFileHash,
|
|
57
|
+
function getLockFileDependencies(packageManager, contents, lockFileHash, context) {
|
|
58
58
|
try {
|
|
59
59
|
if (packageManager === 'yarn') {
|
|
60
|
-
return (0, yarn_parser_1.getYarnLockfileDependencies)(contents, lockFileHash,
|
|
60
|
+
return (0, yarn_parser_1.getYarnLockfileDependencies)(contents, lockFileHash, context);
|
|
61
61
|
}
|
|
62
62
|
if (packageManager === 'pnpm') {
|
|
63
|
-
return (0, pnpm_parser_1.getPnpmLockfileDependencies)(contents, lockFileHash,
|
|
63
|
+
return (0, pnpm_parser_1.getPnpmLockfileDependencies)(contents, lockFileHash, context);
|
|
64
64
|
}
|
|
65
65
|
if (packageManager === 'npm') {
|
|
66
|
-
return (0, npm_parser_1.getNpmLockfileDependencies)(contents, lockFileHash,
|
|
66
|
+
return (0, npm_parser_1.getNpmLockfileDependencies)(contents, lockFileHash, context);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
catch (e) {
|