create-nx-workspace 19.2.0-alpha.3 → 19.2.0-beta.1
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.
|
@@ -16,6 +16,7 @@ const yargs_options_1 = require("../src/internal-utils/yargs-options");
|
|
|
16
16
|
const show_nx_warning_1 = require("../src/utils/nx/show-nx-warning");
|
|
17
17
|
const nx_cloud_1 = require("../src/utils/nx/nx-cloud");
|
|
18
18
|
const ab_testing_1 = require("../src/utils/nx/ab-testing");
|
|
19
|
+
const error_utils_1 = require("../src/utils/error-utils");
|
|
19
20
|
const fs_1 = require("fs");
|
|
20
21
|
exports.commandsObject = yargs
|
|
21
22
|
.wrap(yargs.terminalWidth())
|
|
@@ -146,29 +147,29 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
146
147
|
title: "Let's create a new workspace [https://nx.dev/getting-started/intro]",
|
|
147
148
|
});
|
|
148
149
|
try {
|
|
149
|
-
let thirdPartyPreset;
|
|
150
|
-
try {
|
|
151
|
-
thirdPartyPreset = await (0, get_third_party_preset_1.getThirdPartyPreset)(argv.preset);
|
|
152
|
-
}
|
|
153
|
-
catch (e) {
|
|
154
|
-
output_1.output.error({
|
|
155
|
-
title: `Could not find preset "${argv.preset}"`,
|
|
156
|
-
});
|
|
157
|
-
process.exit(1);
|
|
158
|
-
}
|
|
159
150
|
argv.name = await determineFolder(argv);
|
|
160
|
-
if (
|
|
161
|
-
Object.assign(argv, {
|
|
162
|
-
preset: thirdPartyPreset,
|
|
163
|
-
appName: '',
|
|
164
|
-
style: '',
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
151
|
+
if (!argv.preset || (0, preset_1.isKnownPreset)(argv.preset)) {
|
|
168
152
|
argv.stack = await determineStack(argv);
|
|
169
153
|
const presetOptions = await determinePresetOptions(argv);
|
|
170
154
|
Object.assign(argv, presetOptions);
|
|
171
155
|
}
|
|
156
|
+
else {
|
|
157
|
+
try {
|
|
158
|
+
(0, get_third_party_preset_1.getPackageNameFromThirdPartyPreset)(argv.preset);
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
if (e instanceof Error) {
|
|
162
|
+
output_1.output.error({
|
|
163
|
+
title: `Could not find preset "${argv.preset}"`,
|
|
164
|
+
bodyLines: (0, error_utils_1.mapErrorToBodyLines)(e),
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
console.error(e);
|
|
169
|
+
}
|
|
170
|
+
process.exit(1);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
172
173
|
const packageManager = await (0, prompts_1.determinePackageManager)(argv);
|
|
173
174
|
const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
|
|
174
175
|
const nxCloud = await (0, prompts_1.determineNxCloud)(argv);
|
package/package.json
CHANGED
package/src/create-workspace.js
CHANGED
|
@@ -21,9 +21,9 @@ async function createWorkspace(preset, options) {
|
|
|
21
21
|
// If the preset is a third-party preset, we need to call createPreset to install it
|
|
22
22
|
// For first-party presets, it will be created by createEmptyWorkspace instead.
|
|
23
23
|
// In createEmptyWorkspace, it will call `nx new` -> `@nx/workspace newGenerator` -> `@nx/workspace generatePreset`.
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
26
|
-
await (0, create_preset_1.createPreset)(
|
|
24
|
+
const thirdPartyPackageName = (0, get_third_party_preset_1.getPackageNameFromThirdPartyPreset)(preset);
|
|
25
|
+
if (thirdPartyPackageName) {
|
|
26
|
+
await (0, create_preset_1.createPreset)(thirdPartyPackageName, options, packageManager, directory);
|
|
27
27
|
}
|
|
28
28
|
let nxCloudInstallRes;
|
|
29
29
|
if (nxCloud !== 'skip') {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This function is used to check if a preset is a third party preset.
|
|
3
3
|
* @param preset
|
|
4
|
-
* @returns
|
|
4
|
+
* @returns
|
|
5
|
+
* - undefined if the preset is a known Nx preset or invalid.
|
|
6
|
+
* - packageName if the preset is a third party preset.
|
|
7
|
+
* - throws an error if the preset is invalid.
|
|
5
8
|
*/
|
|
6
|
-
export declare function
|
|
9
|
+
export declare function getPackageNameFromThirdPartyPreset(preset?: string): string | undefined;
|
|
@@ -1,39 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const output_1 = require("../output");
|
|
3
|
+
exports.getPackageNameFromThirdPartyPreset = void 0;
|
|
5
4
|
const validate_npm_package_1 = require("../validate-npm-package");
|
|
6
5
|
const preset_1 = require("./preset");
|
|
7
6
|
/**
|
|
8
7
|
* This function is used to check if a preset is a third party preset.
|
|
9
8
|
* @param preset
|
|
10
|
-
* @returns
|
|
9
|
+
* @returns
|
|
10
|
+
* - undefined if the preset is a known Nx preset or invalid.
|
|
11
|
+
* - packageName if the preset is a third party preset.
|
|
12
|
+
* - throws an error if the preset is invalid.
|
|
11
13
|
*/
|
|
12
|
-
|
|
13
|
-
if (preset
|
|
14
|
-
|
|
15
|
-
const packageName = preset.match(/.+@/)
|
|
16
|
-
? preset[0] + preset.substring(1).split('@')[0]
|
|
17
|
-
: preset;
|
|
18
|
-
const validateResult = (0, validate_npm_package_1.validateNpmPackage)(packageName);
|
|
19
|
-
if (validateResult.validForNewPackages) {
|
|
20
|
-
return Promise.resolve(packageName);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
//! Error here
|
|
24
|
-
output_1.output.error({
|
|
25
|
-
title: 'Invalid preset npm package',
|
|
26
|
-
bodyLines: [
|
|
27
|
-
`There was an error with the preset npm package you provided:`,
|
|
28
|
-
'',
|
|
29
|
-
...(validateResult.errors ?? []),
|
|
30
|
-
],
|
|
31
|
-
});
|
|
32
|
-
throw new Error('Invalid preset npm package');
|
|
33
|
-
}
|
|
14
|
+
function getPackageNameFromThirdPartyPreset(preset) {
|
|
15
|
+
if (!preset || (0, preset_1.isKnownPreset)(preset)) {
|
|
16
|
+
return;
|
|
34
17
|
}
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
// extract the package name from the preset
|
|
19
|
+
const packageName = preset.match(/.+@/)
|
|
20
|
+
? preset[0] + preset.substring(1).split('@')[0]
|
|
21
|
+
: preset;
|
|
22
|
+
const validateResult = (0, validate_npm_package_1.validateNpmPackage)(packageName);
|
|
23
|
+
if (!validateResult.validForNewPackages) {
|
|
24
|
+
throw new Error(`Invalid preset npm package ${packageName}. There was an error with the preset npm package you provided: ` +
|
|
25
|
+
(validateResult.errors ?? []).join('\n'));
|
|
37
26
|
}
|
|
27
|
+
return packageName;
|
|
38
28
|
}
|
|
39
|
-
exports.
|
|
29
|
+
exports.getPackageNameFromThirdPartyPreset = getPackageNameFromThirdPartyPreset;
|