nx 16.7.0-beta.1 → 16.7.0-beta.3
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/package.json +13 -13
- package/src/command-line/generate/generate.js +7 -8
- package/src/command-line/init/command-object.js +8 -3
- package/src/command-line/init/implementation/angular/standalone-workspace.js +6 -1
- package/src/command-line/init/implementation/dot-nx/add-nx-scripts.js +6 -1
- package/src/command-line/init/implementation/react/index.js +1 -10
- package/src/command-line/init/init.d.ts +1 -0
- package/src/command-line/init/init.js +1 -11
- package/src/command-line/list/list.js +3 -1
- package/src/command-line/report/report.js +4 -3
- package/src/command-line/run/run.js +4 -7
- package/src/config/workspaces.d.ts +1 -1
- package/src/config/workspaces.js +22 -21
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +4 -2
- package/src/project-graph/build-nodes/workspace-projects.d.ts +7 -1
- package/src/project-graph/build-nodes/workspace-projects.js +20 -12
- package/src/utils/plugins/local-plugins.d.ts +2 -1
- package/src/utils/plugins/local-plugins.js +12 -4
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +4 -2
- package/src/command-line/init/implementation/react/setup-e2e-project.d.ts +0 -1
- package/src/command-line/init/implementation/react/setup-e2e-project.js +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "16.7.0-beta.
|
|
3
|
+
"version": "16.7.0-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://nx.dev",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nrwl/tao": "16.7.0-beta.
|
|
35
|
+
"@nrwl/tao": "16.7.0-beta.3",
|
|
36
36
|
"@parcel/watcher": "2.0.4",
|
|
37
37
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
38
38
|
"@yarnpkg/parsers": "3.0.0-rc.46",
|
|
@@ -81,16 +81,16 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@nx/nx-darwin-arm64": "16.7.0-beta.
|
|
85
|
-
"@nx/nx-darwin-x64": "16.7.0-beta.
|
|
86
|
-
"@nx/nx-freebsd-x64": "16.7.0-beta.
|
|
87
|
-
"@nx/nx-linux-arm-gnueabihf": "16.7.0-beta.
|
|
88
|
-
"@nx/nx-linux-arm64-gnu": "16.7.0-beta.
|
|
89
|
-
"@nx/nx-linux-arm64-musl": "16.7.0-beta.
|
|
90
|
-
"@nx/nx-linux-x64-gnu": "16.7.0-beta.
|
|
91
|
-
"@nx/nx-linux-x64-musl": "16.7.0-beta.
|
|
92
|
-
"@nx/nx-win32-arm64-msvc": "16.7.0-beta.
|
|
93
|
-
"@nx/nx-win32-x64-msvc": "16.7.0-beta.
|
|
84
|
+
"@nx/nx-darwin-arm64": "16.7.0-beta.3",
|
|
85
|
+
"@nx/nx-darwin-x64": "16.7.0-beta.3",
|
|
86
|
+
"@nx/nx-freebsd-x64": "16.7.0-beta.3",
|
|
87
|
+
"@nx/nx-linux-arm-gnueabihf": "16.7.0-beta.3",
|
|
88
|
+
"@nx/nx-linux-arm64-gnu": "16.7.0-beta.3",
|
|
89
|
+
"@nx/nx-linux-arm64-musl": "16.7.0-beta.3",
|
|
90
|
+
"@nx/nx-linux-x64-gnu": "16.7.0-beta.3",
|
|
91
|
+
"@nx/nx-linux-x64-musl": "16.7.0-beta.3",
|
|
92
|
+
"@nx/nx-win32-arm64-msvc": "16.7.0-beta.3",
|
|
93
|
+
"@nx/nx-win32-x64-msvc": "16.7.0-beta.3"
|
|
94
94
|
},
|
|
95
95
|
"nx-migrations": {
|
|
96
96
|
"migrations": "./migrations.json",
|
|
@@ -177,5 +177,5 @@
|
|
|
177
177
|
},
|
|
178
178
|
"main": "./bin/nx.js",
|
|
179
179
|
"types": "./bin/nx.d.ts",
|
|
180
|
-
"gitHead": "
|
|
180
|
+
"gitHead": "118faf4e432667fd041954d96aa6c9c99fea5ebd"
|
|
181
181
|
}
|
|
@@ -4,8 +4,8 @@ exports.workspaceGenerators = exports.generate = exports.printGenHelp = exports.
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
const enquirer_1 = require("enquirer");
|
|
7
|
+
const path_1 = require("path");
|
|
7
8
|
const configuration_1 = require("../../config/configuration");
|
|
8
|
-
const workspaces_1 = require("../../config/workspaces");
|
|
9
9
|
const tree_1 = require("../../generators/tree");
|
|
10
10
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
11
11
|
const logger_1 = require("../../utils/logger");
|
|
@@ -31,9 +31,9 @@ function printChanges(fileChanges) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
exports.printChanges = printChanges;
|
|
34
|
-
function promptForCollection(generatorName,
|
|
34
|
+
function promptForCollection(generatorName, interactive, projectsConfiguration) {
|
|
35
35
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)(projectsConfiguration);
|
|
36
|
+
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)(projectsConfiguration, (0, configuration_1.readNxJson)());
|
|
37
37
|
const installedCollections = Array.from(new Set((0, installed_plugins_1.findInstalledPlugins)().map((x) => x.name)));
|
|
38
38
|
const choicesMap = new Set();
|
|
39
39
|
const deprecatedChoices = new Set();
|
|
@@ -148,7 +148,7 @@ function parseGeneratorString(value) {
|
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
function convertToGenerateOptions(generatorOptions,
|
|
151
|
+
function convertToGenerateOptions(generatorOptions, defaultCollectionName, mode, projectsConfiguration) {
|
|
152
152
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
153
153
|
let collectionName = null;
|
|
154
154
|
let generatorName = null;
|
|
@@ -161,7 +161,7 @@ function convertToGenerateOptions(generatorOptions, ws, defaultCollectionName, m
|
|
|
161
161
|
generatorName = generator;
|
|
162
162
|
}
|
|
163
163
|
else if (!defaultCollectionName) {
|
|
164
|
-
const generatorString = yield promptForCollection(generatorDescriptor,
|
|
164
|
+
const generatorString = yield promptForCollection(generatorDescriptor, interactive, projectsConfiguration);
|
|
165
165
|
const parsedGeneratorString = parseGeneratorString(generatorString);
|
|
166
166
|
collectionName = parsedGeneratorString.collection;
|
|
167
167
|
generatorName = parsedGeneratorString.generator;
|
|
@@ -220,12 +220,11 @@ function generate(cwd, args) {
|
|
|
220
220
|
process.env.NX_VERBOSE_LOGGING = 'true';
|
|
221
221
|
}
|
|
222
222
|
const verbose = process.env.NX_VERBOSE_LOGGING === 'true';
|
|
223
|
-
const ws = new workspaces_1.Workspaces(workspace_root_1.workspaceRoot);
|
|
224
223
|
const nxJsonConfiguration = (0, configuration_1.readNxJson)();
|
|
225
224
|
const projectGraph = yield (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
226
225
|
const projectsConfigurations = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph);
|
|
227
226
|
return (0, params_1.handleErrors)(verbose, () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
228
|
-
const opts = yield convertToGenerateOptions(args,
|
|
227
|
+
const opts = yield convertToGenerateOptions(args, readDefaultCollection(nxJsonConfiguration), 'generate', projectsConfigurations);
|
|
229
228
|
const { normalizedGeneratorName, schema, implementationFactory, generatorConfiguration: { aliases, hidden, ['x-deprecated']: deprecated, ['x-use-standalone-layout']: isStandalonePreset, }, } = (0, generator_utils_1.getGeneratorInformation)(opts.collectionName, opts.generatorName, workspace_root_1.workspaceRoot);
|
|
230
229
|
if (deprecated) {
|
|
231
230
|
logger_1.logger.warn([
|
|
@@ -240,7 +239,7 @@ function generate(cwd, args) {
|
|
|
240
239
|
printGenHelp(opts, schema, normalizedGeneratorName, aliases);
|
|
241
240
|
return 0;
|
|
242
241
|
}
|
|
243
|
-
const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, projectsConfigurations, nxJsonConfiguration),
|
|
242
|
+
const combinedOpts = yield (0, params_1.combineOptionsForGenerator)(opts.generatorOptions, opts.collectionName, normalizedGeneratorName, projectsConfigurations, nxJsonConfiguration, schema, opts.interactive, (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, projectsConfigurations, nxJsonConfiguration), (0, path_1.relative)(cwd, workspace_root_1.workspaceRoot), verbose);
|
|
244
243
|
if ((0, generator_utils_1.getGeneratorInformation)(opts.collectionName, normalizedGeneratorName, workspace_root_1.workspaceRoot).isNxGenerator) {
|
|
245
244
|
const host = new tree_1.FsTree(workspace_root_1.workspaceRoot, verbose, `generating (${opts.collectionName}:${normalizedGeneratorName})`);
|
|
246
245
|
const implementation = implementationFactory();
|
|
@@ -14,7 +14,7 @@ exports.yargsInitCommand = {
|
|
|
14
14
|
};
|
|
15
15
|
function withInitOptions(yargs) {
|
|
16
16
|
return yargs
|
|
17
|
-
.
|
|
17
|
+
.option('nxCloud', {
|
|
18
18
|
type: 'boolean',
|
|
19
19
|
description: 'Set up distributed caching with Nx Cloud.',
|
|
20
20
|
})
|
|
@@ -32,18 +32,23 @@ function withInitOptions(yargs) {
|
|
|
32
32
|
describe: 'Set up Cypress E2E tests in integrated workspaces. Only for CRA projects.',
|
|
33
33
|
type: 'boolean',
|
|
34
34
|
default: false,
|
|
35
|
+
})
|
|
36
|
+
.option('useDotNxInstallation', {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
description: 'Initialize an Nx workspace setup in the .nx directory of the current repository.',
|
|
39
|
+
default: false,
|
|
35
40
|
})
|
|
36
41
|
.option('force', {
|
|
37
42
|
describe: 'Force the migration to continue and ignore custom webpack setup or uncommitted changes. Only for CRA projects.',
|
|
38
43
|
type: 'boolean',
|
|
39
44
|
default: false,
|
|
40
45
|
})
|
|
41
|
-
.
|
|
46
|
+
.option('vite', {
|
|
42
47
|
type: 'boolean',
|
|
43
48
|
description: 'Use Vite as the bundler. Only for CRA projects.',
|
|
44
49
|
default: true,
|
|
45
50
|
})
|
|
46
|
-
.
|
|
51
|
+
.option('cacheable', {
|
|
47
52
|
type: 'string',
|
|
48
53
|
description: 'Comma-separated list of cacheable operations. Only used for internal testing.',
|
|
49
54
|
coerce: shared_options_1.parseCSV,
|
|
@@ -48,7 +48,9 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
48
48
|
karmaProjectConfigFile ? '!{projectRoot}/karma.conf.js' : undefined,
|
|
49
49
|
].filter(Boolean)
|
|
50
50
|
: []),
|
|
51
|
-
eslintProjectConfigFile
|
|
51
|
+
...(eslintProjectConfigFile
|
|
52
|
+
? ['!{projectRoot}/.eslintrc.json', '!{projectRoot}/eslint.config.js']
|
|
53
|
+
: []),
|
|
52
54
|
].filter(Boolean),
|
|
53
55
|
};
|
|
54
56
|
nxJson.targetDefaults = {};
|
|
@@ -73,6 +75,9 @@ function createNxJson(repoRoot, angularJson, cacheableOperations, { eslintProjec
|
|
|
73
75
|
if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, '.eslintrc.json'))) {
|
|
74
76
|
inputs.push('{workspaceRoot}/.eslintrc.json');
|
|
75
77
|
}
|
|
78
|
+
if ((0, fileutils_1.fileExists)((0, path_1.join)(repoRoot, 'eslint.config.js'))) {
|
|
79
|
+
inputs.push('{workspaceRoot}/eslint.config.js');
|
|
80
|
+
}
|
|
76
81
|
nxJson.targetDefaults.lint = { inputs };
|
|
77
82
|
}
|
|
78
83
|
if (workspaceTargets.includes('e2e')) {
|
|
@@ -46,10 +46,15 @@ function writeMinimalNxJson(host, version) {
|
|
|
46
46
|
default: {
|
|
47
47
|
runner: 'nx/tasks-runners/default',
|
|
48
48
|
options: {
|
|
49
|
-
cacheableOperations: [],
|
|
49
|
+
cacheableOperations: ['build', 'lint', 'test', 'e2e'],
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
+
targetDefaults: {
|
|
54
|
+
build: {
|
|
55
|
+
dependsOn: ['^build'],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
53
58
|
installation: {
|
|
54
59
|
version: version.trimEnd(),
|
|
55
60
|
},
|
|
@@ -14,7 +14,6 @@ const check_for_uncommitted_changes_1 = require("./check-for-uncommitted-changes
|
|
|
14
14
|
const clean_up_files_1 = require("./clean-up-files");
|
|
15
15
|
const read_name_from_package_json_1 = require("./read-name-from-package-json");
|
|
16
16
|
const rename_js_to_jsx_1 = require("./rename-js-to-jsx");
|
|
17
|
-
const setup_e2e_project_1 = require("./setup-e2e-project");
|
|
18
17
|
const tsconfig_setup_1 = require("./tsconfig-setup");
|
|
19
18
|
const write_craco_config_1 = require("./write-craco-config");
|
|
20
19
|
const write_vite_config_1 = require("./write-vite-config");
|
|
@@ -129,7 +128,7 @@ function reorgnizeWorkspaceStructure(options) {
|
|
|
129
128
|
}
|
|
130
129
|
function createTempWorkspace(options) {
|
|
131
130
|
(0, fs_extra_1.removeSync)('temp-workspace');
|
|
132
|
-
(0, child_process_1.execSync)(`npx ${options.npxYesFlagNeeded ? '-y' : ''} create-nx-workspace@latest temp-workspace --appName=${options.reactAppName} --preset=react-monorepo --style=css --bundler=${options.isVite ? 'vite' : 'webpack'} --packageManager=${options.packageManager} ${options.nxCloud ? '--nxCloud' : '--nxCloud=false'}`, { stdio: [0, 1, 2] });
|
|
131
|
+
(0, child_process_1.execSync)(`npx ${options.npxYesFlagNeeded ? '-y' : ''} create-nx-workspace@latest temp-workspace --appName=${options.reactAppName} --preset=react-monorepo --style=css --bundler=${options.isVite ? 'vite' : 'webpack'} --packageManager=${options.packageManager} ${options.nxCloud ? '--nxCloud' : '--nxCloud=false'} ${options.addE2e ? '--e2eTestRunner=cypress' : '--e2eTestRunner=none'}`, { stdio: [0, 1, 2] });
|
|
133
132
|
output_1.output.log({ title: '👋 Welcome to Nx!' });
|
|
134
133
|
output_1.output.log({ title: '🧹 Clearing unused files' });
|
|
135
134
|
(0, fs_extra_1.copySync)((0, path_1.join)('temp-workspace', 'apps', options.reactAppName, 'project.json'), 'project.json');
|
|
@@ -228,14 +227,6 @@ function cleanUpUnusedFilesAndAddConfigFiles(options) {
|
|
|
228
227
|
(0, clean_up_files_1.cleanUpFiles)(options.reactAppName, options.isStandalone);
|
|
229
228
|
output_1.output.log({ title: "📃 Extend the app's tsconfig.json from the base" });
|
|
230
229
|
(0, tsconfig_setup_1.setupTsConfig)(options.reactAppName, options.isStandalone);
|
|
231
|
-
if (options.addE2e && !options.isStandalone) {
|
|
232
|
-
output_1.output.log({ title: '📃 Setup e2e tests' });
|
|
233
|
-
(0, setup_e2e_project_1.setupE2eProject)(options.reactAppName);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
(0, fs_extra_1.removeSync)((0, path_1.join)('apps', `${options.reactAppName}-e2e`));
|
|
237
|
-
(0, child_process_1.execSync)(`${options.pmc.rm} cypress @nx/cypress eslint-plugin-cypress`);
|
|
238
|
-
}
|
|
239
230
|
if (options.isStandalone) {
|
|
240
231
|
(0, fs_extra_1.removeSync)('apps');
|
|
241
232
|
}
|
|
@@ -6,7 +6,6 @@ const child_process_1 = require("child_process");
|
|
|
6
6
|
const enquirer_1 = require("enquirer");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const semver_1 = require("semver");
|
|
9
|
-
const parser = require("yargs-parser");
|
|
10
9
|
const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
|
|
11
10
|
const add_nx_to_nest_1 = require("./implementation/add-nx-to-nest");
|
|
12
11
|
const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
|
|
@@ -21,20 +20,11 @@ function initHandler(options) {
|
|
|
21
20
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
21
|
// strip the 'init' command itself so we don't forward it
|
|
23
22
|
const args = process.argv.slice(3).join(' ');
|
|
24
|
-
const flags = parser(args, {
|
|
25
|
-
boolean: ['useDotNxInstallation'],
|
|
26
|
-
alias: {
|
|
27
|
-
useDotNxInstallation: ['encapsulated'],
|
|
28
|
-
},
|
|
29
|
-
default: {
|
|
30
|
-
useDotNxInstallation: false,
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
23
|
const version = (_a = process.env.NX_VERSION) !== null && _a !== void 0 ? _a : ((0, semver_1.prerelease)(versions_1.nxVersion) ? 'next' : 'latest');
|
|
34
24
|
if (process.env.NX_VERSION) {
|
|
35
25
|
console.log(`Using version ${process.env.NX_VERSION}`);
|
|
36
26
|
}
|
|
37
|
-
if (
|
|
27
|
+
if (options.useDotNxInstallation === true) {
|
|
38
28
|
setupDotNxInstallation(version);
|
|
39
29
|
}
|
|
40
30
|
else if ((0, fs_1.existsSync)('package.json')) {
|
|
@@ -7,6 +7,7 @@ const output_1 = require("../../utils/output");
|
|
|
7
7
|
const plugins_1 = require("../../utils/plugins");
|
|
8
8
|
const local_plugins_1 = require("../../utils/plugins/local-plugins");
|
|
9
9
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
10
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
10
11
|
/**
|
|
11
12
|
* List available plugins or capabilities within a specific plugin
|
|
12
13
|
*
|
|
@@ -21,9 +22,10 @@ function listHandler(args) {
|
|
|
21
22
|
yield (0, plugins_1.listPluginCapabilities)(args.plugin);
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
25
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
|
24
26
|
const corePlugins = (0, plugins_1.fetchCorePlugins)();
|
|
25
27
|
const projectGraph = yield (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
26
|
-
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph));
|
|
28
|
+
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
|
|
27
29
|
const installedPlugins = yield (0, plugins_1.getInstalledPluginsAndCapabilities)(workspace_root_1.workspaceRoot);
|
|
28
30
|
if (localPlugins.size) {
|
|
29
31
|
(0, local_plugins_1.listLocalWorkspacePlugins)(localPlugins);
|
|
@@ -13,6 +13,7 @@ const project_graph_1 = require("../../project-graph/project-graph");
|
|
|
13
13
|
const semver_1 = require("semver");
|
|
14
14
|
const installed_plugins_1 = require("../../utils/plugins/installed-plugins");
|
|
15
15
|
const installation_directory_1 = require("../../utils/installation-directory");
|
|
16
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
16
17
|
const nxPackageJson = (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '../../../package.json'));
|
|
17
18
|
exports.packagesWeCareAbout = [
|
|
18
19
|
'lerna',
|
|
@@ -89,7 +90,7 @@ function getReportData() {
|
|
|
89
90
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
91
|
const pm = (0, package_manager_1.detectPackageManager)();
|
|
91
92
|
const pmVersion = (0, package_manager_1.getPackageManagerVersion)(pm);
|
|
92
|
-
const localPlugins = yield findLocalPlugins();
|
|
93
|
+
const localPlugins = yield findLocalPlugins((0, nx_json_1.readNxJson)());
|
|
93
94
|
const communityPlugins = findInstalledCommunityPlugins();
|
|
94
95
|
let projectGraphError = null;
|
|
95
96
|
if (isNativeAvailable()) {
|
|
@@ -124,11 +125,11 @@ function getReportData() {
|
|
|
124
125
|
});
|
|
125
126
|
}
|
|
126
127
|
exports.getReportData = getReportData;
|
|
127
|
-
function findLocalPlugins() {
|
|
128
|
+
function findLocalPlugins(nxJson) {
|
|
128
129
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
129
130
|
try {
|
|
130
131
|
const projectGraph = yield (0, project_graph_1.createProjectGraphAsync)({ exitOnError: true });
|
|
131
|
-
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph));
|
|
132
|
+
const localPlugins = yield (0, local_plugins_1.getLocalWorkspacePlugins)((0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
|
|
132
133
|
return Array.from(localPlugins.keys());
|
|
133
134
|
}
|
|
134
135
|
catch (_a) {
|
|
@@ -4,7 +4,6 @@ exports.run = exports.printTargetRunHelp = exports.runExecutor = exports.validat
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const params_1 = require("../../utils/params");
|
|
6
6
|
const print_help_1 = require("../../utils/print-help");
|
|
7
|
-
const workspaces_1 = require("../../config/workspaces");
|
|
8
7
|
const fileutils_1 = require("../../utils/fileutils");
|
|
9
8
|
const package_json_1 = require("../../utils/package-json");
|
|
10
9
|
const path_1 = require("path");
|
|
@@ -64,7 +63,7 @@ function createImplicitTargetConfig(root, proj, targetName) {
|
|
|
64
63
|
}
|
|
65
64
|
return (0, package_json_1.buildTargetFromScript)(targetName, nx);
|
|
66
65
|
}
|
|
67
|
-
function parseExecutorAndTarget(
|
|
66
|
+
function parseExecutorAndTarget({ project, target, configuration }, root, projectsConfigurations, nxJsonConfiguration) {
|
|
68
67
|
var _a;
|
|
69
68
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
70
69
|
const proj = projectsConfigurations.projects[project];
|
|
@@ -81,8 +80,7 @@ function parseExecutorAndTarget(ws, { project, target, configuration }, root, pr
|
|
|
81
80
|
}
|
|
82
81
|
function printTargetRunHelpInternal({ project, target, configuration }, root, projectsConfigurations, nxJsonConfiguration) {
|
|
83
82
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const
|
|
85
|
-
const { executor, nodeModule, schema } = yield parseExecutorAndTarget(ws, { project, target, configuration }, root, projectsConfigurations, nxJsonConfiguration);
|
|
83
|
+
const { executor, nodeModule, schema } = yield parseExecutorAndTarget({ project, target, configuration }, root, projectsConfigurations, nxJsonConfiguration);
|
|
86
84
|
printRunHelp({ project, target }, schema, {
|
|
87
85
|
plugin: nodeModule,
|
|
88
86
|
entity: executor,
|
|
@@ -93,10 +91,9 @@ function printTargetRunHelpInternal({ project, target, configuration }, root, pr
|
|
|
93
91
|
function runExecutorInternal({ project, target, configuration }, overrides, root, cwd, projectsConfigurations, nxJsonConfiguration, projectGraph, taskGraph, isVerbose) {
|
|
94
92
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
95
93
|
validateProject(projectsConfigurations, project);
|
|
96
|
-
const
|
|
97
|
-
const { executor, implementationFactory, nodeModule, schema, targetConfig } = yield parseExecutorAndTarget(ws, { project, target, configuration }, root, projectsConfigurations, nxJsonConfiguration);
|
|
94
|
+
const { executor, implementationFactory, nodeModule, schema, targetConfig } = yield parseExecutorAndTarget({ project, target, configuration }, root, projectsConfigurations, nxJsonConfiguration);
|
|
98
95
|
configuration !== null && configuration !== void 0 ? configuration : (configuration = targetConfig.defaultConfiguration);
|
|
99
|
-
const combinedOptions = (0, params_1.combineOptionsForExecutor)(overrides, configuration, targetConfig, schema, project,
|
|
96
|
+
const combinedOptions = (0, params_1.combineOptionsForExecutor)(overrides, configuration, targetConfig, schema, project, (0, path_1.relative)(cwd, root), isVerbose);
|
|
100
97
|
if ((0, executor_utils_1.getExecutorInformation)(nodeModule, executor, root).isNxExecutor) {
|
|
101
98
|
const implementation = implementationFactory();
|
|
102
99
|
const r = implementation(combinedOptions, {
|
|
@@ -4,7 +4,6 @@ export declare class Workspaces {
|
|
|
4
4
|
private root;
|
|
5
5
|
private cachedProjectsConfig;
|
|
6
6
|
constructor(root: string);
|
|
7
|
-
relativeCwd(cwd: string): string;
|
|
8
7
|
/**
|
|
9
8
|
* @deprecated
|
|
10
9
|
*/
|
|
@@ -45,5 +44,6 @@ export declare function inferProjectFromNonStandardFile(file: string): ProjectCo
|
|
|
45
44
|
export declare function buildProjectsConfigurationsFromProjectPaths(nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
|
|
46
45
|
readJson?: <T extends Object>(string: any) => T): Record<string, ProjectConfiguration>;
|
|
47
46
|
export declare function mergeTargetConfigurations(projectConfiguration: ProjectConfiguration, target: string, targetDefaults: TargetDefaults[string]): TargetConfiguration;
|
|
47
|
+
export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
|
|
48
48
|
export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
|
|
49
49
|
export declare function renamePropertyWithStableKeys(obj: any, from: string, to: string): void;
|
package/src/config/workspaces.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renamePropertyWithStableKeys = exports.readTargetDefaultsForTarget = exports.mergeTargetConfigurations = exports.buildProjectsConfigurationsFromProjectPaths = exports.inferProjectFromNonStandardFile = exports.deduplicateProjectFiles = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.getGlobPatternsFromPluginsAsync = exports.getGlobPatternsFromPlugins = exports.toProjectName = exports.Workspaces = void 0;
|
|
3
|
+
exports.renamePropertyWithStableKeys = exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.mergeTargetConfigurations = exports.buildProjectsConfigurationsFromProjectPaths = exports.inferProjectFromNonStandardFile = exports.deduplicateProjectFiles = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.getGlobPatternsFromPluginsAsync = exports.getGlobPatternsFromPlugins = exports.toProjectName = exports.Workspaces = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const path = require("path");
|
|
7
6
|
const path_1 = require("path");
|
|
8
7
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
9
8
|
const fileutils_1 = require("../utils/fileutils");
|
|
@@ -18,9 +17,6 @@ class Workspaces {
|
|
|
18
17
|
constructor(root) {
|
|
19
18
|
this.root = root;
|
|
20
19
|
}
|
|
21
|
-
relativeCwd(cwd) {
|
|
22
|
-
return path.relative(this.root, cwd).replace(/\\/g, '/') || null;
|
|
23
|
-
}
|
|
24
20
|
/**
|
|
25
21
|
* @deprecated
|
|
26
22
|
*/
|
|
@@ -49,9 +45,10 @@ class Workspaces {
|
|
|
49
45
|
return Object.assign(Object.assign({}, this.readProjectsConfigurations(opts)), nxJson);
|
|
50
46
|
}
|
|
51
47
|
mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
|
|
48
|
+
var _a;
|
|
52
49
|
for (const proj of Object.values(projects)) {
|
|
53
50
|
if (proj.targets) {
|
|
54
|
-
for (const targetName of Object.keys(proj.targets)) {
|
|
51
|
+
for (const targetName of Object.keys((_a = proj.targets) !== null && _a !== void 0 ? _a : {})) {
|
|
55
52
|
const projectTargetDefinition = proj.targets[targetName];
|
|
56
53
|
const defaults = readTargetDefaultsForTarget(targetName, nxJson.targetDefaults, projectTargetDefinition.executor);
|
|
57
54
|
if (defaults) {
|
|
@@ -265,7 +262,7 @@ readJson = (string) => (0, fileutils_1.readJsonFile)(string) // making this an a
|
|
|
265
262
|
}
|
|
266
263
|
exports.buildProjectsConfigurationsFromProjectPaths = buildProjectsConfigurationsFromProjectPaths;
|
|
267
264
|
function mergeTargetConfigurations(projectConfiguration, target, targetDefaults) {
|
|
268
|
-
var _a
|
|
265
|
+
var _a;
|
|
269
266
|
const targetConfiguration = (_a = projectConfiguration.targets) === null || _a === void 0 ? void 0 : _a[target];
|
|
270
267
|
if (!targetConfiguration) {
|
|
271
268
|
throw new Error(`Attempted to merge targetDefaults for ${projectConfiguration.name}.${target}, which doesn't exist.`);
|
|
@@ -277,28 +274,31 @@ function mergeTargetConfigurations(projectConfiguration, target, targetDefaults)
|
|
|
277
274
|
if (!targetDefaults.executor ||
|
|
278
275
|
!targetConfiguration.executor ||
|
|
279
276
|
targetDefaults.executor === targetConfiguration.executor) {
|
|
280
|
-
result.options =
|
|
281
|
-
result.configurations = mergeConfigurations(defaultConfigurations, targetConfiguration.configurations
|
|
277
|
+
result.options = Object.assign(Object.assign({}, defaultOptions), targetConfiguration === null || targetConfiguration === void 0 ? void 0 : targetConfiguration.options);
|
|
278
|
+
result.configurations = mergeConfigurations(defaultConfigurations, targetConfiguration.configurations);
|
|
282
279
|
}
|
|
283
280
|
return result;
|
|
284
281
|
}
|
|
285
282
|
exports.mergeTargetConfigurations = mergeTargetConfigurations;
|
|
286
|
-
function
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
283
|
+
function mergeConfigurations(defaultConfigurations, projectDefinedConfigurations) {
|
|
284
|
+
var _a, _b;
|
|
285
|
+
const result = {};
|
|
286
|
+
const configurations = new Set([
|
|
287
|
+
...Object.keys(defaultConfigurations !== null && defaultConfigurations !== void 0 ? defaultConfigurations : {}),
|
|
288
|
+
...Object.keys(projectDefinedConfigurations !== null && projectDefinedConfigurations !== void 0 ? projectDefinedConfigurations : {}),
|
|
289
|
+
]);
|
|
290
|
+
for (const configuration of configurations) {
|
|
291
|
+
result[configuration] = Object.assign(Object.assign({}, ((_a = defaultConfigurations === null || defaultConfigurations === void 0 ? void 0 : defaultConfigurations[configuration]) !== null && _a !== void 0 ? _a : {})), ((_b = projectDefinedConfigurations === null || projectDefinedConfigurations === void 0 ? void 0 : projectDefinedConfigurations[configuration]) !== null && _b !== void 0 ? _b : {}));
|
|
293
292
|
}
|
|
294
|
-
return
|
|
293
|
+
return result;
|
|
295
294
|
}
|
|
296
|
-
function
|
|
295
|
+
function resolveNxTokensInOptions(object, project, key) {
|
|
297
296
|
const result = Array.isArray(object) ? [...object] : Object.assign({}, object);
|
|
298
297
|
for (let [opt, value] of Object.entries(object !== null && object !== void 0 ? object : {})) {
|
|
299
298
|
if (typeof value === 'string') {
|
|
300
|
-
|
|
301
|
-
|
|
299
|
+
const workspaceRootMatch = /^(\{workspaceRoot\}\/?)/.exec(value);
|
|
300
|
+
if (workspaceRootMatch === null || workspaceRootMatch === void 0 ? void 0 : workspaceRootMatch.length) {
|
|
301
|
+
value = value.replace(workspaceRootMatch[0], '');
|
|
302
302
|
}
|
|
303
303
|
if (value.includes('{workspaceRoot}')) {
|
|
304
304
|
throw new Error(`${logger_1.NX_PREFIX} The {workspaceRoot} token is only valid at the beginning of an option. (${key})`);
|
|
@@ -307,11 +307,12 @@ function resolvePathTokensInOptions(object, project, key) {
|
|
|
307
307
|
result[opt] = value.replace(/\{projectName\}/g, project.name);
|
|
308
308
|
}
|
|
309
309
|
else if (typeof value === 'object' && value) {
|
|
310
|
-
result[opt] =
|
|
310
|
+
result[opt] = resolveNxTokensInOptions(value, project, [key, opt].join('.'));
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
return result;
|
|
314
314
|
}
|
|
315
|
+
exports.resolveNxTokensInOptions = resolveNxTokensInOptions;
|
|
315
316
|
function readTargetDefaultsForTarget(targetName, targetDefaults, executor) {
|
|
316
317
|
if (executor) {
|
|
317
318
|
// If an executor is defined in project.json, defaults should be read
|