nx 20.3.1 → 20.4.0-beta.0

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 (52) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +11 -11
  3. package/src/command-line/release/version.js +8 -0
  4. package/src/command-line/run/run-one.js +37 -13
  5. package/src/command-line/show/project.js +21 -3
  6. package/src/command-line/yargs-utils/shared-options.d.ts +1 -0
  7. package/src/command-line/yargs-utils/shared-options.js +7 -0
  8. package/src/core/graph/main.js +1 -1
  9. package/src/daemon/server/server.js +2 -2
  10. package/src/devkit-internals.d.ts +1 -1
  11. package/src/devkit-internals.js +2 -2
  12. package/src/native/nx.wasm32-wasi.wasm +0 -0
  13. package/src/nx-cloud/update-manager.js +13 -1
  14. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +4 -1
  15. package/src/plugins/js/utils/packages.js +16 -2
  16. package/src/project-graph/build-project-graph.d.ts +1 -1
  17. package/src/project-graph/error-types.d.ts +2 -0
  18. package/src/project-graph/error-types.js +66 -8
  19. package/src/project-graph/plugins/get-plugins.d.ts +3 -3
  20. package/src/project-graph/plugins/get-plugins.js +112 -12
  21. package/src/project-graph/plugins/in-process-loader.d.ts +10 -0
  22. package/src/project-graph/plugins/in-process-loader.js +60 -0
  23. package/src/project-graph/plugins/index.d.ts +2 -1
  24. package/src/project-graph/plugins/index.js +4 -3
  25. package/src/project-graph/plugins/isolation/index.d.ts +2 -2
  26. package/src/project-graph/plugins/isolation/messaging.d.ts +1 -1
  27. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
  28. package/src/project-graph/plugins/isolation/plugin-pool.js +2 -2
  29. package/src/project-graph/plugins/isolation/plugin-worker.js +1 -2
  30. package/src/project-graph/plugins/load-resolved-plugin.d.ts +1 -1
  31. package/src/project-graph/plugins/load-resolved-plugin.js +2 -2
  32. package/src/project-graph/plugins/{internal-api.d.ts → loaded-nx-plugin.d.ts} +4 -10
  33. package/src/project-graph/plugins/loaded-nx-plugin.js +57 -0
  34. package/src/project-graph/plugins/resolve-plugin.d.ts +15 -0
  35. package/src/project-graph/plugins/{loader.js → resolve-plugin.js} +60 -149
  36. package/src/project-graph/plugins/transpiler.d.ts +8 -0
  37. package/src/project-graph/plugins/transpiler.js +47 -0
  38. package/src/project-graph/project-graph.js +0 -3
  39. package/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  40. package/src/project-graph/utils/project-configuration-utils.js +1 -17
  41. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  42. package/src/tasks-runner/cache.d.ts +1 -0
  43. package/src/tasks-runner/cache.js +20 -2
  44. package/src/tasks-runner/default-tasks-runner.d.ts +1 -0
  45. package/src/utils/command-line-utils.d.ts +1 -0
  46. package/src/utils/command-line-utils.js +8 -1
  47. package/src/utils/find-matching-projects.js +11 -0
  48. package/src/utils/handle-errors.js +7 -11
  49. package/src/utils/package-json.d.ts +1 -0
  50. package/src/utils/plugins/plugin-capabilities.js +2 -2
  51. package/src/project-graph/plugins/internal-api.js +0 -135
  52. package/src/project-graph/plugins/loader.d.ts +0 -30
