@tanstack/cta-cli 0.30.0 → 0.31.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 +3 -3
- package/dist/command-line.js +3 -3
- package/dist/options.js +2 -2
- package/dist/types/cli.d.ts +2 -1
- package/dist/types/command-line.d.ts +1 -0
- package/package.json +2 -2
- package/src/cli.ts +28 -13
- package/src/command-line.ts +4 -3
- package/src/options.ts +5 -2
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ import { normalizeOptions } from './command-line.js';
|
|
|
12
12
|
import { createUIEnvironment } from './ui-environment.js';
|
|
13
13
|
import { convertTemplateToMode } from './utils.js';
|
|
14
14
|
// This CLI assumes that all of the registered frameworks have the same set of toolchains, hosts, modes, etc.
|
|
15
|
-
export function cli({ name, appName, forcedMode, forcedAddOns = [], defaultTemplate = 'javascript', defaultFramework, craCompatible = false, webBase, }) {
|
|
15
|
+
export function cli({ name, appName, forcedMode, forcedAddOns = [], defaultTemplate = 'javascript', forcedHost, defaultFramework, craCompatible = false, webBase, }) {
|
|
16
16
|
const environment = createUIEnvironment(appName, false);
|
|
17
17
|
const program = new Command();
|
|
18
18
|
const availableFrameworks = getFrameworks().map((f) => f.name);
|
|
@@ -323,10 +323,10 @@ Remove your node_modules directory and package lock file and re-install.`);
|
|
|
323
323
|
cliOptions.addOns = true;
|
|
324
324
|
}
|
|
325
325
|
else {
|
|
326
|
-
finalOptions = await normalizeOptions(cliOptions, defaultMode, forcedAddOns);
|
|
326
|
+
finalOptions = await normalizeOptions(cliOptions, defaultMode, forcedAddOns, { forcedHost });
|
|
327
327
|
}
|
|
328
328
|
if (options.ui) {
|
|
329
|
-
const optionsFromCLI = await normalizeOptions(cliOptions, defaultMode, forcedAddOns, { disableNameCheck: true });
|
|
329
|
+
const optionsFromCLI = await normalizeOptions(cliOptions, defaultMode, forcedAddOns, { disableNameCheck: true, forcedHost });
|
|
330
330
|
const options = {
|
|
331
331
|
...createSerializedOptions(optionsFromCLI),
|
|
332
332
|
projectName: 'my-app',
|
package/dist/command-line.js
CHANGED
|
@@ -57,8 +57,8 @@ export async function normalizeOptions(cliOptions, forcedMode, forcedAddOns, opt
|
|
|
57
57
|
if (cliOptions.host) {
|
|
58
58
|
selectedAddOns.add(cliOptions.host);
|
|
59
59
|
}
|
|
60
|
-
if (!cliOptions.host) {
|
|
61
|
-
selectedAddOns.add(
|
|
60
|
+
if (!cliOptions.host && opts?.forcedHost) {
|
|
61
|
+
selectedAddOns.add(opts.forcedHost);
|
|
62
62
|
}
|
|
63
63
|
return await finalizeAddOns(framework, mode, Array.from(selectedAddOns));
|
|
64
64
|
}
|
|
@@ -94,7 +94,7 @@ export async function normalizeOptions(cliOptions, forcedMode, forcedAddOns, opt
|
|
|
94
94
|
chosenAddOns,
|
|
95
95
|
addOnOptions: {
|
|
96
96
|
...populateAddOnOptionsDefaults(chosenAddOns),
|
|
97
|
-
...addOnOptionsFromCLI
|
|
97
|
+
...addOnOptionsFromCLI,
|
|
98
98
|
},
|
|
99
99
|
starter: starter,
|
|
100
100
|
};
|
package/dist/options.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, selectPackageManager, selectRouterType, selectTailwind, selectToolchain,
|
|
3
|
+
import { getProjectName, promptForAddOnOptions, selectAddOns, selectGit, selectHost, selectPackageManager, selectRouterType, selectTailwind, selectToolchain, selectTypescript, } from './ui-prompts.js';
|
|
4
4
|
export async function promptForCreateOptions(cliOptions, { forcedAddOns = [], forcedMode, }) {
|
|
5
5
|
const options = {};
|
|
6
6
|
options.framework = getFrameworkById(cliOptions.framework || 'react-cra');
|
|
@@ -83,7 +83,7 @@ export async function promptForCreateOptions(cliOptions, { forcedAddOns = [], fo
|
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
85
|
// Interactive mode: prompt for options
|
|
86
|
-
const userOptions = await promptForAddOnOptions(options.chosenAddOns.map(a => a.id), options.framework);
|
|
86
|
+
const userOptions = await promptForAddOnOptions(options.chosenAddOns.map((a) => a.id), options.framework);
|
|
87
87
|
const defaultOptions = populateAddOnOptionsDefaults(options.chosenAddOns);
|
|
88
88
|
// Merge user options with defaults
|
|
89
89
|
options.addOnOptions = { ...defaultOptions, ...userOptions };
|
package/dist/types/cli.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { TemplateOptions } from './types.js';
|
|
2
|
-
export declare function cli({ name, appName, forcedMode, forcedAddOns, defaultTemplate, defaultFramework, craCompatible, webBase, }: {
|
|
2
|
+
export declare function cli({ name, appName, forcedMode, forcedAddOns, defaultTemplate, forcedHost, defaultFramework, craCompatible, webBase, }: {
|
|
3
3
|
name: string;
|
|
4
4
|
appName: string;
|
|
5
5
|
forcedMode?: string;
|
|
6
6
|
forcedAddOns?: Array<string>;
|
|
7
|
+
forcedHost?: string;
|
|
7
8
|
defaultTemplate?: TemplateOptions;
|
|
8
9
|
defaultFramework?: string;
|
|
9
10
|
craCompatible?: boolean;
|
|
@@ -2,4 +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
|
+
forcedHost?: string;
|
|
5
6
|
}): Promise<Options | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/cta-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Tanstack Application Builder CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"semver": "^7.7.2",
|
|
32
32
|
"zod": "^3.24.2",
|
|
33
33
|
"@tanstack/cta-engine": "0.29.1",
|
|
34
|
-
"@tanstack/cta-ui": "0.30.
|
|
34
|
+
"@tanstack/cta-ui": "0.30.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@tanstack/config": "^0.16.2",
|
package/src/cli.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
createApp,
|
|
14
14
|
createSerializedOptions,
|
|
15
15
|
getAllAddOns,
|
|
16
|
-
getFrameworkById,
|
|
17
16
|
getFrameworkByName,
|
|
18
17
|
getFrameworks,
|
|
19
18
|
initAddOn,
|
|
@@ -41,6 +40,7 @@ export function cli({
|
|
|
41
40
|
forcedMode,
|
|
42
41
|
forcedAddOns = [],
|
|
43
42
|
defaultTemplate = 'javascript',
|
|
43
|
+
forcedHost,
|
|
44
44
|
defaultFramework,
|
|
45
45
|
craCompatible = false,
|
|
46
46
|
webBase,
|
|
@@ -49,6 +49,7 @@ export function cli({
|
|
|
49
49
|
appName: string
|
|
50
50
|
forcedMode?: string
|
|
51
51
|
forcedAddOns?: Array<string>
|
|
52
|
+
forcedHost?: string
|
|
52
53
|
defaultTemplate?: TemplateOptions
|
|
53
54
|
defaultFramework?: string
|
|
54
55
|
craCompatible?: boolean
|
|
@@ -353,7 +354,10 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
353
354
|
},
|
|
354
355
|
)
|
|
355
356
|
.option('--list-add-ons', 'list all available add-ons', false)
|
|
356
|
-
.option(
|
|
357
|
+
.option(
|
|
358
|
+
'--addon-details <addon-id>',
|
|
359
|
+
'show detailed information about a specific add-on',
|
|
360
|
+
)
|
|
357
361
|
.option('--no-git', 'do not create a git repository')
|
|
358
362
|
.option(
|
|
359
363
|
'--target-dir <path>',
|
|
@@ -362,7 +366,10 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
362
366
|
.option('--mcp', 'run the MCP server', false)
|
|
363
367
|
.option('--mcp-sse', 'run the MCP server in SSE mode', false)
|
|
364
368
|
.option('--ui', 'Add with the UI')
|
|
365
|
-
.option(
|
|
369
|
+
.option(
|
|
370
|
+
'--add-on-config <config>',
|
|
371
|
+
'JSON string with add-on configuration options',
|
|
372
|
+
)
|
|
366
373
|
|
|
367
374
|
program.action(async (projectName: string, options: CliOptions) => {
|
|
368
375
|
if (options.listAddOns) {
|
|
@@ -373,10 +380,13 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
373
380
|
)
|
|
374
381
|
let hasConfigurableAddOns = false
|
|
375
382
|
for (const addOn of addOns.filter((a) => !forcedAddOns.includes(a.id))) {
|
|
376
|
-
const hasOptions =
|
|
383
|
+
const hasOptions =
|
|
384
|
+
addOn.options && Object.keys(addOn.options).length > 0
|
|
377
385
|
const optionMarker = hasOptions ? '*' : ' '
|
|
378
386
|
if (hasOptions) hasConfigurableAddOns = true
|
|
379
|
-
console.log(
|
|
387
|
+
console.log(
|
|
388
|
+
`${optionMarker} ${chalk.bold(addOn.id)}: ${addOn.description}`,
|
|
389
|
+
)
|
|
380
390
|
}
|
|
381
391
|
if (hasConfigurableAddOns) {
|
|
382
392
|
console.log('\n* = has configuration options')
|
|
@@ -392,22 +402,26 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
392
402
|
console.error(`Add-on '${options.addonDetails}' not found`)
|
|
393
403
|
process.exit(1)
|
|
394
404
|
}
|
|
395
|
-
|
|
396
|
-
console.log(
|
|
405
|
+
|
|
406
|
+
console.log(
|
|
407
|
+
`${chalk.bold.cyan('Add-on Details:')} ${chalk.bold(addOn.name)}`,
|
|
408
|
+
)
|
|
397
409
|
console.log(`${chalk.bold('ID:')} ${addOn.id}`)
|
|
398
410
|
console.log(`${chalk.bold('Description:')} ${addOn.description}`)
|
|
399
411
|
console.log(`${chalk.bold('Type:')} ${addOn.type}`)
|
|
400
412
|
console.log(`${chalk.bold('Phase:')} ${addOn.phase}`)
|
|
401
413
|
console.log(`${chalk.bold('Supported Modes:')} ${addOn.modes.join(', ')}`)
|
|
402
|
-
|
|
414
|
+
|
|
403
415
|
if (addOn.link) {
|
|
404
416
|
console.log(`${chalk.bold('Link:')} ${chalk.blue(addOn.link)}`)
|
|
405
417
|
}
|
|
406
|
-
|
|
418
|
+
|
|
407
419
|
if (addOn.dependsOn && addOn.dependsOn.length > 0) {
|
|
408
|
-
console.log(
|
|
420
|
+
console.log(
|
|
421
|
+
`${chalk.bold('Dependencies:')} ${addOn.dependsOn.join(', ')}`,
|
|
422
|
+
)
|
|
409
423
|
}
|
|
410
|
-
|
|
424
|
+
|
|
411
425
|
if (addOn.options && Object.keys(addOn.options).length > 0) {
|
|
412
426
|
console.log(`\n${chalk.bold.yellow('Configuration Options:')}`)
|
|
413
427
|
for (const [optionName, option] of Object.entries(addOn.options)) {
|
|
@@ -431,7 +445,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
431
445
|
} else {
|
|
432
446
|
console.log(`\n${chalk.gray('No configuration options available')}`)
|
|
433
447
|
}
|
|
434
|
-
|
|
448
|
+
|
|
435
449
|
if (addOn.routes && addOn.routes.length > 0) {
|
|
436
450
|
console.log(`\n${chalk.bold.green('Routes:')}`)
|
|
437
451
|
for (const route of addOn.routes) {
|
|
@@ -468,6 +482,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
468
482
|
cliOptions,
|
|
469
483
|
defaultMode,
|
|
470
484
|
forcedAddOns,
|
|
485
|
+
{ forcedHost },
|
|
471
486
|
)
|
|
472
487
|
}
|
|
473
488
|
|
|
@@ -476,7 +491,7 @@ Remove your node_modules directory and package lock file and re-install.`,
|
|
|
476
491
|
cliOptions,
|
|
477
492
|
defaultMode,
|
|
478
493
|
forcedAddOns,
|
|
479
|
-
{ disableNameCheck: true },
|
|
494
|
+
{ disableNameCheck: true, forcedHost },
|
|
480
495
|
)
|
|
481
496
|
const options = {
|
|
482
497
|
...createSerializedOptions(optionsFromCLI!),
|
package/src/command-line.ts
CHANGED
|
@@ -19,6 +19,7 @@ export async function normalizeOptions(
|
|
|
19
19
|
forcedAddOns?: Array<string>,
|
|
20
20
|
opts?: {
|
|
21
21
|
disableNameCheck?: boolean
|
|
22
|
+
forcedHost?: string
|
|
22
23
|
},
|
|
23
24
|
): Promise<Options | undefined> {
|
|
24
25
|
const projectName = (cliOptions.projectName ?? '').trim()
|
|
@@ -94,8 +95,8 @@ export async function normalizeOptions(
|
|
|
94
95
|
selectedAddOns.add(cliOptions.host)
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
if (!cliOptions.host) {
|
|
98
|
-
selectedAddOns.add(
|
|
98
|
+
if (!cliOptions.host && opts?.forcedHost) {
|
|
99
|
+
selectedAddOns.add(opts.forcedHost)
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
return await finalizeAddOns(framework, mode, Array.from(selectedAddOns))
|
|
@@ -137,7 +138,7 @@ export async function normalizeOptions(
|
|
|
137
138
|
chosenAddOns,
|
|
138
139
|
addOnOptions: {
|
|
139
140
|
...populateAddOnOptionsDefaults(chosenAddOns),
|
|
140
|
-
...addOnOptionsFromCLI
|
|
141
|
+
...addOnOptionsFromCLI,
|
|
141
142
|
},
|
|
142
143
|
starter: starter,
|
|
143
144
|
}
|
package/src/options.ts
CHANGED
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
promptForAddOnOptions,
|
|
14
14
|
selectAddOns,
|
|
15
15
|
selectGit,
|
|
16
|
+
selectHost,
|
|
16
17
|
selectPackageManager,
|
|
17
18
|
selectRouterType,
|
|
18
19
|
selectTailwind,
|
|
19
20
|
selectToolchain,
|
|
20
|
-
selectHost,
|
|
21
21
|
selectTypescript,
|
|
22
22
|
} from './ui-prompts.js'
|
|
23
23
|
|
|
@@ -145,7 +145,10 @@ export async function promptForCreateOptions(
|
|
|
145
145
|
options.addOnOptions = populateAddOnOptionsDefaults(options.chosenAddOns)
|
|
146
146
|
} else {
|
|
147
147
|
// Interactive mode: prompt for options
|
|
148
|
-
const userOptions = await promptForAddOnOptions(
|
|
148
|
+
const userOptions = await promptForAddOnOptions(
|
|
149
|
+
options.chosenAddOns.map((a) => a.id),
|
|
150
|
+
options.framework,
|
|
151
|
+
)
|
|
149
152
|
const defaultOptions = populateAddOnOptionsDefaults(options.chosenAddOns)
|
|
150
153
|
// Merge user options with defaults
|
|
151
154
|
options.addOnOptions = { ...defaultOptions, ...userOptions }
|