nx 19.5.1 → 19.5.2

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -7,6 +7,7 @@ const json_1 = require("../../../generators/utils/json");
7
7
  const nx_json_1 = require("../../../generators/utils/nx-json");
8
8
  const format_changed_files_with_prettier_if_available_1 = require("../../../generators/internal-utils/format-changed-files-with-prettier-if-available");
9
9
  const url_shorten_1 = require("../../utilities/url-shorten");
10
+ const get_cloud_options_1 = require("../../utilities/get-cloud-options");
10
11
  const git_utils_1 = require("../../../utils/git-utils");
11
12
  const ora = require("ora");
12
13
  const open = require("open");
@@ -30,11 +31,6 @@ function getRootPackageName(tree) {
30
31
  catch (e) { }
31
32
  return packageJson?.name ?? 'my-workspace';
32
33
  }
33
- function removeTrailingSlash(apiUrl) {
34
- return apiUrl[apiUrl.length - 1] === '/'
35
- ? apiUrl.substr(0, apiUrl.length - 1)
36
- : apiUrl;
37
- }
38
34
  function getNxInitDate() {
39
35
  try {
40
36
  const nxInitIso = (0, child_process_1.execSync)('git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1', { stdio: 'pipe' })
@@ -48,7 +44,7 @@ function getNxInitDate() {
48
44
  }
49
45
  }
50
46
  async function createNxCloudWorkspace(workspaceName, installationSource, nxInitDate) {
51
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
47
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
52
48
  const response = await require('axios').post(`${apiUrl}/nx-cloud/create-org-and-workspace`, {
53
49
  workspaceName,
54
50
  installationSource,
@@ -145,7 +141,7 @@ async function connectToNxCloud(tree, schema) {
145
141
  silent: schema.hideFormatLogs,
146
142
  });
147
143
  }
148
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
144
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
149
145
  return async () => await printSuccessMessage(responseFromCreateNxCloudWorkspace?.url ?? apiUrl, responseFromCreateNxCloudWorkspace?.token, schema.installationSource, usesGithub, schema.directory);
150
146
  }
151
147
  }
@@ -1,2 +1,4 @@
1
1
  import { CloudTaskRunnerOptions } from '../nx-cloud-tasks-runner-shell';
2
2
  export declare function getCloudOptions(): CloudTaskRunnerOptions;
3
+ export declare function getCloudUrl(): string;
4
+ export declare function removeTrailingSlash(apiUrl: string): string;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCloudOptions = getCloudOptions;
4
+ exports.getCloudUrl = getCloudUrl;
5
+ exports.removeTrailingSlash = removeTrailingSlash;
4
6
  const nx_json_1 = require("../../config/nx-json");
5
7
  const run_command_1 = require("../../tasks-runner/run-command");
