nx 19.0.3 → 19.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "19.0.3",
3
+ "version": "19.0.4",
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": {
@@ -66,7 +66,7 @@
66
66
  "yargs-parser": "21.1.1",
67
67
  "node-machine-id": "1.1.12",
68
68
  "ora": "5.3.0",
69
- "@nrwl/tao": "19.0.3"
69
+ "@nrwl/tao": "19.0.4"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@swc-node/register": "^1.8.0",
@@ -81,16 +81,16 @@
81
81
  }
82
82
  },
83
83
  "optionalDependencies": {
84
- "@nx/nx-darwin-x64": "19.0.3",
85
- "@nx/nx-darwin-arm64": "19.0.3",
86
- "@nx/nx-linux-x64-gnu": "19.0.3",
87
- "@nx/nx-linux-x64-musl": "19.0.3",
88
- "@nx/nx-win32-x64-msvc": "19.0.3",
89
- "@nx/nx-linux-arm64-gnu": "19.0.3",
90
- "@nx/nx-linux-arm64-musl": "19.0.3",
91
- "@nx/nx-linux-arm-gnueabihf": "19.0.3",
92
- "@nx/nx-win32-arm64-msvc": "19.0.3",
93
- "@nx/nx-freebsd-x64": "19.0.3"
84
+ "@nx/nx-darwin-x64": "19.0.4",
85
+ "@nx/nx-darwin-arm64": "19.0.4",
86
+ "@nx/nx-linux-x64-gnu": "19.0.4",
87
+ "@nx/nx-linux-x64-musl": "19.0.4",
88
+ "@nx/nx-win32-x64-msvc": "19.0.4",
89
+ "@nx/nx-linux-arm64-gnu": "19.0.4",
90
+ "@nx/nx-linux-arm64-musl": "19.0.4",
91
+ "@nx/nx-linux-arm-gnueabihf": "19.0.4",
92
+ "@nx/nx-win32-arm64-msvc": "19.0.4",
93
+ "@nx/nx-freebsd-x64": "19.0.4"
94
94
  },
95
95
  "nx-migrations": {
96
96
  "migrations": "./migrations.json",
@@ -3,5 +3,8 @@ import { ProjectGraph, ProjectGraphProjectNode } from '../../config/project-grap
3
3
  import { TargetDependencyConfig } from '../../config/workspace-json-project-json';
4
4
  export declare function affected(command: 'graph' | 'print-affected' | 'affected', args: {
5
5
  [k: string]: any;
6
- }, extraTargetDependencies?: Record<string, (TargetDependencyConfig | string)[]>): Promise<void>;
6
+ }, extraTargetDependencies?: Record<string, (TargetDependencyConfig | string)[]>, extraOptions?: {
7
+ excludeTaskDependencies: boolean;
8
+ loadDotEnvFiles: boolean;
9
+ }): Promise<void>;
7
10
  export declare function getAffectedGraphNodes(nxArgs: NxArgs, projectGraph: ProjectGraph): Promise<ProjectGraphProjectNode[]>;
