create-nx-workspace 17.3.0-beta.5 → 17.3.0-beta.6
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.d.ts +1 -0
- package/bin/create-nx-workspace.js +42 -6
- package/package.json +1 -1
- package/src/create-preset.js +1 -1
- package/src/create-workspace-options.d.ts +2 -7
- package/src/create-workspace.js +5 -5
- package/src/internal-utils/prompts.d.ts +3 -7
- package/src/internal-utils/prompts.js +22 -57
- package/src/internal-utils/yargs-options.d.ts +1 -4
- package/src/internal-utils/yargs-options.js +6 -13
- package/src/utils/nx/ab-testing.d.ts +59 -9
- package/src/utils/nx/ab-testing.js +43 -11
- package/src/utils/nx/nx-cloud.d.ts +1 -0
- package/src/utils/ci/ci-list.d.ts +0 -2
- package/src/utils/ci/ci-list.js +0 -10
|
@@ -18,6 +18,7 @@ interface ReactArguments extends BaseArguments {
|
|
|
18
18
|
style: string;
|
|
19
19
|
bundler: 'webpack' | 'vite' | 'rspack';
|
|
20
20
|
nextAppDir: boolean;
|
|
21
|
+
nextSrcDir: boolean;
|
|
21
22
|
e2eTestRunner: 'none' | 'cypress' | 'playwright';
|
|
22
23
|
}
|
|
23
24
|
interface AngularArguments extends BaseArguments {
|
|
@@ -79,6 +79,10 @@ exports.commandsObject = yargs
|
|
|
79
79
|
.option('nextAppDir', {
|
|
80
80
|
describe: chalk.dim `Enable the App Router for Next.js`,
|
|
81
81
|
type: 'boolean',
|
|
82
|
+
})
|
|
83
|
+
.option('nextSrcDir', {
|
|
84
|
+
describe: chalk.dim `Generate a 'src/' directory for Next.js`,
|
|
85
|
+
type: 'boolean',
|
|
82
86
|
})
|
|
83
87
|
.option('e2eTestRunner', {
|
|
84
88
|
describe: chalk.dim `Test runner to use for end to end (E2E) tests.`,
|
|
@@ -88,7 +92,7 @@ exports.commandsObject = yargs
|
|
|
88
92
|
.option('ssr', {
|
|
89
93
|
describe: chalk.dim `Enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) for the Angular application`,
|
|
90
94
|
type: 'boolean',
|
|
91
|
-
}), yargs_options_1.withNxCloud, yargs_options_1.
|
|
95
|
+
}), yargs_options_1.withNxCloud, yargs_options_1.withAllPrompts, yargs_options_1.withPackageManager, yargs_options_1.withGitOptions), async function handler(argv) {
|
|
92
96
|
await main(argv).catch((error) => {
|
|
93
97
|
const { version } = require('../package.json');
|
|
94
98
|
output_1.output.error({
|
|
@@ -120,8 +124,11 @@ async function main(parsedArgs) {
|
|
|
120
124
|
await (0, ab_testing_1.recordStat)({
|
|
121
125
|
nxVersion: nx_version_1.nxVersion,
|
|
122
126
|
command: 'create-nx-workspace',
|
|
123
|
-
useCloud: parsedArgs.nxCloud,
|
|
124
|
-
meta:
|
|
127
|
+
useCloud: parsedArgs.nxCloud !== 'skip',
|
|
128
|
+
meta: [
|
|
129
|
+
ab_testing_1.messages.codeOfSelectedPromptMessage('setupCI'),
|
|
130
|
+
ab_testing_1.messages.codeOfSelectedPromptMessage('setupNxCloud'),
|
|
131
|
+
],
|
|
125
132
|
});
|
|
126
133
|
if (parsedArgs.nxCloud && workspaceInfo.nxCloudInfo) {
|
|
127
134
|
(0, nx_cloud_1.printNxCloudSuccessMessage)(workspaceInfo.nxCloudInfo);
|
|
@@ -190,12 +197,10 @@ async function normalizeArgsMiddleware(argv) {
|
|
|
190
197
|
const packageManager = await (0, prompts_1.determinePackageManager)(argv);
|
|
191
198
|
const defaultBase = await (0, prompts_1.determineDefaultBase)(argv);
|
|
192
199
|
const nxCloud = await (0, prompts_1.determineNxCloud)(argv);
|
|
193
|
-
const ci = await (0, prompts_1.determineCI)(argv, nxCloud);
|
|
194
200
|
Object.assign(argv, {
|
|
195
201
|
nxCloud,
|
|
196
202
|
packageManager,
|
|
197
203
|
defaultBase,
|
|
198
|
-
ci,
|
|
199
204
|
});
|
|
200
205
|
}
|
|
201
206
|
catch (e) {
|
|
@@ -366,6 +371,7 @@ async function determineReactOptions(parsedArgs) {
|
|
|
366
371
|
let bundler = undefined;
|
|
367
372
|
let e2eTestRunner = undefined;
|
|
368
373
|
let nextAppDir = false;
|
|
374
|
+
let nextSrcDir = false;
|
|
369
375
|
if (parsedArgs.preset && parsedArgs.preset !== preset_1.Preset.React) {
|
|
370
376
|
preset = parsedArgs.preset;
|
|
371
377
|
if (preset === preset_1.Preset.ReactStandalone ||
|
|
@@ -418,6 +424,7 @@ async function determineReactOptions(parsedArgs) {
|
|
|
418
424
|
}
|
|
419
425
|
else if (preset === preset_1.Preset.NextJs || preset === preset_1.Preset.NextJsStandalone) {
|
|
420
426
|
nextAppDir = await determineNextAppDir(parsedArgs);
|
|
427
|
+
nextSrcDir = await determineNextSrcDir(parsedArgs);
|
|
421
428
|
e2eTestRunner = await determineE2eTestRunner(parsedArgs);
|
|
422
429
|
}
|
|
423
430
|
if (parsedArgs.style) {
|
|
@@ -463,7 +470,15 @@ async function determineReactOptions(parsedArgs) {
|
|
|
463
470
|
]);
|
|
464
471
|
style = reply.style;
|
|
465
472
|
}
|
|
466
|
-
return {
|
|
473
|
+
return {
|
|
474
|
+
preset,
|
|
475
|
+
style,
|
|
476
|
+
appName,
|
|
477
|
+
bundler,
|
|
478
|
+
nextAppDir,
|
|
479
|
+
nextSrcDir,
|
|
480
|
+
e2eTestRunner,
|
|
481
|
+
};
|
|
467
482
|
}
|
|
468
483
|
async function determineVueOptions(parsedArgs) {
|
|
469
484
|
let preset;
|
|
@@ -864,6 +879,27 @@ async function determineNextAppDir(parsedArgs) {
|
|
|
864
879
|
]);
|
|
865
880
|
return reply.nextAppDir === 'Yes';
|
|
866
881
|
}
|
|
882
|
+
async function determineNextSrcDir(parsedArgs) {
|
|
883
|
+
if (parsedArgs.nextSrcDir !== undefined)
|
|
884
|
+
return parsedArgs.nextSrcDir;
|
|
885
|
+
const reply = await enquirer.prompt([
|
|
886
|
+
{
|
|
887
|
+
name: 'nextSrcDir',
|
|
888
|
+
message: 'Would you like to use the src/ directory?',
|
|
889
|
+
type: 'autocomplete',
|
|
890
|
+
choices: [
|
|
891
|
+
{
|
|
892
|
+
name: 'Yes',
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
name: 'No',
|
|
896
|
+
},
|
|
897
|
+
],
|
|
898
|
+
initial: 'Yes',
|
|
899
|
+
},
|
|
900
|
+
]);
|
|
901
|
+
return reply.nextSrcDir === 'Yes';
|
|
902
|
+
}
|
|
867
903
|
async function determineVueFramework(parsedArgs) {
|
|
868
904
|
if (!!parsedArgs.framework)
|
|
869
905
|
return parsedArgs.framework;
|
package/package.json
CHANGED
package/src/create-preset.js
CHANGED
|
@@ -6,7 +6,7 @@ const package_manager_1 = require("./utils/package-manager");
|
|
|
6
6
|
const child_process_utils_1 = require("./utils/child-process-utils");
|
|
7
7
|
const unparse_1 = require("./utils/unparse");
|
|
8
8
|
async function createPreset(preset, parsedArgs, packageManager, directory) {
|
|
9
|
-
const { skipGit,
|
|
9
|
+
const { skipGit, commit, nxCloud, ...restArgs } = parsedArgs;
|
|
10
10
|
let args = (0, unparse_1.unparse)({
|
|
11
11
|
interactive: true,
|
|
12
12
|
...restArgs,
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
+
import { NxCloud } from './utils/nx/nx-cloud';
|
|
1
2
|
import { PackageManager } from './utils/package-manager';
|
|
2
|
-
import { CI } from './utils/ci/ci-list';
|
|
3
3
|
export interface CreateWorkspaceOptions {
|
|
4
4
|
name: string;
|
|
5
5
|
packageManager: PackageManager;
|
|
6
|
-
nxCloud:
|
|
6
|
+
nxCloud: NxCloud;
|
|
7
7
|
/**
|
|
8
8
|
* @description Enable interactive mode with presets
|
|
9
9
|
* @default true
|
|
10
10
|
*/
|
|
11
11
|
interactive?: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* @description Generate a CI workflow file
|
|
14
|
-
* @default ''
|
|
15
|
-
*/
|
|
16
|
-
ci?: CI;
|
|
17
12
|
/**
|
|
18
13
|
* @description Default base to use for new projects. e.g. main, master
|
|
19
14
|
* @default 'main'
|
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,
|
|
14
|
+
const { packageManager, name, nxCloud, skipGit = false, defaultBase = 'main', commit, cliName, } = options;
|
|
15
15
|
if (cliName) {
|
|
16
16
|
output_1.output.setCliName(cliName ?? 'NX');
|
|
17
17
|
}
|
|
@@ -26,11 +26,11 @@ async function createWorkspace(preset, options) {
|
|
|
26
26
|
await (0, create_preset_1.createPreset)(thirdPartyPreset, options, packageManager, directory);
|
|
27
27
|
}
|
|
28
28
|
let nxCloudInstallRes;
|
|
29
|
-
if (nxCloud) {
|
|
29
|
+
if (nxCloud !== 'skip') {
|
|
30
30
|
nxCloudInstallRes = await (0, nx_cloud_1.setupNxCloud)(directory, packageManager);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (nxCloud !== 'yes') {
|
|
32
|
+
await (0, setup_ci_1.setupCI)(directory, nxCloud, packageManager, nxCloudInstallRes?.code === 0);
|
|
33
|
+
}
|
|
34
34
|
}
|
|
35
35
|
if (!skipGit && commit) {
|
|
36
36
|
try {
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import * as yargs from 'yargs';
|
|
2
|
-
import { CI } from '../utils/ci/ci-list';
|
|
3
2
|
import { PackageManager } from '../utils/package-manager';
|
|
3
|
+
import { NxCloud } from '../utils/nx/nx-cloud';
|
|
4
4
|
export declare function determineNxCloud(parsedArgs: yargs.Arguments<{
|
|
5
|
-
nxCloud:
|
|
6
|
-
}>): Promise<
|
|
7
|
-
export declare function determineCI(parsedArgs: yargs.Arguments<{
|
|
8
|
-
ci?: CI;
|
|
9
|
-
allPrompts?: boolean;
|
|
10
|
-
}>, nxCloud: boolean): Promise<string>;
|
|
5
|
+
nxCloud: NxCloud;
|
|
6
|
+
}>): Promise<NxCloud>;
|
|
11
7
|
export declare function determineDefaultBase(parsedArgs: yargs.Arguments<{
|
|
12
8
|
defaultBase?: string;
|
|
13
9
|
}>): Promise<string>;
|
|
@@ -1,79 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.determinePackageManager = exports.determineDefaultBase = exports.
|
|
3
|
+
exports.determinePackageManager = exports.determineDefaultBase = 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");
|
|
7
7
|
const package_manager_1 = require("../utils/package-manager");
|
|
8
8
|
const string_utils_1 = require("../utils/string-utils");
|
|
9
9
|
const enquirer = require("enquirer");
|
|
10
|
+
const chalk = require("chalk");
|
|
10
11
|
async function determineNxCloud(parsedArgs) {
|
|
11
12
|
if (parsedArgs.nxCloud === undefined) {
|
|
12
|
-
return
|
|
13
|
-
.prompt([
|
|
14
|
-
{
|
|
15
|
-
name: 'NxCloud',
|
|
16
|
-
message: ab_testing_1.messages.getPromptMessage('nxCloudCreation'),
|
|
17
|
-
type: 'autocomplete',
|
|
18
|
-
choices: [
|
|
19
|
-
{
|
|
20
|
-
name: 'Yes',
|
|
21
|
-
hint: 'I want faster builds',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
name: 'No',
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
initial: 'Yes',
|
|
28
|
-
},
|
|
29
|
-
])
|
|
30
|
-
.then((a) => a.NxCloud === 'Yes');
|
|
13
|
+
return nxCloudPrompt('setupCI');
|
|
31
14
|
}
|
|
32
15
|
else {
|
|
33
16
|
return parsedArgs.nxCloud;
|
|
34
17
|
}
|
|
35
18
|
}
|
|
36
19
|
exports.determineNxCloud = determineNxCloud;
|
|
37
|
-
async function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return '';
|
|
20
|
+
async function nxCloudPrompt(key) {
|
|
21
|
+
const { message, choices, initial, fallback, footer, hint } = ab_testing_1.messages.getPrompt(key);
|
|
22
|
+
const promptConfig = {
|
|
23
|
+
name: 'NxCloud',
|
|
24
|
+
message,
|
|
25
|
+
type: 'autocomplete',
|
|
26
|
+
choices,
|
|
27
|
+
initial,
|
|
28
|
+
}; // meeroslav: types in enquirer are not up to date
|
|
29
|
+
if (footer) {
|
|
30
|
+
promptConfig.footer = () => chalk.dim(footer);
|
|
49
31
|
}
|
|
50
|
-
if (
|
|
51
|
-
|
|
32
|
+
if (hint) {
|
|
33
|
+
promptConfig.hint = () => chalk.dim(hint);
|
|
52
34
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
type: 'autocomplete',
|
|
60
|
-
initial: '',
|
|
61
|
-
choices: [
|
|
62
|
-
{ message: 'none', name: '' },
|
|
63
|
-
{ message: 'GitHub Actions', name: 'github' },
|
|
64
|
-
{ message: 'Circle CI', name: 'circleci' },
|
|
65
|
-
{ message: 'Azure DevOps', name: 'azure' },
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
])
|
|
69
|
-
// enquirer ignores name and value if they are falsy and takes
|
|
70
|
-
// first field that has a truthy value, so wee need to explicitly
|
|
71
|
-
// check for none
|
|
72
|
-
.then((a) => (a.CI !== 'none' ? a.CI : '')));
|
|
73
|
-
}
|
|
74
|
-
return '';
|
|
35
|
+
return enquirer.prompt([promptConfig]).then((a) => {
|
|
36
|
+
if (fallback && a.NxCloud === fallback.value) {
|
|
37
|
+
return nxCloudPrompt(fallback.key);
|
|
38
|
+
}
|
|
39
|
+
return a.NxCloud;
|
|
40
|
+
});
|
|
75
41
|
}
|
|
76
|
-
exports.determineCI = determineCI;
|
|
77
42
|
async function determineDefaultBase(parsedArgs) {
|
|
78
43
|
if (parsedArgs.defaultBase) {
|
|
79
44
|
return Promise.resolve(parsedArgs.defaultBase);
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import yargs = require('yargs');
|
|
2
2
|
export declare function withNxCloud<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & {
|
|
3
|
-
nxCloud:
|
|
4
|
-
}>;
|
|
5
|
-
export declare function withCI<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & {
|
|
6
|
-
ci: string | undefined;
|
|
3
|
+
nxCloud: string | undefined;
|
|
7
4
|
}>;
|
|
8
5
|
export declare function withAllPrompts<T = unknown>(argv: yargs.Argv<T>): yargs.Argv<T & {
|
|
9
6
|
allPrompts: boolean;
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withOptions = exports.withGitOptions = exports.withPackageManager = exports.withAllPrompts = exports.
|
|
3
|
+
exports.withOptions = exports.withGitOptions = exports.withPackageManager = exports.withAllPrompts = exports.withNxCloud = void 0;
|
|
4
4
|
const chalk = require("chalk");
|
|
5
|
-
const ci_list_1 = require("../utils/ci/ci-list");
|
|
6
5
|
const ab_testing_1 = require("../utils/nx/ab-testing");
|
|
7
6
|
const package_manager_1 = require("../utils/package-manager");
|
|
8
7
|
function withNxCloud(argv) {
|
|
8
|
+
const { message } = ab_testing_1.messages.getPrompt('setupCI');
|
|
9
9
|
const result = argv.option('nxCloud', {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
alias: 'ci',
|
|
11
|
+
describe: chalk.dim(message),
|
|
12
|
+
choices: ab_testing_1.NxCloudChoices,
|
|
13
|
+
type: 'string',
|
|
12
14
|
});
|
|
13
15
|
return result;
|
|
14
16
|
}
|
|
15
17
|
exports.withNxCloud = withNxCloud;
|
|
16
|
-
function withCI(argv) {
|
|
17
|
-
return argv.option('ci', {
|
|
18
|
-
describe: chalk.dim `Generate a CI workflow file`,
|
|
19
|
-
choices: ci_list_1.ciList,
|
|
20
|
-
defaultDescription: '',
|
|
21
|
-
type: 'string',
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
exports.withCI = withCI;
|
|
25
18
|
function withAllPrompts(argv) {
|
|
26
19
|
return argv.option('allPrompts', {
|
|
27
20
|
alias: 'a',
|
|
@@ -1,17 +1,67 @@
|
|
|
1
|
+
export declare const NxCloudChoices: string[];
|
|
1
2
|
declare const messageOptions: {
|
|
2
|
-
readonly
|
|
3
|
-
readonly code: "
|
|
4
|
-
readonly message: "
|
|
3
|
+
readonly setupCI: readonly [{
|
|
4
|
+
readonly code: "enable-nx-cloud";
|
|
5
|
+
readonly message: "Do you want Nx Cloud to make your CI fast?";
|
|
6
|
+
readonly initial: "github";
|
|
7
|
+
readonly choices: readonly [{
|
|
8
|
+
readonly value: "yes";
|
|
9
|
+
readonly name: "Yes, enable Nx Cloud";
|
|
10
|
+
}, {
|
|
11
|
+
readonly value: "github";
|
|
12
|
+
readonly name: "Yes, configure Nx Cloud for GitHub Actions";
|
|
13
|
+
}, {
|
|
14
|
+
readonly value: "circleci";
|
|
15
|
+
readonly name: "Yes, configure Nx Cloud for Circle CI";
|
|
16
|
+
}, {
|
|
17
|
+
readonly value: "skip";
|
|
18
|
+
readonly name: "Skip for now";
|
|
19
|
+
}];
|
|
20
|
+
readonly footer: "\nRead more about remote cache at https://nx.dev/ci/features/remote-cache";
|
|
21
|
+
readonly hint: "\n(it's free and can be disabled any time)";
|
|
22
|
+
readonly fallback: undefined;
|
|
23
|
+
}, {
|
|
24
|
+
readonly code: "set-up-ci";
|
|
25
|
+
readonly message: "Set up CI with caching, distribution and test deflaking";
|
|
26
|
+
readonly initial: "github";
|
|
27
|
+
readonly choices: readonly [{
|
|
28
|
+
readonly value: "github";
|
|
29
|
+
readonly name: "Yes, for GitHub Actions with Nx Cloud";
|
|
30
|
+
}, {
|
|
31
|
+
readonly value: "circleci";
|
|
32
|
+
readonly name: "Yes, for CircleCI with Nx Cloud";
|
|
33
|
+
}, {
|
|
34
|
+
readonly value: "skip";
|
|
35
|
+
readonly name: "Skip for now";
|
|
36
|
+
}];
|
|
37
|
+
readonly footer: "\nRead more about CI benefits with Nx at https://nx.dev/ci/intro/ci-with-nx";
|
|
38
|
+
readonly hint: "\n(it's free and can be disabled any time)";
|
|
39
|
+
readonly fallback: {
|
|
40
|
+
readonly value: "skip";
|
|
41
|
+
readonly key: "setupNxCloud";
|
|
42
|
+
};
|
|
5
43
|
}];
|
|
6
|
-
readonly
|
|
7
|
-
readonly code: "
|
|
8
|
-
readonly message: "
|
|
44
|
+
readonly setupNxCloud: readonly [{
|
|
45
|
+
readonly code: "enable-caching";
|
|
46
|
+
readonly message: "Would you like remote caching to make your build faster?";
|
|
47
|
+
readonly initial: "yes";
|
|
48
|
+
readonly choices: readonly [{
|
|
49
|
+
readonly value: "yes";
|
|
50
|
+
readonly name: "Yes";
|
|
51
|
+
}, {
|
|
52
|
+
readonly value: "skip";
|
|
53
|
+
readonly name: "Skip for now";
|
|
54
|
+
}];
|
|
55
|
+
readonly footer: "\nRead more about remote caching at https://nx.dev/ci/features/remote-cache";
|
|
56
|
+
readonly hint: "\n(it's free and can be disabled any time)";
|
|
57
|
+
readonly fallback: undefined;
|
|
9
58
|
}];
|
|
10
59
|
};
|
|
11
|
-
type MessageKey = keyof typeof messageOptions;
|
|
60
|
+
export type MessageKey = keyof typeof messageOptions;
|
|
61
|
+
type MessageData = typeof messageOptions[MessageKey][number];
|
|
12
62
|
export declare class PromptMessages {
|
|
13
63
|
private selectedMessages;
|
|
14
|
-
|
|
64
|
+
getPrompt(key: MessageKey): MessageData;
|
|
15
65
|
codeOfSelectedPromptMessage(key: MessageKey): string;
|
|
16
66
|
}
|
|
17
67
|
export declare const messages: PromptMessages;
|
|
@@ -23,6 +73,6 @@ export declare function recordStat(opts: {
|
|
|
23
73
|
command: string;
|
|
24
74
|
nxVersion: string;
|
|
25
75
|
useCloud: boolean;
|
|
26
|
-
meta: string;
|
|
76
|
+
meta: string[];
|
|
27
77
|
}): Promise<void>;
|
|
28
78
|
export {};
|
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.recordStat = exports.messages = exports.PromptMessages = void 0;
|
|
3
|
+
exports.recordStat = exports.messages = exports.PromptMessages = exports.NxCloudChoices = void 0;
|
|
4
4
|
const is_ci_1 = require("../ci/is-ci");
|
|
5
|
+
exports.NxCloudChoices = ['yes', 'github', 'circleci', 'skip'];
|
|
5
6
|
const messageOptions = {
|
|
6
|
-
|
|
7
|
+
setupCI: [
|
|
7
8
|
{
|
|
8
|
-
code: '
|
|
9
|
-
message: `
|
|
9
|
+
code: 'enable-nx-cloud',
|
|
10
|
+
message: `Do you want Nx Cloud to make your CI fast?`,
|
|
11
|
+
initial: 'github',
|
|
12
|
+
choices: [
|
|
13
|
+
{ value: 'yes', name: 'Yes, enable Nx Cloud' },
|
|
14
|
+
{ value: 'github', name: 'Yes, configure Nx Cloud for GitHub Actions' },
|
|
15
|
+
{ value: 'circleci', name: 'Yes, configure Nx Cloud for Circle CI' },
|
|
16
|
+
{ value: 'skip', name: 'Skip for now' },
|
|
17
|
+
],
|
|
18
|
+
footer: '\nRead more about remote cache at https://nx.dev/ci/features/remote-cache',
|
|
19
|
+
hint: `\n(it's free and can be disabled any time)`,
|
|
20
|
+
fallback: undefined,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
code: 'set-up-ci',
|
|
24
|
+
message: `Set up CI with caching, distribution and test deflaking`,
|
|
25
|
+
initial: 'github',
|
|
26
|
+
choices: [
|
|
27
|
+
{ value: 'github', name: 'Yes, for GitHub Actions with Nx Cloud' },
|
|
28
|
+
{ value: 'circleci', name: 'Yes, for CircleCI with Nx Cloud' },
|
|
29
|
+
{ value: 'skip', name: 'Skip for now' },
|
|
30
|
+
],
|
|
31
|
+
footer: '\nRead more about CI benefits with Nx at https://nx.dev/ci/intro/ci-with-nx',
|
|
32
|
+
hint: `\n(it's free and can be disabled any time)`,
|
|
33
|
+
fallback: { value: 'skip', key: 'setupNxCloud' },
|
|
10
34
|
},
|
|
11
35
|
],
|
|
12
|
-
|
|
36
|
+
setupNxCloud: [
|
|
13
37
|
{
|
|
14
|
-
code: '
|
|
15
|
-
message: `
|
|
38
|
+
code: 'enable-caching',
|
|
39
|
+
message: `Would you like remote caching to make your build faster?`,
|
|
40
|
+
initial: 'yes',
|
|
41
|
+
choices: [
|
|
42
|
+
{ value: 'yes', name: 'Yes' },
|
|
43
|
+
{ value: 'skip', name: 'Skip for now' },
|
|
44
|
+
],
|
|
45
|
+
footer: '\nRead more about remote caching at https://nx.dev/ci/features/remote-cache',
|
|
46
|
+
hint: `\n(it's free and can be disabled any time)`,
|
|
47
|
+
fallback: undefined,
|
|
16
48
|
},
|
|
17
49
|
],
|
|
18
50
|
};
|
|
@@ -20,7 +52,7 @@ class PromptMessages {
|
|
|
20
52
|
constructor() {
|
|
21
53
|
this.selectedMessages = {};
|
|
22
54
|
}
|
|
23
|
-
|
|
55
|
+
getPrompt(key) {
|
|
24
56
|
if (this.selectedMessages[key] === undefined) {
|
|
25
57
|
if (process.env.NX_GENERATE_DOCS_PROCESS === 'true') {
|
|
26
58
|
this.selectedMessages[key] = 0;
|
|
@@ -29,12 +61,12 @@ class PromptMessages {
|
|
|
29
61
|
this.selectedMessages[key] = Math.floor(Math.random() * messageOptions[key].length);
|
|
30
62
|
}
|
|
31
63
|
}
|
|
32
|
-
return messageOptions[key][this.selectedMessages[key]]
|
|
64
|
+
return messageOptions[key][this.selectedMessages[key]];
|
|
33
65
|
}
|
|
34
66
|
codeOfSelectedPromptMessage(key) {
|
|
35
67
|
const selected = this.selectedMessages[key];
|
|
36
68
|
if (selected === undefined) {
|
|
37
|
-
return
|
|
69
|
+
return '';
|
|
38
70
|
}
|
|
39
71
|
else {
|
|
40
72
|
return messageOptions[key][selected].code;
|
|
@@ -65,7 +97,7 @@ async function recordStat(opts) {
|
|
|
65
97
|
command: opts.command,
|
|
66
98
|
isCI: (0, is_ci_1.isCI)(),
|
|
67
99
|
useCloud: opts.useCloud,
|
|
68
|
-
meta: opts.meta,
|
|
100
|
+
meta: opts.meta.filter((v) => !!v).join(','),
|
|
69
101
|
});
|
|
70
102
|
}
|
|
71
103
|
catch (e) {
|