@tanstack/cta-cli 0.35.0 → 0.36.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/dist/cli.js +14 -14
- package/dist/command-line.js +5 -5
- package/dist/options.js +7 -7
- package/dist/types/cli.d.ts +3 -3
- package/dist/types/command-line.d.ts +1 -1
- package/dist/types/options.d.ts +2 -2
- package/dist/types/types.d.ts +1 -1
- package/dist/types/ui-prompts.d.ts +1 -1
- package/dist/ui-prompts.js +13 -13
- package/package.json +3 -3
- package/src/cli.ts +19 -19
- package/src/command-line.ts +6 -6
- package/src/options.ts +8 -8
- package/src/types.ts +1 -1
- package/src/ui-prompts.ts +14 -14
- package/tests/command-line.test.ts +1 -1
package/dist/cli.js
CHANGED
|
@@ -11,8 +11,8 @@ import { promptForAddOns, promptForCreateOptions } from './options.js';
|
|
|
11
11
|
import { normalizeOptions } from './command-line.js';
|
|
12
12
|
import { createUIEnvironment } from './ui-environment.js';
|
|
13
13
|
import { convertTemplateToMode } from './utils.js';
|
|
14
|
-
// This CLI assumes that all of the registered frameworks have the same set of toolchains,
|
|
15
|
-
export function cli({ name, appName, forcedMode, forcedAddOns = [], defaultTemplate = 'javascript',
|
|
14
|
+
// This CLI assumes that all of the registered frameworks have the same set of toolchains, deployments, modes, etc.
|
|
15
|
+
export function cli({ name, appName, forcedMode, forcedAddOns = [], defaultTemplate = 'javascript', forcedDeployment, defaultFramework, craCompatible = false, webBase, showDeploymentOptions = false, }) {
|
|
16
16
|
const environment = createUIEnvironment(appName, false);
|
|
17
17
|
const program = new Command();
|
|
18
18
|
const availableFrameworks = getFrameworks().map((f) => f.name);
|
|
@@ -24,11 +24,11 @@ export function cli({ name, appName, forcedMode, forcedAddOns = [], defaultTempl
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const deployments = new Set();
|
|
28
28
|
for (const framework of getFrameworks()) {
|
|
29
29
|
for (const addOn of framework.getAddOns()) {
|
|
30
|
-
if (addOn.type === '
|
|
31
|
-
|
|
30
|
+
if (addOn.type === 'deployment') {
|
|
31
|
+
deployments.add(addOn.id);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -130,7 +130,7 @@ Remove your node_modules directory and package lock file and re-install.`);
|
|
|
130
130
|
forcedAddOns,
|
|
131
131
|
environmentFactory: () => createUIEnvironment(appName, false),
|
|
132
132
|
webBase,
|
|
133
|
-
|
|
133
|
+
showDeploymentOptions,
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
else if (parsedAddOns.length < 1) {
|
|
@@ -200,10 +200,10 @@ Remove your node_modules directory and package lock file and re-install.`);
|
|
|
200
200
|
}
|
|
201
201
|
return value;
|
|
202
202
|
});
|
|
203
|
-
if (
|
|
204
|
-
program.option(`--
|
|
205
|
-
if (!
|
|
206
|
-
throw new InvalidArgumentError(`Invalid
|
|
203
|
+
if (deployments.size > 0) {
|
|
204
|
+
program.option(`--deployment <${Array.from(deployments).join('|')}>`, `Explicitly tell the CLI to use this deployment adapter`, (value) => {
|
|
205
|
+
if (!deployments.has(value)) {
|
|
206
|
+
throw new InvalidArgumentError(`Invalid adapter: ${value}. The following are allowed: ${Array.from(deployments).join(', ')}`);
|
|
207
207
|
}
|
|
208
208
|
return value;
|
|
209
209
|
});
|
|
@@ -324,10 +324,10 @@ Remove your node_modules directory and package lock file and re-install.`);
|
|
|
324
324
|
cliOptions.addOns = true;
|
|
325
325
|
}
|
|
326
326
|
else {
|
|
327
|
-
finalOptions = await normalizeOptions(cliOptions, defaultMode, forcedAddOns, {
|
|
327
|
+
finalOptions = await normalizeOptions(cliOptions, defaultMode, forcedAddOns, { forcedDeployment });
|
|
328
328
|
}
|
|
329
329
|
if (options.ui) {
|
|
330
|
-
const optionsFromCLI = await normalizeOptions(cliOptions, defaultMode, forcedAddOns, { disableNameCheck: true,
|
|
330
|
+
const optionsFromCLI = await normalizeOptions(cliOptions, defaultMode, forcedAddOns, { disableNameCheck: true, forcedDeployment });
|
|
331
331
|
const options = {
|
|
332
332
|
...createSerializedOptions(optionsFromCLI),
|
|
333
333
|
projectName: 'my-app',
|
|
@@ -340,7 +340,7 @@ Remove your node_modules directory and package lock file and re-install.`);
|
|
|
340
340
|
forcedAddOns,
|
|
341
341
|
environmentFactory: () => createUIEnvironment(appName, false),
|
|
342
342
|
webBase,
|
|
343
|
-
|
|
343
|
+
showDeploymentOptions,
|
|
344
344
|
});
|
|
345
345
|
return;
|
|
346
346
|
}
|
|
@@ -352,7 +352,7 @@ Remove your node_modules directory and package lock file and re-install.`);
|
|
|
352
352
|
finalOptions = await promptForCreateOptions(cliOptions, {
|
|
353
353
|
forcedMode: defaultMode,
|
|
354
354
|
forcedAddOns,
|
|
355
|
-
|
|
355
|
+
showDeploymentOptions,
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
if (!finalOptions) {
|
package/dist/command-line.js
CHANGED
|
@@ -41,7 +41,7 @@ export async function normalizeOptions(cliOptions, forcedMode, forcedAddOns, opt
|
|
|
41
41
|
starter?.dependsOn ||
|
|
42
42
|
forcedAddOns ||
|
|
43
43
|
cliOptions.toolchain ||
|
|
44
|
-
cliOptions.
|
|
44
|
+
cliOptions.deployment) {
|
|
45
45
|
const selectedAddOns = new Set([
|
|
46
46
|
...(starter?.dependsOn || []),
|
|
47
47
|
...(forcedAddOns || []),
|
|
@@ -54,11 +54,11 @@ export async function normalizeOptions(cliOptions, forcedMode, forcedAddOns, opt
|
|
|
54
54
|
if (cliOptions.toolchain) {
|
|
55
55
|
selectedAddOns.add(cliOptions.toolchain);
|
|
56
56
|
}
|
|
57
|
-
if (cliOptions.
|
|
58
|
-
selectedAddOns.add(cliOptions.
|
|
57
|
+
if (cliOptions.deployment) {
|
|
58
|
+
selectedAddOns.add(cliOptions.deployment);
|
|
59
59
|
}
|
|
60
|
-
if (!cliOptions.
|
|
61
|
-
selectedAddOns.add(opts.
|
|
60
|
+
if (!cliOptions.deployment && opts?.forcedDeployment) {
|
|
61
|
+
selectedAddOns.add(opts.forcedDeployment);
|
|
62
62
|
}
|
|
63
63
|
return await finalizeAddOns(framework, mode, Array.from(selectedAddOns));
|
|
64
64
|
}
|
package/dist/options.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { intro } from '@clack/prompts';
|
|
2
2
|
import { finalizeAddOns, getFrameworkById, getPackageManager, populateAddOnOptionsDefaults, readConfigFile, } from '@tanstack/cta-engine';
|
|
3
|
-
import { getProjectName, promptForAddOnOptions, selectAddOns, selectGit,
|
|
4
|
-
export async function promptForCreateOptions(cliOptions, { forcedAddOns = [], forcedMode,
|
|
3
|
+
import { getProjectName, promptForAddOnOptions, selectAddOns, selectGit, selectDeployment, selectPackageManager, selectRouterType, selectTailwind, selectToolchain, selectTypescript, } from './ui-prompts.js';
|
|
4
|
+
export async function promptForCreateOptions(cliOptions, { forcedAddOns = [], forcedMode, showDeploymentOptions = false, }) {
|
|
5
5
|
const options = {};
|
|
6
6
|
options.framework = getFrameworkById(cliOptions.framework || 'react-cra');
|
|
7
7
|
options.projectName = cliOptions.projectName || (await getProjectName());
|
|
@@ -45,17 +45,17 @@ export async function promptForCreateOptions(cliOptions, { forcedAddOns = [], fo
|
|
|
45
45
|
}
|
|
46
46
|
// Toolchain selection
|
|
47
47
|
const toolchain = await selectToolchain(options.framework, cliOptions.toolchain);
|
|
48
|
-
//
|
|
49
|
-
const
|
|
50
|
-
? await
|
|
48
|
+
// Deployment selection
|
|
49
|
+
const deployment = showDeploymentOptions
|
|
50
|
+
? await selectDeployment(options.framework, cliOptions.deployment)
|
|
51
51
|
: undefined;
|
|
52
52
|
// Add-ons selection
|
|
53
53
|
const addOns = new Set();
|
|
54
54
|
if (toolchain) {
|
|
55
55
|
addOns.add(toolchain);
|
|
56
56
|
}
|
|
57
|
-
if (
|
|
58
|
-
addOns.add(
|
|
57
|
+
if (deployment) {
|
|
58
|
+
addOns.add(deployment);
|
|
59
59
|
}
|
|
60
60
|
for (const addOn of forcedAddOns) {
|
|
61
61
|
addOns.add(addOn);
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { TemplateOptions } from './types.js';
|
|
2
|
-
export declare function cli({ name, appName, forcedMode, forcedAddOns, defaultTemplate,
|
|
2
|
+
export declare function cli({ name, appName, forcedMode, forcedAddOns, defaultTemplate, forcedDeployment, defaultFramework, craCompatible, webBase, showDeploymentOptions, }: {
|
|
3
3
|
name: string;
|
|
4
4
|
appName: string;
|
|
5
5
|
forcedMode?: string;
|
|
6
6
|
forcedAddOns?: Array<string>;
|
|
7
|
-
|
|
7
|
+
forcedDeployment?: string;
|
|
8
8
|
defaultTemplate?: TemplateOptions;
|
|
9
9
|
defaultFramework?: string;
|
|
10
10
|
craCompatible?: boolean;
|
|
11
11
|
webBase?: string;
|
|
12
|
-
|
|
12
|
+
showDeploymentOptions?: boolean;
|
|
13
13
|
}): void;
|
|
@@ -2,5 +2,5 @@ import type { Options } from '@tanstack/cta-engine';
|
|
|
2
2
|
import type { CliOptions } from './types.js';
|
|
3
3
|
export declare function normalizeOptions(cliOptions: CliOptions, forcedMode?: string, forcedAddOns?: Array<string>, opts?: {
|
|
4
4
|
disableNameCheck?: boolean;
|
|
5
|
-
|
|
5
|
+
forcedDeployment?: string;
|
|
6
6
|
}): Promise<Options | undefined>;
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Options } from '@tanstack/cta-engine';
|
|
2
2
|
import type { CliOptions } from './types.js';
|
|
3
|
-
export declare function promptForCreateOptions(cliOptions: CliOptions, { forcedAddOns, forcedMode,
|
|
3
|
+
export declare function promptForCreateOptions(cliOptions: CliOptions, { forcedAddOns, forcedMode, showDeploymentOptions, }: {
|
|
4
4
|
forcedAddOns?: Array<string>;
|
|
5
5
|
forcedMode?: string;
|
|
6
|
-
|
|
6
|
+
showDeploymentOptions?: boolean;
|
|
7
7
|
}): Promise<Required<Options> | undefined>;
|
|
8
8
|
export declare function promptForAddOns(): Promise<Array<string>>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export declare function selectAddOns(framework: Framework, mode: string, type: s
|
|
|
9
9
|
export declare function selectGit(): Promise<boolean>;
|
|
10
10
|
export declare function selectToolchain(framework: Framework, toolchain?: string): Promise<string | undefined>;
|
|
11
11
|
export declare function promptForAddOnOptions(addOnIds: Array<string>, framework: Framework): Promise<Record<string, Record<string, any>>>;
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function selectDeployment(framework: Framework, deployment?: string): Promise<string | undefined>;
|
package/dist/ui-prompts.js
CHANGED
|
@@ -169,35 +169,35 @@ export async function promptForAddOnOptions(addOnIds, framework) {
|
|
|
169
169
|
}
|
|
170
170
|
return addOnOptions;
|
|
171
171
|
}
|
|
172
|
-
export async function
|
|
173
|
-
const
|
|
172
|
+
export async function selectDeployment(framework, deployment) {
|
|
173
|
+
const deployments = new Set();
|
|
174
174
|
let initialValue = undefined;
|
|
175
175
|
for (const addOn of framework
|
|
176
176
|
.getAddOns()
|
|
177
177
|
.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
178
|
-
if (addOn.type === '
|
|
179
|
-
|
|
180
|
-
if (
|
|
181
|
-
return
|
|
178
|
+
if (addOn.type === 'deployment') {
|
|
179
|
+
deployments.add(addOn);
|
|
180
|
+
if (deployment && addOn.id === deployment) {
|
|
181
|
+
return deployment;
|
|
182
182
|
}
|
|
183
183
|
if (addOn.default) {
|
|
184
184
|
initialValue = addOn.id;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
const
|
|
189
|
-
message: 'Select
|
|
188
|
+
const dp = await select({
|
|
189
|
+
message: 'Select deployment adapter',
|
|
190
190
|
options: [
|
|
191
|
-
...Array.from(
|
|
192
|
-
value:
|
|
193
|
-
label:
|
|
191
|
+
...Array.from(deployments).map((d) => ({
|
|
192
|
+
value: d.id,
|
|
193
|
+
label: d.name,
|
|
194
194
|
})),
|
|
195
195
|
],
|
|
196
196
|
initialValue: initialValue,
|
|
197
197
|
});
|
|
198
|
-
if (isCancel(
|
|
198
|
+
if (isCancel(dp)) {
|
|
199
199
|
cancel('Operation cancelled.');
|
|
200
200
|
process.exit(0);
|
|
201
201
|
}
|
|
202
|
-
return
|
|
202
|
+
return dp;
|
|
203
203
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/cta-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "Tanstack Application Builder CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"express": "^4.21.2",
|
|
31
31
|
"semver": "^7.7.2",
|
|
32
32
|
"zod": "^3.24.2",
|
|
33
|
-
"@tanstack/cta-engine": "0.
|
|
34
|
-
"@tanstack/cta-ui": "0.
|
|
33
|
+
"@tanstack/cta-engine": "0.36.0",
|
|
34
|
+
"@tanstack/cta-ui": "0.36.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@tanstack/config": "^0.16.2",
|
package/src/cli.ts
CHANGED
|
@@ -32,7 +32,7 @@ import { convertTemplateToMode } from './utils.js'
|
|
|
32
32
|
import type { CliOptions, TemplateOptions } from './types.js'
|
|
33
33
|
import type { Options, PackageManager } from '@tanstack/cta-engine'
|
|
34
34
|
|
|
35
|
-
// This CLI assumes that all of the registered frameworks have the same set of toolchains,
|
|
35
|
+
// This CLI assumes that all of the registered frameworks have the same set of toolchains, deployments, modes, etc.
|
|
36
36
|
|
|
37
37
|
export function cli({
|
|
38
38
|
name,
|
|
@@ -40,22 +40,22 @@ export function cli({
|
|
|
40
40
|
forcedMode,
|
|
41
41
|
forcedAddOns = [],
|
|
42
42
|
defaultTemplate = 'javascript',
|
|
43
|
-
|
|
43
|
+
forcedDeployment,
|
|
44
44
|
defaultFramework,
|
|
45
45
|
craCompatible = false,
|
|
46
46
|
webBase,
|
|
47
|
-
|
|
47
|
+
showDeploymentOptions = false,
|
|
48
48
|
}: {
|
|
49
49
|
name: string
|
|
50
50
|
appName: string
|
|
51
51
|
forcedMode?: string
|
|
52
52
|
forcedAddOns?: Array<string>
|
|
53
|
-
|
|
53
|
+
forcedDeployment?: string
|
|
54
54
|
defaultTemplate?: TemplateOptions
|
|
55
55
|
defaultFramework?: string
|
|
56
56
|
craCompatible?: boolean
|
|
57
57
|
webBase?: string
|
|
58
|
-
|
|
58
|
+
showDeploymentOptions?: boolean
|
|
59
59
|
}) {
|
|
60
60
|
const environment = createUIEnvironment(appName, false)
|
|
61
61
|
|
|
@@ -72,11 +72,11 @@ export function cli({
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const
|
|
75
|
+
const deployments = new Set<string>()
|
|
76
76
|
for (const framework of getFrameworks()) {
|
|
77
77
|
for (const addOn of framework.getAddOns()) {
|
|
78
|
-
if (addOn.type === '
|
|
79
|
-
|
|
78
|
+
if (addOn.type === 'deployment') {
|
|
79
|
+
deployments.add(addOn.id)
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -202,7 +202,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
202
202
|
forcedAddOns,
|
|
203
203
|
environmentFactory: () => createUIEnvironment(appName, false),
|
|
204
204
|
webBase,
|
|
205
|
-
|
|
205
|
+
showDeploymentOptions,
|
|
206
206
|
})
|
|
207
207
|
} else if (parsedAddOns.length < 1) {
|
|
208
208
|
const addOns = await promptForAddOns()
|
|
@@ -308,15 +308,15 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
308
308
|
},
|
|
309
309
|
)
|
|
310
310
|
|
|
311
|
-
if (
|
|
311
|
+
if (deployments.size > 0) {
|
|
312
312
|
program.option<string>(
|
|
313
|
-
`--
|
|
314
|
-
`Explicitly tell the CLI to use this
|
|
313
|
+
`--deployment <${Array.from(deployments).join('|')}>`,
|
|
314
|
+
`Explicitly tell the CLI to use this deployment adapter`,
|
|
315
315
|
(value) => {
|
|
316
|
-
if (!
|
|
316
|
+
if (!deployments.has(value)) {
|
|
317
317
|
throw new InvalidArgumentError(
|
|
318
|
-
`Invalid
|
|
319
|
-
|
|
318
|
+
`Invalid adapter: ${value}. The following are allowed: ${Array.from(
|
|
319
|
+
deployments,
|
|
320
320
|
).join(', ')}`,
|
|
321
321
|
)
|
|
322
322
|
}
|
|
@@ -485,7 +485,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
485
485
|
cliOptions,
|
|
486
486
|
defaultMode,
|
|
487
487
|
forcedAddOns,
|
|
488
|
-
{
|
|
488
|
+
{ forcedDeployment },
|
|
489
489
|
)
|
|
490
490
|
}
|
|
491
491
|
|
|
@@ -494,7 +494,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
494
494
|
cliOptions,
|
|
495
495
|
defaultMode,
|
|
496
496
|
forcedAddOns,
|
|
497
|
-
{ disableNameCheck: true,
|
|
497
|
+
{ disableNameCheck: true, forcedDeployment },
|
|
498
498
|
)
|
|
499
499
|
const options = {
|
|
500
500
|
...createSerializedOptions(optionsFromCLI!),
|
|
@@ -508,7 +508,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
508
508
|
forcedAddOns,
|
|
509
509
|
environmentFactory: () => createUIEnvironment(appName, false),
|
|
510
510
|
webBase,
|
|
511
|
-
|
|
511
|
+
showDeploymentOptions,
|
|
512
512
|
})
|
|
513
513
|
return
|
|
514
514
|
}
|
|
@@ -520,7 +520,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
520
520
|
finalOptions = await promptForCreateOptions(cliOptions, {
|
|
521
521
|
forcedMode: defaultMode,
|
|
522
522
|
forcedAddOns,
|
|
523
|
-
|
|
523
|
+
showDeploymentOptions,
|
|
524
524
|
})
|
|
525
525
|
}
|
|
526
526
|
|
package/src/command-line.ts
CHANGED
|
@@ -19,7 +19,7 @@ export async function normalizeOptions(
|
|
|
19
19
|
forcedAddOns?: Array<string>,
|
|
20
20
|
opts?: {
|
|
21
21
|
disableNameCheck?: boolean
|
|
22
|
-
|
|
22
|
+
forcedDeployment?: string
|
|
23
23
|
},
|
|
24
24
|
): Promise<Options | undefined> {
|
|
25
25
|
const projectName = (cliOptions.projectName ?? '').trim()
|
|
@@ -77,7 +77,7 @@ export async function normalizeOptions(
|
|
|
77
77
|
starter?.dependsOn ||
|
|
78
78
|
forcedAddOns ||
|
|
79
79
|
cliOptions.toolchain ||
|
|
80
|
-
cliOptions.
|
|
80
|
+
cliOptions.deployment
|
|
81
81
|
) {
|
|
82
82
|
const selectedAddOns = new Set<string>([
|
|
83
83
|
...(starter?.dependsOn || []),
|
|
@@ -91,12 +91,12 @@ export async function normalizeOptions(
|
|
|
91
91
|
if (cliOptions.toolchain) {
|
|
92
92
|
selectedAddOns.add(cliOptions.toolchain)
|
|
93
93
|
}
|
|
94
|
-
if (cliOptions.
|
|
95
|
-
selectedAddOns.add(cliOptions.
|
|
94
|
+
if (cliOptions.deployment) {
|
|
95
|
+
selectedAddOns.add(cliOptions.deployment)
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
if (!cliOptions.
|
|
99
|
-
selectedAddOns.add(opts.
|
|
98
|
+
if (!cliOptions.deployment && opts?.forcedDeployment) {
|
|
99
|
+
selectedAddOns.add(opts.forcedDeployment)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
return await finalizeAddOns(framework, mode, Array.from(selectedAddOns))
|
package/src/options.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
promptForAddOnOptions,
|
|
14
14
|
selectAddOns,
|
|
15
15
|
selectGit,
|
|
16
|
-
|
|
16
|
+
selectDeployment,
|
|
17
17
|
selectPackageManager,
|
|
18
18
|
selectRouterType,
|
|
19
19
|
selectTailwind,
|
|
@@ -30,11 +30,11 @@ export async function promptForCreateOptions(
|
|
|
30
30
|
{
|
|
31
31
|
forcedAddOns = [],
|
|
32
32
|
forcedMode,
|
|
33
|
-
|
|
33
|
+
showDeploymentOptions = false,
|
|
34
34
|
}: {
|
|
35
35
|
forcedAddOns?: Array<string>
|
|
36
36
|
forcedMode?: string
|
|
37
|
-
|
|
37
|
+
showDeploymentOptions?: boolean
|
|
38
38
|
},
|
|
39
39
|
): Promise<Required<Options> | undefined> {
|
|
40
40
|
const options = {} as Required<Options>
|
|
@@ -89,9 +89,9 @@ export async function promptForCreateOptions(
|
|
|
89
89
|
cliOptions.toolchain,
|
|
90
90
|
)
|
|
91
91
|
|
|
92
|
-
//
|
|
93
|
-
const
|
|
94
|
-
? await
|
|
92
|
+
// Deployment selection
|
|
93
|
+
const deployment = showDeploymentOptions
|
|
94
|
+
? await selectDeployment(options.framework, cliOptions.deployment)
|
|
95
95
|
: undefined
|
|
96
96
|
|
|
97
97
|
// Add-ons selection
|
|
@@ -100,8 +100,8 @@ export async function promptForCreateOptions(
|
|
|
100
100
|
if (toolchain) {
|
|
101
101
|
addOns.add(toolchain)
|
|
102
102
|
}
|
|
103
|
-
if (
|
|
104
|
-
addOns.add(
|
|
103
|
+
if (deployment) {
|
|
104
|
+
addOns.add(deployment)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
for (const addOn of forcedAddOns) {
|
package/src/types.ts
CHANGED
package/src/ui-prompts.ts
CHANGED
|
@@ -232,19 +232,19 @@ export async function promptForAddOnOptions(
|
|
|
232
232
|
return addOnOptions
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
export async function
|
|
235
|
+
export async function selectDeployment(
|
|
236
236
|
framework: Framework,
|
|
237
|
-
|
|
237
|
+
deployment?: string,
|
|
238
238
|
): Promise<string | undefined> {
|
|
239
|
-
const
|
|
239
|
+
const deployments = new Set<AddOn>()
|
|
240
240
|
let initialValue: string | undefined = undefined
|
|
241
241
|
for (const addOn of framework
|
|
242
242
|
.getAddOns()
|
|
243
243
|
.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
244
|
-
if (addOn.type === '
|
|
245
|
-
|
|
246
|
-
if (
|
|
247
|
-
return
|
|
244
|
+
if (addOn.type === 'deployment') {
|
|
245
|
+
deployments.add(addOn)
|
|
246
|
+
if (deployment && addOn.id === deployment) {
|
|
247
|
+
return deployment
|
|
248
248
|
}
|
|
249
249
|
if (addOn.default) {
|
|
250
250
|
initialValue = addOn.id
|
|
@@ -252,21 +252,21 @@ export async function selectHost(
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
const
|
|
256
|
-
message: 'Select
|
|
255
|
+
const dp = await select({
|
|
256
|
+
message: 'Select deployment adapter',
|
|
257
257
|
options: [
|
|
258
|
-
...Array.from(
|
|
259
|
-
value:
|
|
260
|
-
label:
|
|
258
|
+
...Array.from(deployments).map((d) => ({
|
|
259
|
+
value: d.id,
|
|
260
|
+
label: d.name,
|
|
261
261
|
})),
|
|
262
262
|
],
|
|
263
263
|
initialValue: initialValue,
|
|
264
264
|
})
|
|
265
265
|
|
|
266
|
-
if (isCancel(
|
|
266
|
+
if (isCancel(dp)) {
|
|
267
267
|
cancel('Operation cancelled.')
|
|
268
268
|
process.exit(0)
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
return
|
|
271
|
+
return dp
|
|
272
272
|
}
|
|
@@ -102,7 +102,7 @@ describe('normalizeOptions', () => {
|
|
|
102
102
|
const options = await normalizeOptions({
|
|
103
103
|
projectName: 'test',
|
|
104
104
|
starter: 'https://github.com/cta-dev/cta-starter-solid',
|
|
105
|
-
|
|
105
|
+
deployment: 'nitro',
|
|
106
106
|
})
|
|
107
107
|
expect(options?.mode).toBe('file-router')
|
|
108
108
|
expect(options?.tailwind).toBe(true)
|