@@ -1,135 +0,0 @@
1
- "use strict";
2
- // This file contains the bits and bobs of the internal API for loading and interacting with Nx plugins.
3
- // For the public API, used by plugin authors, see `./public-api.ts`.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.LoadedNxPlugin = void 0;
6
- exports.loadNxPlugins = loadNxPlugins;
7
- exports.getDefaultPlugins = getDefaultPlugins;
8
- const path_1 = require("path");
9
- const workspace_root_1 = require("../../utils/workspace-root");
10
- const angular_json_1 = require("../../adapter/angular-json");
11
- const isolation_1 = require("./isolation");
12
- const loader_1 = require("./loader");
13
- const utils_1 = require("./utils");
14
- const error_types_1 = require("../error-types");
15
- const native_1 = require("../../native");
16
- class LoadedNxPlugin {
17
- constructor(plugin, pluginDefinition) {
18
- this.name = plugin.name;
19
- if (typeof pluginDefinition !== 'string') {
20
- this.options = pluginDefinition.options;
21
- this.include = pluginDefinition.include;
22
- this.exclude = pluginDefinition.exclude;
23
- }
24
- if (plugin.createNodes && !plugin.createNodesV2) {
25
- this.createNodes = [
26
- plugin.createNodes[0],
27
- (configFiles, context) => (0, utils_1.createNodesFromFiles)(plugin.createNodes[1], configFiles, this.options, context).then((results) => results.map((r) => [this.name, r[0], r[1]])),
28
- ];
29
- }
30
- if (plugin.createNodesV2) {
31
- this.createNodes = [
32
- plugin.createNodesV2[0],
33
- async (configFiles, context) => {
34
- const result = await plugin.createNodesV2[1](configFiles, this.options, context);
35
- return result.map((r) => [this.name, r[0], r[1]]);
36
- },
37
- ];
38
- }
39
- if (this.createNodes) {
40
- const inner = this.createNodes[1];
41
- this.createNodes[1] = async (...args) => {
42
- performance.mark(`${plugin.name}:createNodes - start`);
43
- try {
44
- return await inner(...args);
45
- }
46
- catch (e) {
47
- if ((0, error_types_1.isAggregateCreateNodesError)(e)) {
48
- throw e;
49
- }
50
- // The underlying plugin errored out. We can't know any partial results.
51
- throw new error_types_1.AggregateCreateNodesError([[null, e]], []);
52
- }
53
- finally {
54
- performance.mark(`${plugin.name}:createNodes - end`);
55
- performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
56
- }
57
- };
58
- }
59
- if (plugin.createDependencies) {
60
- this.createDependencies = async (context) => plugin.createDependencies(this.options, context);
61
- }
62
- if (plugin.createMetadata) {
63
- this.createMetadata = async (graph, context) => plugin.createMetadata(graph, this.options, context);
64
- }
65
- }
66
- }
67
- exports.LoadedNxPlugin = LoadedNxPlugin;
68
- function isIsolationEnabled() {
69
- // Explicitly enabled, regardless of further conditions
70
- if (process.env.NX_ISOLATE_PLUGINS === 'true') {
71
- return true;
72
- }
73
- if (
74
- // Explicitly disabled
75
- process.env.NX_ISOLATE_PLUGINS === 'false' ||
76
- // Isolation is disabled on WASM builds currently.
77
- native_1.IS_WASM) {
78
- return false;
79
- }
80
- // Default value
81
- return true;
82
- }
83
- /**
84
- * Use `getPlugins` instead.
85
- * @deprecated Do not use this. Use `getPlugins` instead.
86
- */
87
- async function loadNxPlugins(plugins, root = workspace_root_1.workspaceRoot) {
88
- performance.mark('loadNxPlugins:start');
89
- const loadingMethod = isIsolationEnabled()
90
- ? isolation_1.loadNxPluginInIsolation
91
- : loader_1.loadNxPlugin;
92
- plugins = await normalizePlugins(plugins, root);
93
- const cleanupFunctions = [];
94
- const ret = [
95
- await Promise.all(plugins.map(async (plugin) => {
96
- const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
97
- performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
98
- const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
99
- cleanupFunctions.push(cleanup);
100
- const res = await loadedPluginPromise;
101
- performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
102
- performance.measure(`Load Nx Plugin: ${pluginPath}`, `Load Nx Plugin: ${pluginPath} - start`, `Load Nx Plugin: ${pluginPath} - end`);
103
- return res;
104
- })),
105
- () => {
106
- for (const fn of cleanupFunctions) {
107
- fn();
108
- }
109
- if (loader_1.unregisterPluginTSTranspiler) {
110
- (0, loader_1.unregisterPluginTSTranspiler)();
111
- }
112
- },
113
- ];
114
- performance.mark('loadNxPlugins:end');
115
- performance.measure('loadNxPlugins', 'loadNxPlugins:start', 'loadNxPlugins:end');
116
- return ret;
117
- }
118
- async function normalizePlugins(plugins, root) {
119
- plugins ??= [];
120
- return [
121
- ...plugins,
122
- // Most of the nx core node plugins go on the end, s.t. it overwrites any other plugins
123
- ...(await getDefaultPlugins(root)),
124
- ];
125
- }
126
- async function getDefaultPlugins(root) {
127
- return [
128
- (0, path_1.join)(__dirname, '../../plugins/js'),
129
- ...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
130
- ? [(0, path_1.join)(__dirname, '../../adapter/angular-json')]
131
- : []),
132
- (0, path_1.join)(__dirname, '../../plugins/package-json'),
133
- (0, path_1.join)(__dirname, '../../plugins/project-json/build-nodes/project-json'),
134
- ];
135
- }
@@ -1,30 +0,0 @@
1
- import { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
- import { PackageJson } from '../../utils/package-json';
3
- import type { PluginConfiguration } from '../../config/nx-json';
4
- import { LoadedNxPlugin } from './internal-api';
5
- export declare function readPluginPackageJson(pluginName: string, projects: Record<string, ProjectConfiguration>, paths?: string[]): {
6
- path: string;
7
- json: PackageJson;
8
- };
9
- export declare function resolveLocalNxPlugin(importPath: string, projects: Record<string, ProjectConfiguration>, root?: string): {
10
- path: string;
11
- projectConfig: ProjectConfiguration;
12
- } | null;
13
- export declare let unregisterPluginTSTranspiler: (() => void) | null;
14
- /**
15
- * Register swc-node or ts-node if they are not currently registered
16
- * with some default settings which work well for Nx plugins.
17
- */
18
- export declare function registerPluginTSTranspiler(): void;
19
- export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
20
- pluginPath: string;
21
- name: any;
22
- shouldRegisterTSTranspiler: boolean;
23
- };
24
- export declare function loadNxPlugin(plugin: PluginConfiguration, root: string): readonly [Promise<LoadedNxPlugin>, () => void];
25
- export declare function resolveNxPlugin(moduleName: string, root: string, paths: string[]): Promise<{
26
- pluginPath: string;
27
- name: any;
28
- shouldRegisterTSTranspiler: boolean;
29
- }>;
30
- export declare function loadNxPluginAsync(pluginConfiguration: PluginConfiguration, paths: string[], root: string): Promise<LoadedNxPlugin>;