nx 19.7.0-beta.2 → 19.7.0-beta.3

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.7.0-beta.2",
3
+ "version": "19.7.0-beta.3",
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": {
@@ -71,7 +71,7 @@
71
71
  "yargs-parser": "21.1.1",
72
72
  "node-machine-id": "1.1.12",
73
73
  "ora": "5.3.0",
74
- "@nrwl/tao": "19.7.0-beta.2"
74
+ "@nrwl/tao": "19.7.0-beta.3"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@swc-node/register": "^1.8.0",
@@ -86,16 +86,16 @@
86
86
  }
87
87
  },
88
88
  "optionalDependencies": {
89
- "@nx/nx-darwin-x64": "19.7.0-beta.2",
90
- "@nx/nx-darwin-arm64": "19.7.0-beta.2",
91
- "@nx/nx-linux-x64-gnu": "19.7.0-beta.2",
92
- "@nx/nx-linux-x64-musl": "19.7.0-beta.2",
93
- "@nx/nx-win32-x64-msvc": "19.7.0-beta.2",
94
- "@nx/nx-linux-arm64-gnu": "19.7.0-beta.2",
95
- "@nx/nx-linux-arm64-musl": "19.7.0-beta.2",
96
- "@nx/nx-linux-arm-gnueabihf": "19.7.0-beta.2",
97
- "@nx/nx-win32-arm64-msvc": "19.7.0-beta.2",
98
- "@nx/nx-freebsd-x64": "19.7.0-beta.2"
89
+ "@nx/nx-darwin-x64": "19.7.0-beta.3",
90
+ "@nx/nx-darwin-arm64": "19.7.0-beta.3",
91
+ "@nx/nx-linux-x64-gnu": "19.7.0-beta.3",
92
+ "@nx/nx-linux-x64-musl": "19.7.0-beta.3",
93
+ "@nx/nx-win32-x64-msvc": "19.7.0-beta.3",
94
+ "@nx/nx-linux-arm64-gnu": "19.7.0-beta.3",
95
+ "@nx/nx-linux-arm64-musl": "19.7.0-beta.3",
96
+ "@nx/nx-linux-arm-gnueabihf": "19.7.0-beta.3",
97
+ "@nx/nx-win32-arm64-msvc": "19.7.0-beta.3",
98
+ "@nx/nx-freebsd-x64": "19.7.0-beta.3"
99
99
  },
100
100
  "nx-migrations": {
101
101
  "migrations": "./migrations.json",
@@ -282,6 +282,13 @@
282
282
  "applyChanges": {
283
283
  "type": "boolean",
284
284
  "description": "Whether to automatically apply sync generator changes when running tasks. If not set, the user will be prompted. If set to `true`, the user will not be prompted and the changes will be applied. If set to `false`, the user will not be prompted and the changes will not be applied."
285
+ },
286
+ "disabledTaskSyncGenerators": {
287
+ "type": "array",
288
+ "items": {
289
+ "type": "string"
290
+ },
291
+ "description": "List of registered task sync generators to disable."
285
292
  }
286
293
  },
287
294
  "additionalProperties": false
@@ -10,19 +10,21 @@ export declare class ReleaseClient {
10
10
  release: (args: import("./command-object").ReleaseOptions) => Promise<import("./version").NxReleaseVersionResult | number>;
11
11
  constructor(overrideReleaseConfig: NxReleaseConfiguration);
12
12
  }
13
+ declare const defaultClient: ReleaseClient;
13
14
  /**
14
15
  * @public
15
16
  */
16
- export declare const releaseChangelog: any;
17
+ export declare const releaseChangelog: typeof defaultClient.releaseChangelog;
17
18
  /**
18
19
  * @public
19
20
  */
20
- export declare const releasePublish: any;
21
+ export declare const releasePublish: typeof defaultClient.releasePublish;
21
22
  /**
22
23
  * @public
23
24
  */
24
- export declare const releaseVersion: any;
25
+ export declare const releaseVersion: typeof defaultClient.releaseVersion;
25
26
  /**
26
27
  * @public
27
28
  */
28
- export declare const release: any;
29
+ export declare const release: typeof defaultClient.release;
30
+ export {};
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.syncHandler = syncHandler;
4
4
  const ora = require("ora");
5
+ const nx_json_1 = require("../../config/nx-json");
5
6
  const project_graph_1 = require("../../project-graph/project-graph");
