nx 18.1.0-canary.20240309-235ca8c → 18.1.0-canary.20240313-81df848
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.
- package/bin/post-install.js +5 -7
- package/package.json +12 -12
- package/src/adapter/angular-json.d.ts +1 -2
- package/src/adapter/angular-json.js +0 -1
- package/src/adapter/ngcli-adapter.js +3 -3
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/config/schema-utils.js +2 -2
- package/src/core/graph/3rdpartylicenses.txt +51 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +7 -8
- package/src/daemon/server/shutdown-utils.js +0 -2
- package/src/devkit-exports.d.ts +1 -2
- package/src/executors/run-commands/run-commands.impl.d.ts +3 -0
- package/src/executors/run-commands/run-commands.impl.js +77 -38
- package/src/executors/utils/convert-nx-executor.js +1 -4
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/hasher/hash-task.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +2 -2
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/js/utils/register.js +3 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +31 -24
- package/src/plugins/package-json-workspaces/index.d.ts +0 -1
- package/src/plugins/package-json-workspaces/index.js +0 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -1
- package/src/plugins/project-json/build-nodes/project-json.d.ts +1 -2
- package/src/plugins/project-json/build-nodes/project-json.js +0 -1
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +1 -2
- package/src/plugins/target-defaults/target-defaults-plugin.js +0 -1
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
- package/src/project-graph/build-project-graph.d.ts +1 -2
- package/src/project-graph/build-project-graph.js +13 -12
- package/src/project-graph/file-utils.js +3 -3
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.js +15 -19
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +2 -2
- package/src/project-graph/utils/project-configuration-utils.js +55 -11
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +8 -6
- package/src/project-graph/utils/retrieve-workspace-files.js +21 -18
- package/src/tasks-runner/task-orchestrator.js +45 -8
- package/src/tasks-runner/tasks-schedule.js +3 -3
- package/src/tasks-runner/utils.d.ts +7 -6
- package/src/tasks-runner/utils.js +11 -7
- package/src/utils/logger.d.ts +0 -1
- package/src/utils/logger.js +0 -5
- package/src/{project-graph/plugins/public-api.d.ts → utils/nx-plugin.d.ts} +41 -7
- package/src/utils/nx-plugin.deprecated.d.ts +2 -4
- package/src/utils/nx-plugin.deprecated.js +4 -4
- package/src/utils/nx-plugin.js +293 -0
- package/src/utils/output.js +1 -1
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +9 -10
- package/src/daemon/server/plugins.d.ts +0 -3
- package/src/daemon/server/plugins.js +0 -22
- package/src/project-graph/plugins/index.d.ts +0 -2
- package/src/project-graph/plugins/index.js +0 -8
- package/src/project-graph/plugins/internal-api.d.ts +0 -22
- package/src/project-graph/plugins/internal-api.js +0 -64
- package/src/project-graph/plugins/messaging.d.ts +0 -94
- package/src/project-graph/plugins/messaging.js +0 -23
- package/src/project-graph/plugins/plugin-pool.d.ts +0 -3
- package/src/project-graph/plugins/plugin-pool.js +0 -189
- package/src/project-graph/plugins/plugin-worker.d.ts +0 -1
- package/src/project-graph/plugins/plugin-worker.js +0 -101
- package/src/project-graph/plugins/public-api.js +0 -4
- package/src/project-graph/plugins/utils.d.ts +0 -9
- package/src/project-graph/plugins/utils.js +0 -55
- package/src/project-graph/plugins/worker-api.d.ts +0 -28
- package/src/project-graph/plugins/worker-api.js +0 -195
@@ -1,195 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
// This file contains methods and utilities that should **only** be used by the plugin worker.
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.loadNxPluginAsync = exports.loadPlugin = exports.loadPlugins = exports.getPluginPathAndName = exports.registerPluginTSTranspiler = exports.resolveLocalNxPlugin = exports.readPluginPackageJson = void 0;
|
5
|
-
const posix_1 = require("node:path/posix");
|
6
|
-
const installation_directory_1 = require("../../utils/installation-directory");
|
7
|
-
const package_json_1 = require("../../utils/package-json");
|
8
|
-
const fileutils_1 = require("../../utils/fileutils");
|
9
|
-
const workspace_root_1 = require("../../utils/workspace-root");
|
10
|
-
const node_fs_1 = require("node:fs");
|
11
|
-
const typescript_1 = require("../../utils/typescript");
|
12
|
-
const register_1 = require("../../plugins/js/utils/register");
|
13
|
-
const find_project_for_path_1 = require("../utils/find-project-for-path");
|
14
|
-
const path_1 = require("../../utils/path");
|
15
|
-
const logger_1 = require("../../utils/logger");
|
16
|
-
const node_path_1 = require("node:path");
|
17
|
-
const path = require("node:path/posix");
|
18
|
-
const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
|
19
|
-
const utils_1 = require("./utils");
|
20
|
-
function readPluginPackageJson(pluginName, projects, paths = (0, installation_directory_1.getNxRequirePaths)()) {
|
21
|
-
try {
|
22
|
-
const result = (0, package_json_1.readModulePackageJsonWithoutFallbacks)(pluginName, paths);
|
23
|
-
return {
|
24
|
-
json: result.packageJson,
|
25
|
-
path: result.path,
|
26
|
-
};
|
27
|
-
}
|
28
|
-
catch (e) {
|
29
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
30
|
-
const localPluginPath = resolveLocalNxPlugin(pluginName, projects);
|
31
|
-
if (localPluginPath) {
|
32
|
-
const localPluginPackageJson = path.join(localPluginPath.path, 'package.json');
|
33
|
-
return {
|
34
|
-
path: localPluginPackageJson,
|
35
|
-
json: (0, fileutils_1.readJsonFile)(localPluginPackageJson),
|
36
|
-
};
|
37
|
-
}
|
38
|
-
}
|
39
|
-
throw e;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
exports.readPluginPackageJson = readPluginPackageJson;
|
43
|
-
function resolveLocalNxPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
44
|
-
return lookupLocalPlugin(importPath, projects, root);
|
45
|
-
}
|
46
|
-
exports.resolveLocalNxPlugin = resolveLocalNxPlugin;
|
47
|
-
/**
|
48
|
-
* Register swc-node or ts-node if they are not currently registered
|
49
|
-
* with some default settings which work well for Nx plugins.
|
50
|
-
*/
|
51
|
-
function registerPluginTSTranspiler() {
|
52
|
-
// Get the first tsconfig that matches the allowed set
|
53
|
-
const tsConfigName = [
|
54
|
-
(0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.base.json'),
|
55
|
-
(0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.json'),
|
56
|
-
].find((x) => (0, node_fs_1.existsSync)(x));
|
57
|
-
const tsConfig = tsConfigName
|
58
|
-
? (0, typescript_1.readTsConfig)(tsConfigName)
|
59
|
-
: {};
|
60
|
-
(0, register_1.registerTsConfigPaths)(tsConfigName);
|
61
|
-
(0, register_1.registerTranspiler)({
|
62
|
-
experimentalDecorators: true,
|
63
|
-
emitDecoratorMetadata: true,
|
64
|
-
...tsConfig.options,
|
65
|
-
});
|
66
|
-
}
|
67
|
-
exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
|
68
|
-
function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
69
|
-
const plugin = findNxProjectForImportPath(importPath, projects, root);
|
70
|
-
if (!plugin) {
|
71
|
-
return null;
|
72
|
-
}
|
73
|
-
const projectConfig = projects[plugin];
|
74
|
-
return { path: path.join(root, projectConfig.root), projectConfig };
|
75
|
-
}
|
76
|
-
function findNxProjectForImportPath(importPath, projects, root = workspace_root_1.workspaceRoot) {
|
77
|
-
const tsConfigPaths = readTsConfigPaths(root);
|
78
|
-
const possiblePaths = tsConfigPaths[importPath]?.map((p) => (0, path_1.normalizePath)(path.relative(root, path.join(root, p))));
|
79
|
-
if (possiblePaths?.length) {
|
80
|
-
const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations)(projects);
|
81
|
-
for (const tsConfigPath of possiblePaths) {
|
82
|
-
const nxProject = (0, find_project_for_path_1.findProjectForPath)(tsConfigPath, projectRootMappings);
|
83
|
-
if (nxProject) {
|
84
|
-
return nxProject;
|
85
|
-
}
|
86
|
-
}
|
87
|
-
logger_1.logger.verbose('Unable to find local plugin', possiblePaths, projectRootMappings);
|
88
|
-
throw new Error('Unable to resolve local plugin with import path ' + importPath);
|
89
|
-
}
|
90
|
-
}
|
91
|
-
let tsconfigPaths;
|
92
|
-
function readTsConfigPaths(root = workspace_root_1.workspaceRoot) {
|
93
|
-
if (!tsconfigPaths) {
|
94
|
-
const tsconfigPath = ['tsconfig.base.json', 'tsconfig.json']
|
95
|
-
.map((x) => path.join(root, x))
|
96
|
-
.filter((x) => (0, node_fs_1.existsSync)(x))[0];
|
97
|
-
if (!tsconfigPath) {
|
98
|
-
throw new Error('unable to find tsconfig.base.json or tsconfig.json');
|
99
|
-
}
|
100
|
-
const { compilerOptions } = (0, fileutils_1.readJsonFile)(tsconfigPath);
|
101
|
-
tsconfigPaths = compilerOptions?.paths;
|
102
|
-
}
|
103
|
-
return tsconfigPaths ?? {};
|
104
|
-
}
|
105
|
-
function readPluginMainFromProjectConfiguration(plugin) {
|
106
|
-
const { main } = Object.values(plugin.targets).find((x) => [
|
107
|
-
'@nx/js:tsc',
|
108
|
-
'@nrwl/js:tsc',
|
109
|
-
'@nx/js:swc',
|
110
|
-
'@nrwl/js:swc',
|
111
|
-
'@nx/node:package',
|
112
|
-
'@nrwl/node:package',
|
113
|
-
].includes(x.executor))?.options ||
|
114
|
-
plugin.targets?.build?.options ||
|
115
|
-
{};
|
116
|
-
return main;
|
117
|
-
}
|
118
|
-
function getPluginPathAndName(moduleName, paths, projects, root) {
|
119
|
-
let pluginPath;
|
120
|
-
let registerTSTranspiler = false;
|
121
|
-
try {
|
122
|
-
pluginPath = require.resolve(moduleName, {
|
123
|
-
paths,
|
124
|
-
});
|
125
|
-
const extension = path.extname(pluginPath);
|
126
|
-
registerTSTranspiler = extension === '.ts';
|
127
|
-
}
|
128
|
-
catch (e) {
|
129
|
-
if (e.code === 'MODULE_NOT_FOUND') {
|
130
|
-
const plugin = resolveLocalNxPlugin(moduleName, projects, root);
|
131
|
-
if (plugin) {
|
132
|
-
registerTSTranspiler = true;
|
133
|
-
const main = readPluginMainFromProjectConfiguration(plugin.projectConfig);
|
134
|
-
pluginPath = main ? path.join(root, main) : plugin.path;
|
135
|
-
}
|
136
|
-
else {
|
137
|
-
logger_1.logger.error(`Plugin listed in \`nx.json\` not found: ${moduleName}`);
|
138
|
-
throw e;
|
139
|
-
}
|
140
|
-
}
|
141
|
-
else {
|
142
|
-
throw e;
|
143
|
-
}
|
144
|
-
}
|
145
|
-
const packageJsonPath = path.join(pluginPath, 'package.json');
|
146
|
-
// Register the ts-transpiler if we are pointing to a
|
147
|
-
// plain ts file that's not part of a plugin project
|
148
|
-
if (registerTSTranspiler) {
|
149
|
-
registerPluginTSTranspiler();
|
150
|
-
}
|
151
|
-
const { name } = !['.ts', '.js'].some((x) => (0, node_path_1.extname)(moduleName) === x) && // Not trying to point to a ts or js file
|
152
|
-
(0, node_fs_1.existsSync)(packageJsonPath) // plugin has a package.json
|
153
|
-
? (0, fileutils_1.readJsonFile)(packageJsonPath) // read name from package.json
|
154
|
-
: { name: moduleName };
|
155
|
-
return { pluginPath, name };
|
156
|
-
}
|
157
|
-
exports.getPluginPathAndName = getPluginPathAndName;
|
158
|
-
let projectsWithoutInference;
|
159
|
-
async function loadPlugins(plugins, root) {
|
160
|
-
return await Promise.all(plugins.map((p) => loadPlugin(p, root)));
|
161
|
-
}
|
162
|
-
exports.loadPlugins = loadPlugins;
|
163
|
-
async function loadPlugin(plugin, root) {
|
164
|
-
try {
|
165
|
-
require.resolve(typeof plugin === 'string' ? plugin : plugin.plugin);
|
166
|
-
}
|
167
|
-
catch {
|
168
|
-
// If a plugin cannot be resolved, we will need projects to resolve it
|
169
|
-
projectsWithoutInference ??=
|
170
|
-
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
171
|
-
}
|
172
|
-
return await loadNxPluginAsync(plugin, (0, installation_directory_1.getNxRequirePaths)(root), projectsWithoutInference, root);
|
173
|
-
}
|
174
|
-
exports.loadPlugin = loadPlugin;
|
175
|
-
async function loadNxPluginAsync(pluginConfiguration, paths, projects, root) {
|
176
|
-
const { plugin: moduleName, options } = typeof pluginConfiguration === 'object'
|
177
|
-
? pluginConfiguration
|
178
|
-
: { plugin: pluginConfiguration, options: undefined };
|
179
|
-
performance.mark(`Load Nx Plugin: ${moduleName} - start`);
|
180
|
-
let { pluginPath, name } = await getPluginPathAndName(moduleName, paths, projects, root);
|
181
|
-
const plugin = (0, utils_1.normalizeNxPlugin)(await importPluginModule(pluginPath));
|
182
|
-
plugin.name ??= name;
|
183
|
-
performance.mark(`Load Nx Plugin: ${moduleName} - end`);
|
184
|
-
performance.measure(`Load Nx Plugin: ${moduleName}`, `Load Nx Plugin: ${moduleName} - start`, `Load Nx Plugin: ${moduleName} - end`);
|
185
|
-
return { plugin, options };
|
186
|
-
}
|
187
|
-
exports.loadNxPluginAsync = loadNxPluginAsync;
|
188
|
-
async function importPluginModule(pluginPath) {
|
189
|
-
const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
|
190
|
-
if (m.default &&
|
191
|
-
('createNodes' in m.default || 'createDependencies' in m.default)) {
|
192
|
-
return m.default;
|
193
|
-
}
|
194
|
-
return m;
|
195
|
-
}
|