nx 19.6.0-canary.20240723-c4f9d89 → 19.6.0-canary.20240725-3890edc

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/bin/nx-cloud.d.ts +2 -1
  2. package/bin/nx-cloud.js +9 -17
  3. package/package.json +12 -12
  4. package/src/command-line/list/list.js +10 -14
  5. package/src/command-line/release/command-object.js +5 -21
  6. package/src/command-line/reset/command-object.d.ts +1 -0
  7. package/src/command-line/reset/command-object.js +4 -0
  8. package/src/command-line/reset/reset.js +13 -0
  9. package/src/command-line/run/run.js +2 -14
  10. package/src/command-line/watch/watch.js +1 -1
  11. package/src/daemon/socket-utils.js +1 -1
  12. package/src/daemon/tmp-dir.d.ts +1 -1
  13. package/src/daemon/tmp-dir.js +3 -2
  14. package/src/migrations/update-16-0-0/update-nx-cloud-runner.js +2 -0
  15. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.d.ts +1 -1
  16. package/src/migrations/update-18-0-0/disable-crystal-for-existing-workspaces.js +3 -1
  17. package/src/native/nx.wasm32-wasi.wasm +0 -0
  18. package/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +2 -10
  19. package/src/nx-cloud/utilities/client.d.ts +10 -0
  20. package/src/nx-cloud/utilities/client.js +35 -0
  21. package/src/nx-cloud/utilities/url-shorten.d.ts +2 -2
  22. package/src/nx-cloud/utilities/url-shorten.js +13 -6
  23. package/src/tasks-runner/run-command.d.ts +4 -4
  24. package/src/tasks-runner/run-command.js +22 -17
  25. package/src/tasks-runner/task-graph-utils.d.ts +3 -0
  26. package/src/tasks-runner/task-graph-utils.js +34 -0
  27. package/src/tasks-runner/utils.js +9 -5
  28. package/src/utils/chunkify.d.ts +10 -0
  29. package/src/utils/chunkify.js +19 -12
  30. package/src/utils/command-line-utils.d.ts +3 -0
  31. package/src/utils/command-line-utils.js +11 -7
  32. package/src/utils/git-utils.js +14 -4
  33. package/src/utils/plugins/core-plugins.d.ts +6 -3
  34. package/src/utils/plugins/core-plugins.js +107 -115
  35. package/src/utils/plugins/index.d.ts +4 -4
  36. package/src/utils/plugins/index.js +7 -8
  37. package/src/utils/plugins/installed-plugins.d.ts +2 -3
  38. package/src/utils/plugins/installed-plugins.js +4 -31
  39. package/src/utils/plugins/local-plugins.d.ts +2 -3
  40. package/src/utils/plugins/local-plugins.js +2 -29
  41. package/src/utils/plugins/output.d.ts +5 -0
  42. package/src/utils/plugins/output.js +104 -0
  43. package/src/utils/plugins/plugin-capabilities.d.ts +12 -2
  44. package/src/utils/plugins/plugin-capabilities.js +2 -87
  45. package/src/utils/plugins/community-plugins.d.ts +0 -2
  46. package/src/utils/plugins/community-plugins.js +0 -28
  47. package/src/utils/plugins/models.d.ts +0 -22
  48. package/src/utils/plugins/models.js +0 -2
  49. package/src/utils/plugins/shared.d.ts +0 -1
  50. package/src/utils/plugins/shared.js +0 -7
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listPlugins = listPlugins;
4
+ exports.listAlsoAvailableCorePlugins = listAlsoAvailableCorePlugins;
5
+ exports.listPluginCapabilities = listPluginCapabilities;
6
+ const chalk = require("chalk");
7
+ const output_1 = require("../output");
8
+ const package_manager_1 = require("../package-manager");
9
+ const workspace_root_1 = require("../workspace-root");
10
+ const core_plugins_1 = require("./core-plugins");
11
+ const plugin_capabilities_1 = require("./plugin-capabilities");
12
+ const package_json_1 = require("../package-json");
13
+ function listPlugins(plugins, title) {
14
+ package_json_1.readModulePackageJson;
15
+ const bodyLines = [];
16
+ for (const [, p] of plugins) {
17
+ const capabilities = [];
18
+ if (hasElements(p.executors)) {
19
+ capabilities.push('executors');
20
+ }
21
+ if (hasElements(p.generators)) {
22
+ capabilities.push('generators');
23
+ }
24
+ if (p.projectGraphExtension) {
25
+ capabilities.push('graph-extension');
26
+ }
27
+ if (p.projectInference) {
28
+ capabilities.push('project-inference');
29
+ }
30
+ bodyLines.push(`${chalk.bold(p.name)} (${capabilities.join()})`);
31
+ }
32
+ output_1.output.log({
33
+ title: title,
34
+ bodyLines: bodyLines,
35
+ });
36
+ }
37
+ function listAlsoAvailableCorePlugins(installedPlugins) {
38
+ const alsoAvailable = core_plugins_1.CORE_PLUGINS.filter((p) => !installedPlugins.has(p.name));
39
+ if (alsoAvailable.length) {
40
+ output_1.output.log({
41
+ title: `Also available:`,
42
+ bodyLines: alsoAvailable.map((p) => {
43
+ return `${chalk.bold(p.name)} (${p.capabilities})`;
44
+ }),
45
+ });
46
+ }
47
+ }
48
+ async function listPluginCapabilities(pluginName, projects) {
49
+ const plugin = await (0, plugin_capabilities_1.getPluginCapabilities)(workspace_root_1.workspaceRoot, pluginName, projects);
50
+ if (!plugin) {
51
+ const pmc = (0, package_manager_1.getPackageManagerCommand)();
52
+ output_1.output.note({
53
+ title: `${pluginName} is not currently installed`,
54
+ bodyLines: [
55
+ `Use "${pmc.addDev} ${pluginName}" to install the plugin.`,
56
+ `After that, use "${pmc.exec} nx g ${pluginName}:init" to add the required peer deps and initialize the plugin.`,
57
+ ],
58
+ });
59
+ return;
60
+ }
61
+ const hasBuilders = hasElements(plugin.executors);
62
+ const hasGenerators = hasElements(plugin.generators);
63
+ const hasProjectGraphExtension = !!plugin.projectGraphExtension;
64
+ const hasProjectInference = !!plugin.projectInference;
65
+ if (!hasBuilders &&
66
+ !hasGenerators &&
67
+ !hasProjectGraphExtension &&
68
+ !hasProjectInference) {
69
+ output_1.output.warn({ title: `No capabilities found in ${pluginName}` });
70
+ return;
71
+ }
72
+ const bodyLines = [];
73
+ if (hasGenerators) {
74
+ bodyLines.push(chalk.bold(chalk.green('GENERATORS')));
75
+ bodyLines.push('');
76
+ bodyLines.push(...Object.keys(plugin.generators).map((name) => `${chalk.bold(name)} : ${plugin.generators[name].description}`));
77
+ if (hasBuilders) {
78
+ bodyLines.push('');
79
+ }
80
+ }
81
+ if (hasBuilders) {
82
+ bodyLines.push(chalk.bold(chalk.green('EXECUTORS/BUILDERS')));
83
+ bodyLines.push('');
84
+ bodyLines.push(...Object.keys(plugin.executors).map((name) => {
85
+ const definition = plugin.executors[name];
86
+ return typeof definition === 'string'
87
+ ? chalk.bold(name)
88
+ : `${chalk.bold(name)} : ${definition.description}`;
89
+ }));
90
+ }
91
+ if (hasProjectGraphExtension) {
92
+ bodyLines.push(`✔️ Project Graph Extension`);
93
+ }
94
+ if (hasProjectInference) {
95
+ bodyLines.push(`✔️ Project Inference`);
96
+ }
97
+ output_1.output.log({
98
+ title: `Capabilities in ${plugin.name}:`,
99
+ bodyLines,
100
+ });
101
+ }
102
+ function hasElements(obj) {
103
+ return obj && Object.values(obj).length > 0;
104
+ }
@@ -1,4 +1,14 @@
1
+ import { ExecutorsJsonEntry, GeneratorsJsonEntry } from '../../config/misc-interfaces';
1
2
  import { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
- import type { PluginCapabilities } from './models';
3
+ export interface PluginCapabilities {
4
+ name: string;
5
+ executors?: {
6
+ [name: string]: ExecutorsJsonEntry;
7
+ };
8
+ generators?: {
9
+ [name: string]: GeneratorsJsonEntry;
10
+ };
11
+ projectInference?: boolean;
12
+ projectGraphExtension?: boolean;
13
+ }
3
14
  export declare function getPluginCapabilities(workspaceRoot: string, pluginName: string, projects: Record<string, ProjectConfiguration>, includeRuntimeCapabilities?: boolean): Promise<PluginCapabilities | null>;
4
- export declare function listPluginCapabilities(pluginName: string, projects: Record<string, ProjectConfiguration>): Promise<void>;
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPluginCapabilities = getPluginCapabilities;
4
- exports.listPluginCapabilities = listPluginCapabilities;
5
- const chalk = require("chalk");
6
4
  const path_1 = require("path");
7
- const plugins_1 = require("../../project-graph/plugins");
8
- const loader_1 = require("../../project-graph/plugins/loader");
9
5
  const fileutils_1 = require("../fileutils");
10
6
  const installation_directory_1 = require("../installation-directory");
11
- const output_1 = require("../output");
12
- const package_manager_1 = require("../package-manager");
13
- const workspace_root_1 = require("../workspace-root");
14
- const shared_1 = require("./shared");
7
+ const plugins_1 = require("../../project-graph/plugins");
8
+ const loader_1 = require("../../project-graph/plugins/loader");
15
9
  function tryGetCollection(packageJsonPath, collectionFile, propName) {
16
10
  if (!collectionFile) {
17
11
  return null;
@@ -78,82 +72,3 @@ async function tryGetModule(packageJson, workspaceRoot) {
78
72
  return null;
79
73
  }
80
74
  }
81
- async function listPluginCapabilities(pluginName, projects) {
82
- const plugin = await getPluginCapabilities(workspace_root_1.workspaceRoot, pluginName, projects);
83
- if (!plugin) {
84
- const pmc = (0, package_manager_1.getPackageManagerCommand)();
85
- output_1.output.note({
86
- title: `${pluginName} is not currently installed`,
87
- bodyLines: [
88
- `Use "${pmc.addDev} ${pluginName}" to install the plugin.`,
89
- `After that, use "${pmc.exec} nx g ${pluginName}:init" to add the required peer deps and initialize the plugin.`,
90
- ],
91
- });
92
- return;
93
- }
94
- const hasBuilders = (0, shared_1.hasElements)(plugin.executors);
95
- const hasGenerators = (0, shared_1.hasElements)(plugin.generators);
96
- const hasProjectGraphExtension = !!plugin.projectGraphExtension;
97
- const hasProjectInference = !!plugin.projectInference;
98
- if (!hasBuilders &&
99
- !hasGenerators &&
100
- !hasProjectGraphExtension &&
101
- !hasProjectInference) {
102
- output_1.output.warn({ title: `No capabilities found in ${pluginName}` });
103
- return;
104
- }
105
- const bodyLines = [];
106
- if (hasGenerators) {
107
- bodyLines.push(chalk.bold(chalk.green('GENERATORS')));
108
- bodyLines.push('');
109
- bodyLines.push(...Object.keys(plugin.generators).map((name) => `${chalk.bold(name)} : ${plugin.generators[name].description}`));
110
- if (hasBuilders) {
111
- bodyLines.push('');
112
- }
113
- }
114
- if (hasBuilders) {
115
- bodyLines.push(chalk.bold(chalk.green('EXECUTORS/BUILDERS')));
116
- bodyLines.push('');
117
- bodyLines.push(...Object.keys(plugin.executors).map((name) => `${chalk.bold(name)} : ${resolveExecutorDescription(pluginName, plugin.executors[name], projects)}`));
118
- }
119
- if (hasProjectGraphExtension) {
120
- bodyLines.push(`✔️ Project Graph Extension`);
121
- }
122
- if (hasProjectInference) {
123
- bodyLines.push(`✔️ Project Inference`);
124
- }
125
- output_1.output.log({
126
- title: `Capabilities in ${plugin.name}:`,
127
- bodyLines,
128
- });
129
- }
130
- function resolveExecutorDescription(pluginName, executorJsonEntry, projects, requirePaths = (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot)) {
131
- try {
132
- if (typeof executorJsonEntry === 'string') {
133
- // it points to another executor, resolve it
134
- const [pkgName, executor] = executorJsonEntry.split(':');
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);
144
- }
145
- return executorJsonEntry.description;
146
- }
147
- catch {
148
- return 'No description available';
149
- }
150
- }
151
- function loadExecutorsCollection(pluginName, projects, requirePaths) {
152
- const { json: packageJson, path: packageJsonPath } = (0, plugins_1.readPluginPackageJson)(pluginName, projects, requirePaths);
153
- return {
154
- ...tryGetCollection(packageJsonPath, packageJson.builders, 'builders'),
155
- ...tryGetCollection(packageJsonPath, packageJson.executors, 'builders'),
156
- ...tryGetCollection(packageJsonPath, packageJson.builders, 'executors'),
157
- ...tryGetCollection(packageJsonPath, packageJson.executors, 'executors'),
158
- };
159
- }
@@ -1,2 +0,0 @@
1
- import type { CommunityPlugin } from './models';
2
- export declare function fetchCommunityPlugins(): Promise<CommunityPlugin[]>;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchCommunityPlugins = fetchCommunityPlugins;
4
- const https_1 = require("https");
5
- const COMMUNITY_PLUGINS_JSON_URL = 'https://raw.githubusercontent.com/nrwl/nx/master/community/approved-plugins.json';
6
- async function fetchCommunityPlugins() {
7
- return new Promise((resolve, reject) => {
8
- const req = (0, https_1.get)(COMMUNITY_PLUGINS_JSON_URL, (res) => {
9
- if (res.statusCode < 200 || res.statusCode >= 300) {
10
- reject(new Error(`Request failed with status code ${res.statusCode}`));
11
- }
12
- const data = [];
13
- res.on('data', (chunk) => {
14
- data.push(chunk);
15
- });
16
- res.on('end', () => {
17
- try {
18
- resolve(JSON.parse(Buffer.concat(data).toString('utf-8')));
19
- }
20
- catch (e) {
21
- reject(e);
22
- }
23
- });
24
- });
25
- req.on('error', reject);
26
- req.end();
27
- });
28
- }
@@ -1,22 +0,0 @@
1
- import { ExecutorsJsonEntry, GeneratorsJsonEntry } from '../../config/misc-interfaces';
2
- export interface PluginCapabilities {
3
- name: string;
4
- executors?: {
5
- [name: string]: ExecutorsJsonEntry;
6
- };
7
- generators?: {
8
- [name: string]: GeneratorsJsonEntry;
9
- };
10
- projectInference?: boolean;
11
- projectGraphExtension?: boolean;
12
- }
13
- export interface CorePlugin {
14
- name: string;
15
- capabilities: 'executors' | 'generators' | 'executors,generators';
16
- link?: string;
17
- }
18
- export interface CommunityPlugin {
19
- name: string;
20
- url: string;
21
- description: string;
22
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export declare function hasElements(obj: any): boolean;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- // Lifted in part from https://github.com/nrwl/angular-console
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.hasElements = hasElements;
5
- function hasElements(obj) {
6
- return obj && Object.values(obj).length > 0;
7
- }