nx 19.7.0-canary.20240904-f39b995 → 19.7.0-canary.20240906-a3c2db8

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 (37) hide show
  1. package/package.json +12 -12
  2. package/src/command-line/add/command-object.js +2 -2
  3. package/src/command-line/affected/command-object.js +1 -1
  4. package/src/command-line/connect/command-object.js +2 -2
  5. package/src/command-line/daemon/command-object.js +1 -1
  6. package/src/command-line/deprecated/command-objects.js +2 -2
  7. package/src/command-line/exec/command-object.js +1 -1
  8. package/src/command-line/format/command-object.js +4 -4
  9. package/src/command-line/generate/command-object.js +4 -4
  10. package/src/command-line/graph/command-object.js +6 -6
  11. package/src/command-line/import/command-object.js +6 -6
  12. package/src/command-line/list/command-object.js +1 -1
  13. package/src/command-line/login/command-object.js +1 -1
  14. package/src/command-line/logout/command-object.js +1 -1
  15. package/src/command-line/migrate/command-object.js +9 -9
  16. package/src/command-line/new/command-object.js +2 -2
  17. package/src/command-line/release/changelog.js +1 -1
  18. package/src/command-line/release/command-object.d.ts +1 -0
  19. package/src/command-line/release/command-object.js +32 -33
  20. package/src/command-line/release/publish.js +3 -0
  21. package/src/command-line/release/utils/git.js +1 -1
  22. package/src/command-line/report/command-object.js +1 -1
  23. package/src/command-line/reset/command-object.js +1 -1
  24. package/src/command-line/run/command-object.js +1 -1
  25. package/src/command-line/run-many/command-object.js +1 -1
  26. package/src/command-line/show/command-object.js +10 -10
  27. package/src/command-line/watch/command-object.js +1 -1
  28. package/src/command-line/yargs-utils/shared-options.d.ts +2 -1
  29. package/src/command-line/yargs-utils/shared-options.js +25 -20
  30. package/src/core/graph/main.js +1 -1
  31. package/src/native/nx.wasm32-wasi.wasm +0 -0
  32. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +6 -41
  33. package/src/tasks-runner/cache.d.ts +2 -0
  34. package/src/tasks-runner/cache.js +15 -1
  35. package/src/tasks-runner/run-command.js +4 -1
  36. package/src/tasks-runner/task-orchestrator.js +1 -10
  37. package/src/utils/command-line-utils.d.ts +1 -0
Binary file
@@ -42,18 +42,6 @@ function getNxInitDate() {
42
42
  return null;
43
43
  }
44
44
  }
