nx 19.0.3 → 19.0.5
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/.eslintrc.json +2 -1
- package/package.json +13 -14
- package/src/adapter/ngcli-adapter.js +6 -3
- package/src/command-line/affected/affected.d.ts +4 -1
- package/src/command-line/affected/affected.js +5 -2
- package/src/command-line/graph/graph.js +1 -1
- package/src/command-line/migrate/migrate.js +16 -6
- package/src/command-line/release/publish.js +10 -7
- package/src/command-line/release/utils/github.js +1 -1
- package/src/command-line/release/utils/shared.js +5 -3
- package/src/command-line/reset/reset.js +7 -0
- package/src/command-line/run/executor-utils.js +5 -0
- package/src/command-line/run/run-one.js +4 -1
- package/src/command-line/run/run.js +10 -2
- package/src/command-line/run-many/run-many.js +4 -1
- package/src/config/misc-interfaces.d.ts +2 -1
- package/src/core/graph/main.js +1 -1
- package/src/daemon/client/client.js +5 -3
- package/src/daemon/server/server.js +3 -3
- package/src/daemon/server/watcher.js +4 -1
- package/src/daemon/socket-utils.d.ts +2 -2
- package/src/daemon/socket-utils.js +9 -8
- package/src/daemon/tmp-dir.d.ts +6 -2
- package/src/daemon/tmp-dir.js +6 -5
- package/src/devkit-internals.d.ts +2 -3
- package/src/devkit-internals.js +1 -5
- package/src/executors/run-commands/run-commands.impl.js +3 -1
- package/src/generators/utils/json.js +2 -1
- package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +8 -1
- package/src/native/index.js +6 -5
- package/src/native/native-file-cache-location.d.ts +1 -0
- package/src/native/native-file-cache-location.js +8 -0
- package/src/plugins/js/lock-file/npm-parser.js +10 -1
- package/src/plugins/js/lock-file/utils/pnpm-normalizer.js +3 -3
- package/src/project-graph/affected/locators/workspace-projects.js +1 -1
- package/src/project-graph/plugins/internal-api.d.ts +1 -1
- package/src/project-graph/plugins/internal-api.js +2 -4
- package/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.js +1 -1
- package/src/tasks-runner/pseudo-terminal.js +1 -1
- package/src/utils/json.js +1 -1
- package/src/utils/package-manager.js +14 -5
- package/src/utils/plugins/plugin-capabilities.js +24 -1
@@ -19,6 +19,7 @@ const nx_json_1 = require("../../config/nx-json");
|
|
19
19
|
const daemon_socket_messenger_1 = require("./daemon-socket-messenger");
|
20
20
|
const cache_1 = require("../cache");
|
21
21
|
const error_types_1 = require("../../project-graph/error-types");
|
22
|
+
const dotenv_1 = require("../../utils/dotenv");
|
22
23
|
const DAEMON_ENV_SETTINGS = {
|
23
24
|
NX_PROJECT_GLOB_CACHE: 'false',
|
24
25
|
NX_CACHE_PROJECTS_CONFIG: 'false',
|
@@ -36,6 +37,7 @@ class DaemonClient {
|
|
36
37
|
this._daemonReady = null;
|
37
38
|
this._out = null;
|
38
39
|
this._err = null;
|
40
|
+
(0, dotenv_1.loadRootEnvFiles)(workspace_root_1.workspaceRoot);
|
39
41
|
try {
|
40
42
|
this.nxJson = (0, configuration_1.readNxJson)();
|
41
43
|
}
|
@@ -139,7 +141,7 @@ class DaemonClient {
|
|
139
141
|
}
|
140
142
|
let messenger;
|
141
143
|
await this.queue.sendToQueue(() => {
|
142
|
-
messenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socket_utils_1.
|
144
|
+
messenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)((0, socket_utils_1.getFullOsSocketPath)())).listen((message) => {
|
143
145
|
try {
|
144
146
|
const parsedMessage = JSON.parse(message);
|
145
147
|
callback(null, parsedMessage);
|
@@ -184,7 +186,7 @@ class DaemonClient {
|
|
184
186
|
async isServerAvailable() {
|
185
187
|
return new Promise((resolve) => {
|
186
188
|
try {
|
187
|
-
const socket = (0, net_1.connect)(socket_utils_1.
|
189
|
+
const socket = (0, net_1.connect)((0, socket_utils_1.getFullOsSocketPath)(), () => {
|
188
190
|
socket.destroy();
|
189
191
|
resolve(true);
|
190
192
|
});
|
@@ -201,7 +203,7 @@ class DaemonClient {
|
|
201
203
|
return this.queue.sendToQueue(() => this.sendMessageToDaemon(messageToDaemon));
|
202
204
|
}
|
203
205
|
setUpConnection() {
|
204
|
-
this.socketMessenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socket_utils_1.
|
206
|
+
this.socketMessenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)((0, socket_utils_1.getFullOsSocketPath)())).listen((message) => this.handleMessage(message), () => {
|
205
207
|
// it's ok for the daemon to terminate if the client doesn't wait on
|
206
208
|
// any messages from the daemon
|
207
209
|
if (this.queue.isEmpty()) {
|
@@ -198,7 +198,7 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
|
|
198
198
|
});
|
199
199
|
return;
|
200
200
|
}
|
201
|
-
if (err
|
201
|
+
if (err) {
|
202
202
|
let error = typeof err === 'string' ? new Error(err) : err;
|
203
203
|
logger_1.serverLogger.watcherLog('Unexpected workspace watcher error', error.message);
|
204
204
|
console.error(error);
|
@@ -273,9 +273,9 @@ async function startServer() {
|
|
273
273
|
}
|
274
274
|
return new Promise(async (resolve, reject) => {
|
275
275
|
try {
|
276
|
-
server.listen(socket_utils_1.
|
276
|
+
server.listen((0, socket_utils_1.getFullOsSocketPath)(), async () => {
|
277
277
|
try {
|
278
|
-
logger_1.serverLogger.log(`Started listening on: ${socket_utils_1.
|
278
|
+
logger_1.serverLogger.log(`Started listening on: ${(0, socket_utils_1.getFullOsSocketPath)()}`);
|
279
279
|
// this triggers the storage of the lock file hash
|
280
280
|
daemonIsOutdated();
|
281
281
|
if (!(0, shutdown_utils_1.getWatcherInstance)()) {
|
@@ -8,7 +8,10 @@ const shutdown_utils_1 = require("./shutdown-utils");
|
|
8
8
|
const path_2 = require("../../utils/path");
|
9
9
|
const ignore_1 = require("../../utils/ignore");
|
10
10
|
const cache_1 = require("../cache");
|
11
|
-
const ALWAYS_IGNORE = [
|
11
|
+
const ALWAYS_IGNORE = [
|
12
|
+
...(0, ignore_1.getAlwaysIgnore)(workspace_root_1.workspaceRoot),
|
13
|
+
(0, socket_utils_1.getFullOsSocketPath)(),
|
14
|
+
];
|
12
15
|
async function watchWorkspace(server, cb) {
|
13
16
|
const { Watcher } = await Promise.resolve().then(() => require('../../native'));
|
14
17
|
let relativeServerProcess = (0, path_2.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, cache_1.serverProcessJsonPath));
|
@@ -5,7 +5,7 @@ export declare const isWindows: boolean;
|
|
5
5
|
* See https://nodejs.org/dist/latest-v14.x/docs/api/net.html#net_identifying_paths_for_ipc_connections for a full breakdown
|
6
6
|
* of OS differences between Unix domain sockets and named pipes.
|
7
7
|
*/
|
8
|
-
export declare const
|
9
|
-
export declare const
|
8
|
+
export declare const getFullOsSocketPath: () => string;
|
9
|
+
export declare const getForkedProcessOsSocketPath: (id: string) => string;
|
10
10
|
export declare function killSocketOrPath(): void;
|
11
11
|
export declare function serializeResult(error: Error | null, serializedProjectGraph: string | null, serializedSourceMaps: string | null): string | null;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.serializeResult = exports.killSocketOrPath = exports.
|
3
|
+
exports.serializeResult = exports.killSocketOrPath = exports.getForkedProcessOsSocketPath = exports.getFullOsSocketPath = exports.isWindows = void 0;
|
4
4
|
const fs_1 = require("fs");
|
5
5
|
const os_1 = require("os");
|
6
6
|
const path_1 = require("path");
|
@@ -13,17 +13,18 @@ exports.isWindows = (0, os_1.platform)() === 'win32';
|
|
13
13
|
* See https://nodejs.org/dist/latest-v14.x/docs/api/net.html#net_identifying_paths_for_ipc_connections for a full breakdown
|
14
14
|
* of OS differences between Unix domain sockets and named pipes.
|
15
15
|
*/
|
16
|
-
|
17
|
-
? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)(tmp_dir_1.
|
18
|
-
: (0, path_1.resolve)(tmp_dir_1.
|
19
|
-
|
20
|
-
|
16
|
+
const getFullOsSocketPath = () => exports.isWindows
|
17
|
+
? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)((0, tmp_dir_1.getDaemonSocketDir)())
|
18
|
+
: (0, path_1.resolve)((0, tmp_dir_1.getDaemonSocketDir)());
|
19
|
+
exports.getFullOsSocketPath = getFullOsSocketPath;
|
20
|
+
const getForkedProcessOsSocketPath = (id) => {
|
21
|
+
let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getSocketDir)(), 'fp' + id + '.sock'));
|
21
22
|
return exports.isWindows ? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)(path) : (0, path_1.resolve)(path);
|
22
23
|
};
|
23
|
-
exports.
|
24
|
+
exports.getForkedProcessOsSocketPath = getForkedProcessOsSocketPath;
|
24
25
|
function killSocketOrPath() {
|
25
26
|
try {
|
26
|
-
(0, fs_1.unlinkSync)(exports.
|
27
|
+
(0, fs_1.unlinkSync)((0, exports.getFullOsSocketPath)());
|
27
28
|
}
|
28
29
|
catch { }
|
29
30
|
}
|
package/src/daemon/tmp-dir.d.ts
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
export declare const DAEMON_DIR_FOR_CURRENT_WORKSPACE: string;
|
2
2
|
export declare const DAEMON_OUTPUT_LOG_FILE: string;
|
3
|
-
export declare const
|
4
|
-
export declare const DAEMON_SOCKET_PATH: string;
|
3
|
+
export declare const getDaemonSocketDir: () => string;
|
5
4
|
export declare function writeDaemonLogs(error?: string): string;
|
6
5
|
export declare function markDaemonAsDisabled(): void;
|
7
6
|
export declare function isDaemonDisabled(): boolean;
|
7
|
+
/**
|
8
|
+
* We try to create a socket file in a tmp dir, but if it doesn't work because
|
9
|
+
* for instance we don't have permissions, we create it in DAEMON_DIR_FOR_CURRENT_WORKSPACE
|
10
|
+
*/
|
11
|
+
export declare function getSocketDir(): string;
|
8
12
|
export declare function removeSocketDir(): void;
|
package/src/daemon/tmp-dir.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.removeSocketDir = exports.
|
3
|
+
exports.removeSocketDir = exports.getSocketDir = exports.isDaemonDisabled = exports.markDaemonAsDisabled = exports.writeDaemonLogs = exports.getDaemonSocketDir = exports.DAEMON_OUTPUT_LOG_FILE = exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = void 0;
|
4
4
|
/**
|
5
5
|
* Per workspace (to avoid subtle differences and issues), we want to have a deterministic
|
6
6
|
* location within the OS's tmp directory where we write log files for background processes
|
@@ -15,10 +15,10 @@ const tmp_1 = require("tmp");
|
|
15
15
|
const workspace_root_1 = require("../utils/workspace-root");
|
16
16
|
exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = (0, path_1.join)(cache_directory_1.projectGraphCacheDirectory, 'd');
|
17
17
|
exports.DAEMON_OUTPUT_LOG_FILE = (0, path_1.join)(exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'daemon.log');
|
18
|
-
|
19
|
-
exports.DAEMON_SOCKET_PATH = (0, path_1.join)(exports.socketDir,
|
18
|
+
const getDaemonSocketDir = () => (0, path_1.join)(getSocketDir(),
|
20
19
|
// As per notes above on socket/named pipe length limitations, we keep this intentionally short
|
21
20
|
'd.sock');
|
21
|
+
exports.getDaemonSocketDir = getDaemonSocketDir;
|
22
22
|
function writeDaemonLogs(error) {
|
23
23
|
const file = (0, path_1.join)(exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'daemon-error.log');
|
24
24
|
(0, fs_1.writeFileSync)(file, error);
|
@@ -49,7 +49,7 @@ function socketDirName() {
|
|
49
49
|
* We try to create a socket file in a tmp dir, but if it doesn't work because
|
50
50
|
* for instance we don't have permissions, we create it in DAEMON_DIR_FOR_CURRENT_WORKSPACE
|
51
51
|
*/
|
52
|
-
function
|
52
|
+
function getSocketDir() {
|
53
53
|
try {
|
54
54
|
const dir = process.env.NX_DAEMON_SOCKET_DIR ?? socketDirName();
|
55
55
|
(0, fs_extra_1.ensureDirSync)(dir);
|
@@ -59,9 +59,10 @@ function createSocketDir() {
|
|
59
59
|
return exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE;
|
60
60
|
}
|
61
61
|
}
|
62
|
+
exports.getSocketDir = getSocketDir;
|
62
63
|
function removeSocketDir() {
|
63
64
|
try {
|
64
|
-
(0, fs_extra_1.rmSync)(
|
65
|
+
(0, fs_extra_1.rmSync)(getSocketDir(), { recursive: true, force: true });
|
65
66
|
}
|
66
67
|
catch (e) { }
|
67
68
|
}
|
@@ -4,13 +4,12 @@
|
|
4
4
|
* These may not be available in certain version of Nx, so be sure to check them first.
|
5
5
|
*/
|
6
6
|
export { createTempNpmDirectory } from './utils/package-manager';
|
7
|
-
export { deepEquals } from './utils/json-diff';
|
8
7
|
export { getExecutorInformation } from './command-line/run/executor-utils';
|
9
8
|
export { readNxJson as readNxJsonFromDisk } from './config/nx-json';
|
10
9
|
export { calculateDefaultProjectName } from './config/calculate-default-project-name';
|
11
10
|
export { retrieveProjectConfigurationsWithAngularProjects } from './project-graph/utils/retrieve-workspace-files';
|
12
11
|
export { mergeTargetConfigurations } from './project-graph/utils/project-configuration-utils';
|
13
|
-
export { readProjectConfigurationsFromRootMap
|
12
|
+
export { readProjectConfigurationsFromRootMap } from './project-graph/utils/project-configuration-utils';
|
14
13
|
export { splitTarget } from './utils/split-target';
|
15
14
|
export { combineOptionsForExecutor } from './utils/params';
|
16
15
|
export { sortObjectByKeys } from './utils/object-sort';
|
@@ -21,6 +20,6 @@ export { hashObject } from './hasher/file-hasher';
|
|
21
20
|
export { hashWithWorkspaceContext } from './utils/workspace-context';
|
22
21
|
export { createProjectRootMappingsFromProjectConfigurations, findProjectForPath, } from './project-graph/utils/find-project-for-path';
|
23
22
|
export { retrieveProjectConfigurations } from './project-graph/utils/retrieve-workspace-files';
|
24
|
-
export { LoadedNxPlugin
|
23
|
+
export { LoadedNxPlugin } from './project-graph/plugins/internal-api';
|
25
24
|
export * from './project-graph/error-types';
|
26
25
|
export { registerTsProject } from './plugins/js/utils/register';
|
package/src/devkit-internals.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.registerTsProject = exports.
|
3
|
+
exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = 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.
|
@@ -9,8 +9,6 @@ const tslib_1 = require("tslib");
|
|
9
9
|
*/
|
10
10
|
var package_manager_1 = require("./utils/package-manager");
|
11
11
|
Object.defineProperty(exports, "createTempNpmDirectory", { enumerable: true, get: function () { return package_manager_1.createTempNpmDirectory; } });
|
12
|
-
var json_diff_1 = require("./utils/json-diff");
|
13
|
-
Object.defineProperty(exports, "deepEquals", { enumerable: true, get: function () { return json_diff_1.deepEquals; } });
|
14
12
|
var executor_utils_1 = require("./command-line/run/executor-utils");
|
15
13
|
Object.defineProperty(exports, "getExecutorInformation", { enumerable: true, get: function () { return executor_utils_1.getExecutorInformation; } });
|
16
14
|
var nx_json_1 = require("./config/nx-json");
|
@@ -23,7 +21,6 @@ var project_configuration_utils_1 = require("./project-graph/utils/project-confi
|
|
23
21
|
Object.defineProperty(exports, "mergeTargetConfigurations", { enumerable: true, get: function () { return project_configuration_utils_1.mergeTargetConfigurations; } });
|
24
22
|
var project_configuration_utils_2 = require("./project-graph/utils/project-configuration-utils");
|
25
23
|
Object.defineProperty(exports, "readProjectConfigurationsFromRootMap", { enumerable: true, get: function () { return project_configuration_utils_2.readProjectConfigurationsFromRootMap; } });
|
26
|
-
Object.defineProperty(exports, "isCompatibleTarget", { enumerable: true, get: function () { return project_configuration_utils_2.isCompatibleTarget; } });
|
27
24
|
var split_target_1 = require("./utils/split-target");
|
28
25
|
Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
|
29
26
|
var params_1 = require("./utils/params");
|
@@ -47,7 +44,6 @@ var retrieve_workspace_files_2 = require("./project-graph/utils/retrieve-workspa
|
|
47
44
|
Object.defineProperty(exports, "retrieveProjectConfigurations", { enumerable: true, get: function () { return retrieve_workspace_files_2.retrieveProjectConfigurations; } });
|
48
45
|
var internal_api_1 = require("./project-graph/plugins/internal-api");
|
49
46
|
Object.defineProperty(exports, "LoadedNxPlugin", { enumerable: true, get: function () { return internal_api_1.LoadedNxPlugin; } });
|
50
|
-
Object.defineProperty(exports, "loadNxPlugins", { enumerable: true, get: function () { return internal_api_1.loadNxPlugins; } });
|
51
47
|
tslib_1.__exportStar(require("./project-graph/error-types"), exports);
|
52
48
|
var register_1 = require("./plugins/js/utils/register");
|
53
49
|
Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
|
@@ -44,7 +44,9 @@ const propKeys = [
|
|
44
44
|
];
|
45
45
|
async function default_1(options, context) {
|
46
46
|
registerProcessListener();
|
47
|
-
|
47
|
+
if (process.env.NX_LOAD_DOT_ENV_FILES !== 'false') {
|
48
|
+
await loadEnvVars(options.envFile);
|
49
|
+
}
|
48
50
|
const normalized = normalizeOptions(options);
|
49
51
|
if (options.readyWhen && !options.parallel) {
|
50
52
|
throw new Error('ERROR: Bad executor config for run-commands - "readyWhen" can only be used when "parallel=true".');
|
@@ -30,7 +30,8 @@ exports.readJson = readJson;
|
|
30
30
|
* @param options Optional JSON Serialize Options
|
31
31
|
*/
|
32
32
|
function writeJson(tree, path, value, options) {
|
33
|
-
|
33
|
+
const serialized = (0, json_1.serializeJson)(value, options);
|
34
|
+
tree.write(path, `${serialized}\n`);
|
34
35
|
}
|
35
36
|
exports.writeJson = writeJson;
|
36
37
|
/**
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const logger_1 = require("../../utils/logger");
|
3
4
|
const project_configuration_1 = require("../../generators/utils/project-configuration");
|
4
5
|
/**
|
5
6
|
* This function escapes dollar sign in env variables
|
@@ -41,11 +42,17 @@ function parseEnvFile(tree, envFilePath) {
|
|
41
42
|
return;
|
42
43
|
}
|
43
44
|
let envFileContent = tree.read(envFilePath, 'utf-8');
|
45
|
+
if (!envFileContent) {
|
46
|
+
// envFileContent is null if we fail to read the file for any reason
|
47
|
+
// e.g. the file is not utf-8 encoded
|
48
|
+
logger_1.logger.info(`Unable to update ${envFilePath}. Nx interpolates environment variables in the form of $VAR_NAME. To escape the dollar sign, use \\$VAR_NAME.`);
|
49
|
+
return;
|
50
|
+
}
|
44
51
|
envFileContent = envFileContent
|
45
52
|
.split('\n')
|
46
53
|
.map((line) => {
|
47
54
|
line = line.trim();
|
48
|
-
if (!line.includes('$')) {
|
55
|
+
if (!line || !line.includes('$')) {
|
49
56
|
return line;
|
50
57
|
}
|
51
58
|
const declarations = line.split('=');
|
package/src/native/index.js
CHANGED
@@ -2,7 +2,7 @@ const { join, basename } = require('path');
|
|
2
2
|
const { copyFileSync, existsSync, mkdirSync } = require('fs');
|
3
3
|
const Module = require('module');
|
4
4
|
const { nxVersion } = require('../utils/versions');
|
5
|
-
const {
|
5
|
+
const { nativeFileCacheLocation } = require('./native-file-cache-location');
|
6
6
|
|
7
7
|
const nxPackages = new Set([
|
8
8
|
'@nx/nx-android-arm64',
|
@@ -52,13 +52,14 @@ Module._load = function (request, parent, isMain) {
|
|
52
52
|
) {
|
53
53
|
const nativeLocation = require.resolve(modulePath);
|
54
54
|
const fileName = basename(nativeLocation);
|
55
|
-
|
56
|
-
|
55
|
+
|
56
|
+
// we copy the file to a workspace-scoped tmp directory and prefix with nxVersion to avoid stale files being loaded
|
57
|
+
const tmpFile = join(nativeFileCacheLocation, nxVersion + '-' + fileName);
|
57
58
|
if (existsSync(tmpFile)) {
|
58
59
|
return originalLoad.apply(this, [tmpFile, parent, isMain]);
|
59
60
|
}
|
60
|
-
if (!existsSync(
|
61
|
-
mkdirSync(
|
61
|
+
if (!existsSync(nativeFileCacheLocation)) {
|
62
|
+
mkdirSync(nativeFileCacheLocation, { recursive: true });
|
62
63
|
}
|
63
64
|
copyFileSync(nativeLocation, tmpFile);
|
64
65
|
return originalLoad.apply(this, [tmpFile, parent, isMain]);
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const nativeFileCacheLocation: string;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.nativeFileCacheLocation = void 0;
|
4
|
+
const os_1 = require("os");
|
5
|
+
const path_1 = require("path");
|
6
|
+
const crypto_1 = require("crypto");
|
7
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
8
|
+
exports.nativeFileCacheLocation = (0, path_1.join)((0, os_1.tmpdir)(), 'nx-native-file-cache', (0, crypto_1.createHash)('sha256').update(workspace_root_1.workspaceRoot).digest('hex'));
|
@@ -175,7 +175,16 @@ function findTarget(sourcePath, keyMap, targetName, versionRange) {
|
|
175
175
|
const searchPath = `${sourcePath}node_modules/${targetName}`;
|
176
176
|
if (keyMap.has(searchPath)) {
|
177
177
|
const child = keyMap.get(searchPath);
|
178
|
-
if
|
178
|
+
// if the version is alias to another package we need to parse the versions to compare
|
179
|
+
if (child.data.version.startsWith('npm:') &&
|
180
|
+
versionRange.startsWith('npm:')) {
|
181
|
+
const nodeVersion = child.data.version.slice(child.data.version.indexOf('@', 5) + 1);
|
182
|
+
const depVersion = versionRange.slice(versionRange.indexOf('@', 5) + 1);
|
183
|
+
if (nodeVersion === depVersion || (0, semver_1.satisfies)(nodeVersion, depVersion)) {
|
184
|
+
return child;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
else if (child.data.version === versionRange ||
|
179
188
|
(0, semver_1.satisfies)(child.data.version, versionRange)) {
|
180
189
|
return child;
|
181
190
|
}
|
@@ -16,7 +16,7 @@ function loadPnpmHoistedDepsDefinition() {
|
|
16
16
|
const fullPath = `${workspace_root_1.workspaceRoot}/node_modules/.modules.yaml`;
|
17
17
|
if ((0, fs_1.existsSync)(fullPath)) {
|
18
18
|
const content = (0, fs_1.readFileSync)(fullPath, 'utf-8');
|
19
|
-
const { load } = require('
|
19
|
+
const { load } = require('js-yaml');
|
20
20
|
return load(content)?.hoistedDependencies ?? {};
|
21
21
|
}
|
22
22
|
else {
|
@@ -32,7 +32,7 @@ exports.loadPnpmHoistedDepsDefinition = loadPnpmHoistedDepsDefinition;
|
|
32
32
|
* https://github.com/pnpm/pnpm/blob/af3e5559d377870d4c3d303429b3ed1a4e64fedc/lockfile/lockfile-file/src/read.ts#L91
|
33
33
|
*/
|
34
34
|
function parseAndNormalizePnpmLockfile(content) {
|
35
|
-
const { load } = require('
|
35
|
+
const { load } = require('js-yaml');
|
36
36
|
const lockFileData = load(content);
|
37
37
|
return revertFromInlineSpecifiersFormatIfNecessary(convertFromLockfileFileMutable(lockFileData));
|
38
38
|
}
|
@@ -77,7 +77,7 @@ function stringifyToPnpmYaml(lockfile) {
|
|
77
77
|
const adaptedLockfile = isLockfileV6
|
78
78
|
? convertToInlineSpecifiersFormat(lockfile)
|
79
79
|
: lockfile;
|
80
|
-
const { dump } = require('
|
80
|
+
const { dump } = require('js-yaml');
|
81
81
|
return dump(sortLockfileKeys(normalizeLockfile(adaptedLockfile, isLockfileV6)), LOCKFILE_YAML_FORMAT);
|
82
82
|
}
|
83
83
|
exports.stringifyToPnpmYaml = stringifyToPnpmYaml;
|
@@ -60,7 +60,7 @@ function extractFilesFromInputs(inputs, namedInputs) {
|
|
60
60
|
const globalFiles = [];
|
61
61
|
for (const input of inputs) {
|
62
62
|
if (typeof input === 'string' && input in namedInputs) {
|
63
|
-
|
63
|
+
globalFiles.push(...extractFilesFromInputs(namedInputs[input], namedInputs));
|
64
64
|
}
|
65
65
|
else if (typeof input === 'string' &&
|
66
66
|
input.startsWith('{workspaceRoot}/')) {
|
@@ -25,5 +25,5 @@ export declare const nxPluginCache: Map<unknown, [
|
|
25
25
|
Promise<LoadedNxPlugin>,
|
26
26
|
() => void
|
27
27
|
]>;
|
28
|
-
export declare function loadNxPlugins(plugins: PluginConfiguration[], root?: string
|
28
|
+
export declare function loadNxPlugins(plugins: PluginConfiguration[], root?: string): Promise<[LoadedNxPlugin[], () => void]>;
|
29
29
|
export declare function getDefaultPlugins(root: string): Promise<string[]>;
|
@@ -38,14 +38,12 @@ exports.LoadedNxPlugin = LoadedNxPlugin;
|
|
38
38
|
// Allows loaded plugins to not be reloaded when
|
39
39
|
// referenced multiple times.
|
40
40
|
exports.nxPluginCache = new Map();
|
41
|
-
async function loadNxPlugins(plugins, root = workspace_root_1.workspaceRoot
|
41
|
+
async function loadNxPlugins(plugins, root = workspace_root_1.workspaceRoot) {
|
42
42
|
const result = [];
|
43
43
|
const loadingMethod = process.env.NX_ISOLATE_PLUGINS === 'true'
|
44
44
|
? isolation_1.loadNxPluginInIsolation
|
45
45
|
: loader_1.loadNxPlugin;
|
46
|
-
plugins =
|
47
|
-
? plugins ?? []
|
48
|
-
: await normalizePlugins(plugins, root);
|
46
|
+
plugins = await normalizePlugins(plugins, root);
|
49
47
|
const cleanupFunctions = [];
|
50
48
|
for (const plugin of plugins) {
|
51
49
|
const [loadedPluginPromise, cleanup] = loadingMethod(plugin, root);
|
@@ -331,7 +331,7 @@ function writeCompletedTaskResultLine(line) {
|
|
331
331
|
function writeCommandOutputBlock(commandOutput) {
|
332
332
|
commandOutput = commandOutput || '';
|
333
333
|
commandOutput = commandOutput.trimStart();
|
334
|
-
const lines = commandOutput.split(
|
334
|
+
const lines = commandOutput.split(/\r?\n/);
|
335
335
|
let totalTrailingEmptyLines = 0;
|
336
336
|
for (let i = lines.length - 1; i >= 0; i--) {
|
337
337
|
if (lines[i] !== '') {
|
@@ -20,7 +20,7 @@ class PseudoTerminal {
|
|
20
20
|
}
|
21
21
|
constructor(rustPseudoTerminal) {
|
22
22
|
this.rustPseudoTerminal = rustPseudoTerminal;
|
23
|
-
this.pseudoIPCPath = (0, socket_utils_1.
|
23
|
+
this.pseudoIPCPath = (0, socket_utils_1.getForkedProcessOsSocketPath)(process.pid.toString());
|
24
24
|
this.pseudoIPC = new pseudo_ipc_1.PseudoIPCServer(this.pseudoIPCPath);
|
25
25
|
this.initialized = false;
|
26
26
|
this.setupProcessListeners();
|
package/src/utils/json.js
CHANGED
@@ -57,6 +57,6 @@ function formatParseError(input, parseError) {
|
|
57
57
|
* @returns the formatted JSON representation of the object
|
58
58
|
*/
|
59
59
|
function serializeJson(input, options) {
|
60
|
-
return JSON.stringify(input, null, options?.spaces ?? 2)
|
60
|
+
return JSON.stringify(input, null, options?.spaces ?? 2);
|
61
61
|
}
|
62
62
|
exports.serializeJson = serializeJson;
|
@@ -254,11 +254,20 @@ async function resolvePackageVersionUsingRegistry(packageName, version) {
|
|
254
254
|
if (!result) {
|
255
255
|
throw new Error(`Unable to resolve version ${packageName}@${version}.`);
|
256
256
|
}
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
257
|
+
const lines = result.split('\n');
|
258
|
+
if (lines.length === 1) {
|
259
|
+
return lines[0];
|
260
|
+
}
|
261
|
+
/**
|
262
|
+
* The output contains multiple lines ordered by release date, so the last
|
263
|
+
* version might not be the last one in the list. We need to sort it. Each
|
264
|
+
* line looks like:
|
265
|
+
*
|
266
|
+
* <package>@<version> '<version>'
|
267
|
+
*/
|
268
|
+
const resolvedVersion = lines
|
269
|
+
.map((line) => line.split(' ')[1])
|
270
|
+
.sort()
|
262
271
|
.pop()
|
263
272
|
.replace(/'/g, '');
|
264
273
|
return resolvedVersion;
|
@@ -114,7 +114,7 @@ async function listPluginCapabilities(pluginName, projects) {
|
|
114
114
|
if (hasBuilders) {
|
115
115
|
bodyLines.push(chalk.bold(chalk.green('EXECUTORS/BUILDERS')));
|
116
116
|
bodyLines.push('');
|
117
|
-
bodyLines.push(...Object.keys(plugin.executors).map((name) => `${chalk.bold(name)} : ${plugin.executors[name]
|
117
|
+
bodyLines.push(...Object.keys(plugin.executors).map((name) => `${chalk.bold(name)} : ${resolveExecutorDescription(plugin.executors[name], projects)}`));
|
118
118
|
}
|
119
119
|
if (hasProjectGraphExtension) {
|
120
120
|
bodyLines.push(`✔️ Project Graph Extension`);
|
@@ -128,3 +128,26 @@ async function listPluginCapabilities(pluginName, projects) {
|
|
128
128
|
});
|
129
129
|
}
|
130
130
|
exports.listPluginCapabilities = listPluginCapabilities;
|
131
|
+
function resolveExecutorDescription(executorJsonEntry, projects) {
|
132
|
+
try {
|
133
|
+
if (typeof executorJsonEntry === 'string') {
|
134
|
+
// it points to another executor, resolve it
|
135
|
+
const [pkgName, executor] = executorJsonEntry.split(':');
|
136
|
+
const collection = loadExecutorsCollection(workspace_root_1.workspaceRoot, pkgName, projects);
|
137
|
+
return resolveExecutorDescription(collection[executor], projects);
|
138
|
+
}
|
139
|
+
return executorJsonEntry.description;
|
140
|
+
}
|
141
|
+
catch {
|
142
|
+
return 'No description available';
|
143
|
+
}
|
144
|
+
}
|
145
|
+
function loadExecutorsCollection(workspaceRoot, pluginName, projects) {
|
146
|
+
const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(pluginName, projects, (0, installation_directory_1.getNxRequirePaths)(workspaceRoot));
|
147
|
+
return {
|
148
|
+
...tryGetCollection(packageJsonPath, packageJson.builders, 'builders'),
|
149
|
+
...tryGetCollection(packageJsonPath, packageJson.executors, 'builders'),
|
150
|
+
...tryGetCollection(packageJsonPath, packageJson.builders, 'executors'),
|
151
|
+
...tryGetCollection(packageJsonPath, packageJson.executors, 'executors'),
|
152
|
+
};
|
153
|
+
}
|