Skip to content

Commit f2fcb1c

Browse files
committed
feat: add more command-line arguments
Added template positional, and selectors for typescript and javascript
1 parent 233d8ce commit f2fcb1c

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

packages/create/src/index.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,38 @@ export const createSolid = (version: string) =>
4242
alias: "p",
4343
description: "Project name",
4444
},
45+
template: {
46+
type: "string",
47+
required: false,
48+
alias: "t",
49+
description: "Template name",
50+
},
4551
"solidstart": {
4652
type: "boolean",
4753
required: false,
4854
alias: "s",
4955
description: "Create a SolidStart project",
5056
},
57+
"ts": {
58+
type: "boolean",
59+
required: false,
60+
description: "Use typescript"
61+
},
62+
"js": {
63+
type: "boolean",
64+
required: false,
65+
description: "Use javascript"
66+
}
5167
},
5268
async run({
53-
args: { projectNamePositional, templatePositional, "project-name": projectNameOptional, solidstart },
69+
args: { projectNamePositional, templatePositional, "project-name": projectNameOptional, template: templateOptional, solidstart, ts, js },
5470
}) {
5571
// Show prompts for any unknown arguments
5672
let projectName: string = projectNamePositional ?? projectNameOptional;
57-
let template: string = templatePositional;
73+
let template: string = templatePositional ?? templateOptional;
5874
let projectType: ProjectType | undefined = solidstart ? "start" : undefined;
75+
// False if user has selected ts, true if they have selected js, and undefined if they've done neither
76+
let useJS = ts ? !ts : js ? js : undefined;
5977
projectName ??= await cancelable(
6078
p.text({ message: "Project Name", placeholder: "solid-project", defaultValue: "solid-project" }),
6179
);
@@ -70,7 +88,7 @@ export const createSolid = (version: string) =>
7088
}),
7189
);
7290
// Don't offer javascript if `projectType` is library
73-
const useJS = projectType === "library" ? false : !(await cancelable(p.confirm({ message: "Use Typescript?" })));
91+
useJS ??= projectType === "library" ? false : !(await cancelable(p.confirm({ message: "Use Typescript?" })));
7492

7593
const template_opts = getTemplatesList(projectType);
7694
template ??= await cancelable(

0 commit comments

Comments
 (0)