nx 20.0.0-beta.5 → 20.0.0-beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. package/.eslintrc.json +12 -2
  2. package/migrations.json +0 -37
  3. package/package.json +11 -11
  4. package/src/command-line/release/index.d.ts +5 -2
  5. package/src/command-line/release/publish.d.ts +6 -1
  6. package/src/command-line/release/publish.js +31 -25
  7. package/src/command-line/release/utils/print-changes.js +6 -4
  8. package/src/command-line/release/utils/resolve-nx-json-error-message.js +4 -3
  9. package/src/command-line/release/version.d.ts +3 -3
  10. package/src/config/workspace-json-project-json.d.ts +14 -0
  11. package/src/core/graph/main.js +1 -1
  12. package/src/native/nx.wasm32-wasi.wasm +0 -0
  13. package/src/nx-cloud/utilities/axios.js +1 -2
  14. package/src/nx-cloud/utilities/onboarding.js +2 -2
  15. package/src/nx-cloud/utilities/url-shorten.js +5 -5
  16. package/src/project-graph/file-utils.d.ts +2 -2
  17. package/src/project-graph/file-utils.js +2 -2
  18. package/src/tasks-runner/cache.d.ts +1 -2
  19. package/src/tasks-runner/cache.js +4 -4
  20. package/src/tasks-runner/create-task-graph.d.ts +2 -0
  21. package/src/tasks-runner/create-task-graph.js +35 -1
  22. package/src/tasks-runner/task-orchestrator.js +1 -1
  23. package/src/utils/git-utils.js +2 -2
  24. package/src/migrations/update-15-0-0/prefix-outputs.d.ts +0 -2
  25. package/src/migrations/update-15-0-0/prefix-outputs.js +0 -49
  26. package/src/migrations/update-16-0-0/remove-nrwl-cli.d.ts +0 -2
  27. package/src/migrations/update-16-0-0/remove-nrwl-cli.js +0 -16
  28. package/src/migrations/update-16-0-0/update-depends-on-to-tokens.d.ts +0 -2
  29. package/src/migrations/update-16-0-0/update-depends-on-to-tokens.js +0 -97
  30. package/src/migrations/update-16-0-0/update-nx-cloud-runner.d.ts +0 -2
  31. package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +0 -29
  32. package/src/migrations/update-16-2-0/remove-run-commands-output-path.d.ts +0 -2
  33. package/src/migrations/update-16-2-0/remove-run-commands-output-path.js +0 -45
  34. package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.d.ts +0 -12
  35. package/src/migrations/update-16-8-0/escape-dollar-sign-env-variables.js +0 -67
Binary file
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createApiAxiosInstance = createApiAxiosInstance;
4
4
  const path_1 = require("path");
5
5
  const environment_1 = require("./environment");