6
8
  function getCloudOptions() {
@@ -8,3 +10,9 @@ function getCloudOptions() {
8
10
  // TODO: The default is not always cloud? But it's not handled at the moment
9
11
  return (0, run_command_1.getRunnerOptions)('default', nxJson, {}, true);
10
12
  }
13
+ function getCloudUrl() {
14
+ return removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
15
+ }
16
+ function removeTrailingSlash(apiUrl) {
17
+ return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl;
18
+ }
@@ -1,6 +1,5 @@
1
1
  export declare function shortenedCloudUrl(installationSource: string, accessToken?: string, usesGithub?: boolean): Promise<string>;
2
2
  export declare function repoUsesGithub(github?: boolean): Promise<boolean>;
3
- export declare function removeTrailingSlash(apiUrl: string): string;
4
3
  export declare function getURLifShortenFailed(usesGithub: boolean, githubSlug: string, apiUrl: string, source: string, accessToken?: string): string;
5
4
  export declare function getNxCloudVersion(apiUrl: string): Promise<string | null>;
6
5
  export declare function removeVersionModifier(versionString: string): string;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.shortenedCloudUrl = shortenedCloudUrl;
4
4
  exports.repoUsesGithub = repoUsesGithub;
5
- exports.removeTrailingSlash = removeTrailingSlash;
6
5
  exports.getURLifShortenFailed = getURLifShortenFailed;
7
6
  exports.getNxCloudVersion = getNxCloudVersion;
8
7
  exports.removeVersionModifier = removeVersionModifier;
@@ -10,9 +9,10 @@ exports.versionIsValid = versionIsValid;
10
9
  exports.compareCleanCloudVersions = compareCleanCloudVersions;
11
10
  const devkit_exports_1 = require("../../devkit-exports");
12
11
  const git_utils_1 = require("../../utils/git-utils");
12
+ const get_cloud_options_1 = require("./get-cloud-options");
13
13
  async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
14
14
  const githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
15
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
15
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
16
16
  try {
17
17
  const version = await getNxCloudVersion(apiUrl);
18
18
  if ((version && compareCleanCloudVersions(version, '2406.11.5') < 0) ||
@@ -46,16 +46,13 @@ async function shortenedCloudUrl(installationSource, accessToken, usesGithub) {
46
46
  }
47
47
  async function repoUsesGithub(github) {
48
48
  const githubSlug = (0, git_utils_1.getGithubSlugOrNull)();
49
- const apiUrl = removeTrailingSlash(process.env.NX_CLOUD_API || process.env.NRWL_API || `https://cloud.nx.app`);
49
+ const apiUrl = (0, get_cloud_options_1.getCloudUrl)();
50
50
  const installationSupportsGitHub = await getInstallationSupportsGitHub(apiUrl);
51
51
  return ((githubSlug || github) &&
52
52
  (apiUrl.includes('cloud.nx.app') ||
53
53
  apiUrl.includes('eu.nx.app') ||
54
54
  installationSupportsGitHub));
55
55
  }
56
- function removeTrailingSlash(apiUrl) {
57
- return apiUrl[apiUrl.length - 1] === '/' ? apiUrl.slice(0, -1) : apiUrl;
58
- }
59
56
  function getSource(installationSource) {
60
57
  if (installationSource.includes('nx-init')) {
61
58
  return 'nx-init';
@@ -136,7 +136,6 @@ function normalizeTargetDependencyWithStringProjects(dependencyConfig) {
136
136
  else if (dependencyConfig.projects === 'dependencies') {
137
137
  dependencyConfig.dependencies = true;
138
138
  delete dependencyConfig.projects;
139
- return;
140
139
  /** LERNA SUPPORT END - Remove in v20 */
141
140
  }
142
141
  else {
@@ -46,6 +46,6 @@ export declare function recordStat(opts: {
46
46
  command: string;
47
47
  nxVersion: string;
48
48
  useCloud: boolean;
49
- meta: string;
49
+ meta?: string;
50
50
  }): Promise<void>;
51
51
  export {};
@@ -5,6 +5,7 @@ exports.recordStat = recordStat;
5
5
  const node_child_process_1 = require("node:child_process");
6
6
  const is_ci_1 = require("./is-ci");
7
7
  const package_manager_1 = require("./package-manager");
8
+ const get_cloud_options_1 = require("../nx-cloud/utilities/get-cloud-options");
8
9
  const messageOptions = {
9
10
  setupNxCloud: [
10
11
  {
@@ -72,7 +73,7 @@ async function recordStat(opts) {
72
73
  const axios = require('axios');
73
74
  await (axios['default'] ?? axios)
74
75
  .create({
75
- baseURL: 'https://cloud.nx.app',
76
+ baseURL: (0, get_cloud_options_1.getCloudUrl)(),
76
77
  timeout: 400,
77
78
  })
78
79
  .post('/nx-cloud/stats', {
@@ -114,7 +114,7 @@ async function listPluginCapabilities(pluginName, projects) {
114
114
  if (hasBuilders) {
115
115
  bodyLines.push(chalk.bold(chalk.green('EXECUTORS/BUILDERS')));
116
116
  bodyLines.push('');
117
- bodyLines.push(...Object.keys(plugin.executors).map((name) => `${chalk.bold(name)} : ${resolveExecutorDescription(plugin.executors[name], projects)}`));
117
+ bodyLines.push(...Object.keys(plugin.executors).map((name) => `${chalk.bold(name)} : ${resolveExecutorDescription(pluginName, plugin.executors[name], projects)}`));
118
118
  }
119
119
  if (hasProjectGraphExtension) {
120
120
  bodyLines.push(`✔️ Project Graph Extension`);
@@ -127,13 +127,20 @@ async function listPluginCapabilities(pluginName, projects) {
127
127
  bodyLines,
128
128
  });
129
129
  }
130
- function resolveExecutorDescription(executorJsonEntry, projects) {
130
+ function resolveExecutorDescription(pluginName, executorJsonEntry, projects, requirePaths = (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot)) {
131
131
  try {
132
132
  if (typeof executorJsonEntry === 'string') {
133
133
  // it points to another executor, resolve it
134
134
  const [pkgName, executor] = executorJsonEntry.split(':');
135
- const collection = loadExecutorsCollection(workspace_root_1.workspaceRoot, pkgName, projects);
136
- return resolveExecutorDescription(collection[executor], projects);
135
+ // read the package.json of the parent plugin
136
+ const { path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(pluginName, projects, requirePaths);
137
+ // accumulate the require paths to resolve nested packages
138
+ const cummulativeRequirePaths = [
139
+ ...requirePaths,
140
+ (0, path_1.dirname)(packageJsonPath),
141
+ ];
142
+ const collection = loadExecutorsCollection(pkgName, projects, cummulativeRequirePaths);
143
+ return resolveExecutorDescription(pkgName, collection[executor], projects, cummulativeRequirePaths);
137
144
  }
138
145
  return executorJsonEntry.description;
139
146
  }
@@ -141,8 +148,8 @@ function resolveExecutorDescription(executorJsonEntry, projects) {
141
148
  return 'No description available';
142
149
  }
143
150
  }
144
- function loadExecutorsCollection(workspaceRoot, pluginName, projects) {
145
- const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(pluginName, projects, (0, installation_directory_1.getNxRequirePaths)(workspaceRoot));
151
+ function loadExecutorsCollection(pluginName, projects, requirePaths) {
152
+ const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(pluginName, projects, requirePaths);
146
153
  return {
147
154
  ...tryGetCollection(packageJsonPath, packageJson.builders, 'builders'),
148
155
  ...tryGetCollection(packageJsonPath, packageJson.executors, 'builders'),