6
7
  const output_1 = require("../../utils/output");
7
8
  const params_1 = require("../../utils/params");
@@ -10,7 +11,17 @@ const chalk = require("chalk");
10
11
  function syncHandler(options) {
11
12
  return (0, params_1.handleErrors)(options.verbose, async () => {
12
13
  const projectGraph = await (0, project_graph_1.createProjectGraphAsync)();
13
- const syncGenerators = await (0, sync_generators_1.collectAllRegisteredSyncGenerators)(projectGraph);
14
+ const nxJson = (0, nx_json_1.readNxJson)();
15
+ const syncGenerators = await (0, sync_generators_1.collectAllRegisteredSyncGenerators)(projectGraph, nxJson);
16
+ if (!syncGenerators.length) {
17
+ output_1.output.success({
18
+ title: options.check
19
+ ? 'The workspace is up to date'
20
+ : 'The workspace is already up to date',
21
+ bodyLines: ['There are no sync generators to run.'],
22
+ });
23
+ return 0;
24
+ }
14
25
  const results = await (0, sync_generators_1.getSyncGeneratorChanges)(syncGenerators);
15
26
  if (!results.length) {
16
27
  output_1.output.success({
@@ -286,11 +286,15 @@ export interface NxSyncConfiguration {
286
286
  };
287
287
  /**
288
288
  * Whether to automatically apply sync generator changes when running tasks.
289
- * If not set, the user will be prompted.
289
+ * If not set, the user will be prompted in interactive mode.
290
290
  * If set to `true`, the user will not be prompted and the changes will be applied.
291
291
  * If set to `false`, the user will not be prompted and the changes will not be applied.
292
292
  */
293
293
  applyChanges?: boolean;
294
+ /**
295
+ * List of registered task sync generators to disable.
296
+ */
297
+ disabledTaskSyncGenerators?: string[];
294
298
  }
295
299
  /**
296
300
  * Nx.json configuration
@@ -21,6 +21,7 @@ let registeredSyncGenerators;
21
21
  let scheduledTimeoutId;
22
22
  let storedProjectGraphHash;
23
23
  let storedNxJsonHash;
24
+ let storedDisabledTaskSyncGeneratorsHash;
24
25
  const log = (...messageParts) => {
25
26
  logger_1.serverLogger.log('[SYNC]:', ...messageParts);
26
27
  };
@@ -107,6 +108,10 @@ function collectAndScheduleSyncGenerators(projectGraph) {
107
108
  // a change imply we need to re-run all the generators
108
109
  // make sure to schedule all the collected generators
109
110
  scheduledGenerators.clear();
111
+ if (!registeredSyncGenerators.size) {
112
+ // there are no generators to run
113
+ return;
114
+ }
110
115
  for (const generator of registeredSyncGenerators) {
111
116
  scheduledGenerators.add(generator);
112
117
  }
@@ -144,16 +149,19 @@ async function getCachedRegisteredSyncGenerators() {
144
149
  return [...registeredSyncGenerators];
145
150
  }
146
151
  function collectAllRegisteredSyncGenerators(projectGraph) {
152
+ const nxJson = (0, nx_json_1.readNxJson)();
147
153
  const projectGraphHash = hashProjectGraph(projectGraph);
148
- if (storedProjectGraphHash !== projectGraphHash) {
154
+ const disabledTaskSyncGeneratorsHash = (0, file_hasher_1.hashArray)(nxJson.sync?.disabledTaskSyncGenerators?.sort() ?? []);
155
+ if (projectGraphHash !== storedProjectGraphHash ||
156
+ disabledTaskSyncGeneratorsHash !== storedDisabledTaskSyncGeneratorsHash) {
149
157
  storedProjectGraphHash = projectGraphHash;
158
+ storedDisabledTaskSyncGeneratorsHash = disabledTaskSyncGeneratorsHash;
150
159
  registeredTaskSyncGenerators =
151
- (0, sync_generators_1.collectRegisteredTaskSyncGenerators)(projectGraph);
160
+ (0, sync_generators_1.collectEnabledTaskSyncGeneratorsFromProjectGraph)(projectGraph, nxJson);
152
161
  }
153
162
  else {
154
163
  log('project graph hash is the same, not collecting task sync generators');
155
164
  }
156
- const nxJson = (0, nx_json_1.readNxJson)();
157
165
  const nxJsonHash = (0, file_hasher_1.hashArray)(nxJson.sync?.globalGenerators?.sort() ?? []);
158
166
  if (storedNxJsonHash !== nxJsonHash) {
159
167
  storedNxJsonHash = nxJsonHash;
Binary file
@@ -11,7 +11,7 @@ export interface NxCloudClient {
11
11
  configureLightClientRequire: () => (paths: string[]) => void;
12
12
  commands: Record<string, () => Promise<void>>;
13
13
  nxCloudTasksRunner: TasksRunner<CloudTaskRunnerOptions>;
14
- remoteCache: RemoteCacheV2;
14
+ getRemoteCache: () => RemoteCacheV2;
15
15
  }
16
16
  export declare function verifyOrUpdateNxCloudClient(options: CloudTaskRunnerOptions): Promise<{
17
17
  nxCloudClient: NxCloudClient;
@@ -81,8 +81,8 @@ class DbCache {
81
81
  if ((0, nx_cloud_utils_1.isNxCloudUsed)(nxJson)) {
82
82
  const options = (0, get_cloud_options_1.getCloudOptions)();
83
83
  const { nxCloudClient } = await (0, update_manager_1.verifyOrUpdateNxCloudClient)(options);
84
- if (nxCloudClient.remoteCache) {
85
- return nxCloudClient.remoteCache;
84
+ if (nxCloudClient.getRemoteCache) {
85
+ return nxCloudClient.getRemoteCache();
86
86
  }
87
87
  else {
88
88
  // old nx cloud instance
@@ -121,16 +121,7 @@ async function runCommand(projectsToRun, currentProjectGraph, { nxJson }, nxArgs
121
121
  async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions) {
122
122
  let taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
123
123
  // collect unique syncGenerators from the tasks
124
- const uniqueSyncGenerators = new Set();
125
- for (const { target } of Object.values(taskGraph.tasks)) {
126
- const { syncGenerators } = projectGraph.nodes[target.project].data.targets[target.target];
127
- if (!syncGenerators) {
128
- continue;
129
- }
130
- for (const generator of syncGenerators) {
131
- uniqueSyncGenerators.add(generator);
132
- }
133
- }
124
+ const uniqueSyncGenerators = (0, sync_generators_1.collectEnabledTaskSyncGeneratorsFromTaskGraph)(taskGraph, projectGraph, nxJson);
134
125
  if (!uniqueSyncGenerators.size) {
135
126
  // There are no sync generators registered in the tasks to run
136
127
  return { projectGraph, taskGraph };
@@ -1,5 +1,7 @@
1
1
  import type { GeneratorCallback } from '../config/misc-interfaces';
2
+ import { type NxJsonConfiguration } from '../config/nx-json';
2
3
  import type { ProjectGraph } from '../config/project-graph';
4
+ import type { TaskGraph } from '../config/task-graph';
3
5
  import type { ProjectConfiguration } from '../config/workspace-json-project-json';
4
6
  import { FsTree, type FileChange, type Tree } from '../generators/tree';
5
7
  export type SyncGeneratorResult = void | {
@@ -15,8 +17,9 @@ export type SyncGeneratorChangesResult = {
15
17
  };
16
18
  export declare function getSyncGeneratorChanges(generators: string[]): Promise<SyncGeneratorChangesResult[]>;
17
19
  export declare function flushSyncGeneratorChanges(results: SyncGeneratorChangesResult[]): Promise<void>;
18
- export declare function collectAllRegisteredSyncGenerators(projectGraph: ProjectGraph): Promise<string[]>;
20
+ export declare function collectAllRegisteredSyncGenerators(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Promise<string[]>;
19
21
  export declare function runSyncGenerator(tree: FsTree, generatorSpecifier: string, projects: Record<string, ProjectConfiguration>): Promise<SyncGeneratorChangesResult>;
20
- export declare function collectRegisteredTaskSyncGenerators(projectGraph: ProjectGraph): Set<string>;
21
- export declare function collectRegisteredGlobalSyncGenerators(nxJson?: import("../config/nx-json").NxJsonConfiguration<string[] | "*">): Set<string>;
22
+ export declare function collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Set<string>;
23
+ export declare function collectEnabledTaskSyncGeneratorsFromTaskGraph(taskGraph: TaskGraph, projectGraph: ProjectGraph, nxJson: NxJsonConfiguration): Set<string>;
24
+ export declare function collectRegisteredGlobalSyncGenerators(nxJson?: NxJsonConfiguration<string[] | "*">): Set<string>;
22
25
  export declare function syncGeneratorResultsToMessageLines(results: SyncGeneratorChangesResult[]): string[];
@@ -4,7 +4,8 @@ exports.getSyncGeneratorChanges = getSyncGeneratorChanges;
4
4
  exports.flushSyncGeneratorChanges = flushSyncGeneratorChanges;
5
5
  exports.collectAllRegisteredSyncGenerators = collectAllRegisteredSyncGenerators;
6
6
  exports.runSyncGenerator = runSyncGenerator;
7
- exports.collectRegisteredTaskSyncGenerators = collectRegisteredTaskSyncGenerators;
7
+ exports.collectEnabledTaskSyncGeneratorsFromProjectGraph = collectEnabledTaskSyncGeneratorsFromProjectGraph;
8
+ exports.collectEnabledTaskSyncGeneratorsFromTaskGraph = collectEnabledTaskSyncGeneratorsFromTaskGraph;
8
9
  exports.collectRegisteredGlobalSyncGenerators = collectRegisteredGlobalSyncGenerators;
9
10
  exports.syncGeneratorResultsToMessageLines = syncGeneratorResultsToMessageLines;
10
11
  const perf_hooks_1 = require("perf_hooks");
@@ -39,10 +40,10 @@ async function flushSyncGeneratorChanges(results) {
39
40
  await client_1.daemonClient.flushSyncGeneratorChangesToDisk(results.map((r) => r.generatorName));
40
41
  }
41
42
  }
42
- async function collectAllRegisteredSyncGenerators(projectGraph) {
43
+ async function collectAllRegisteredSyncGenerators(projectGraph, nxJson) {
43
44
  if (!client_1.daemonClient.enabled()) {
44
45
  return [
45
- ...collectRegisteredTaskSyncGenerators(projectGraph),
46
+ ...collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph, nxJson),
46
47
  ...collectRegisteredGlobalSyncGenerators(),
47
48
  ];
48
49
  }
@@ -69,17 +70,38 @@ async function runSyncGenerator(tree, generatorSpecifier, projects) {
69
70
  outOfSyncMessage,
70
71
  };
71
72
  }
72
- function collectRegisteredTaskSyncGenerators(projectGraph) {
73
+ function collectEnabledTaskSyncGeneratorsFromProjectGraph(projectGraph, nxJson) {
73
74
  const taskSyncGenerators = new Set();
75
+ const disabledTaskSyncGenerators = new Set(nxJson.sync?.disabledTaskSyncGenerators ?? []);
74
76
  for (const { data: { targets }, } of Object.values(projectGraph.nodes)) {
75
77
  if (!targets) {
76
78
  continue;
77
79
  }
78
80
  for (const target of Object.values(targets)) {
79
- if (!target.syncGenerators) {
81
+ if (!target.syncGenerators?.length) {
80
82
  continue;
81
83
  }
82
84
  for (const generator of target.syncGenerators) {
85
+ if (!disabledTaskSyncGenerators.has(generator) &&
86
+ !taskSyncGenerators.has(generator)) {
87
+ taskSyncGenerators.add(generator);
88
+ }
89
+ }
90
+ }
91
+ }
92
+ return taskSyncGenerators;
93
+ }
94
+ function collectEnabledTaskSyncGeneratorsFromTaskGraph(taskGraph, projectGraph, nxJson) {
95
+ const taskSyncGenerators = new Set();
96
+ const disabledTaskSyncGenerators = new Set(nxJson.sync?.disabledTaskSyncGenerators ?? []);
97
+ for (const { target } of Object.values(taskGraph.tasks)) {
98
+ const { syncGenerators } = projectGraph.nodes[target.project].data.targets[target.target];
99
+ if (!syncGenerators?.length) {
100
+ continue;
101
+ }
102
+ for (const generator of syncGenerators) {
103
+ if (!disabledTaskSyncGenerators.has(generator) &&
104
+ !taskSyncGenerators.has(generator)) {
83
105
  taskSyncGenerators.add(generator);
84
106
  }
85
107
  }