@@ -15,7 +15,10 @@ const workspace_configuration_check_1 = require("../../utils/workspace-configura
15
15
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
16
16
  const graph_1 = require("../graph/graph");
17
17
  const all_file_data_1 = require("../../utils/all-file-data");
18
- async function affected(command, args, extraTargetDependencies = {}) {
18
+ async function affected(command, args, extraTargetDependencies = {}, extraOptions = {
19
+ excludeTaskDependencies: false,
20
+ loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
21
+ }) {
19
22
  perf_hooks_1.performance.mark('code-loading:end');
20
23
  perf_hooks_1.performance.measure('code-loading', 'init-local', 'code-loading:end');
21
24
  (0, workspace_configuration_check_1.workspaceConfigurationCheck)();
@@ -46,7 +49,7 @@ async function affected(command, args, extraTargetDependencies = {}) {
46
49
  }, projectNames);
47
50
  }
48
51
  else {
49
- const status = await (0, run_command_1.runCommand)(projectsWithTarget, projectGraph, { nxJson }, nxArgs, overrides, null, extraTargetDependencies, { excludeTaskDependencies: false, loadDotEnvFiles: true });
52
+ const status = await (0, run_command_1.runCommand)(projectsWithTarget, projectGraph, { nxJson }, nxArgs, overrides, null, extraTargetDependencies, extraOptions);
50
53
  process.exit(status);
51
54
  }
52
55
  break;
@@ -255,7 +255,7 @@ async function generateGraph(args, affectedProjects) {
255
255
  const environmentJs = buildEnvironmentJs(args.exclude || [], args.watch, !!args.file && args.file.endsWith('html') ? 'build' : 'serve', projectGraphClientResponse, taskGraphClientResponse, taskInputsReponse, sourceMaps);
256
256
  html = html.replace(/src="/g, 'src="static/');
257
257
  html = html.replace(/href="styles/g, 'href="static/styles');
258
- html = html.replace('<base href="/" />', '');
258
+ html = html.replace(/<base href="\/".*>/g, '');
259
259
  html = html.replace(/type="module"/g, '');
260
260
  (0, fs_1.writeFileSync)(fullFilePath, html);
261
261
  (0, fs_1.writeFileSync)((0, path_1.join)(assetsFolder, 'environment.js'), environmentJs);
@@ -54,7 +54,10 @@ async function releasePublish(args, isCLI = false) {
54
54
  * Run publishing for all remaining release groups and filtered projects within them
55
55
  */
56
56
  for (const releaseGroup of releaseGroups) {
57
- const status = await runPublishOnProjects(_args, projectGraph, nxJson, Array.from(releaseGroupToFilteredProjects.get(releaseGroup)), shouldExcludeTaskDependencies, isCLI);
57
+ const status = await runPublishOnProjects(_args, projectGraph, nxJson, Array.from(releaseGroupToFilteredProjects.get(releaseGroup)), isCLI, {
58
+ excludeTaskDependencies: shouldExcludeTaskDependencies,
59
+ loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
60
+ });
58
61
  if (status !== 0) {
59
62
  overallExitStatus = status || 1;
60
63
  }
@@ -65,7 +68,10 @@ async function releasePublish(args, isCLI = false) {
65
68
  * Run publishing for all remaining release groups
66
69
  */
67
70
  for (const releaseGroup of releaseGroups) {
68
- const status = await runPublishOnProjects(_args, projectGraph, nxJson, releaseGroup.projects, shouldExcludeTaskDependencies, isCLI);
71
+ const status = await runPublishOnProjects(_args, projectGraph, nxJson, releaseGroup.projects, isCLI, {
72
+ excludeTaskDependencies: shouldExcludeTaskDependencies,
73
+ loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
74
+ });
69
75
  if (status !== 0) {
70
76
  overallExitStatus = status || 1;
71
77
  }
@@ -73,7 +79,7 @@ async function releasePublish(args, isCLI = false) {
73
79
  return overallExitStatus;
74
80
  }
75
81
  exports.releasePublish = releasePublish;
76
- async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, shouldExcludeTaskDependencies, isCLI) {
82
+ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, isCLI, extraOptions) {
77
83
  const projectsToRun = projectNames.map((projectName) => projectGraph.nodes[projectName]);
78
84
  const overrides = (0, command_line_utils_1.createOverrides)(args.__overrides_unparsed__);
79
85
  if (args.registry) {
@@ -131,10 +137,7 @@ async function runPublishOnProjects(args, projectGraph, nxJson, projectNames, sh
131
137
  targets: [requiredTargetName],
132
138
  outputStyle: 'static',
133
139
  ...args,
134
- }, overrides, null, {}, {
135
- excludeTaskDependencies: shouldExcludeTaskDependencies,
136
- loadDotEnvFiles: true,
137
- });
140
+ }, overrides, null, {}, extraOptions);
138
141
  if (status !== 0) {
139
142
  // In order to not add noise to the overall CLI output, do not throw an additional error
140
143
  if (isCLI) {
@@ -5,6 +5,7 @@ const fs_extra_1 = require("fs-extra");
5
5
  const client_1 = require("../../daemon/client/client");
6
6
  const cache_directory_1 = require("../../utils/cache-directory");
7
7
  const output_1 = require("../../utils/output");
8
+ const native_file_cache_location_1 = require("../../native/native-file-cache-location");
8
9
  async function resetHandler() {
9
10
  output_1.output.note({
10
11
  title: 'Resetting the Nx workspace cache and stopping the Nx Daemon.',
@@ -12,6 +13,12 @@ async function resetHandler() {
12
13
  });
13
14
  await client_1.daemonClient.stop();
14
15
  output_1.output.log({ title: 'Daemon Server - Stopped' });
16
+ try {
17
+ (0, fs_extra_1.rmSync)(native_file_cache_location_1.nativeFileCacheLocation, { recursive: true, force: true });
18
+ }
19
+ catch (e) {
20
+ // ignore, deleting the native file cache is not critical and can fail if another process is locking the file
21
+ }
15
22
  (0, fs_extra_1.rmSync)(cache_directory_1.cacheDir, { recursive: true, force: true });
16
23
  if (cache_directory_1.projectGraphCacheDirectory !== cache_directory_1.cacheDir) {
17
24
  (0, fs_extra_1.rmSync)(cache_directory_1.projectGraphCacheDirectory, { recursive: true, force: true });
@@ -13,7 +13,10 @@ const configuration_1 = require("../../config/configuration");
13
13
  const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
14
14
  const workspace_configuration_check_1 = require("../../utils/workspace-configuration-check");
15
15
  const graph_1 = require("../graph/graph");
16
- async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = { excludeTaskDependencies: false, loadDotEnvFiles: true }) {
16
+ async function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = {
17
+ excludeTaskDependencies: false,
18
+ loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
19
+ }) {
17
20
  perf_hooks_1.performance.mark('code-loading:end');
18
21
  perf_hooks_1.performance.measure('code-loading', 'init-local', 'code-loading:end');
19
22
  (0, workspace_configuration_check_1.workspaceConfigurationCheck)();
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.run = exports.printTargetRunHelp = exports.runExecutor = exports.validateProject = exports.printRunHelp = void 0;
4
+ const npm_run_path_1 = require("npm-run-path");
4
5
  const params_1 = require("../../utils/params");
5
6
  const print_help_1 = require("../../utils/print-help");
6
7
  const path_1 = require("path");
@@ -68,17 +69,24 @@ async function printTargetRunHelpInternal({ project, target }, root, projectsCon
68
69
  targetConfig.options.command) {
69
70
  const command = targetConfig.options.command.split(' ')[0];
70
71
  const helpCommand = `${command} --help`;
72
+ const localEnv = (0, npm_run_path_1.env)();
73
+ const env = {
74
+ ...process.env,
75
+ ...localEnv,
76
+ };
71
77
  if (pseudo_terminal_1.PseudoTerminal.isSupported()) {
72
78
  const terminal = (0, pseudo_terminal_1.getPseudoTerminal)();
73
79
  await new Promise(() => {
74
- const cp = terminal.runCommand(helpCommand);
80
+ const cp = terminal.runCommand(helpCommand, { jsEnv: env });
75
81
  cp.onExit((code) => {
76
82
  process.exit(code);
77
83
  });
78
84
  });
79
85
  }
80
86
  else {
81
- const cp = (0, child_process_1.exec)(helpCommand);
87
+ const cp = (0, child_process_1.exec)(helpCommand, {
88
+ env,
89
+ });
82
90
  cp.on('exit', (code) => {
83
91
  process.exit(code);
84
92
  });
@@ -13,7 +13,10 @@ const output_1 = require("../../utils/output");
13
13
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
14
14
  const workspace_configuration_check_1 = require("../../utils/workspace-configuration-check");
15
15
  const graph_1 = require("../graph/graph");
16
- async function runMany(args, extraTargetDependencies = {}, extraOptions = { excludeTaskDependencies: false, loadDotEnvFiles: true }) {
16
+ async function runMany(args, extraTargetDependencies = {}, extraOptions = {
17
+ excludeTaskDependencies: false,
18
+ loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
19
+ }) {
17
20
  perf_hooks_1.performance.mark('code-loading:end');
18
21
  perf_hooks_1.performance.measure('code-loading', 'init-local', 'code-loading:end');
19
22
  (0, workspace_configuration_check_1.workspaceConfigurationCheck)();
@@ -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.FULL_OS_SOCKET_PATH)).listen((message) => {
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.FULL_OS_SOCKET_PATH, () => {
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.FULL_OS_SOCKET_PATH)).listen((message) => this.handleMessage(message), () => {
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()) {
@@ -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.FULL_OS_SOCKET_PATH, async () => {
276
+ server.listen((0, socket_utils_1.getFullOsSocketPath)(), async () => {
277
277
  try {
278
- logger_1.serverLogger.log(`Started listening on: ${socket_utils_1.FULL_OS_SOCKET_PATH}`);
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 = [...(0, ignore_1.getAlwaysIgnore)(workspace_root_1.workspaceRoot), socket_utils_1.FULL_OS_SOCKET_PATH];
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 FULL_OS_SOCKET_PATH: string;
9
- export declare const FORKED_PROCESS_OS_SOCKET_PATH: (id: string) => string;
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.FORKED_PROCESS_OS_SOCKET_PATH = exports.FULL_OS_SOCKET_PATH = exports.isWindows = void 0;
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
- exports.FULL_OS_SOCKET_PATH = exports.isWindows
17
- ? '\\\\.\\pipe\\nx\\' + (0, path_1.resolve)(tmp_dir_1.DAEMON_SOCKET_PATH)
18
- : (0, path_1.resolve)(tmp_dir_1.DAEMON_SOCKET_PATH);
19
- const FORKED_PROCESS_OS_SOCKET_PATH = (id) => {
20
- let path = (0, path_1.resolve)((0, path_1.join)(tmp_dir_1.socketDir, 'fp' + id + '.sock'));
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.FORKED_PROCESS_OS_SOCKET_PATH = FORKED_PROCESS_OS_SOCKET_PATH;
24
+ exports.getForkedProcessOsSocketPath = getForkedProcessOsSocketPath;
24
25
  function killSocketOrPath() {
25
26
  try {
26
- (0, fs_1.unlinkSync)(exports.FULL_OS_SOCKET_PATH);
27
+ (0, fs_1.unlinkSync)((0, exports.getFullOsSocketPath)());
27
28
  }
28
29
  catch { }
29
30
  }
@@ -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 socketDir: string;
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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeSocketDir = exports.isDaemonDisabled = exports.markDaemonAsDisabled = exports.writeDaemonLogs = exports.DAEMON_SOCKET_PATH = exports.socketDir = exports.DAEMON_OUTPUT_LOG_FILE = exports.DAEMON_DIR_FOR_CURRENT_WORKSPACE = void 0;
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
- exports.socketDir = createSocketDir();
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 createSocketDir() {
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)(exports.socketDir, { recursive: true, force: true });
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, isCompatibleTarget, } from './project-graph/utils/project-configuration-utils';
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, loadNxPlugins, } from './project-graph/plugins/internal-api';
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';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerTsProject = exports.loadNxPlugins = 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.isCompatibleTarget = exports.readProjectConfigurationsFromRootMap = exports.mergeTargetConfigurations = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.deepEquals = exports.createTempNpmDirectory = void 0;
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
- await loadEnvVars(options.envFile);
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".');
@@ -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('=');
@@ -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 { cacheDir } = require('../utils/cache-directory');
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
- // we copy the file to the cache directory (.nx/cache by default) and prefix with nxVersion to avoid stale files being loaded
56
- const tmpFile = join(cacheDir, nxVersion + '-' + fileName);
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(cacheDir)) {
61
- mkdirSync(cacheDir, { recursive: true });
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'));
@@ -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
- return extractFilesFromInputs(namedInputs[input], namedInputs);
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, skipDefaultPlugins?: boolean): Promise<[LoadedNxPlugin[], () => void]>;
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, skipDefaultPlugins = false) {
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 = skipDefaultPlugins
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(os_1.EOL);
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.FORKED_PROCESS_OS_SOCKET_PATH)(process.pid.toString());
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();
@@ -22,6 +22,15 @@ function findMatchingProjects(patterns = [], projects) {
22
22
  }
23
23
  const projectNames = Object.keys(projects);
24
24
  const matchedProjects = new Set();
25
+ // If the first pattern is an exclude pattern,
26
+ // we add a wildcard pattern at the first to select
27
+ // all projects, except the ones that match the exclude pattern.
28
+ // e.g. ['!tag:someTag', 'project2'] will match all projects except
29
+ // the ones with the tag 'someTag', and also match the project 'project2',
30
+ // regardless of its tags.
31
+ if (isExcludePattern(patterns[0])) {
32
+ patterns.unshift('*');
33
+ }
25
34
  for (const stringPattern of patterns) {
26
35
  if (!stringPattern.length) {
27
36
  continue;
@@ -139,8 +148,11 @@ function addMatchingProjectsByTag(projectNames, projects, pattern, matchedProjec
139
148
  }
140
149
  }
141
150
  }
151
+ function isExcludePattern(pattern) {
152
+ return pattern.startsWith('!');
153
+ }
142
154
  function parseStringPattern(pattern, projects) {
143
- const isExclude = pattern.startsWith('!');
155
+ const isExclude = isExcludePattern(pattern);
144
156
  // Support for things like: `!{type}:value`
145
157
  if (isExclude) {
146
158
  pattern = pattern.substring(1);