45
- async function createNxCloudWorkspaceV1(workspaceName, installationSource, nxInitDate) {
46
- const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
47
- const response = await require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
48
- workspaceName,
49
- installationSource,
50
- nxInitDate,
51
- });
52
- if (response.data.message) {
53
- throw new Error(response.data.message);
54
- }
55
- return response.data;
56
- }
57
45
  async function createNxCloudWorkspaceV2(workspaceName, installationSource, nxInitDate) {
58
46
  const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
59
47
  const response = await require('axios').post(`${apiUrl}/nx-cloud/v2/create-org-and-workspace`, {
@@ -81,19 +69,6 @@ async function printSuccessMessage(token, installationSource, usesGithub) {
81
69
  });
82
70
  return connectCloudUrl;
83
71
  }
84
- function addNxCloudOptionsToNxJson(tree, token, directory = '') {
85
- const nxJsonPath = (0, path_1.join)(directory, 'nx.json');
86
- if (tree.exists(nxJsonPath)) {
87
- (0, json_1.updateJson)(tree, (0, path_1.join)(directory, 'nx.json'), (nxJson) => {
88
- const overrideUrl = process.env.NX_CLOUD_API || process.env.NRWL_API;
89
- if (overrideUrl) {
90
- nxJson.nxCloudUrl = overrideUrl;
91
- }
92
- nxJson.nxCloudAccessToken = token;
93
- return nxJson;
94
- });
95
- }
96
- }
97
72
  function addNxCloudIdToNxJson(tree, nxCloudId, directory = '') {
98
73
  const nxJsonPath = (0, path_1.join)(directory, 'nx.json');
99
74
  if (tree.exists(nxJsonPath)) {
@@ -124,22 +99,12 @@ async function connectToNxCloud(tree, schema, nxJson = (0, nx_json_1.readNxJson)
124
99
  isGitHubDetected &&
125
100
  schema.installationSource === 'nx-connect')
126
101
  return null;
127
- if (process.env.NX_ENABLE_LOGIN === 'true') {
128
- responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(getRootPackageName(tree), schema.installationSource, getNxInitDate());
129
- addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
130
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
131
- silent: schema.hideFormatLogs,
132
- });
133
- return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
134
- }
135
- else {
136
- responseFromCreateNxCloudWorkspaceV1 = await createNxCloudWorkspaceV1(getRootPackageName(tree), schema.installationSource, getNxInitDate());
137
- addNxCloudOptionsToNxJson(tree, responseFromCreateNxCloudWorkspaceV1?.token, schema.directory);
138
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
139
- silent: schema.hideFormatLogs,
140
- });
141
- return responseFromCreateNxCloudWorkspaceV1.token;
142
- }
102
+ responseFromCreateNxCloudWorkspaceV2 = await createNxCloudWorkspaceV2(getRootPackageName(tree), schema.installationSource, getNxInitDate());
103
+ addNxCloudIdToNxJson(tree, responseFromCreateNxCloudWorkspaceV2?.nxCloudId, schema.directory);
104
+ await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree, {
105
+ silent: schema.hideFormatLogs,
106
+ });
107
+ return responseFromCreateNxCloudWorkspaceV2.nxCloudId;
143
108
  }
