nx 17.0.0 → 17.0.2

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.
Files changed (36) hide show
  1. package/changelog-renderer/index.d.ts +43 -0
  2. package/changelog-renderer/index.js +180 -0
  3. package/package.json +12 -13
  4. package/schemas/nx-schema.json +141 -0
  5. package/src/adapter/ngcli-adapter.js +32 -0
  6. package/src/command-line/release/changelog.js +332 -75
  7. package/src/command-line/release/command-object.d.ts +1 -3
  8. package/src/command-line/release/command-object.js +3 -17
  9. package/src/command-line/release/config/config.d.ts +1 -1
  10. package/src/command-line/release/config/config.js +153 -50
  11. package/src/command-line/release/utils/markdown.d.ts +1 -4
  12. package/src/command-line/release/utils/markdown.js +3 -136
  13. package/src/command-line/release/utils/print-changes.d.ts +5 -1
  14. package/src/command-line/release/utils/print-changes.js +3 -2
  15. package/src/command-line/show/show.js +2 -0
  16. package/src/config/nx-json.d.ts +80 -3
  17. package/src/config/nx-json.js +1 -1
  18. package/src/config/project-graph.d.ts +1 -1
  19. package/src/core/graph/3rdpartylicenses.txt +76 -26
  20. package/src/core/graph/main.js +1 -1
  21. package/src/core/graph/polyfills.js +1 -1
  22. package/src/core/graph/runtime.js +1 -1
  23. package/src/core/graph/styles.js +1 -1
  24. package/src/daemon/client/client.js +0 -6
  25. package/src/daemon/server/outputs-tracking.d.ts +2 -2
  26. package/src/daemon/server/outputs-tracking.js +2 -2
  27. package/src/daemon/server/project-graph-incremental-recomputation.js +1 -28
  28. package/src/daemon/server/server.js +22 -58
  29. package/src/daemon/server/shutdown-utils.d.ts +0 -6
  30. package/src/daemon/server/shutdown-utils.js +1 -36
  31. package/src/daemon/server/watcher.d.ts +2 -6
  32. package/src/daemon/server/watcher.js +1 -92
  33. package/src/migrations/update-15-0-0/prefix-outputs.js +9 -9
  34. package/src/project-graph/project-graph.js +6 -1
  35. package/src/project-graph/utils/retrieve-workspace-files.js +1 -1
  36. package/src/tasks-runner/utils.js +8 -4
@@ -1 +1 @@
1
- (()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={666:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[l,a,u]=t,d=0;if(l.some((r=>0!==e[r]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(u)var f=u(o)}for(r&&r(t);d<l.length;d++)i=l[d],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(f)},t=self.webpackChunk=self.webpackChunk||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();
1
+ (()=>{"use strict";var e,r={},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={id:e,loaded:!1,exports:{}};return r[e].call(i.exports,i,i.exports,o),i.loaded=!0,i.exports}o.m=r,e=[],o.O=(r,t,n,i)=>{if(!t){var l=1/0;for(f=0;f<e.length;f++){for(var[t,n,i]=e[f],a=!0,u=0;u<t.length;u++)(!1&i||l>=i)&&Object.keys(o.O).every((e=>o.O[e](t[u])))?t.splice(u--,1):(a=!1,i<l&&(l=i));if(a){e.splice(f--,1);var d=n();void 0!==d&&(r=d)}}return r}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[t,n,i]},o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{var e={2:0};o.O.j=r=>0===e[r];var r=(r,t)=>{var n,i,[l,a,u]=t,d=0;if(l.some((r=>0!==e[r]))){for(n in a)o.o(a,n)&&(o.m[n]=a[n]);if(u)var f=u(o)}for(r&&r(t);d<l.length;d++)i=l[d],o.o(e,i)&&e[i]&&e[i][0](),e[i]=0;return o.O(f)},t=self.webpackChunk=self.webpackChunk||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})()})();
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{7407:()=>{}},s=>{var e;e=7407,s(s.s=e)}]);
1
+ "use strict";(self.webpackChunk=self.webpackChunk||[]).push([[3],{7407:(s,e,k)=>{k.r(e)}},s=>{var e;e=7407,s(s.s=e)}]);
@@ -268,12 +268,6 @@ class DaemonClient {
268
268
  (0, fs_extra_1.ensureFileSync)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE);