6
- const axios = require('axios');
7
6
  function createApiAxiosInstance(options) {
8
7
  let axiosConfigBuilder = (axiosConfig) => axiosConfig;
9
8
  const baseUrl = process.env.NX_CLOUD_API || options.url || 'https://cloud.nx.app';
@@ -17,7 +16,7 @@ function createApiAxiosInstance(options) {
17
16
  const { nxCloudProxyConfig } = require((0, path_1.join)(process.cwd(), options.customProxyConfigPath));
18
17
  axiosConfigBuilder = nxCloudProxyConfig ?? axiosConfigBuilder;
19
18
  }
20
- return axios.create(axiosConfigBuilder({
19
+ return require('axios').create(axiosConfigBuilder({
21
20
  baseURL: baseUrl,
22
21
  timeout: environment_1.NX_CLOUD_NO_TIMEOUTS ? environment_1.UNLIMITED_TIMEOUT : 10000,
23
22
  headers: { authorization: accessToken },
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createNxCloudOnboardingURLForWelcomeApp = createNxCloudOnboardingURLForWelcomeApp;
4
4
  exports.getNxCloudAppOnBoardingUrl = getNxCloudAppOnBoardingUrl;
5
5
  exports.readNxCloudToken = readNxCloudToken;
6
- const devkit_exports_1 = require("../../devkit-exports");
7
6
  const is_workspace_claimed_1 = require("./is-workspace-claimed");
8
7
  const url_shorten_1 = require("./url-shorten");
9
8
  const run_command_1 = require("../../tasks-runner/run-command");
9
+ const nx_json_1 = require("../../generators/utils/nx-json");
10
10
  async function createNxCloudOnboardingURLForWelcomeApp(tree, token) {
11
11
  token = token || readNxCloudToken(tree);
12
12
  if (!token) {
@@ -22,7 +22,7 @@ async function getNxCloudAppOnBoardingUrl(token) {
22
22
  return onboardingUrl;
23
23
  }
24
24
  function readNxCloudToken(tree) {
25
- const nxJson = (0, devkit_exports_1.readNxJson)(tree);
25
+ const nxJson = (0, nx_json_1.readNxJson)(tree);
26
26
  const { accessToken, nxCloudId } = (0, run_command_1.getRunnerOptions)('default', nxJson, {}, true);
27
27
  return accessToken || nxCloudId;
28
28
  }
@@ -7,7 +7,7 @@ exports.getNxCloudVersion = getNxCloudVersion;
7
7
  exports.removeVersionModifier = removeVersionModifier;
8
8
  exports.versionIsValid = versionIsValid;
9
9
  exports.compareCleanCloudVersions = compareCleanCloudVersions;
10
- const devkit_exports_1 = require("../../devkit-exports");
10
+ const logger_1 = require("../../utils/logger");
11
11
  const git_utils_1 = require("../../utils/git-utils");
12
12
  const get_cloud_options_1 = require("./get-cloud-options");
13
13
  /**
@@ -27,7 +27,7 @@ async function createNxCloudOnboardingURL(onboardingSource, accessToken, usesGit
27
27
  }
28
28
  }
29
29
  catch (e) {
30
- devkit_exports_1.logger.verbose(`Failed to get Nx Cloud version.
30
+ logger_1.logger.verbose(`Failed to get Nx Cloud version.
31
31
  ${e}`);
32
32
  return apiUrl;
33
33
  }
@@ -46,7 +46,7 @@ async function createNxCloudOnboardingURL(onboardingSource, accessToken, usesGit
46
46
  return `${apiUrl}/connect/${response.data}`;
47
47
  }
48
48
  catch (e) {
49
- devkit_exports_1.logger.verbose(`Failed to shorten Nx Cloud URL.
49
+ logger_1.logger.verbose(`Failed to shorten Nx Cloud URL.
50
50
  ${e}`);
51
51
  return getURLifShortenFailed(usesGithub, githubSlug === 'github' ? null : githubSlug, apiUrl, source, accessToken);
52
52
  }
@@ -96,7 +96,7 @@ async function getInstallationSupportsGitHub(apiUrl) {
96
96
  }
97
97
  catch (e) {
98
98
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
99
- devkit_exports_1.logger.warn(`Failed to access system features. GitHub integration assumed to be disabled.
99
+ logger_1.logger.warn(`Failed to access system features. GitHub integration assumed to be disabled.
100
100
  ${e}`);
101
101
  }
102
102
  return false;
@@ -116,7 +116,7 @@ async function getNxCloudVersion(apiUrl) {
116
116
  return version;
117
117
  }
118
118
  catch (e) {
119
- devkit_exports_1.logger.verbose(`Failed to get version of Nx Cloud.
119
+ logger_1.logger.verbose(`Failed to get version of Nx Cloud.
120
120
  ${e}`);
121
121
  return null;
122
122
  }
@@ -18,8 +18,8 @@ export declare function isDeletedFileChange(change: Change): change is DeletedFi
18
18
  export declare function calculateFileChanges(files: string[], allWorkspaceFiles: FileData[], nxArgs?: NxArgs, readFileAtRevision?: (f: string, r: void | string) => string, ignore?: ReturnType<typeof ignore>): FileChange[];
19
19
  export declare const TEN_MEGABYTES: number;
20
20
  /**
21
- * TODO(v20): Remove this function
22
- * @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v20.
21
+ * TODO(v21): Remove this function
22
+ * @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v21.
23
23
  */
24
24
  export declare function readWorkspaceConfig(opts: {
25
25
  format: 'angularCli' | 'nx';
@@ -101,8 +101,8 @@ function defaultReadFileAtRevision(file, revision) {
101
101
  }
102
102
  }
103
103
  /**
104
- * TODO(v20): Remove this function
105
- * @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v20.
104
+ * TODO(v21): Remove this function
105
+ * @deprecated To get projects use {@link retrieveProjectConfigurations} instead. This will be removed in v21.
106
106
  */
107
107
  function readWorkspaceConfig(opts) {
108
108
  let configuration = null;
@@ -1,6 +1,5 @@
1
1
  import { DefaultTasksRunnerOptions, RemoteCache } from './default-tasks-runner';
2
2
  import { Task } from '../config/task-graph';
3
- import { NxJsonConfiguration } from '../config/nx-json';
4
3
  export type CachedResult = {
5
4
  terminalOutput: string;
6
5
  outputsPath: string;
@@ -11,7 +10,7 @@ export type TaskWithCachedResult = {
11
10
  task: Task;
12
11
  cachedResult: CachedResult;
13
12
  };
14
- export declare function getCache(nxJson: NxJsonConfiguration, options: DefaultTasksRunnerOptions): DbCache | Cache;
13
+ export declare function getCache(options: DefaultTasksRunnerOptions): DbCache | Cache;
15
14
  export declare class DbCache {
16
15
  private readonly options;
17
16
  private cache;
@@ -19,14 +19,14 @@ const update_manager_1 = require("../nx-cloud/update-manager");
19
19
  const get_cloud_options_1 = require("../nx-cloud/utilities/get-cloud-options");
20
20
  const is_ci_1 = require("../utils/is-ci");
21
21
  const output_1 = require("../utils/output");
22
- function getCache(nxJson, options) {
22
+ // Do not change the order of these arguments as this function is used by nx cloud
23
+ function getCache(options) {
24
+ const nxJson = (0, nx_json_1.readNxJson)();
23
25
  return process.env.NX_DISABLE_DB !== 'true' &&
24
26
  (nxJson.enableDbCache === true || process.env.NX_DB_CACHE === 'true')
25
27
  ? new DbCache({
26
28
  // Remove this in Nx 21
27
- nxCloudRemoteCache: (0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())
28
- ? options.remoteCache
29
- : null,
29
+ nxCloudRemoteCache: (0, nx_cloud_utils_1.isNxCloudUsed)(nxJson) ? options.remoteCache : null,
30
30
  })
31
31
  : new Cache(options);
32
32
  }
@@ -18,9 +18,11 @@ export declare class ProcessTasks {
18
18
  private processTasksForMultipleProjects;
19
19
  private processTasksForSingleProject;
20
20
  private processTasksForDependencies;
21
+ private createDummyTask;
21
22
  createTask(id: string, project: ProjectGraphProjectNode, target: string, resolvedConfiguration: string | undefined, overrides: Object): Task;
22
23
  resolveConfiguration(project: ProjectGraphProjectNode, target: string, configuration: string | undefined): string;
23
24
  getId(project: string, target: string, configuration: string | undefined): string;
25
+ private filterDummyTasks;
24
26
  }
25
27
  export declare function createTaskGraph(projectGraph: ProjectGraph, extraTargetDependencies: TargetDependencies, projectNames: string[], targets: string[], configuration: string | undefined, overrides: Object, excludeTaskDependencies?: boolean): TaskGraph;
26
28
  export declare function mapTargetDefaultsToDependencies(defaults: TargetDefaults | undefined): TargetDependencies;
@@ -6,6 +6,7 @@ exports.mapTargetDefaultsToDependencies = mapTargetDefaultsToDependencies;
6
6
  const utils_1 = require("./utils");
7
7
  const project_graph_utils_1 = require("../utils/project-graph-utils");
8
8
  const output_1 = require("../utils/output");
9
+ const DUMMY_TASK_TARGET = '__nx_dummy_task__';
9
10
  class ProcessTasks {
10
11
  constructor(extraTargetDependencies, projectGraph) {
11
12
  this.extraTargetDependencies = extraTargetDependencies;
@@ -52,6 +53,7 @@ class ProcessTasks {
52
53
  this.dependencies[d] = this.dependencies[d].filter((dd) => !!initialTasks[dd]);
53
54
  }
54
55
  }
56
+ this.filterDummyTasks();
55
57
  for (const projectName of Object.keys(this.dependencies)) {
56
58
  if (this.dependencies[projectName].length > 1) {
57
59
  this.dependencies[projectName] = [
@@ -113,6 +115,9 @@ class ProcessTasks {
113
115
  }
114
116
  }
115
117
  processTasksForDependencies(projectUsedToDeriveDependencies, dependencyConfig, configuration, task, taskOverrides, overrides) {
118
+ if (!this.projectGraph.dependencies.hasOwnProperty(projectUsedToDeriveDependencies)) {
119
+ return;
120
+ }
116
121
  for (const dep of this.projectGraph.dependencies[projectUsedToDeriveDependencies]) {
117
122
  const depProject = this.projectGraph.nodes[dep.target];
118
123
  // this is to handle external dependencies
@@ -132,10 +137,20 @@ class ProcessTasks {
132
137
  }
133
138
  }
134
139
  else {
135
- this.processTask(task, depProject.name, configuration, overrides);
140
+ const dummyId = this.getId(depProject.name, DUMMY_TASK_TARGET, undefined);
141
+ this.dependencies[task.id].push(dummyId);
142
+ this.dependencies[dummyId] = [];
143
+ const noopTask = this.createDummyTask(dummyId, task);
144
+ this.processTask(noopTask, depProject.name, configuration, overrides);
136
145
  }
137
146
  }
138
147
  }
148
+ createDummyTask(id, task) {
149
+ return {
150
+ ...task,
151
+ id,
152
+ };
153
+ }
139
154
  createTask(id, project, target, resolvedConfiguration, overrides) {
140
155
  if (!project.data.targets[target]) {
141
156
  throw new Error(`Cannot find configuration for task ${project.name}:${target}`);
@@ -173,6 +188,25 @@ class ProcessTasks {
173
188
  }
174
189
  return id;
175
190
  }
191
+ filterDummyTasks() {
192
+ for (const [key, deps] of Object.entries(this.dependencies)) {
193
+ const normalizedDeps = [];
194
+ for (const dep of deps) {
195
+ if (dep.endsWith(DUMMY_TASK_TARGET)) {
196
+ normalizedDeps.push(...this.dependencies[dep].filter((d) => !d.endsWith(DUMMY_TASK_TARGET)));
197
+ }
198
+ else {
199
+ normalizedDeps.push(dep);
200
+ }
201
+ }
202
+ this.dependencies[key] = normalizedDeps;
203
+ }
204
+ for (const key of Object.keys(this.dependencies)) {
205
+ if (key.endsWith(DUMMY_TASK_TARGET)) {
206
+ delete this.dependencies[key];
207
+ }
208
+ }
209
+ }
176
210
  }
177
211
  exports.ProcessTasks = ProcessTasks;
178
212
  function createTaskGraph(projectGraph, extraTargetDependencies, projectNames, targets, configuration, overrides, excludeTaskDependencies = false) {
@@ -28,7 +28,7 @@ class TaskOrchestrator {
28
28
  this.daemon = daemon;
29
29
  this.outputStyle = outputStyle;
30
30
  this.taskDetails = (0, hash_task_1.getTaskDetails)();
31
- this.cache = (0, cache_1.getCache)(this.nxJson, this.options);
31
+ this.cache = (0, cache_1.getCache)(this.options);
32
32
  this.forkedProcessTaskRunner = new forked_process_task_runner_1.ForkedProcessTaskRunner(this.options);
33
33
  this.tasksSchedule = new tasks_schedule_1.TasksSchedule(this.projectGraph, this.taskGraph, this.options);
34
34
  // region internal state
@@ -8,7 +8,7 @@ exports.commitChanges = commitChanges;
8
8
  exports.getLatestCommitSha = getLatestCommitSha;
9
9
  const child_process_1 = require("child_process");
10
10
  const path_1 = require("path");
11
- const devkit_exports_1 = require("../devkit-exports");
11
+ const logger_1 = require("./logger");
12
12
  function execAsync(command, execOptions) {
13
13
  return new Promise((res, rej) => {
14
14
  (0, child_process_1.exec)(command, execOptions, (err, stdout, stderr) => {
@@ -236,7 +236,7 @@ function commitChanges(commitMessage, directory) {
236
236
  // We don't want to throw during create-nx-workspace
237
237
  // because maybe there was an error when setting up git
238
238
  // initially.
239
- devkit_exports_1.logger.verbose(`Git may not be set up correctly for this new workspace.
239
+ logger_1.logger.verbose(`Git may not be set up correctly for this new workspace.
240
240
  ${err}`);
241
241
  }
242
242
  else {
@@ -1,2 +0,0 @@
1
- import { Tree } from '../../generators/tree';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,49 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
5
- const project_configuration_1 = require("../../generators/utils/project-configuration");
6
- const nx_json_1 = require("../../generators/utils/nx-json");
7
- const path_1 = require("path");
8
- const utils_1 = require("../../tasks-runner/utils");
9
- const json_1 = require("../../generators/utils/json");
10
- async function default_1(tree) {
11
- // If the workspace doesn't have a nx.json, don't make any changes
12
- if (!tree.exists('nx.json')) {
13
- return;
14
- }
15
- const nxJson = (0, nx_json_1.readNxJson)(tree);
16
- for (const [projectName, project] of (0, project_configuration_1.getProjects)(tree)) {
17
- for (const [_, target] of Object.entries(project.targets ?? {})) {
18
- if (!target.outputs) {
19
- continue;
20
- }
21
- target.outputs = (0, utils_1.transformLegacyOutputs)(project.root, target.outputs);
22
- }
23
- try {
24
- (0, project_configuration_1.updateProjectConfiguration)(tree, projectName, project);
25
- }
26
- catch {
27
- if (tree.exists((0, path_1.join)(project.root, 'package.json'))) {
28
- (0, json_1.updateJson)(tree, (0, path_1.join)(project.root, 'package.json'), (json) => {
29
- for (const target of Object.values(json.nx?.targets ?? {})) {
30
- if (target.outputs) {
31
- target.outputs = (0, utils_1.transformLegacyOutputs)(project.root, target.outputs);
32
- }
33
- }
34
- return json;
35
- });
36
- }
37
- }
38
- }
39
- if (nxJson.targetDefaults) {
40
- for (const [_, target] of Object.entries(nxJson.targetDefaults)) {
41
- if (!target.outputs) {
42
- continue;
43
- }
44
- target.outputs = (0, utils_1.transformLegacyOutputs)('{projectRoot}', target.outputs);
45
- }
46
- (0, nx_json_1.updateNxJson)(tree, nxJson);
47
- }
48
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
49
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '../../generators/tree';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
5
- const json_1 = require("../../generators/utils/json");
6
- async function default_1(tree) {
7
- (0, json_1.updateJson)(tree, 'package.json', (json) => {
8
- for (const deps of [json.dependencies, json.devDependencies]) {
9
- if (deps) {
10
- delete deps['@nrwl/cli'];
11
- }
12
- }
13
- return json;
14
- });
15
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
16
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '../../generators/tree';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const project_configuration_1 = require("../../generators/utils/project-configuration");
5
- const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
6
- async function default_1(tree) {
7
- updateDependsOnAndInputsInsideNxJson(tree);
8
- const projectsConfigurations = (0, project_configuration_1.getProjects)(tree);
9
- for (const [projectName, projectConfiguration] of projectsConfigurations) {
10
- let projectChanged = false;
11
- for (const [targetName, targetConfiguration] of Object.entries(projectConfiguration.targets ?? {})) {
12
- for (const dependency of targetConfiguration.dependsOn ?? []) {
13
- if (typeof dependency !== 'string') {
14
- if (dependency.projects === 'self' ||
15
- dependency.projects === '{self}') {
16
- delete dependency.projects;
17
- projectChanged = true;
18
- }
19
- else if (dependency.projects === 'dependencies' ||
20
- dependency.projects === '{dependencies}') {
21
- delete dependency.projects;
22
- dependency.dependencies = true;
23
- projectChanged = true;
24
- }
25
- }
26
- }
27
- for (let i = 0; i < targetConfiguration.inputs?.length ?? 0; i++) {
28
- const input = targetConfiguration.inputs[i];
29
- if (typeof input !== 'string') {
30
- if ('projects' in input &&
31
- (input.projects === 'self' || input.projects === '{self}')) {
32
- delete input.projects;
33
- projectChanged = true;
34
- }
35
- else if ('projects' in input &&
36
- (input.projects === 'dependencies' ||
37
- input.projects === '{dependencies}')) {
38
- delete input.projects;
39
- targetConfiguration.inputs[i] = {
40
- ...input,
41
- dependencies: true,
42
- };
43
- projectChanged = true;
44
- }
45
- }
46
- }
47
- }
48
- if (projectChanged) {
49
- (0, project_configuration_1.updateProjectConfiguration)(tree, projectName, projectConfiguration);
50
- }
51
- }
52
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
53
- }
54
- function updateDependsOnAndInputsInsideNxJson(tree) {
55
- const nxJson = (0, project_configuration_1.readNxJson)(tree);
56
- let nxJsonChanged = false;
57
- for (const [target, defaults] of Object.entries(nxJson?.targetDefaults ?? {})) {
58
- for (const dependency of defaults.dependsOn ?? []) {
59
- if (typeof dependency !== 'string') {
60
- if (dependency.projects === 'self' ||
61
- dependency.projects === '{self}') {
62
- delete dependency.projects;
63
- nxJsonChanged = true;
64
- }
65
- else if (dependency.projects === 'dependencies' ||
66
- dependency.projects === '{dependencies}') {
67
- delete dependency.projects;
68
- dependency.dependencies = true;
69
- nxJsonChanged = true;
70
- }
71
- }
72
- }
73
- for (let i = 0; i < defaults.inputs?.length ?? 0; i++) {
74
- const input = defaults.inputs[i];
75
- if (typeof input !== 'string') {
76
- if ('projects' in input &&
77
- (input.projects === 'self' || input.projects === '{self}')) {
78
- delete input.projects;
79
- nxJsonChanged = true;
80
- }
81
- else if ('projects' in input &&
82
- (input.projects === 'dependencies' ||
83
- input.projects === '{dependencies}')) {
84
- delete input.projects;
85
- defaults.inputs[i] = {
86
- ...input,
87
- dependencies: true,
88
- };
89
- nxJsonChanged = true;
90
- }
91
- }
92
- }
93
- }
94
- if (nxJsonChanged) {
95
- (0, project_configuration_1.updateNxJson)(tree, nxJson);
96
- }
97
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '../../generators/tree';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = default_1;
4
- const project_configuration_1 = require("../../generators/utils/project-configuration");
5
- const json_1 = require("../../generators/utils/json");
6
- const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
7
- async function default_1(tree) {
8
- (0, json_1.updateJson)(tree, 'package.json', (json) => {
9
- if (json.dependencies && json.dependencies['@nrwl/nx-cloud']) {
10
- json.dependencies['nx-cloud'] = json.dependencies['@nrwl/nx-cloud'];
11
- delete json.dependencies['@nrwl/nx-cloud'];
12
- }
13
- if (json.devDependencies && json.devDependencies['@nrwl/nx-cloud']) {
14
- json.devDependencies['nx-cloud'] = json.devDependencies['@nrwl/nx-cloud'];
15
- delete json.devDependencies['@nrwl/nx-cloud'];
16
- }
17
- return json;
18
- });
19
- const nxJson = (0, project_configuration_1.readNxJson)(tree);
20
- if (!nxJson)
21
- return;
22
- for (let opts of Object.values(nxJson.tasksRunnerOptions ?? {})) {
23
- if (opts.runner === '@nrwl/nx-cloud') {
24
- opts.runner = 'nx-cloud';
25
- }
26
- }
27
- (0, project_configuration_1.updateNxJson)(tree, nxJson);
28
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
29
- }
@@ -1,2 +0,0 @@
1
- import { Tree } from '../../generators/tree';
2
- export default function removeRunCommandsOutputPath(tree: Tree): Promise<void>;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = removeRunCommandsOutputPath;
4
- const path_1 = require("../../utils/path");
5
- const format_changed_files_with_prettier_if_available_1 = require("../../generators/internal-utils/format-changed-files-with-prettier-if-available");
6
- const json_1 = require("../../generators/utils/json");
7
- const project_configuration_1 = require("../../generators/utils/project-configuration");
8
- async function removeRunCommandsOutputPath(tree) {
9
- for (const [project, configuration] of (0, project_configuration_1.getProjects)(tree).entries()) {
10
- const targets = configuration.targets ?? {};
11
- let changed = false;
12
- for (const [, target] of Object.entries(targets)) {
13
- changed ||= updateTargetBlock(target);
14
- }
15
- if (changed) {
16
- (0, project_configuration_1.updateProjectConfiguration)(tree, project, configuration);
17
- }
18
- }
19
- if (tree.exists('nx.json')) {
20
- (0, json_1.updateJson)(tree, 'nx.json', (json) => {
21
- for (const [, target] of Object.entries(json.targetDefaults ?? {})) {
22
- updateTargetBlock(target);
23
- }
24
- return json;
25
- });
26
- }
27
- await (0, format_changed_files_with_prettier_if_available_1.formatChangedFilesWithPrettierIfAvailable)(tree);
28
- }
29
- function updateTargetBlock(target) {
30
- let changed = false;
31
- if (target.executor === 'nx:run-commands' && target.options?.outputPath) {
32
- changed = true;
33
- const outputs = new Set(target.outputs ?? []);
34
- outputs.delete('{options.outputPath}');
35
- const newOutputs = Array.isArray(target.options.outputPath)
36
- ? target.options.outputPath.map((p) => (0, path_1.joinPathFragments)('{workspaceRoot}', p))
37
- : [(0, path_1.joinPathFragments)('{workspaceRoot}', target.options.outputPath)];
38
- for (const outputPath of newOutputs) {
39
- outputs.add(outputPath);
40
- }
41
- delete target.options.outputPath;
42
- target.outputs = Array.from(outputs);
43
- }
44
- return changed;
45
- }
@@ -1,12 +0,0 @@
1
- import { Tree } from '../../generators/tree';
2
- /**
3
- * This function escapes dollar sign in env variables
4
- * It will go through:
5
- * - '.env', '.local.env', '.env.local'
6
- * - .env.[target-name], .[target-name].env
7
- * - .env.[target-name].[configuration-name], .[target-name].[configuration-name].env
8
- * - .env.[configuration-name], .[configuration-name].env
9
- * at each project root and workspace root
10
- * @param tree
11
- */
12
- export default function escapeDollarSignEnvVariables(tree: Tree): void;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = escapeDollarSignEnvVariables;
4
- const logger_1 = require("../../utils/logger");
5
- const project_configuration_1 = require("../../generators/utils/project-configuration");
6
- /**
7
- * This function escapes dollar sign in env variables
8
- * It will go through:
9
- * - '.env', '.local.env', '.env.local'
10
- * - .env.[target-name], .[target-name].env
11
- * - .env.[target-name].[configuration-name], .[target-name].[configuration-name].env
12
- * - .env.[configuration-name], .[configuration-name].env
13
- * at each project root and workspace root
14
- * @param tree
15
- */
16
- function escapeDollarSignEnvVariables(tree) {
17
- const envFiles = ['.env', '.local.env', '.env.local'];
18
- for (const [_, configuration] of (0, project_configuration_1.getProjects)(tree).entries()) {
19
- envFiles.push(`${configuration.root}/.env`, `${configuration.root}/.local.env`, `${configuration.root}/.env.local`);
20
- for (const targetName in configuration.targets) {
21
- const task = configuration.targets[targetName];
22
- envFiles.push(`.env.${targetName}`, `.${targetName}.env`, `${configuration.root}/.env.${targetName}`, `${configuration.root}/.${targetName}.env`);
23
- if (task.configurations) {
24
- for (const configurationName in task.configurations) {
25
- envFiles.push(`.env.${targetName}.${configurationName}`, `.${targetName}.${configurationName}.env`, `.env.${configurationName}`, `.${configurationName}.env`, `${configuration.root}/.env.${targetName}.${configurationName}`, `${configuration.root}/.${targetName}.${configurationName}.env`, `${configuration.root}/.env.${configurationName}`, `${configuration.root}/.${configurationName}.env`);
26
- }
27
- }
28
- }
29
- }
30
- for (const envFile of new Set(envFiles)) {
31
- parseEnvFile(tree, envFile);
32
- }
33
- }
34
- /**
35
- * This function parse the env file and escape dollar sign
36
- * @param tree
37
- * @param envFilePath
38
- * @returns
39
- */
40
- function parseEnvFile(tree, envFilePath) {
41
- if (!tree.exists(envFilePath)) {
42
- return;
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
- }
51
- envFileContent = envFileContent
52
- .split('\n')
53
- .map((line) => {
54
- line = line.trim();
55
- if (!line || !line.includes('$')) {
56
- return line;
57
- }
58
- const declarations = line.split('=');
59
- if (declarations[1].includes('$') && !declarations[1].includes(`\\$`)) {
60
- declarations[1] = declarations[1].replace('$', `\\$`);
61
- line = declarations.join('=');
62
- }
63
- return line;
64
- })
65
- .join('\n');
66
- tree.write(envFilePath, envFileContent);
67
- }