Skip to content

Commit 424c4a7

Browse files
committed
simplify flag
1 parent 84bd24c commit 424c4a7

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/cli/commands/create.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@ import * as common from '../common.js';
1515
import { runAddCommand } from './add/index.ts';
1616
import { detectSync, type AgentName } from 'package-manager-detector';
1717

18-
const langs = ['typescript', 'checkjs', 'none'] as const;
18+
const langs = ['ts', 'jsdoc'] as const;
19+
const langMap: Record<string, LanguageType | undefined> = {
20+
ts: 'typescript',
21+
jsdoc: 'checkjs',
22+
false: 'none'
23+
};
1924
const templateChoices = templates.map((t) => t.name);
20-
const langOption = new Option('--check-types <lang>', 'add type checking').choices(langs);
25+
const langOption = new Option('--types <lang>', 'adds type checking').choices(langs);
2126
const templateOption = new Option('--template <type>', 'template to scaffold').choices(
2227
templateChoices
2328
);
2429

2530
const ProjectPathSchema = v.string();
2631
const OptionsSchema = v.strictObject({
27-
checkTypes: v.optional(v.picklist(langs)),
32+
types: v.pipe(
33+
v.optional(v.union([v.picklist(langs), v.boolean()])),
34+
v.transform((lang) => langMap[String(lang)])
35+
),
2836
integrations: v.boolean(),
2937
install: v.boolean(),
3038
template: v.optional(v.picklist(templateChoices))
@@ -34,8 +42,9 @@ type Options = v.InferOutput<typeof OptionsSchema>;
3442
export const create = new Command('create')
3543
.description('scaffolds a new SvelteKit project')
3644
.argument('[path]', 'where the project will be created', process.cwd())
37-
.addOption(langOption)
3845
.addOption(templateOption)
46+
.addOption(langOption)
47+
.option('--no-types')
3948
.option('--no-integrations', 'skips interactive integration installer')
4049
.option('--no-install', 'skips installing dependencies')
4150
.configureHelp(common.helpConfig)
@@ -113,7 +122,7 @@ async function createProject(cwd: string, options: Options) {
113122
});
114123
},
115124
language: () => {
116-
if (options.checkTypes) return Promise.resolve(options.checkTypes);
125+
if (options.types) return Promise.resolve(options.types);
117126
return p.select<LanguageType>({
118127
message: 'Add type checking with Typescript?',
119128
initialValue: 'typescript',

0 commit comments

Comments
 (0)