144
109
  async function connectToNxCloudGenerator(tree, options) {
145
110
  await connectToNxCloud(tree, options);
@@ -10,6 +10,7 @@ export type TaskWithCachedResult = {
10
10
  task: Task;
11
11
  cachedResult: CachedResult;
12
12
  };
13
+ export declare function getCache(options: DefaultTasksRunnerOptions): DbCache | Cache;
13
14
  export declare class DbCache {
14
15
  private readonly options;
15
16
  private cache;
@@ -20,6 +21,7 @@ export declare class DbCache {
20
21
  nxCloudRemoteCache: RemoteCache;
21
22
  });
22
23
  get(task: Task): Promise<CachedResult | null>;
24
+ private applyRemoteCacheResults;
23
25
  put(task: Task, terminalOutput: string | null, outputs: string[], code: number): Promise<void>;
24
26
  copyFilesFromCache(_: string, cachedResult: CachedResult, outputs: string[]): Promise<void>;
25
27
  removeOldCacheRecords(): void;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cache = exports.DbCache = void 0;
4
+ exports.getCache = getCache;
4
5
  const workspace_root_1 = require("../utils/workspace-root");
5
6
  const fs_extra_1 = require("fs-extra");
6
7
  const path_1 = require("path");
@@ -15,6 +16,16 @@ const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
15
16
  const nx_json_1 = require("../config/nx-json");
16
17
  const update_manager_1 = require("../nx-cloud/update-manager");
17
18
  const get_cloud_options_1 = require("../nx-cloud/utilities/get-cloud-options");
19
+ function getCache(options) {
20
+ return process.env.NX_DB_CACHE === 'true'
21
+ ? new DbCache({
22
+ // Remove this in Nx 21
23
+ nxCloudRemoteCache: (0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())
24
+ ? options.remoteCache
25
+ : null,
26
+ })
27
+ : new Cache(options);
28
+ }
18
29
  class DbCache {
19
30
  async setup() {
20
31
  this.remoteCache = await this.getRemoteCache();
@@ -37,7 +48,7 @@ class DbCache {
37
48
  // attempt remote cache
38
49
  const res = await this.remoteCache.retrieve(task.hash, this.cache.cacheDirectory);
39
50
  if (res) {
40
- this.cache.applyRemoteCacheResults(task.hash, res);
51
+ this.applyRemoteCacheResults(task.hash, res);
41
52
  return {
42
53
  ...res,
43
54
  remote: true,
@@ -51,6 +62,9 @@ class DbCache {
51
62
  return null;
52
63
  }
53
64
  }
65
+ applyRemoteCacheResults(hash, res) {
66
+ return this.cache.applyRemoteCacheResults(hash, res);
67
+ }
54
68
  async put(task, terminalOutput, outputs, code) {
55
69
  return tryAndRetry(async () => {
56
70
  this.cache.put(task.hash, terminalOutput, outputs, code);
@@ -120,6 +120,9 @@ async function runCommand(projectsToRun, currentProjectGraph, { nxJson }, nxArgs
120
120
  }
121
121
  async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, projectNames, nxArgs, overrides, extraTargetDependencies, extraOptions) {
122
122
  let taskGraph = createTaskGraphAndRunValidations(projectGraph, extraTargetDependencies ?? {}, projectNames, nxArgs, overrides, extraOptions);
123
+ if (nxArgs.skipSync) {
124
+ return { projectGraph, taskGraph };
125
+ }
123
126
  // collect unique syncGenerators from the tasks
124
127
  const uniqueSyncGenerators = (0, sync_generators_1.collectEnabledTaskSyncGeneratorsFromTaskGraph)(taskGraph, projectGraph, nxJson);
125
128
  if (!uniqueSyncGenerators.size) {
@@ -134,7 +137,7 @@ async function ensureWorkspaceIsInSyncAndGetGraphs(projectGraph, nxJson, project
134
137
  }
135
138
  const outOfSyncTitle = 'The workspace is out of sync';
136
139
  const resultBodyLines = [...(0, sync_generators_1.syncGeneratorResultsToMessageLines)(results), ''];
137
- const fixMessage = 'You can manually run `nx sync` to update your workspace or you can set `sync.applyChanges` to `true` in your `nx.json` to apply the changes automatically when running tasks.';
140
+ const fixMessage = 'You can manually run `nx sync` to update your workspace or you can set `sync.applyChanges` to `true` in your `nx.json` to apply the changes automatically when running tasks in interactive environments.';
138
141
  const willErrorOnCiMessage = 'Please note that this will be an error on CI.';
139
142
  if ((0, is_ci_1.isCI)() || !process.stdout.isTTY) {
140
143
  // If the user is running in CI or is running in a non-TTY environment we
@@ -15,8 +15,6 @@ const task_env_1 = require("./task-env");
15
15
  const workspace_root_1 = require("../utils/workspace-root");
16
16
  const output_1 = require("../utils/output");
17
17
  const params_1 = require("../utils/params");
18
- const nx_cloud_utils_1 = require("../utils/nx-cloud-utils");
19
- const nx_json_1 = require("../config/nx-json");
20
18
  class TaskOrchestrator {
21
19
  // endregion internal state
22
20
  constructor(hasher, initiatingProject, projectGraph, taskGraph, options, bail, daemon, outputStyle) {
@@ -28,14 +26,7 @@ class TaskOrchestrator {
28
26
  this.bail = bail;
29
27
  this.daemon = daemon;
30
28
  this.outputStyle = outputStyle;
31
- this.cache = process.env.NX_DB_CACHE === 'true'
32
- ? new cache_1.DbCache({
33
- // Remove this in Nx 21
34
- nxCloudRemoteCache: (0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())
35
- ? this.options.remoteCache
36
- : null,
37
- })
38
- : new cache_1.Cache(this.options);
29
+ this.cache = (0, cache_1.getCache)(this.options);
39
30
  this.forkedProcessTaskRunner = new forked_process_task_runner_1.ForkedProcessTaskRunner(this.options);
40
31
  this.tasksSchedule = new tasks_schedule_1.TasksSchedule(this.projectGraph, this.taskGraph, this.options);
41
32
  // region internal state
@@ -30,6 +30,7 @@ export interface NxArgs {
30
30
  type?: string;
31
31
  batch?: boolean;
32
32
  excludeTaskDependencies?: boolean;
33
+ skipSync?: boolean;
33
34
  }
34
35
  export declare function createOverrides(__overrides_unparsed__?: string[]): Record<string, any>;
35
36
  export declare function getBaseRef(nxJson: NxJsonConfiguration): string;