create-nx-workspace 19.2.0-rc.0 → 19.2.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.
- package/bin/create-nx-workspace.js +22 -7
- package/package.json +1 -1
- package/src/create-workspace-options.d.ts +1 -0
- package/src/create-workspace.js +2 -2
- package/src/internal-utils/prompts.d.ts +1 -0
- package/src/internal-utils/prompts.js +17 -1
- package/src/internal-utils/yargs-options.d.ts +3 -0
- package/src/internal-utils/yargs-options.js +9 -1
- package/src/utils/nx/nx-cloud.d.ts +1 -1
- package/src/utils/nx/nx-cloud.js +4 -2
|
@@ -97,7 +97,7 @@ exports.commandsObject = yargs
|
|
|
97
97
|
.option('prefix', {
|
|
98
98
|
describe: chalk.dim `Prefix to use for Angular component and directive selectors.`,
|
|
99
99
|
type: 'string',
|
|
100
|
-
}), yargs_options_1.withNxCloud, yargs_options_1.withAllPrompts, yargs_options_1.withPackageManager, yargs_options_1.withGitOptions), async function handler(argv) {
|
|
100
|
+
}), yargs_options_1.withNxCloud, yargs_options_1.withUseGitHub, yargs_options_1.withAllPrompts, yargs_options_1.withPackageManager, yargs_options_1.withGitOptions), async function handler(argv) {
|
|
101
101
|
await main(argv).catch((error) => {
|
|
102
102
|
const { version } = require('../package.json');
|
|
103
103
|
output_1.output.error({
|
|
@@ -172,12 +172,27 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
172
172
|
}
|
|
173
173
|
const packageManager = await (0, prompts_1.determinePackageManager)(argv);
|
|
174
174
|
const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
nxCloud
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
if (process.env.NX_NEW_CLOUD_ONBOARDING === 'true') {
|
|
176
|
+
const nxCloud = argv.skipGit === true ? 'skip' : await (0, prompts_1.determineNxCloud)(argv);
|
|
177
|
+
const useGitHub = nxCloud === 'skip'
|
|
178
|
+
? undefined
|
|
179
|
+
: nxCloud === 'github' ||
|
|
180
|
+
(await (0, prompts_1.determineIfGitHubWillBeUsed)(nxCloud));
|
|
181
|
+
Object.assign(argv, {
|
|
182
|
+
nxCloud,
|
|
183
|
+
useGitHub,
|
|
184
|
+
packageManager,
|
|
185
|
+
defaultBase,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
const nxCloud = await (0, prompts_1.determineNxCloud)(argv);
|
|
190
|
+
Object.assign(argv, {
|
|
191
|
+
nxCloud,
|
|
192
|
+
packageManager,
|
|
193
|
+
defaultBase,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
181
196
|
}
|
|
182
197
|
catch (e) {
|
|
183
198
|
console.error(e);
|
package/package.json
CHANGED
package/src/create-workspace.js
CHANGED
|
@@ -11,7 +11,7 @@ const git_1 = require("./utils/git/git");
|
|
|
11
11
|
const get_third_party_preset_1 = require("./utils/preset/get-third-party-preset");
|
|
12
12
|
const error_utils_1 = require("./utils/error-utils");
|
|
13
13
|
async function createWorkspace(preset, options) {
|
|
14
|
-
const { packageManager, name, nxCloud, skipGit = false, defaultBase = 'main', commit, cliName, } = options;
|
|
14
|
+
const { packageManager, name, nxCloud, skipGit = false, defaultBase = 'main', commit, cliName, useGitHub, } = options;
|
|
15
15
|
if (cliName) {
|
|
16
16
|
output_1.output.setCliName(cliName ?? 'NX');
|
|
17
17
|
}
|
|
@@ -27,7 +27,7 @@ async function createWorkspace(preset, options) {
|
|
|
27
27
|
}
|
|
28
28
|
let nxCloudInstallRes;
|
|
29
29
|
if (nxCloud !== 'skip') {
|
|
30
|
-
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud);
|
|
30
|
+
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager, nxCloud, useGitHub);
|
|
31
31
|
if (nxCloud !== 'yes') {
|
|
32
32
|
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
|
|
33
33
|
}
|
|
@@ -4,6 +4,7 @@ import { NxCloud } from '../utils/nx/nx-cloud';
|
|
|
4
4
|
export declare function determineNxCloud(parsedArgs: yargs.Arguments<{
|
|
5
5
|
nxCloud: NxCloud;
|
|
6
6
|
}>): Promise<NxCloud>;
|
|
7
|
+
export declare function determineIfGitHubWillBeUsed(nxCloud: NxCloud): Promise<boolean>;
|
|
7
8
|
export declare function determineDefaultBase(parsedArgs: yargs.Arguments<{
|
|
8
9
|
defaultBase?: string;
|
|
9
10
|
}>): Promise<string>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.determinePackageManager = exports.determineDefaultBase = exports.determineNxCloud = void 0;
|
|
3
|
+
exports.determinePackageManager = exports.determineDefaultBase = exports.determineIfGitHubWillBeUsed = exports.determineNxCloud = void 0;
|
|
4
4
|
const ab_testing_1 = require("../utils/nx/ab-testing");
|
|
5
5
|
const output_1 = require("../utils/output");
|
|
6
6
|
const default_base_1 = require("../utils/git/default-base");
|
|
@@ -17,6 +17,22 @@ async function determineNxCloud(parsedArgs) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.determineNxCloud = determineNxCloud;
|
|
20
|
+
async function determineIfGitHubWillBeUsed(nxCloud) {
|
|
21
|
+
if (nxCloud === 'yes' || nxCloud === 'circleci') {
|
|
22
|
+
const reply = await enquirer.prompt([
|
|
23
|
+
{
|
|
24
|
+
name: 'github',
|
|
25
|
+
message: 'Will you be using GitHub as your git hosting provider?',
|
|
26
|
+
type: 'autocomplete',
|
|
27
|
+
choices: [{ name: 'Yes' }, { name: 'No' }],
|
|
28
|
+
initial: 0,
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
return reply.github === 'Yes';
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
exports.determineIfGitHubWillBeUsed = determineIfGitHubWillBeUsed;
|
|
20
36
|
async function nxCloudPrompt(key) {
|
|
21
37
|
const { message, choices, initial, fallback, footer, hint } = ab_testing_1.messages.getPrompt(key);
|
|
22
38
|
const promptConfig = {
|
|
@@ -2,6 +2,9 @@ import yargs = require('yargs');
|
|
|
2
2
|
export declare function withNxCloud<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & {
|
|
3
3
|
nxCloud: string | undefined;
|
|
4
4
|
}>;
|
|
5
|
+
export declare function withUseGitHub<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & {
|
|
6
|
+
useGitHub: boolean;
|
|
7
|
+
}>;
|
|
5
8
|
export declare function withAllPrompts<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & {
|
|
6
9
|
allPrompts: boolean;
|
|
7
10
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withOptions = exports.withGitOptions = exports.withPackageManager = exports.withAllPrompts = exports.withNxCloud = void 0;
|
|
3
|
+
exports.withOptions = exports.withGitOptions = exports.withPackageManager = exports.withAllPrompts = exports.withUseGitHub = exports.withNxCloud = void 0;
|
|
4
4
|
const chalk = require("chalk");
|
|
5
5
|
const ab_testing_1 = require("../utils/nx/ab-testing");
|
|
6
6
|
const package_manager_1 = require("../utils/package-manager");
|
|
@@ -15,6 +15,14 @@ function withNxCloud(argv) {
|
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
17
|
exports.withNxCloud = withNxCloud;
|
|
18
|
+
function withUseGitHub(argv) {
|
|
19
|
+
return argv.option('useGitHub', {
|
|
20
|
+
describe: chalk.dim `Will you be using GitHub as your git hosting provider?`,
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
default: false,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
exports.withUseGitHub = withUseGitHub;
|
|
18
26
|
function withAllPrompts(argv) {
|
|
19
27
|
return argv.option('allPrompts', {
|
|
20
28
|
alias: 'a',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PackageManager } from '../package-manager';
|
|
2
2
|
export type NxCloud = 'yes' | 'github' | 'circleci' | 'skip';
|
|
3
|
-
export declare function setupNxCloud(directory: string, packageManager: PackageManager, nxCloud: NxCloud): Promise<{
|
|
3
|
+
export declare function setupNxCloud(directory: string, packageManager: PackageManager, nxCloud: NxCloud, useGitHub?: boolean): Promise<{
|
|
4
4
|
code: number;
|
|
5
5
|
stdout: string;
|
|
6
6
|
}>;
|
package/src/utils/nx/nx-cloud.js
CHANGED
|
@@ -6,11 +6,13 @@ const child_process_utils_1 = require("../child-process-utils");
|
|
|
6
6
|
const output_1 = require("../output");
|
|
7
7
|
const package_manager_1 = require("../package-manager");
|
|
8
8
|
const error_utils_1 = require("../error-utils");
|
|
9
|
-
async function setupNxCloud(directory, packageManager, nxCloud) {
|
|
9
|
+
async function setupNxCloud(directory, packageManager, nxCloud, useGitHub) {
|
|
10
10
|
const nxCloudSpinner = ora(`Setting up Nx Cloud`).start();
|
|
11
11
|
try {
|
|
12
12
|
const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
|
|
13
|
-
const res = await (0, child_process_utils_1.execAndWait)(
|
|
13
|
+
const res = await (0, child_process_utils_1.execAndWait)(process.env.NX_NEW_CLOUD_ONBOARDING === 'true'
|
|
14
|
+
? `${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=create-nx-workspace ${useGitHub ? '--github' : ''} --no-interactive`
|
|
15
|
+
: `${pmc.exec} nx g nx:connect-to-nx-cloud --no-interactive --quiet`, directory);
|
|
14
16
|
if (nxCloud !== 'yes') {
|
|
15
17
|
nxCloudSpinner.succeed('CI workflow with Nx Cloud has been generated successfully');
|
|
16
18
|
}
|