269
269
  this._out = await (0, promises_1.open)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, 'a');
270
270
  this._err = await (0, promises_1.open)(tmp_dir_1.DAEMON_OUTPUT_LOG_FILE, 'a');
271
- if (this.nxJson.tasksRunnerOptions?.default?.options?.useParcelWatcher) {
272
- DAEMON_ENV_SETTINGS['NX_NATIVE_WATCHER'] = 'false';
273
- }
274
- else {
275
- DAEMON_ENV_SETTINGS['NX_NATIVE_WATCHER'] = 'true';
276
- }
277
271
  const backgroundProcess = (0, child_process_1.spawn)(process.execPath, [(0, path_1.join)(__dirname, '../server/start.js')], {
278
272
  cwd: workspace_root_1.workspaceRoot,
279
273
  stdio: ['ignore', this._out.fd, this._err.fd],
@@ -1,8 +1,8 @@
1
- import type { Event } from '@parcel/watcher';
1
+ import { WatchEvent } from '../../native';
2
2
  export declare function _recordOutputsHash(outputs: string[], hash: string): void;
3
3
  export declare function _outputsHashesMatch(outputs: string[], hash: string): boolean;
4
4
  export declare function recordedHash(output: string): string;
5
5
  export declare function recordOutputsHash(_outputs: string[], hash: string): Promise<void>;
6
6
  export declare function outputsHashesMatch(_outputs: string[], hash: string): Promise<boolean>;
7
- export declare function processFileChangesInOutputs(changeEvents: Event[], now?: number): void;
7
+ export declare function processFileChangesInOutputs(changeEvents: WatchEvent[], now?: number): void;
8
8
  export declare function disableOutputsTracking(): void;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.disableOutputsTracking = exports.processFileChangesInOutputs = exports.outputsHashesMatch = exports.recordOutputsHash = exports.recordedHash = exports._outputsHashesMatch = exports._recordOutputsHash = void 0;
4
4
  const path_1 = require("path");
5
- const workspace_root_1 = require("../../utils/workspace-root");
6
- const collapse_expanded_outputs_1 = require("../../utils/collapse-expanded-outputs");
7
5
  const native_1 = require("../../native");
6
+ const collapse_expanded_outputs_1 = require("../../utils/collapse-expanded-outputs");
7
+ const workspace_root_1 = require("../../utils/workspace-root");
8
8
  let disabled = false;
9
9
  const dirsContainingOutputs = {};
10
10
  const recordedHashes = {};
@@ -9,7 +9,6 @@ const fileutils_1 = require("../../utils/fileutils");
9
9
  const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
10
10
  const logger_1 = require("./logger");
11
11
  const workspace_root_1 = require("../../utils/workspace-root");
12
- const child_process_1 = require("child_process");
13
12
  const file_hasher_1 = require("../../hasher/file-hasher");
14
13
  const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
15
14
  const nx_json_1 = require("../../config/nx-json");
@@ -91,36 +90,10 @@ function computeWorkspaceConfigHash(projectsConfigurations) {
91
90
  .map(([projectName, projectConfig]) => `${projectName}:${JSON.stringify(projectConfig)}`);
92
91
  return (0, file_hasher_1.hashArray)(projectConfigurationStrings);
93
92
  }
94
- /**
95
- * Temporary work around to handle nested gitignores. The parcel file watcher doesn't handle them well,
96
- * so we need to filter them out here.
97
- *
98
- * TODO(Cammisuli): remove after 16.4 - Rust watcher handles nested gitignores
99
- */
100
- function filterUpdatedFiles(files) {
101
- if (files.length === 0) {
102
- return files;
103
- }
104
- try {
105
- const quoted = files.map((f) => '"' + f + '"');
106
- const ignored = (0, child_process_1.execSync)(`git check-ignore ${quoted.join(' ')}`, {
107
- windowsHide: true,
108
- })
109
- .toString()
110
- .split('\n');
111
- return files.filter((f) => ignored.indexOf(f) === -1);
112
- }
113
- catch (e) {
114
- // none of the files were ignored
115
- return files;
116
- }
117
- }
118
93
  async function processCollectedUpdatedAndDeletedFiles() {
119
94
  try {
120
95
  perf_hooks_1.performance.mark('hash-watched-changes-start');
121
- const updatedFiles = filterUpdatedFiles([
122
- ...collectedUpdatedFiles.values(),
123
- ]);
96
+ const updatedFiles = [...collectedUpdatedFiles.values()];
124
97
  const deletedFiles = [...collectedDeletedFiles.values()];
125
98
  let updatedFileHashes = (0, workspace_context_1.updateFilesInContext)(updatedFiles, deletedFiles);
126
99
  perf_hooks_1.performance.mark('hash-watched-changes-end');
@@ -1,31 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.startServer = exports.handleResult = void 0;
4
- const workspace_root_1 = require("../../utils/workspace-root");
4
+ const fs_1 = require("fs");
5
5
  const net_1 = require("net");
6
6
  const path_1 = require("path");
7
7
  const perf_hooks_1 = require("perf_hooks");
8
- const socket_utils_1 = require("../socket-utils");
9
- const logger_1 = require("./logger");
10
- const shutdown_utils_1 = require("./shutdown-utils");
11
- const watcher_1 = require("./watcher");
12
- const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
13
- const fs_1 = require("fs");
14
- const handle_request_project_graph_1 = require("./handle-request-project-graph");
15
- const handle_process_in_background_1 = require("./handle-process-in-background");
16
- const handle_outputs_tracking_1 = require("./handle-outputs-tracking");
8
+ const file_hasher_1 = require("../../hasher/file-hasher");
9
+ const native_1 = require("../../native");
17
10
  const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
18
- const outputs_tracking_1 = require("./outputs-tracking");
19
- const handle_request_shutdown_1 = require("./handle-request-shutdown");
20
- const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
21
- const versions_1 = require("../../utils/versions");
22
11
  const fileutils_1 = require("../../utils/fileutils");
12
+ const versions_1 = require("../../utils/versions");
13
+ const workspace_context_1 = require("../../utils/workspace-context");
14
+ const workspace_root_1 = require("../../utils/workspace-root");
23
15
  const cache_1 = require("../cache");
16
+ const socket_utils_1 = require("../socket-utils");
17
+ const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
24
18
  const handle_hash_tasks_1 = require("./handle-hash-tasks");
25
- const file_hasher_1 = require("../../hasher/file-hasher");
19
+ const handle_outputs_tracking_1 = require("./handle-outputs-tracking");
20
+ const handle_process_in_background_1 = require("./handle-process-in-background");
26
21
  const handle_request_file_data_1 = require("./handle-request-file-data");
27
- const workspace_context_1 = require("../../utils/workspace-context");
28
- const native_1 = require("../../native");
22
+ const handle_request_project_graph_1 = require("./handle-request-project-graph");
23
+ const handle_request_shutdown_1 = require("./handle-request-shutdown");
24
+ const logger_1 = require("./logger");
25
+ const outputs_tracking_1 = require("./outputs-tracking");
26
+ const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
27
+ const shutdown_utils_1 = require("./shutdown-utils");
28
+ const watcher_1 = require("./watcher");
29
29
  let performanceObserver;
30
30
  let workspaceWatcherError;
31
31
  let outputsWatcherError;
@@ -55,7 +55,6 @@ const server = (0, net_1.createServer)(async (socket) => {
55
55
  });
56
56
  });
57
57
  registerProcessTerminationListeners();
58
- registerProcessServerJsonTracking();
59
58
  async function handleMessage(socket, data) {
60
59
  if (workspaceWatcherError) {
61
60
  await (0, shutdown_utils_1.respondWithErrorAndExit)(socket, `File watcher error in the workspace '${workspace_root_1.workspaceRoot}'.`, workspaceWatcherError);
@@ -147,19 +146,6 @@ function registerProcessTerminationListeners() {
147
146
  reason: 'received process SIGHUP',
148
147
  }));
149
148
  }
150
- async function registerProcessServerJsonTracking() {
151
- if (useNativeWatcher()) {
152
- return;
153
- }
154
- (0, shutdown_utils_1.storeProcessJsonSubscription)(await (0, watcher_1.subscribeToServerProcessJsonChanges)(async () => {
155
- if ((0, cache_1.getDaemonProcessIdSync)() !== process.pid) {
156
- await (0, shutdown_utils_1.handleServerProcessTermination)({
157
- server,
158
- reason: 'this process is no longer the current daemon',
159
- });
160
- }
161
- }));
162
- }
163
149
  let existingLockHash;
164
150
  function daemonIsOutdated() {
165
151
  return nxVersionChanged() || lockFileHashChanged();
@@ -295,30 +281,12 @@ async function startServer() {
295
281
  logger_1.serverLogger.log(`Started listening on: ${socket_utils_1.FULL_OS_SOCKET_PATH}`);
296
282
  // this triggers the storage of the lock file hash
297
283
  daemonIsOutdated();
298
- if (useNativeWatcher()) {
299
- if (!(0, shutdown_utils_1.getWatcherInstance)()) {
300
- (0, shutdown_utils_1.storeWatcherInstance)(await (0, watcher_1.watchWorkspace)(server, handleWorkspaceChanges));
301
- logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${workspace_root_1.workspaceRoot} (native)`);
302
- }
303
- if (!(0, shutdown_utils_1.getOutputWatcherInstance)()) {
304
- (0, shutdown_utils_1.storeOutputWatcherInstance)(await (0, watcher_1.watchOutputFiles)(handleOutputsChanges));
305
- }
284
+ if (!(0, shutdown_utils_1.getWatcherInstance)()) {
285
+ (0, shutdown_utils_1.storeWatcherInstance)(await (0, watcher_1.watchWorkspace)(server, handleWorkspaceChanges));
286
+ logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${workspace_root_1.workspaceRoot} (native)`);
306
287
  }
307
- else {
308
- if (!(0, shutdown_utils_1.getSourceWatcherSubscription)()) {
309
- (0, shutdown_utils_1.storeSourceWatcherSubscription)(await (0, watcher_1.subscribeToWorkspaceChanges)(server, handleWorkspaceChanges));
310
- logger_1.serverLogger.watcherLog(`Subscribed to changes within: ${workspace_root_1.workspaceRoot}`);
311
- }
312
- // temporary disable outputs tracking on linux
313
- const outputsTrackingIsEnabled = process.platform != 'linux';
314
- if (outputsTrackingIsEnabled) {
315
- if (!(0, shutdown_utils_1.getOutputsWatcherSubscription)()) {
316
- (0, shutdown_utils_1.storeOutputsWatcherSubscription)(await (0, watcher_1.subscribeToOutputsChanges)(handleOutputsChanges));
317
- }
318
- }
319
- else {
320
- (0, outputs_tracking_1.disableOutputsTracking)();
321
- }
288
+ if (!(0, shutdown_utils_1.getOutputWatcherInstance)()) {
289
+ (0, shutdown_utils_1.storeOutputWatcherInstance)(await (0, watcher_1.watchOutputFiles)(handleOutputsChanges));
322
290
  }
323
291
  return resolve(server);
324
292
  }
@@ -333,7 +301,3 @@ async function startServer() {
333
301
  });
334
302
  }
335
303
  exports.startServer = startServer;
336
- // TODO(cammisuli): remove with nx 16.6 (only our watcher will be supported)
337
- function useNativeWatcher() {
338
- return process.env.NX_NATIVE_WATCHER === 'true';
339
- }
@@ -1,13 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { Server, Socket } from 'net';
3
- import type { AsyncSubscription } from '@parcel/watcher';
4
3
  import type { Watcher } from '../../native';
5
4
  export declare const SERVER_INACTIVITY_TIMEOUT_MS: 10800000;
6
- export declare function getSourceWatcherSubscription(): AsyncSubscription;
7
- export declare function storeSourceWatcherSubscription(s: AsyncSubscription): void;
8
- export declare function getOutputsWatcherSubscription(): AsyncSubscription;
9
- export declare function storeOutputsWatcherSubscription(s: AsyncSubscription): void;
10
- export declare function storeProcessJsonSubscription(s: AsyncSubscription): void;
11
5
  export declare function storeWatcherInstance(instance: Watcher): void;
12
6
  export declare function getWatcherInstance(): Watcher;
13
7
  export declare function storeOutputWatcherInstance(instance: Watcher): void;
@@ -1,34 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.respondWithErrorAndExit = exports.respondToClient = exports.resetInactivityTimeout = exports.handleServerProcessTermination = exports.getOutputWatcherInstance = exports.storeOutputWatcherInstance = exports.getWatcherInstance = exports.storeWatcherInstance = exports.storeProcessJsonSubscription = exports.storeOutputsWatcherSubscription = exports.getOutputsWatcherSubscription = exports.storeSourceWatcherSubscription = exports.getSourceWatcherSubscription = exports.SERVER_INACTIVITY_TIMEOUT_MS = void 0;
3
+ exports.respondWithErrorAndExit = exports.respondToClient = exports.resetInactivityTimeout = exports.handleServerProcessTermination = exports.getOutputWatcherInstance = exports.storeOutputWatcherInstance = exports.getWatcherInstance = exports.storeWatcherInstance = exports.SERVER_INACTIVITY_TIMEOUT_MS = void 0;
4
4
  const workspace_root_1 = require("../../utils/workspace-root");
5
5
  const logger_1 = require("./logger");
6
6
  const socket_utils_1 = require("../socket-utils");
7
7
  const cache_1 = require("../cache");
8
8
  exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
9
- let sourceWatcherSubscription;
10
- let outputsWatcherSubscription;
11
- function getSourceWatcherSubscription() {
12
- return sourceWatcherSubscription;
13
- }
14
- exports.getSourceWatcherSubscription = getSourceWatcherSubscription;
15
- function storeSourceWatcherSubscription(s) {
16
- sourceWatcherSubscription = s;
17
- }
18
- exports.storeSourceWatcherSubscription = storeSourceWatcherSubscription;
19
- function getOutputsWatcherSubscription() {
20
- return outputsWatcherSubscription;
21
- }
22
- exports.getOutputsWatcherSubscription = getOutputsWatcherSubscription;
23
- function storeOutputsWatcherSubscription(s) {
24
- outputsWatcherSubscription = s;
25
- }
26
- exports.storeOutputsWatcherSubscription = storeOutputsWatcherSubscription;
27
- let processJsonSubscription;
28
- function storeProcessJsonSubscription(s) {
29
- processJsonSubscription = s;
30
- }
31
- exports.storeProcessJsonSubscription = storeProcessJsonSubscription;
32
9
  let watcherInstance;
33
10
  function storeWatcherInstance(instance) {
34
11
  watcherInstance = instance;
@@ -51,18 +28,6 @@ async function handleServerProcessTermination({ server, reason, }) {
51
28
  try {
52
29
  server.close();
53
30
  (0, cache_1.deleteDaemonJsonProcessCache)();
54
- if (sourceWatcherSubscription) {
55
- await sourceWatcherSubscription.unsubscribe();
56
- logger_1.serverLogger.watcherLog(`Unsubscribed from changes within: ${workspace_root_1.workspaceRoot} (sources)`);
57
- }
58
- if (outputsWatcherSubscription) {
59
- await outputsWatcherSubscription.unsubscribe();
60
- logger_1.serverLogger.watcherLog(`Unsubscribed from changes within: ${workspace_root_1.workspaceRoot} (outputs)`);
61
- }
62
- if (processJsonSubscription) {
63
- await processJsonSubscription.unsubscribe();
64
- logger_1.serverLogger.watcherLog(`Unsubscribed from changes within: ${workspace_root_1.workspaceRoot} (server-process.json)`);
65
- }
66
31
  if (watcherInstance) {
67
32
  await watcherInstance.stop();
68
33
  logger_1.serverLogger.watcherLog(`Stopping the watcher for ${workspace_root_1.workspaceRoot} (sources)`);
@@ -1,16 +1,12 @@
1
1
  /// <reference types="node" />
2
- import type { AsyncSubscription, Event } from '@parcel/watcher';
3
2
  import { Server } from 'net';
4
3
  import type { WatchEvent } from '../../native';
5
- export type FileWatcherCallback = (err: Error | string | null, changeEvents: Event[] | WatchEvent[] | null) => Promise<void>;
6
- export declare function subscribeToOutputsChanges(cb: FileWatcherCallback): Promise<AsyncSubscription>;
4
+ export type FileWatcherCallback = (err: Error | string | null, changeEvents: WatchEvent[] | null) => Promise<void>;
7
5
  export declare function watchWorkspace(server: Server, cb: FileWatcherCallback): Promise<import("../../native").Watcher>;
8
6
  export declare function watchOutputFiles(cb: FileWatcherCallback): Promise<import("../../native").Watcher>;
9
- export declare function subscribeToWorkspaceChanges(server: Server, cb: FileWatcherCallback): Promise<AsyncSubscription>;
10
- export declare function subscribeToServerProcessJsonChanges(cb: () => void): Promise<AsyncSubscription>;
11
7
  /**
12
8
  * NOTE: An event type of "create" will also apply to the case where the user has restored
13
9
  * an original version of a file after modifying/deleting it by using git, so we adjust
14
10
  * our log language accordingly.
15
11
  */
16
- export declare function convertChangeEventsToLogMessage(changeEvents: Event[]): string;
12
+ export declare function convertChangeEventsToLogMessage(changeEvents: WatchEvent[]): string;
@@ -1,42 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertChangeEventsToLogMessage = exports.subscribeToServerProcessJsonChanges = exports.subscribeToWorkspaceChanges = exports.watchOutputFiles = exports.watchWorkspace = exports.subscribeToOutputsChanges = void 0;
4
- /**
5
- * In addition to its native performance, another great advantage of `@parcel/watcher` is that it will
6
- * automatically take advantage of Facebook's watchman tool (https://facebook.github.io/watchman/) if
7
- * the user has it installed (but not require it if they don't).
8
- *
9
- * See https://github.com/parcel-bundler/watcher for more details.
10
- */
3
+ exports.convertChangeEventsToLogMessage = exports.watchOutputFiles = exports.watchWorkspace = void 0;
11
4
  const workspace_root_1 = require("../../utils/workspace-root");
12
5
  const path_1 = require("path");
13
6
  const socket_utils_1 = require("../socket-utils");
14
7
  const shutdown_utils_1 = require("./shutdown-utils");
15
8
  const path_2 = require("../../utils/path");
16
9
  const ignore_1 = require("../../utils/ignore");
17
- const os_1 = require("os");
18
10
  const cache_1 = require("../cache");
19
11
  const ALWAYS_IGNORE = [...(0, ignore_1.getAlwaysIgnore)(workspace_root_1.workspaceRoot), socket_utils_1.FULL_OS_SOCKET_PATH];
20
- async function subscribeToOutputsChanges(cb) {
21
- const watcher = await Promise.resolve().then(() => require('@parcel/watcher'));
22
- return await watcher.subscribe(workspace_root_1.workspaceRoot, (err, events) => {
23
- if (err) {
24
- return cb(err, null);
25
- }
26
- else {
27
- const workspaceRelativeEvents = [];
28
- for (const event of events) {
29
- const workspaceRelativeEvent = {
30
- type: event.type,
31
- path: (0, path_2.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, event.path)),
32
- };
33
- workspaceRelativeEvents.push(workspaceRelativeEvent);
34
- }
35
- cb(null, workspaceRelativeEvents);
36
- }
37
- }, watcherOptions([...ALWAYS_IGNORE]));
38
- }
39
- exports.subscribeToOutputsChanges = subscribeToOutputsChanges;
40
12
  async function watchWorkspace(server, cb) {
41
13
  const { Watcher } = await Promise.resolve().then(() => require('../../native'));
42
14
  let relativeServerProcess = (0, path_2.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, cache_1.serverProcessJsonPath));
@@ -83,60 +55,6 @@ async function watchOutputFiles(cb) {
83
55
  return watcher;
84
56
  }
85
57
  exports.watchOutputFiles = watchOutputFiles;
86
- async function subscribeToWorkspaceChanges(server, cb) {
87
- /**
88
- * The imports and exports of @nx/workspace are somewhat messy and far reaching across the repo (and beyond),
89
- * and so it is much safer for us to lazily load here `@parcel/watcher` so that its inclusion is not inadvertently
90
- * executed by packages which do not have its necessary native binaries available.
91
- */
92
- const watcher = await Promise.resolve().then(() => require('@parcel/watcher'));
93
- const ignoreObj = (0, ignore_1.getIgnoreObject)();
94
- return await watcher.subscribe(workspace_root_1.workspaceRoot, (err, events) => {
95
- if (err) {
96
- return cb(err, null);
97
- }
98
- let hasIgnoreFileUpdate = false;
99
- // Most of our utilities (ignore, hashing etc) require unix-style workspace relative paths
100
- const workspaceRelativeEvents = [];
101
- for (const event of events) {
102
- const workspaceRelativeEvent = {
103
- type: event.type,
104
- path: (0, path_2.normalizePath)((0, path_1.relative)(workspace_root_1.workspaceRoot, event.path)),
105
- };
106
- if (workspaceRelativeEvent.path.endsWith('.gitignore') ||
107
- workspaceRelativeEvent.path === '.nxignore') {
108
- hasIgnoreFileUpdate = true;
109
- }
110
- workspaceRelativeEvents.push(workspaceRelativeEvent);
111
- }
112
- // If the ignore files themselves have changed we need to dynamically update our cached ignoreGlobs
113
- if (hasIgnoreFileUpdate) {
114
- (0, shutdown_utils_1.handleServerProcessTermination)({
115
- server,
116
- reason: 'Stopping the daemon the set of ignored files changed.',
117
- });
118
- }
119
- const nonIgnoredEvents = workspaceRelativeEvents
120
- .filter(({ path }) => !!path)
121
- .filter(({ path }) => !ignoreObj.ignores(path));
122
- if (nonIgnoredEvents && nonIgnoredEvents.length > 0) {
123
- cb(null, nonIgnoredEvents);
124
- }
125
- }, watcherOptions((0, ignore_1.getIgnoredGlobs)(workspace_root_1.workspaceRoot)));
126
- }
127
- exports.subscribeToWorkspaceChanges = subscribeToWorkspaceChanges;
128
- // TODO: When we update @parcel/watcher to a version that handles negation globs, then this can be folded into the workspace watcher
129
- async function subscribeToServerProcessJsonChanges(cb) {
130
- const watcher = await Promise.resolve().then(() => require('@parcel/watcher'));
131
- return await watcher.subscribe((0, path_1.dirname)(cache_1.serverProcessJsonPath), (err, events) => {
132
- for (const event of events) {
133
- if (event.path === cache_1.serverProcessJsonPath) {
134
- cb();
135
- }
136
- }
137
- }, watcherOptions([]));
138
- }
139
- exports.subscribeToServerProcessJsonChanges = subscribeToServerProcessJsonChanges;
140
58
  /**
141
59
  * NOTE: An event type of "create" will also apply to the case where the user has restored
142
60
  * an original version of a file after modifying/deleting it by using git, so we adjust
@@ -179,12 +97,3 @@ function convertChangeEventsToLogMessage(changeEvents) {
179
97
  return `${numCreatedOrRestoredFiles} file(s) created or restored, ${numModifiedFiles} file(s) modified, ${numDeletedFiles} file(s) deleted`;
180
98
  }
181
99
  exports.convertChangeEventsToLogMessage = convertChangeEventsToLogMessage;
182
- function watcherOptions(ignore) {
183
- const options = {
184
- ignore,
185
- };
186
- if ((0, os_1.platform)() === 'win32') {
187
- options.backend = 'windows';
188
- }
189
- return options;
190
- }
@@ -3,8 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
4
4
  const project_configuration_1 = require("../../generators/utils/project-configuration");
5
5
  const nx_json_1 = require("../../generators/utils/nx-json");
6
- const path_1 = require("../../utils/path");
7
- const path_2 = require("path");
6
+ const path_1 = require("path");
8
7
  const utils_1 = require("../../tasks-runner/utils");
9
8
  const json_1 = require("../../generators/utils/json");
10
9
  async function default_1(tree) {
@@ -29,8 +28,8 @@ async function default_1(tree) {
29
28
  (0, project_configuration_1.updateProjectConfiguration)(tree, projectName, project);
30
29
  }
31
30
  catch {
32
- if (tree.exists((0, path_2.join)(project.root, 'package.json'))) {
33
- (0, json_1.updateJson)(tree, (0, path_2.join)(project.root, 'package.json'), (json) => {
31
+ if (tree.exists((0, path_1.join)(project.root, 'package.json'))) {
32
+ (0, json_1.updateJson)(tree, (0, path_1.join)(project.root, 'package.json'), (json) => {
34
33
  for (const target of Object.values(json.nx?.targets ?? {})) {
35
34
  if (target.outputs) {
36
35
  try {
@@ -51,11 +50,12 @@ async function default_1(tree) {
51
50
  if (!target.outputs) {
52
51
  continue;
53
52
  }
54
- target.outputs = target.outputs.map((output) => {
55
- return /^{[\s\S]+}/.test(output)
56
- ? output
57
- : (0, path_1.joinPathFragments)('{workspaceRoot}', output);
58
- });
53
+ try {
54
+ (0, utils_1.validateOutputs)(target.outputs);
55
+ }
56
+ catch (e) {
57
+ target.outputs = (0, utils_1.transformLegacyOutputs)('{projectRoot}', e);
58
+ }
59
59
  }
60
60
  (0, nx_json_1.updateNxJson)(tree, nxJson);
61
61
  }
@@ -44,7 +44,12 @@ exports.readCachedProjectGraph = readCachedProjectGraph;
44
44
  function readCachedProjectConfiguration(projectName) {
45
45
  const graph = readCachedProjectGraph();
46
46
  const node = graph.nodes[projectName];
47
- return node.data;
47
+ try {
48
+ return node.data;
49
+ }
50
+ catch (e) {
51
+ throw new Error(`Cannot find project: '${projectName}' in your workspace.`);
52
+ }
48
53
  }
49
54
  exports.readCachedProjectConfiguration = readCachedProjectConfiguration;
50
55
  /**
@@ -121,7 +121,7 @@ exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectCon
121
121
  function buildAllWorkspaceFiles(projectFileMap, globalFiles) {
122
122
  perf_hooks_1.performance.mark('get-all-workspace-files:start');
123
123
  let fileData = Object.values(projectFileMap).flat();
124
- fileData = fileData.concat(globalFiles);
124
+ fileData = fileData.concat(globalFiles).sort();
125
125
  perf_hooks_1.performance.mark('get-all-workspace-files:end');
126
126
  perf_hooks_1.performance.measure('get-all-workspace-files', 'get-all-workspace-files:start', 'get-all-workspace-files:end');
127
127
  return fileData;
@@ -80,7 +80,7 @@ class InvalidOutputsError extends Error {
80
80
  function validateOutputs(outputs) {
81
81
  const invalidOutputs = new Set();
82
82
  for (const output of outputs) {
83
- if (!/^{[\s\S]+}/.test(output)) {
83
+ if (!/^!?{[\s\S]+}/.test(output)) {
84
84
  invalidOutputs.add(output);
85
85
  }
86
86
  }
@@ -94,11 +94,15 @@ function transformLegacyOutputs(projectRoot, error) {
94
94
  if (!error.invalidOutputs.has(output)) {
95
95
  return output;
96
96
  }
97
- const relativePath = (0, fileutils_1.isRelativePath)(output)
97
+ let [isNegated, outputPath] = output.startsWith('!')
98
+ ? [true, output.substring(1)]
99
+ : [false, output];
100
+ const relativePath = (0, fileutils_1.isRelativePath)(outputPath)
98
101
  ? output
99
- : (0, path_1.relative)(projectRoot, output);
102
+ : (0, path_1.relative)(projectRoot, outputPath);
100
103
  const isWithinProject = !relativePath.startsWith('..');
101
- return (0, path_2.joinPathFragments)(isWithinProject ? '{projectRoot}' : '{workspaceRoot}', isWithinProject ? relativePath : output);
104
+ return ((isNegated ? '!' : '') +
105
+ (0, path_2.joinPathFragments)(isWithinProject ? '{projectRoot}' : '{workspaceRoot}', isWithinProject ? relativePath : outputPath));
102
106
  });
103
107
  }
104
108
  exports.transformLegacyOutputs = transformLegacyOutputs;