nx 22.2.0-canary.20251124-70bbbe9 → 22.2.0-canary.20251125-7e00ec4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/init-local.d.ts.map +1 -1
- package/bin/init-local.js +40 -2
- package/package.json +11 -11
- package/release/changelog-renderer/index.d.ts +1 -0
- package/release/changelog-renderer/index.d.ts.map +1 -1
- package/release/changelog-renderer/index.js +12 -12
- package/src/ai/constants.d.ts +6 -1
- package/src/ai/constants.d.ts.map +1 -1
- package/src/ai/constants.js +14 -3
- package/src/ai/set-up-ai-agents/set-up-ai-agents.d.ts.map +1 -1
- package/src/ai/set-up-ai-agents/set-up-ai-agents.js +41 -7
- package/src/command-line/report/report.d.ts +4 -0
- package/src/command-line/report/report.d.ts.map +1 -1
- package/src/command-line/report/report.js +72 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/cache.d.ts +2 -1
- package/src/daemon/cache.d.ts.map +1 -1
- package/src/daemon/cache.js +10 -26
- package/src/daemon/client/client.d.ts +5 -0
- package/src/daemon/client/client.d.ts.map +1 -1
- package/src/daemon/client/client.js +67 -26
- package/src/daemon/is-nx-version-mismatch.d.ts +3 -0
- package/src/daemon/is-nx-version-mismatch.d.ts.map +1 -0
- package/src/daemon/is-nx-version-mismatch.js +24 -0
- package/src/daemon/message-types/nx-console.d.ts +18 -0
- package/src/daemon/message-types/nx-console.d.ts.map +1 -0
- package/src/daemon/message-types/nx-console.js +19 -0
- package/src/daemon/server/handle-nx-console.d.ts +4 -0
- package/src/daemon/server/handle-nx-console.d.ts.map +1 -0
- package/src/daemon/server/handle-nx-console.js +54 -0
- package/src/daemon/server/nx-console-operations.d.ts +31 -0
- package/src/daemon/server/nx-console-operations.d.ts.map +1 -0
- package/src/daemon/server/nx-console-operations.js +135 -0
- package/src/daemon/server/server.d.ts.map +1 -1
- package/src/daemon/server/server.js +19 -18
- package/src/daemon/server/shutdown-utils.d.ts.map +1 -1
- package/src/daemon/server/shutdown-utils.js +3 -0
- package/src/daemon/tmp-dir.d.ts.map +1 -1
- package/src/daemon/tmp-dir.js +1 -0
- package/src/devkit-internals.d.ts +1 -1
- package/src/devkit-internals.d.ts.map +1 -1
- package/src/devkit-internals.js +2 -1
- package/src/tasks-runner/pseudo-terminal.js +1 -1
- package/src/tasks-runner/task-orchestrator.d.ts +1 -0
- package/src/tasks-runner/task-orchestrator.d.ts.map +1 -1
- package/src/tasks-runner/task-orchestrator.js +22 -5
- package/src/utils/package-json.d.ts +4 -0
- package/src/utils/package-json.d.ts.map +1 -1
- package/src/utils/package-json.js +45 -11
- package/src/utils/package-manager.d.ts +1 -0
- package/src/utils/package-manager.d.ts.map +1 -1
- package/src/utils/package-manager.js +4 -0
|
@@ -10,11 +10,11 @@ const perf_hooks_1 = require("perf_hooks");
|
|
|
10
10
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
11
11
|
const native_1 = require("../../native");
|
|
12
12
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
13
|
-
const fileutils_1 = require("../../utils/fileutils");
|
|
14
13
|
const versions_1 = require("../../utils/versions");
|
|
15
14
|
const workspace_context_1 = require("../../utils/workspace-context");
|
|
16
15
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
17
16
|
const cache_1 = require("../cache");
|
|
17
|
+
const is_nx_version_mismatch_1 = require("../is-nx-version-mismatch");
|
|
18
18
|
const socket_utils_1 = require("../socket-utils");
|
|
19
19
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
|
20
20
|
const project_graph_listener_sockets_1 = require("./project-graph-listener-sockets");
|
|
@@ -54,6 +54,8 @@ const handle_flush_sync_generator_changes_to_disk_1 = require("./handle-flush-sy
|
|
|
54
54
|
const run_tasks_execution_hooks_1 = require("../message-types/run-tasks-execution-hooks");
|
|
55
55
|
const handle_tasks_execution_hooks_1 = require("./handle-tasks-execution-hooks");
|
|
56
56
|
const register_project_graph_listener_1 = require("../message-types/register-project-graph-listener");
|
|
57
|
+
const nx_console_1 = require("../message-types/nx-console");
|
|
58
|
+
const handle_nx_console_1 = require("./handle-nx-console");
|
|
57
59
|
const v8_1 = require("v8");
|
|
58
60
|
let performanceObserver;
|
|
59
61
|
let workspaceWatcherError;
|
|
@@ -195,6 +197,12 @@ async function handleMessage(socket, data) {
|
|
|
195
197
|
else if ((0, run_tasks_execution_hooks_1.isHandlePostTasksExecutionMessage)(payload)) {
|
|
196
198
|
await handleResult(socket, run_tasks_execution_hooks_1.POST_TASKS_EXECUTION, () => (0, handle_tasks_execution_hooks_1.handleRunPostTasksExecution)(payload.context), mode);
|
|
197
199
|
}
|
|
200
|
+
else if ((0, nx_console_1.isHandleGetNxConsoleStatusMessage)(payload)) {
|
|
201
|
+
await handleResult(socket, nx_console_1.GET_NX_CONSOLE_STATUS, () => (0, handle_nx_console_1.handleGetNxConsoleStatus)(), mode);
|
|
202
|
+
}
|
|
203
|
+
else if ((0, nx_console_1.isHandleSetNxConsolePreferenceAndInstallMessage)(payload)) {
|
|
204
|
+
await handleResult(socket, nx_console_1.SET_NX_CONSOLE_PREFERENCE_AND_INSTALL, () => (0, handle_nx_console_1.handleSetNxConsolePreferenceAndInstall)(payload.preference), mode);
|
|
205
|
+
}
|
|
198
206
|
else {
|
|
199
207
|
await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `Invalid payload from the client`, new Error(`Unsupported payload sent to daemon server: ${unparsedPayload}`));
|
|
200
208
|
}
|
|
@@ -257,7 +265,7 @@ function registerProcessTerminationListeners() {
|
|
|
257
265
|
}
|
|
258
266
|
let existingLockHash;
|
|
259
267
|
function daemonIsOutdated() {
|
|
260
|
-
if (
|
|
268
|
+
if ((0, is_nx_version_mismatch_1.isNxVersionMismatch)()) {
|
|
261
269
|
return 'NX_VERSION_CHANGED';
|
|
262
270
|
}
|
|
263
271
|
else if (lockFileHashChanged()) {
|
|
@@ -265,20 +273,6 @@ function daemonIsOutdated() {
|
|
|
265
273
|
}
|
|
266
274
|
return null;
|
|
267
275
|
}
|
|
268
|
-
function nxVersionChanged() {
|
|
269
|
-
return versions_1.nxVersion !== getInstalledNxVersion();
|
|
270
|
-
}
|
|
271
|
-
const nxPackageJsonPath = require.resolve('nx/package.json');
|
|
272
|
-
function getInstalledNxVersion() {
|
|
273
|
-
try {
|
|
274
|
-
const { version } = (0, fileutils_1.readJsonFile)(nxPackageJsonPath);
|
|
275
|
-
return version;
|
|
276
|
-
}
|
|
277
|
-
catch (e) {
|
|
278
|
-
// node modules are absent, so we can return null, which would shut down the daemon
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
276
|
function lockFileHashChanged() {
|
|
283
277
|
const lockHashes = [
|
|
284
278
|
(0, path_1.join)(workspace_root_1.workspaceRoot, 'package-lock.json'),
|
|
@@ -385,9 +379,12 @@ const handleOutputsChanges = async (err, changeEvents) => {
|
|
|
385
379
|
};
|
|
386
380
|
async function startServer() {
|
|
387
381
|
(0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
|
|
382
|
+
const socketPath = (0, socket_utils_1.getFullOsSocketPath)();
|
|
388
383
|
// Persist metadata about the background process so that it can be cleaned up later if needed
|
|
389
384
|
await (0, cache_1.writeDaemonJsonProcessCache)({
|
|
390
385
|
processId: process.pid,
|
|
386
|
+
socketPath,
|
|
387
|
+
nxVersion: versions_1.nxVersion,
|
|
391
388
|
});
|
|
392
389
|
// See notes in socket-command-line-utils.ts on OS differences regarding clean up of existings connections.
|
|
393
390
|
if (!socket_utils_1.isWindows) {
|
|
@@ -404,9 +401,9 @@ async function startServer() {
|
|
|
404
401
|
}, 20).unref();
|
|
405
402
|
return new Promise(async (resolve, reject) => {
|
|
406
403
|
try {
|
|
407
|
-
server.listen(
|
|
404
|
+
server.listen(socketPath, async () => {
|
|
408
405
|
try {
|
|
409
|
-
logger_1.serverLogger.log(`Started listening on: ${
|
|
406
|
+
logger_1.serverLogger.log(`Started listening on: ${socketPath}`);
|
|
410
407
|
// this triggers the storage of the lock file hash
|
|
411
408
|
daemonIsOutdated();
|
|
412
409
|
if (!(0, shutdown_utils_1.getWatcherInstance)()) {
|
|
@@ -420,6 +417,10 @@ async function startServer() {
|
|
|
420
417
|
(0, project_graph_incremental_recomputation_1.registerProjectGraphRecomputationListener)(sync_generators_1.collectAndScheduleSyncGenerators);
|
|
421
418
|
// trigger an initial project graph recomputation
|
|
422
419
|
(0, project_graph_incremental_recomputation_1.addUpdatedAndDeletedFiles)([], [], []);
|
|
420
|
+
// Kick off Nx Console check in background to prime the cache
|
|
421
|
+
(0, handle_nx_console_1.handleGetNxConsoleStatus)().catch(() => {
|
|
422
|
+
// Ignore errors, this is a background operation
|
|
423
|
+
});
|
|
423
424
|
return resolve(server);
|
|
424
425
|
}
|
|
425
426
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/shutdown-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"shutdown-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/nx/src/daemon/server/shutdown-utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAI1C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAU5C,eAAO,MAAM,4BAA4B,EAAG,QAAiB,CAAC;AAI9D,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,QAErD;AAED,wBAAgB,kBAAkB,YAEjC;AAID,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,QAE3D;AAED,wBAAgB,wBAAwB,YAEvC;AAED,UAAU,oCAAoC;IAC5C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,wBAAsB,8BAA8B,CAAC,EACnD,MAAM,EACN,MAAM,EACN,OAAO,GACR,EAAE,oCAAoC,iBAsCtC;AAID,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI,CAK3D;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,oBAcpB;AAED,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,iBAsBb"}
|
|
@@ -17,6 +17,7 @@ const error_types_1 = require("../../project-graph/error-types");
|
|
|
17
17
|
const db_connection_1 = require("../../utils/db-connection");
|
|
18
18
|
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
|
19
19
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
20
|
+
const nx_console_operations_1 = require("./nx-console-operations");
|
|
20
21
|
exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
|
|
21
22
|
let watcherInstance;
|
|
22
23
|
function storeWatcherInstance(instance) {
|
|
@@ -53,6 +54,8 @@ async function handleServerProcessTermination({ server, reason, sockets, }) {
|
|
|
53
54
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
|
54
55
|
(0, get_plugins_1.cleanupPlugins)();
|
|
55
56
|
(0, db_connection_1.removeDbConnections)();
|
|
57
|
+
// Clean up Nx Console latest installation
|
|
58
|
+
(0, nx_console_operations_1.cleanupLatestNxInstallation)();
|
|
56
59
|
logger_1.serverLogger.log(`Server stopped because: "${reason}"`);
|
|
57
60
|
}
|
|
58
61
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tmp-dir.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/tmp-dir.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,gCAAgC,QAG5C,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAGlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAK5B,CAAC;AAEJ,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,UAI7C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,QAElD;AAED,wBAAgB,gBAAgB,YAO/B;
|
|
1
|
+
{"version":3,"file":"tmp-dir.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/daemon/tmp-dir.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,gCAAgC,QAG5C,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAGlC,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAK5B,CAAC;AAEJ,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,UAI7C;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,QAElD;AAED,wBAAgB,gBAAgB,YAO/B;AAUD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,aAAa,UAAQ,UAYjD;AAED,wBAAgB,eAAe,SAI9B"}
|
package/src/daemon/tmp-dir.js
CHANGED
|
@@ -43,6 +43,7 @@ function isDaemonDisabled() {
|
|
|
43
43
|
function socketDirName() {
|
|
44
44
|
const hasher = (0, crypto_1.createHash)('sha256');
|
|
45
45
|
hasher.update(workspace_root_1.workspaceRoot.toLowerCase());
|
|
46
|
+
hasher.update(String(process.pid));
|
|
46
47
|
const unique = hasher.digest('hex').substring(0, 20);
|
|
47
48
|
return (0, path_1.join)(tmp_1.tmpdir, unique);
|
|
48
49
|
}
|
|
@@ -15,7 +15,7 @@ export { splitTarget } from './utils/split-target';
|
|
|
15
15
|
export { combineOptionsForExecutor } from './utils/params';
|
|
16
16
|
export { sortObjectByKeys } from './utils/object-sort';
|
|
17
17
|
export { stripIndent } from './utils/logger';
|
|
18
|
-
export { readModulePackageJson, installPackageToTmp, } from './utils/package-json';
|
|
18
|
+
export { readModulePackageJson, installPackageToTmp, installPackageToTmpAsync, } from './utils/package-json';
|
|
19
19
|
export { splitByColons } from './utils/split-target';
|
|
20
20
|
export { hashObject } from './hasher/file-hasher';
|
|
21
21
|
export { hashWithWorkspaceContext, hashMultiGlobWithWorkspaceContext, } from './utils/workspace-context';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devkit-internals.d.ts","sourceRoot":"","sources":["../../../../packages/nx/src/devkit-internals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EACL,sBAAsB,EACtB,aAAa,GACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,gDAAgD,EAAE,MAAM,gDAAgD,CAAC;AAClH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAC9F,OAAO,EACL,oCAAoC,EACpC,uBAAuB,GACxB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EACL,qBAAqB,EACrB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"devkit-internals.d.ts","sourceRoot":"","sources":["../../../../packages/nx/src/devkit-internals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB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e,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
|
package/src/devkit-internals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.getIgnoreObjectForTree = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
|
3
|
+
exports.signalToCode = exports.globalSpinner = exports.readYamlFile = exports.isUsingPrettierInTree = exports.isCI = exports.interpolate = exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappings = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashMultiGlobWithWorkspaceContext = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.installPackageToTmpAsync = exports.installPackageToTmp = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.getIgnoreObjectForTree = exports.findMatchingConfigFiles = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.parseExecutor = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
/**
|
|
6
6
|
* Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
|
|
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "stripIndent", { enumerable: true, get: function
|
|
|
36
36
|
var package_json_1 = require("./utils/package-json");
|
|
37
37
|
Object.defineProperty(exports, "readModulePackageJson", { enumerable: true, get: function () { return package_json_1.readModulePackageJson; } });
|
|
38
38
|
Object.defineProperty(exports, "installPackageToTmp", { enumerable: true, get: function () { return package_json_1.installPackageToTmp; } });
|
|
39
|
+
Object.defineProperty(exports, "installPackageToTmpAsync", { enumerable: true, get: function () { return package_json_1.installPackageToTmpAsync; } });
|
|
39
40
|
var split_target_2 = require("./utils/split-target");
|
|
40
41
|
Object.defineProperty(exports, "splitByColons", { enumerable: true, get: function () { return split_target_2.splitByColons; } });
|
|
41
42
|
var file_hasher_1 = require("./hasher/file-hasher");
|
|
@@ -110,7 +110,7 @@ class PseudoTtyProcess {
|
|
|
110
110
|
kill(s) {
|
|
111
111
|
if (this.isAlive) {
|
|
112
112
|
try {
|
|
113
|
-
this.childProcess.kill(s);
|
|
113
|
+
this.childProcess.kill(s || 'SIGTERM');
|
|
114
114
|
}
|
|
115
115
|
catch {
|
|
116
116
|
// when the child process completes before we explicitly call kill, this will throw
|
|
@@ -37,6 +37,7 @@ export declare class TaskOrchestrator {
|
|
|
37
37
|
private waitingForTasks;
|
|
38
38
|
private groups;
|
|
39
39
|
private bailed;
|
|
40
|
+
private cleaningUp;
|
|
40
41
|
private runningContinuousTasks;
|
|
41
42
|
private runningRunCommandsTasks;
|
|
42
43
|
constructor(hasher: TaskHasher, initiatingProject: string | undefined, initiatingTasks: Task[], projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, options: NxArgs & DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient, outputStyle: string, taskGraphForHashing?: TaskGraph);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-orchestrator.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/tasks-runner/task-orchestrator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAQnD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAMrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,EAAgB,UAAU,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAiB,MAAM,kBAAkB,CAAC;AAUxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAExE,qBAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"task-orchestrator.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/tasks-runner/task-orchestrator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,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A0B;YAQ1B,iBAAiB;YAQjB,OAAO;IA6BrB,OAAO,CAAC,8BAA8B;CA6BvC;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,GAAG,yBAAyB,EAC3C,SAAS,EAAE,SAAS,UAqBrB"}
|
|
@@ -54,6 +54,7 @@ class TaskOrchestrator {
|
|
|
54
54
|
this.waitingForTasks = [];
|
|
55
55
|
this.groups = [];
|
|
56
56
|
this.bailed = false;
|
|
57
|
+
this.cleaningUp = false;
|
|
57
58
|
this.runningContinuousTasks = new Map();
|
|
58
59
|
this.runningRunCommandsTasks = new Map();
|
|
59
60
|
}
|
|
@@ -458,11 +459,16 @@ class TaskOrchestrator {
|
|
|
458
459
|
}
|
|
459
460
|
const runningTask = new shared_running_task_1.SharedRunningTask(this.runningTasksService, task.id);
|
|
460
461
|
this.runningContinuousTasks.set(task.id, runningTask);
|
|
461
|
-
runningTask.onExit(() => {
|
|
462
|
-
if (this.tuiEnabled) {
|
|
462
|
+
runningTask.onExit((code) => {
|
|
463
|
+
if (this.tuiEnabled && !this.completedTasks[task.id]) {
|
|
463
464
|
this.options.lifeCycle.setTaskStatus(task.id, 9 /* NativeTaskStatus.Stopped */);
|
|
464
465
|
}
|
|
465
466
|
this.runningContinuousTasks.delete(task.id);
|
|
467
|
+
// we're not cleaning up, so this is an unexpected exit, fail the task
|
|
468
|
+
if (!this.cleaningUp) {
|
|
469
|
+
console.error(`Task "${task.id}" is continuous but exited with code ${code}`);
|
|
470
|
+
this.complete([{ taskId: task.id, status: 'failure' }]);
|
|
471
|
+
}
|
|
466
472
|
});
|
|
467
473
|
// task is already running by another process, we schedule the next tasks
|
|
468
474
|
// and release the threads
|
|
@@ -497,13 +503,19 @@ class TaskOrchestrator {
|
|
|
497
503
|
const childProcess = await this.runTask(task, streamOutput, env, temporaryOutputPath, pipeOutput);
|
|
498
504
|
this.runningTasksService.addRunningTask(task.id);
|
|
499
505
|
this.runningContinuousTasks.set(task.id, childProcess);
|
|
500
|
-
childProcess.onExit(() => {
|
|
501
|
-
if
|
|
506
|
+
childProcess.onExit((code) => {
|
|
507
|
+
// Only set status to Stopped if task hasn't been completed yet
|
|
508
|
+
if (this.tuiEnabled && !this.completedTasks[task.id]) {
|
|
502
509
|
this.options.lifeCycle.setTaskStatus(task.id, 9 /* NativeTaskStatus.Stopped */);
|
|
503
510
|
}
|
|
504
511
|
if (this.runningContinuousTasks.delete(task.id)) {
|
|
505
512
|
this.runningTasksService.removeRunningTask(task.id);
|
|
506
513
|
}
|
|
514
|
+
// we're not cleaning up, so this is an unexpected exit, fail the task
|
|
515
|
+
if (!this.cleaningUp) {
|
|
516
|
+
console.error(`Task "${task.id}" is continuous but exited with code ${code}`);
|
|
517
|
+
this.complete([{ taskId: task.id, status: 'failure' }]);
|
|
518
|
+
}
|
|
507
519
|
});
|
|
508
520
|
await this.scheduleNextTasksAndReleaseThreads();
|
|
509
521
|
if (this.initializingTaskIds.has(task.id)) {
|
|
@@ -659,6 +671,7 @@ class TaskOrchestrator {
|
|
|
659
671
|
}
|
|
660
672
|
// endregion utils
|
|
661
673
|
async cleanup() {
|
|
674
|
+
this.cleaningUp = true;
|
|
662
675
|
this.forkedProcessTaskRunner.cleanup();
|
|
663
676
|
await Promise.all([
|
|
664
677
|
...Array.from(this.runningContinuousTasks).map(async ([taskId, t]) => {
|
|
@@ -687,8 +700,12 @@ class TaskOrchestrator {
|
|
|
687
700
|
}
|
|
688
701
|
cleanUpUnneededContinuousTasks() {
|
|
689
702
|
const incompleteTasks = this.tasksSchedule.getIncompleteTasks();
|
|
690
|
-
const neededContinuousTasks = new Set(
|
|
703
|
+
const neededContinuousTasks = new Set();
|
|
691
704
|
for (const task of incompleteTasks) {
|
|
705
|
+
// Keep initiating tasks that are still incomplete
|
|
706
|
+
if (task.continuous && this.initializingTaskIds.has(task.id)) {
|
|
707
|
+
neededContinuousTasks.add(task.id);
|
|
708
|
+
}
|
|
692
709
|
const continuousDependencies = this.taskGraph.continuousDependencies[task.id];
|
|
693
710
|
for (const continuousDependency of continuousDependencies) {
|
|
694
711
|
neededContinuousTasks.add(continuousDependency);
|
|
@@ -110,6 +110,10 @@ export declare function installPackageToTmp(pkg: string, requiredVersion: string
|
|
|
110
110
|
tempDir: string;
|
|
111
111
|
cleanup: () => void;
|
|
112
112
|
};
|
|
113
|
+
export declare function installPackageToTmpAsync(pkg: string, requiredVersion: string): Promise<{
|
|
114
|
+
tempDir: string;
|
|
115
|
+
cleanup: () => void;
|
|
116
|
+
}>;
|
|
113
117
|
/**
|
|
114
118
|
* Get the resolved version of a dependency from package.json.
|
|
115
119
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/package-json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package-json.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/package-json.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,mBAAmB,EACpB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAM/C,OAAO,EAML,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,MAAM,WAAW,iCACf,SAAQ,OAAO,CAAC,oBAAoB,CAAC;IACrC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC;AACvE,MAAM,MAAM,iBAAiB,GACzB,CAAC,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,GACjD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC3B,MAAM,MA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AW,EAAE,MAAM,EACnB,eAAe,CAAC,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,4BAA4B,EAAE,GAChD,MAAM,GAAG,IAAI,CAAC;AACjB,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,WAAW,EACzB,gBAAgB,CAAC,EAAE,4BAA4B,EAAE,GAChD,MAAM,GAAG,IAAI,CAAC;AACjB,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,MAAM,EAC1B,eAAe,CAAC,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,4BAA4B,EAAE,GAChD,MAAM,GAAG,IAAI,CAAC;AACjB,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,MAAM,EACnB,iBAAiB,CAAC,EAAE,MAAM,EAC1B,WAAW,CAAC,EAAE,WAAW,EACzB,gBAAgB,CAAC,EAAE,4BAA4B,EAAE,GAChD,MAAM,GAAG,IAAI,CAAC"}
|
|
@@ -9,10 +9,13 @@ exports.readTargetsFromPackageJson = readTargetsFromPackageJson;
|
|
|
9
9
|
exports.readModulePackageJsonWithoutFallbacks = readModulePackageJsonWithoutFallbacks;
|
|
10
10
|
exports.readModulePackageJson = readModulePackageJson;
|
|
11
11
|
exports.installPackageToTmp = installPackageToTmp;
|
|
12
|
+
exports.installPackageToTmpAsync = installPackageToTmpAsync;
|
|
12
13
|
exports.getDependencyVersionFromPackageJson = getDependencyVersionFromPackageJson;
|
|
13
14
|
const child_process_1 = require("child_process");
|
|
15
|
+
const util_1 = require("util");
|
|
14
16
|
const fs_1 = require("fs");
|
|
15
17
|
const path_1 = require("path");
|
|
18
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
16
19
|
const tmp_1 = require("tmp");
|
|
17
20
|
const json_1 = require("../generators/utils/json");
|
|
18
21
|
const project_configuration_utils_1 = require("../project-graph/utils/project-configuration-utils");
|
|
@@ -199,7 +202,11 @@ function readModulePackageJson(moduleSpecifier, requirePaths = (0, installation_
|
|
|
199
202
|
path: packageJsonPath,
|
|
200
203
|
};
|
|
201
204
|
}
|
|
202
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Prepares all necessary information for installing a package to a temporary directory.
|
|
207
|
+
* This is used by both sync and async installation functions.
|
|
208
|
+
*/
|
|
209
|
+
function preparePackageInstallation(pkg, requiredVersion) {
|
|
203
210
|
const { dir: tempDir, cleanup } = (0, package_manager_1.createTempNpmDirectory)?.() ?? {
|
|
204
211
|
dir: (0, tmp_1.dirSync)().name,
|
|
205
212
|
cleanup: () => { },
|
|
@@ -209,29 +216,56 @@ function installPackageToTmp(pkg, requiredVersion) {
|
|
|
209
216
|
const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
210
217
|
generatePackageManagerFiles(tempDir, packageManager);
|
|
211
218
|
const preInstallCommand = (0, package_manager_1.getPackageManagerCommand)(packageManager).preInstall;
|
|
212
|
-
if (preInstallCommand) {
|
|
213
|
-
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
|
214
|
-
(0, child_process_1.execSync)(preInstallCommand, {
|
|
215
|
-
cwd: tempDir,
|
|
216
|
-
stdio: isVerbose ? 'inherit' : 'ignore',
|
|
217
|
-
windowsHide: false,
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
219
|
const pmCommands = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
221
220
|
let addCommand = pmCommands.addDev;
|
|
222
221
|
if (packageManager === 'pnpm') {
|
|
223
222
|
addCommand = 'pnpm add -D'; // we need to ensure that we are not using workspace command
|
|
224
223
|
}
|
|
225
|
-
|
|
224
|
+
const installCommand = `${addCommand} ${pkg}@${requiredVersion} ${pmCommands.ignoreScriptsFlag ?? ''}`;
|
|
225
|
+
const execOptions = {
|
|
226
226
|
cwd: tempDir,
|
|
227
227
|
stdio: isVerbose ? 'inherit' : 'ignore',
|
|
228
228
|
windowsHide: false,
|
|
229
|
-
}
|
|
229
|
+
};
|
|
230
230
|
return {
|
|
231
231
|
tempDir,
|
|
232
232
|
cleanup,
|
|
233
|
+
preInstallCommand,
|
|
234
|
+
installCommand,
|
|
235
|
+
execOptions,
|
|
233
236
|
};
|
|
234
237
|
}
|
|
238
|
+
function installPackageToTmp(pkg, requiredVersion) {
|
|
239
|
+
const { tempDir, cleanup, preInstallCommand, installCommand, execOptions } = preparePackageInstallation(pkg, requiredVersion);
|
|
240
|
+
if (preInstallCommand) {
|
|
241
|
+
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
|
242
|
+
(0, child_process_1.execSync)(preInstallCommand, execOptions);
|
|
243
|
+
}
|
|
244
|
+
(0, child_process_1.execSync)(installCommand, execOptions);
|
|
245
|
+
return {
|
|
246
|
+
tempDir,
|
|
247
|
+
cleanup,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
async function installPackageToTmpAsync(pkg, requiredVersion) {
|
|
251
|
+
const { tempDir, cleanup, preInstallCommand, installCommand, execOptions } = preparePackageInstallation(pkg, requiredVersion);
|
|
252
|
+
try {
|
|
253
|
+
if (preInstallCommand) {
|
|
254
|
+
// ensure package.json and repo in tmp folder is set to a proper package manager state
|
|
255
|
+
await execAsync(preInstallCommand, execOptions);
|
|
256
|
+
}
|
|
257
|
+
await execAsync(installCommand, execOptions);
|
|
258
|
+
return {
|
|
259
|
+
tempDir,
|
|
260
|
+
cleanup,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
// Clean up on error
|
|
265
|
+
cleanup();
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
235
269
|
function getDependencyVersionFromPackageJson(treeOrPackageName, packageNameOrRoot, packageJsonPathOrObjectOrRoot, dependencyLookup) {
|
|
236
270
|
if (typeof treeOrPackageName !== 'string') {
|
|
237
271
|
return getDependencyVersionFromPackageJsonFromTree(treeOrPackageName, packageNameOrRoot, packageJsonPathOrObjectOrRoot, dependencyLookup);
|
|
@@ -10,6 +10,7 @@ export interface PackageManagerCommands {
|
|
|
10
10
|
exec: string;
|
|
11
11
|
dlx: string;
|
|
12
12
|
list: string;
|
|
13
|
+
why: string;
|
|
13
14
|
run: (script: string, args?: string) => string;
|
|
14
15
|
getRegistryUrl?: string;
|
|
15
16
|
publish: (packageRoot: string, registry: string, registryConfigKey: string, tag: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/package-manager.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAE7D,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAE/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,CACP,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,EACzB,GAAG,EAAE,MAAM,KACR,MAAM,CAAC;IAEZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAW,GAAG,cAAc,CAYrE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,GAAE,cAAuC,EACvD,IAAI,GAAE,MAAsB,GAC3B,OAAO,CAmBT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,GAAE,cAAuC,EACvD,IAAI,GAAE,MAAsB,GAC3B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"package-manager.d.ts","sourceRoot":"","sources":["../../../../../packages/nx/src/utils/package-manager.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;AAE7D,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAE/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,CACP,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,EACzB,GAAG,EAAE,MAAM,KACR,MAAM,CAAC;IAEZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAW,GAAG,cAAc,CAYrE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,GAAE,cAAuC,EACvD,IAAI,GAAE,MAAsB,GAC3B,OAAO,CAmBT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACtC,cAAc,GAAE,cAA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AC,CAsBlC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,GAAE,cAAuC,EACvD,IAAI,GAAE,MAAsB,GAC3B,MAAM,EAAE,CAoBV;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,EACnB,cAAc,GAAE,cAAuC,EACvD,UAAU,GAAE,MAAM,EAAyC,EAC3D,IAAI,GAAE,MAAsB,GAC3B,IAAI,CAiEN"}
|
|
@@ -113,6 +113,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
113
113
|
dlx: useBerry ? 'yarn dlx' : 'npx',
|
|
114
114
|
run: (script, args) => `yarn ${script}${args ? ` ${args}` : ''}`,
|
|
115
115
|
list: useBerry ? 'yarn info --name-only' : 'yarn list',
|
|
116
|
+
why: 'yarn why',
|
|
116
117
|
getRegistryUrl: useBerry
|
|
117
118
|
? 'yarn config get npmRegistryServer'
|
|
118
119
|
: 'yarn config get registry',
|
|
@@ -151,6 +152,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
151
152
|
: ` ${args}`
|
|
152
153
|
: ''}`,
|
|
153
154
|
list: 'pnpm ls --depth 100',
|
|
155
|
+
why: 'pnpm why',
|
|
154
156
|
getRegistryUrl: 'pnpm config get registry',
|
|
155
157
|
publish: (packageRoot, registry, registryConfigKey, tag) => `pnpm publish "${packageRoot}" --json --"${allowRegistryConfigKey ? registryConfigKey : 'registry'}=${registry}" --tag=${tag} --no-git-checks`,
|
|
156
158
|
ignoreScriptsFlag: '--ignore-scripts',
|
|
@@ -168,6 +170,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
168
170
|
dlx: 'npx',
|
|
169
171
|
run: (script, args) => `npm run ${script}${args ? ' -- ' + args : ''}`,
|
|
170
172
|
list: 'npm ls',
|
|
173
|
+
why: 'npm explain',
|
|
171
174
|
getRegistryUrl: 'npm config get registry',
|
|
172
175
|
publish: (packageRoot, registry, registryConfigKey, tag) => `npm publish "${packageRoot}" --json --"${registryConfigKey}=${registry}" --tag=${tag}`,
|
|
173
176
|
ignoreScriptsFlag: '--ignore-scripts',
|
|
@@ -186,6 +189,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
186
189
|
dlx: 'bunx',
|
|
187
190
|
run: (script, args) => `bun run ${script} -- ${args}`,
|
|
188
191
|
list: 'bun pm ls',
|
|
192
|
+
why: 'bun why',
|
|
189
193
|
// Unlike npm, bun publish does not support a custom registryConfigKey option
|
|
190
194
|
publish: (packageRoot, registry, registryConfigKey, tag) => `bun publish --cwd="${packageRoot}" --json --registry="${registry}" --tag=${tag}`,
|
|
191
195
|
ignoreScriptsFlag: '--ignore-scripts',
|