@sigx/cli 0.2.8 → 0.3.1
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/README.md +8 -59
- package/dist/cli.js +59 -6
- package/dist/cli.js.map +1 -1
- package/dist/commands/create.d.ts +1 -1
- package/dist/commands/create.js +48 -413
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/scaffold.js +165 -0
- package/dist/commands/scaffold.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/plugin.d.ts +56 -0
- package/dist/plugin.js.map +1 -1
- package/dist/shell/index.d.ts +23 -0
- package/dist/shell/index.js +503 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/templates/lynx/package.json +1 -1
- package/dist/templates/lynx/src/lynx-env.d.ts +1 -0
- package/dist/templates/lynx/src/main.tsx +2 -2
- package/dist/templates/lynx-daisyui/package.json +1 -1
- package/dist/templates/lynx-daisyui/src/lynx-env.d.ts +1 -0
- package/dist/templates/lynx-daisyui/src/main.tsx +2 -2
- package/dist/templates/lynx-tailwind/package.json +1 -1
- package/dist/templates/lynx-tailwind/src/lynx-env.d.ts +1 -0
- package/dist/templates/lynx-tailwind/src/main.tsx +2 -2
- package/dist/templates/ssg/package.json +1 -1
- package/dist/templates/ssg-daisyui/package.json +1 -1
- package/dist/templates/ssg-tailwind/package.json +1 -1
- package/package.json +7 -3
- package/templates/lynx/package.json +1 -1
- package/templates/lynx/src/lynx-env.d.ts +1 -0
- package/templates/lynx/src/main.tsx +2 -2
- package/templates/lynx-daisyui/package.json +1 -1
- package/templates/lynx-daisyui/src/lynx-env.d.ts +1 -0
- package/templates/lynx-daisyui/src/main.tsx +2 -2
- package/templates/lynx-tailwind/package.json +1 -1
- package/templates/lynx-tailwind/src/lynx-env.d.ts +1 -0
- package/templates/lynx-tailwind/src/main.tsx +2 -2
- package/templates/ssg/package.json +1 -1
- package/templates/ssg-daisyui/package.json +1 -1
- package/templates/ssg-tailwind/package.json +1 -1
package/dist/commands/create.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { lynxStylingOptions, projectTypeOptions, scaffoldProject, webStylingOptions } from "./scaffold.js";
|
|
2
|
+
import { cancel, intro, isCancel, note, outro, select, spinner, text } from "@sigx/terminal";
|
|
3
|
+
//#region src/commands/create.ts
|
|
4
|
+
/**
|
|
5
|
+
* `sigx create` — interactive scaffolder on the @sigx/terminal prompt kit,
|
|
6
|
+
* with a flag-driven headless mode for CI (`--type`, `--styling`, `--yes`,
|
|
7
|
+
* or any non-TTY stdio).
|
|
8
|
+
*/
|
|
9
9
|
var rawArgs = process.argv.slice(2);
|
|
10
10
|
function getFlag(name) {
|
|
11
11
|
const eq = rawArgs.find((a) => a.startsWith(`--${name}=`));
|
|
@@ -21,408 +21,6 @@ var argType = getFlag("type");
|
|
|
21
21
|
var argStyling = getFlag("styling");
|
|
22
22
|
var flagYes = hasFlag("yes", "y");
|
|
23
23
|
var isNonInteractive = !process.stdout.isTTY || !process.stdin.isTTY || flagYes || Boolean(argType && argProjectName);
|
|
24
|
-
var projectTypeOptions = [
|
|
25
|
-
{
|
|
26
|
-
value: "basic",
|
|
27
|
-
label: "Basic SPA",
|
|
28
|
-
description: "Simple single-page application (web)"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
value: "ssr",
|
|
32
|
-
label: "SSR",
|
|
33
|
-
description: "Server-side rendering with Express (web)"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
value: "ssg",
|
|
37
|
-
label: "SSG",
|
|
38
|
-
description: "Static site with file-based routing & MDX (web)"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
value: "lynx",
|
|
42
|
-
label: "Lynx",
|
|
43
|
-
description: "Native mobile app with Lynx runtime"
|
|
44
|
-
}
|
|
45
|
-
];
|
|
46
|
-
var webStylingOptions = [
|
|
47
|
-
{
|
|
48
|
-
value: "none",
|
|
49
|
-
label: "None",
|
|
50
|
-
description: "No CSS framework"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
value: "tailwind",
|
|
54
|
-
label: "Tailwind CSS",
|
|
55
|
-
description: "Utility-first CSS framework"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
value: "daisyui",
|
|
59
|
-
label: "Tailwind + Daisy UI",
|
|
60
|
-
description: "Tailwind with component library"
|
|
61
|
-
}
|
|
62
|
-
];
|
|
63
|
-
var lynxStylingOptions = [
|
|
64
|
-
{
|
|
65
|
-
value: "none",
|
|
66
|
-
label: "None",
|
|
67
|
-
description: "No CSS framework"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
value: "tailwind",
|
|
71
|
-
label: "Tailwind CSS",
|
|
72
|
-
description: "Tailwind with Lynx preset"
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
value: "daisyui",
|
|
76
|
-
label: "Tailwind + Daisy UI",
|
|
77
|
-
description: "Lynx + @sigx/lynx-daisyui components"
|
|
78
|
-
}
|
|
79
|
-
];
|
|
80
|
-
var TEXT_EXTS = new Set([
|
|
81
|
-
"ts",
|
|
82
|
-
"tsx",
|
|
83
|
-
"js",
|
|
84
|
-
"jsx",
|
|
85
|
-
"mjs",
|
|
86
|
-
"cjs",
|
|
87
|
-
"mts",
|
|
88
|
-
"cts",
|
|
89
|
-
"json",
|
|
90
|
-
"json5",
|
|
91
|
-
"jsonc",
|
|
92
|
-
"md",
|
|
93
|
-
"mdx",
|
|
94
|
-
"txt",
|
|
95
|
-
"html",
|
|
96
|
-
"htm",
|
|
97
|
-
"css",
|
|
98
|
-
"scss",
|
|
99
|
-
"sass",
|
|
100
|
-
"less",
|
|
101
|
-
"yml",
|
|
102
|
-
"yaml",
|
|
103
|
-
"toml",
|
|
104
|
-
"xml",
|
|
105
|
-
"svg",
|
|
106
|
-
"gitignore",
|
|
107
|
-
"gitattributes",
|
|
108
|
-
"editorconfig",
|
|
109
|
-
"npmrc",
|
|
110
|
-
"nvmrc",
|
|
111
|
-
"env"
|
|
112
|
-
]);
|
|
113
|
-
function isTextExtension(filename) {
|
|
114
|
-
const ext = filename.startsWith(".") ? filename.slice(1).toLowerCase() : filename.split(".").pop()?.toLowerCase() ?? "";
|
|
115
|
-
return TEXT_EXTS.has(ext);
|
|
116
|
-
}
|
|
117
|
-
function copyDirectory(src, dest, projectName) {
|
|
118
|
-
if (!existsSync(dest)) mkdirSync(dest, { recursive: true });
|
|
119
|
-
const entries = readdirSync(src);
|
|
120
|
-
for (const entry of entries) {
|
|
121
|
-
const srcPath = join(src, entry);
|
|
122
|
-
const destPath = join(dest, entry === "gitignore" ? ".gitignore" : entry);
|
|
123
|
-
if (statSync(srcPath).isDirectory()) copyDirectory(srcPath, destPath, projectName);
|
|
124
|
-
else if (isTextExtension(entry)) {
|
|
125
|
-
let content = readFileSync(srcPath, "utf-8");
|
|
126
|
-
content = content.replace(/\{\{projectName\}\}/g, projectName);
|
|
127
|
-
writeFileSync(destPath, content);
|
|
128
|
-
} else writeFileSync(destPath, readFileSync(srcPath));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Detect if the target directory is inside a pnpm workspace that includes @sigx packages.
|
|
133
|
-
* If so, rewrite @sigx/* dependency versions to workspace:* in package.json.
|
|
134
|
-
*/
|
|
135
|
-
function patchWorkspaceDeps(targetDir) {
|
|
136
|
-
const pkgPath = join(targetDir, "package.json");
|
|
137
|
-
if (!existsSync(pkgPath)) return;
|
|
138
|
-
let dir = dirname(targetDir);
|
|
139
|
-
let isWorkspace = false;
|
|
140
|
-
for (let i = 0; i < 10; i++) {
|
|
141
|
-
if (existsSync(join(dir, "pnpm-workspace.yaml"))) {
|
|
142
|
-
isWorkspace = true;
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
const parent = dirname(dir);
|
|
146
|
-
if (parent === dir) break;
|
|
147
|
-
dir = parent;
|
|
148
|
-
}
|
|
149
|
-
if (!isWorkspace) return;
|
|
150
|
-
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
151
|
-
for (const section of ["dependencies", "devDependencies"]) {
|
|
152
|
-
if (!pkg[section]) continue;
|
|
153
|
-
for (const dep of Object.keys(pkg[section])) if (dep.startsWith("@sigx/")) pkg[section][dep] = "workspace:*";
|
|
154
|
-
}
|
|
155
|
-
writeFileSync(pkgPath, JSON.stringify(pkg, null, 4) + "\n");
|
|
156
|
-
}
|
|
157
|
-
function scaffoldProject(opts) {
|
|
158
|
-
const targetDir = resolve(process.cwd(), opts.projectName);
|
|
159
|
-
let templateName;
|
|
160
|
-
if (opts.projectType === "lynx") templateName = opts.styling !== "none" ? `lynx-${opts.styling}` : "lynx";
|
|
161
|
-
else templateName = opts.styling !== "none" ? `${opts.projectType}-${opts.styling}` : opts.projectType;
|
|
162
|
-
const templateDir = resolve(__dirname, "..", "templates", templateName);
|
|
163
|
-
if (existsSync(targetDir)) return {
|
|
164
|
-
ok: false,
|
|
165
|
-
error: `Directory "${opts.projectName}" already exists!`
|
|
166
|
-
};
|
|
167
|
-
if (!existsSync(templateDir)) return {
|
|
168
|
-
ok: false,
|
|
169
|
-
error: `Template "${templateName}" not found at ${templateDir}`
|
|
170
|
-
};
|
|
171
|
-
copyDirectory(templateDir, targetDir, opts.projectName);
|
|
172
|
-
patchWorkspaceDeps(targetDir);
|
|
173
|
-
return { ok: true };
|
|
174
|
-
}
|
|
175
|
-
var projectTypeLabel = (t) => {
|
|
176
|
-
switch (t) {
|
|
177
|
-
case "basic": return "Basic SPA";
|
|
178
|
-
case "ssr": return "SSR";
|
|
179
|
-
case "ssg": return "SSG";
|
|
180
|
-
case "lynx": return "Lynx (Native)";
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
var stylingLabel = (s) => {
|
|
184
|
-
switch (s) {
|
|
185
|
-
case "none": return "None";
|
|
186
|
-
case "tailwind": return "Tailwind CSS";
|
|
187
|
-
case "daisyui": return "Tailwind + Daisy UI";
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
var StepName = component(({ props }) => () => /* @__PURE__ */ jsxs("box", { children: [
|
|
191
|
-
/* @__PURE__ */ jsx("text", {
|
|
192
|
-
color: "gray",
|
|
193
|
-
children: " Step 1 of 3"
|
|
194
|
-
}),
|
|
195
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
196
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
197
|
-
/* @__PURE__ */ jsx("text", {
|
|
198
|
-
color: "white",
|
|
199
|
-
children: " What is your project called?"
|
|
200
|
-
}),
|
|
201
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
202
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
203
|
-
/* @__PURE__ */ jsx(Input, {
|
|
204
|
-
model: () => props.state.projectName,
|
|
205
|
-
label: " Project Name ",
|
|
206
|
-
placeholder: "my-sigx-app",
|
|
207
|
-
autofocus: true,
|
|
208
|
-
onSubmit: props.onSubmit
|
|
209
|
-
}),
|
|
210
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
211
|
-
/* @__PURE__ */ jsx("text", {
|
|
212
|
-
color: "gray",
|
|
213
|
-
children: " Press Enter to continue"
|
|
214
|
-
})
|
|
215
|
-
] }), { name: "StepName" });
|
|
216
|
-
var StepType = component(({ props }) => () => /* @__PURE__ */ jsxs("box", { children: [
|
|
217
|
-
/* @__PURE__ */ jsx("text", {
|
|
218
|
-
color: "gray",
|
|
219
|
-
children: " Step 2 of 3"
|
|
220
|
-
}),
|
|
221
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
222
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
223
|
-
/* @__PURE__ */ jsx("text", {
|
|
224
|
-
color: "white",
|
|
225
|
-
children: " What type of project?"
|
|
226
|
-
}),
|
|
227
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
228
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
229
|
-
/* @__PURE__ */ jsx(Select, {
|
|
230
|
-
model: () => props.state.projectType,
|
|
231
|
-
label: " Project Type ",
|
|
232
|
-
options: projectTypeOptions,
|
|
233
|
-
showDescription: true,
|
|
234
|
-
autofocus: true,
|
|
235
|
-
onSubmit: props.onSubmit
|
|
236
|
-
}),
|
|
237
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
238
|
-
/* @__PURE__ */ jsx("text", {
|
|
239
|
-
color: "gray",
|
|
240
|
-
children: " ↑/↓ navigate · Enter select"
|
|
241
|
-
})
|
|
242
|
-
] }), { name: "StepType" });
|
|
243
|
-
var StepStyling = component(({ props }) => () => /* @__PURE__ */ jsxs("box", { children: [
|
|
244
|
-
/* @__PURE__ */ jsx("text", {
|
|
245
|
-
color: "gray",
|
|
246
|
-
children: " Step 3 of 3"
|
|
247
|
-
}),
|
|
248
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
249
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
250
|
-
/* @__PURE__ */ jsx("text", {
|
|
251
|
-
color: "white",
|
|
252
|
-
children: " Choose a styling approach:"
|
|
253
|
-
}),
|
|
254
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
255
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
256
|
-
/* @__PURE__ */ jsx(Select, {
|
|
257
|
-
model: () => props.state.styling,
|
|
258
|
-
label: " Styling ",
|
|
259
|
-
options: props.state.projectType === "lynx" ? lynxStylingOptions : webStylingOptions,
|
|
260
|
-
showDescription: true,
|
|
261
|
-
autofocus: true,
|
|
262
|
-
onSubmit: props.onSubmit
|
|
263
|
-
}),
|
|
264
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
265
|
-
/* @__PURE__ */ jsx("text", {
|
|
266
|
-
color: "gray",
|
|
267
|
-
children: " ↑/↓ navigate · Enter select"
|
|
268
|
-
})
|
|
269
|
-
] }), { name: "StepStyling" });
|
|
270
|
-
var StepCreating = component(({ props }) => () => /* @__PURE__ */ jsxs("box", { children: [
|
|
271
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
272
|
-
/* @__PURE__ */ jsx("text", {
|
|
273
|
-
color: "yellow",
|
|
274
|
-
children: " Creating project..."
|
|
275
|
-
}),
|
|
276
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
277
|
-
/* @__PURE__ */ jsx(ProgressBar, {
|
|
278
|
-
value: props.state.progress,
|
|
279
|
-
max: 100,
|
|
280
|
-
width: 40,
|
|
281
|
-
color: "green"
|
|
282
|
-
})
|
|
283
|
-
] }), { name: "StepCreating" });
|
|
284
|
-
var StepDone = component(({ props }) => () => /* @__PURE__ */ jsxs("box", { children: [
|
|
285
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
286
|
-
/* @__PURE__ */ jsxs("text", {
|
|
287
|
-
color: "green",
|
|
288
|
-
children: [
|
|
289
|
-
" ✓ Project \"",
|
|
290
|
-
props.state.projectName,
|
|
291
|
-
"\" created!"
|
|
292
|
-
]
|
|
293
|
-
}),
|
|
294
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
295
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
296
|
-
/* @__PURE__ */ jsxs("text", {
|
|
297
|
-
color: "gray",
|
|
298
|
-
children: [" Type: ", projectTypeLabel(props.state.projectType)]
|
|
299
|
-
}),
|
|
300
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
301
|
-
/* @__PURE__ */ jsxs("text", {
|
|
302
|
-
color: "gray",
|
|
303
|
-
children: [" Styling: ", stylingLabel(props.state.styling)]
|
|
304
|
-
}),
|
|
305
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
306
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
307
|
-
/* @__PURE__ */ jsx("text", {
|
|
308
|
-
color: "white",
|
|
309
|
-
children: " Next steps:"
|
|
310
|
-
}),
|
|
311
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
312
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
313
|
-
/* @__PURE__ */ jsxs("text", {
|
|
314
|
-
color: "cyan",
|
|
315
|
-
children: [" cd ", props.state.projectName]
|
|
316
|
-
}),
|
|
317
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
318
|
-
/* @__PURE__ */ jsx("text", {
|
|
319
|
-
color: "cyan",
|
|
320
|
-
children: " pnpm install"
|
|
321
|
-
}),
|
|
322
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
323
|
-
/* @__PURE__ */ jsxs("text", {
|
|
324
|
-
color: "cyan",
|
|
325
|
-
children: [" ", props.state.projectType === "lynx" ? "sigx dev" : "pnpm dev"]
|
|
326
|
-
}),
|
|
327
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
328
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
329
|
-
/* @__PURE__ */ jsx(Button, {
|
|
330
|
-
label: "Exit",
|
|
331
|
-
onClick: props.onExit
|
|
332
|
-
})
|
|
333
|
-
] }), { name: "StepDone" });
|
|
334
|
-
var ErrorScreen = component(({ props }) => () => /* @__PURE__ */ jsxs("box", {
|
|
335
|
-
border: "double",
|
|
336
|
-
borderColor: "red",
|
|
337
|
-
label: " Error ",
|
|
338
|
-
children: [
|
|
339
|
-
/* @__PURE__ */ jsxs("text", {
|
|
340
|
-
color: "red",
|
|
341
|
-
children: [" ", props.message]
|
|
342
|
-
}),
|
|
343
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
344
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
345
|
-
/* @__PURE__ */ jsx(Button, {
|
|
346
|
-
label: "Exit",
|
|
347
|
-
onClick: props.onExit
|
|
348
|
-
})
|
|
349
|
-
]
|
|
350
|
-
}), { name: "ErrorScreen" });
|
|
351
|
-
var CreateSigx = component(() => {
|
|
352
|
-
const state = signal({
|
|
353
|
-
step: "name",
|
|
354
|
-
projectName: argProjectName || "my-sigx-app",
|
|
355
|
-
projectType: "basic",
|
|
356
|
-
styling: "none",
|
|
357
|
-
progress: 0,
|
|
358
|
-
error: ""
|
|
359
|
-
});
|
|
360
|
-
const createProject = () => {
|
|
361
|
-
if (state.step !== "styling") return;
|
|
362
|
-
state.step = "creating";
|
|
363
|
-
state.progress = 30;
|
|
364
|
-
const result = scaffoldProject({
|
|
365
|
-
projectName: state.projectName,
|
|
366
|
-
projectType: state.projectType,
|
|
367
|
-
styling: state.styling
|
|
368
|
-
});
|
|
369
|
-
if (!result.ok) {
|
|
370
|
-
state.error = result.error;
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
state.progress = 100;
|
|
374
|
-
state.step = "done";
|
|
375
|
-
};
|
|
376
|
-
const handleNameSubmit = () => {
|
|
377
|
-
if (state.step !== "name") return;
|
|
378
|
-
if (state.projectName.trim()) state.step = "type";
|
|
379
|
-
};
|
|
380
|
-
const handleTypeSubmit = () => {
|
|
381
|
-
if (state.step !== "type") return;
|
|
382
|
-
state.step = "styling";
|
|
383
|
-
};
|
|
384
|
-
const handleStylingSubmit = () => {
|
|
385
|
-
if (state.step !== "styling") return;
|
|
386
|
-
createProject();
|
|
387
|
-
};
|
|
388
|
-
const handleExit = () => {
|
|
389
|
-
process.exit(0);
|
|
390
|
-
};
|
|
391
|
-
return () => {
|
|
392
|
-
if (state.error) return /* @__PURE__ */ jsx(ErrorScreen, {
|
|
393
|
-
message: state.error,
|
|
394
|
-
onExit: handleExit
|
|
395
|
-
});
|
|
396
|
-
return /* @__PURE__ */ jsxs("box", { children: [
|
|
397
|
-
/* @__PURE__ */ jsx("text", {
|
|
398
|
-
color: "cyan",
|
|
399
|
-
children: " ⚡ Create SignalX App"
|
|
400
|
-
}),
|
|
401
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
402
|
-
(() => {
|
|
403
|
-
switch (state.step) {
|
|
404
|
-
case "name": return /* @__PURE__ */ jsx(StepName, {
|
|
405
|
-
state,
|
|
406
|
-
onSubmit: handleNameSubmit
|
|
407
|
-
});
|
|
408
|
-
case "type": return /* @__PURE__ */ jsx(StepType, {
|
|
409
|
-
state,
|
|
410
|
-
onSubmit: handleTypeSubmit
|
|
411
|
-
});
|
|
412
|
-
case "styling": return /* @__PURE__ */ jsx(StepStyling, {
|
|
413
|
-
state,
|
|
414
|
-
onSubmit: handleStylingSubmit
|
|
415
|
-
});
|
|
416
|
-
case "creating": return /* @__PURE__ */ jsx(StepCreating, { state });
|
|
417
|
-
case "done": return /* @__PURE__ */ jsx(StepDone, {
|
|
418
|
-
state,
|
|
419
|
-
onExit: handleExit
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
})()
|
|
423
|
-
] });
|
|
424
|
-
};
|
|
425
|
-
});
|
|
426
24
|
function runHeadless() {
|
|
427
25
|
const validTypes = [
|
|
428
26
|
"basic",
|
|
@@ -465,10 +63,47 @@ function runHeadless() {
|
|
|
465
63
|
console.log(` ${projectType === "lynx" ? "sigx dev" : "pnpm dev"}\n`);
|
|
466
64
|
return 0;
|
|
467
65
|
}
|
|
468
|
-
function
|
|
66
|
+
function bail() {
|
|
67
|
+
cancel("Cancelled — nothing was created.");
|
|
68
|
+
process.exit(130);
|
|
69
|
+
}
|
|
70
|
+
async function runCreate() {
|
|
469
71
|
if (isNonInteractive) process.exit(runHeadless());
|
|
470
|
-
|
|
471
|
-
|
|
72
|
+
intro("⚡ Create SignalX App");
|
|
73
|
+
const projectName = await text({
|
|
74
|
+
message: "Project name",
|
|
75
|
+
placeholder: "my-sigx-app",
|
|
76
|
+
initialValue: argProjectName || "my-sigx-app",
|
|
77
|
+
validate: (v) => v.trim() ? void 0 : "Project name is required"
|
|
78
|
+
});
|
|
79
|
+
if (isCancel(projectName)) bail();
|
|
80
|
+
const projectType = await select({
|
|
81
|
+
message: "Project type",
|
|
82
|
+
initialValue: argType ?? "basic",
|
|
83
|
+
options: projectTypeOptions
|
|
84
|
+
});
|
|
85
|
+
if (isCancel(projectType)) bail();
|
|
86
|
+
const styling = await select({
|
|
87
|
+
message: "Styling",
|
|
88
|
+
initialValue: argStyling ?? "none",
|
|
89
|
+
options: projectType === "lynx" ? lynxStylingOptions : webStylingOptions
|
|
90
|
+
});
|
|
91
|
+
if (isCancel(styling)) bail();
|
|
92
|
+
const s = spinner();
|
|
93
|
+
s.start(`Scaffolding ${projectName}`);
|
|
94
|
+
const result = scaffoldProject({
|
|
95
|
+
projectName,
|
|
96
|
+
projectType,
|
|
97
|
+
styling
|
|
98
|
+
});
|
|
99
|
+
if (!result.ok) {
|
|
100
|
+
s.stop(result.error, "error");
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
s.stop(`Created ${projectName} (${projectType}${styling !== "none" ? ` + ${styling}` : ""})`);
|
|
104
|
+
note(`cd ${projectName}\npnpm install\n${projectType === "lynx" ? "sigx dev" : "pnpm dev"}`, "Next steps");
|
|
105
|
+
outro("Happy hacking!");
|
|
106
|
+
process.exit(0);
|
|
472
107
|
}
|
|
473
108
|
//#endregion
|
|
474
109
|
export { runCreate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","names":[],"sources":["../../src/commands/create.tsx"],"sourcesContent":["/** @jsxImportSource @sigx/terminal */\nimport { signal, component, defineApp, Input, Button, ProgressBar, Select, type Define } from '@sigx/terminal';\nimport { existsSync, mkdirSync, readdirSync, statSync, writeFileSync, readFileSync } from 'fs';\nimport { dirname, resolve, join } from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\ntype Step = 'name' | 'type' | 'styling' | 'creating' | 'done';\ntype ProjectType = 'basic' | 'ssr' | 'ssg' | 'lynx';\ntype Styling = 'none' | 'tailwind' | 'daisyui';\n\n// Parse CLI args (supports both interactive default and --flag headless mode).\nconst rawArgs = process.argv.slice(2);\nfunction getFlag(name: string): string | undefined {\n const eq = rawArgs.find(a => a.startsWith(`--${name}=`));\n if (eq) return eq.slice(name.length + 3);\n const idx = rawArgs.indexOf(`--${name}`);\n if (idx !== -1 && rawArgs[idx + 1] && !rawArgs[idx + 1].startsWith('-')) return rawArgs[idx + 1];\n return undefined;\n}\nfunction hasFlag(name: string, short?: string): boolean {\n return rawArgs.includes(`--${name}`) || (short ? rawArgs.includes(`-${short}`) : false);\n}\nconst positionalArgs = rawArgs.filter(a => !a.startsWith('-') && a !== 'create');\nconst argProjectName = positionalArgs[0] || '';\nconst argType = getFlag('type') as ProjectType | undefined;\nconst argStyling = getFlag('styling') as Styling | undefined;\nconst flagYes = hasFlag('yes', 'y');\nconst isNonInteractive = !process.stdout.isTTY || !process.stdin.isTTY || flagYes\n || Boolean(argType && argProjectName);\n\nconst projectTypeOptions = [\n { value: 'basic' as ProjectType, label: 'Basic SPA', description: 'Simple single-page application (web)' },\n { value: 'ssr' as ProjectType, label: 'SSR', description: 'Server-side rendering with Express (web)' },\n { value: 'ssg' as ProjectType, label: 'SSG', description: 'Static site with file-based routing & MDX (web)' },\n { value: 'lynx' as ProjectType, label: 'Lynx', description: 'Native mobile app with Lynx runtime' },\n];\n\nconst webStylingOptions = [\n { value: 'none' as Styling, label: 'None', description: 'No CSS framework' },\n { value: 'tailwind' as Styling, label: 'Tailwind CSS', description: 'Utility-first CSS framework' },\n { value: 'daisyui' as Styling, label: 'Tailwind + Daisy UI', description: 'Tailwind with component library' },\n];\n\nconst lynxStylingOptions = [\n { value: 'none' as Styling, label: 'None', description: 'No CSS framework' },\n { value: 'tailwind' as Styling, label: 'Tailwind CSS', description: 'Tailwind with Lynx preset' },\n { value: 'daisyui' as Styling, label: 'Tailwind + Daisy UI', description: 'Lynx + @sigx/lynx-daisyui components' },\n];\n\nconst TEXT_EXTS = new Set([\n 'ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'mts', 'cts',\n 'json', 'json5', 'jsonc',\n 'md', 'mdx', 'txt',\n 'html', 'htm', 'css', 'scss', 'sass', 'less',\n 'yml', 'yaml', 'toml', 'xml', 'svg',\n 'gitignore', 'gitattributes', 'editorconfig', 'npmrc', 'nvmrc', 'env',\n]);\n\nfunction isTextExtension(filename: string): boolean {\n // Dotfiles: name after leading dot (.gitignore → \"gitignore\").\n const ext = filename.startsWith('.')\n ? filename.slice(1).toLowerCase()\n : filename.split('.').pop()?.toLowerCase() ?? '';\n return TEXT_EXTS.has(ext);\n}\n\nfunction copyDirectory(src: string, dest: string, projectName: string) {\n if (!existsSync(dest)) {\n mkdirSync(dest, { recursive: true });\n }\n\n const entries = readdirSync(src);\n for (const entry of entries) {\n const srcPath = join(src, entry);\n // Templates ship `gitignore` (no leading dot) because npm strips\n // `.gitignore` from the published tarball. Rename on copy so the\n // generated project has a real `.gitignore`.\n const destName = entry === 'gitignore' ? '.gitignore' : entry;\n const destPath = join(dest, destName);\n const stat = statSync(srcPath);\n\n if (stat.isDirectory()) {\n copyDirectory(srcPath, destPath, projectName);\n } else if (isTextExtension(entry)) {\n let content = readFileSync(srcPath, 'utf-8');\n content = content.replace(/\\{\\{projectName\\}\\}/g, projectName);\n writeFileSync(destPath, content);\n } else {\n // Binary asset — copy bytes verbatim. Reading as UTF-8 would corrupt\n // non-ASCII bytes (e.g. PNG magic 0x89 → U+FFFD).\n writeFileSync(destPath, readFileSync(srcPath));\n }\n }\n}\n\n/**\n * Detect if the target directory is inside a pnpm workspace that includes @sigx packages.\n * If so, rewrite @sigx/* dependency versions to workspace:* in package.json.\n */\nfunction patchWorkspaceDeps(targetDir: string) {\n const pkgPath = join(targetDir, 'package.json');\n if (!existsSync(pkgPath)) return;\n\n // Walk up to find pnpm-workspace.yaml\n let dir = dirname(targetDir);\n let isWorkspace = false;\n for (let i = 0; i < 10; i++) {\n if (existsSync(join(dir, 'pnpm-workspace.yaml'))) {\n isWorkspace = true;\n break;\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n if (!isWorkspace) return;\n\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n for (const section of ['dependencies', 'devDependencies'] as const) {\n if (!pkg[section]) continue;\n for (const dep of Object.keys(pkg[section])) {\n if (dep.startsWith('@sigx/')) {\n pkg[section][dep] = 'workspace:*';\n }\n }\n }\n writeFileSync(pkgPath, JSON.stringify(pkg, null, 4) + '\\n');\n}\n\nfunction scaffoldProject(opts: {\n projectName: string;\n projectType: ProjectType;\n styling: Styling;\n}): { ok: true } | { ok: false; error: string } {\n const targetDir = resolve(process.cwd(), opts.projectName);\n let templateName: string;\n if (opts.projectType === 'lynx') {\n templateName = opts.styling !== 'none' ? `lynx-${opts.styling}` : 'lynx';\n } else {\n templateName = opts.styling !== 'none' ? `${opts.projectType}-${opts.styling}` : opts.projectType;\n }\n const templateDir = resolve(__dirname, '..', 'templates', templateName);\n if (existsSync(targetDir)) return { ok: false, error: `Directory \"${opts.projectName}\" already exists!` };\n if (!existsSync(templateDir)) return { ok: false, error: `Template \"${templateName}\" not found at ${templateDir}` };\n copyDirectory(templateDir, targetDir, opts.projectName);\n patchWorkspaceDeps(targetDir);\n return { ok: true };\n}\n\ntype CreateState = {\n step: Step;\n projectName: string;\n projectType: ProjectType;\n styling: Styling;\n progress: number;\n error: string;\n};\n\nconst projectTypeLabel = (t: ProjectType): string => {\n switch (t) {\n case 'basic': return 'Basic SPA';\n case 'ssr': return 'SSR';\n case 'ssg': return 'SSG';\n case 'lynx': return 'Lynx (Native)';\n }\n};\n\nconst stylingLabel = (s: Styling): string => {\n switch (s) {\n case 'none': return 'None';\n case 'tailwind': return 'Tailwind CSS';\n case 'daisyui': return 'Tailwind + Daisy UI';\n }\n};\n\n// Each step is its own component so the reconciler sees a different\n// component type at the step slot on every transition. That forces a\n// clean unmount/remount of the focusable inside (Input/Select/Button),\n// which avoids the previous step's key handler lingering and re-firing\n// the submit chain on the next Enter press.\n\nconst StepName = component<\n Define.Prop<\"state\", CreateState, true> &\n Define.Prop<\"onSubmit\", () => void, true>\n>(({ props }) => () => (\n <box>\n <text color=\"gray\"> Step 1 of 3</text>\n <br />\n <br />\n <text color=\"white\"> What is your project called?</text>\n <br />\n <br />\n <Input\n model={() => props.state.projectName}\n label=\" Project Name \"\n placeholder=\"my-sigx-app\"\n autofocus\n onSubmit={props.onSubmit}\n />\n <br />\n <text color=\"gray\"> Press Enter to continue</text>\n </box>\n), { name: 'StepName' });\n\nconst StepType = component<\n Define.Prop<\"state\", CreateState, true> &\n Define.Prop<\"onSubmit\", () => void, true>\n>(({ props }) => () => (\n <box>\n <text color=\"gray\"> Step 2 of 3</text>\n <br />\n <br />\n <text color=\"white\"> What type of project?</text>\n <br />\n <br />\n <Select\n model={() => props.state.projectType}\n label=\" Project Type \"\n options={projectTypeOptions}\n showDescription\n autofocus\n onSubmit={props.onSubmit}\n />\n <br />\n <text color=\"gray\"> ↑/↓ navigate · Enter select</text>\n </box>\n), { name: 'StepType' });\n\nconst StepStyling = component<\n Define.Prop<\"state\", CreateState, true> &\n Define.Prop<\"onSubmit\", () => void, true>\n>(({ props }) => () => (\n <box>\n <text color=\"gray\"> Step 3 of 3</text>\n <br />\n <br />\n <text color=\"white\"> Choose a styling approach:</text>\n <br />\n <br />\n <Select\n model={() => props.state.styling}\n label=\" Styling \"\n options={props.state.projectType === 'lynx' ? lynxStylingOptions : webStylingOptions}\n showDescription\n autofocus\n onSubmit={props.onSubmit}\n />\n <br />\n <text color=\"gray\"> ↑/↓ navigate · Enter select</text>\n </box>\n), { name: 'StepStyling' });\n\nconst StepCreating = component<\n Define.Prop<\"state\", CreateState, true>\n>(({ props }) => () => (\n <box>\n <br />\n <text color=\"yellow\"> Creating project...</text>\n <br />\n <ProgressBar value={props.state.progress} max={100} width={40} color=\"green\" />\n </box>\n), { name: 'StepCreating' });\n\nconst StepDone = component<\n Define.Prop<\"state\", CreateState, true> &\n Define.Prop<\"onExit\", () => void, true>\n>(({ props }) => () => (\n <box>\n <br />\n <text color=\"green\"> ✓ Project \"{props.state.projectName}\" created!</text>\n <br />\n <br />\n <text color=\"gray\"> Type: {projectTypeLabel(props.state.projectType)}</text>\n <br />\n <text color=\"gray\"> Styling: {stylingLabel(props.state.styling)}</text>\n <br />\n <br />\n <text color=\"white\"> Next steps:</text>\n <br />\n <br />\n <text color=\"cyan\"> cd {props.state.projectName}</text>\n <br />\n <text color=\"cyan\"> pnpm install</text>\n <br />\n <text color=\"cyan\"> {props.state.projectType === 'lynx' ? 'sigx dev' : 'pnpm dev'}</text>\n <br />\n <br />\n <Button label=\"Exit\" onClick={props.onExit} />\n </box>\n), { name: 'StepDone' });\n\nconst ErrorScreen = component<\n Define.Prop<\"message\", string, true> &\n Define.Prop<\"onExit\", () => void, true>\n>(({ props }) => () => (\n <box border=\"double\" borderColor=\"red\" label=\" Error \">\n <text color=\"red\"> {props.message}</text>\n <br />\n <br />\n <Button label=\"Exit\" onClick={props.onExit} />\n </box>\n), { name: 'ErrorScreen' });\n\nconst CreateSigx = component(() => {\n const state = signal<CreateState>({\n step: 'name' as Step,\n projectName: argProjectName || 'my-sigx-app',\n projectType: 'basic' as ProjectType,\n styling: 'none' as Styling,\n progress: 0,\n error: '',\n });\n\n // Defense in depth: gate each handler on the current step. If a\n // previous step's focusable lingers across a transition (reconciler\n // edge case observed in the TUI runtime) and its onSubmit fires on a\n // later Enter press, the guard makes it a no-op instead of re-running\n // the scaffolder or rewinding the wizard.\n const createProject = () => {\n if (state.step !== 'styling') return;\n state.step = 'creating';\n state.progress = 30;\n const result = scaffoldProject({\n projectName: state.projectName,\n projectType: state.projectType,\n styling: state.styling,\n });\n if (!result.ok) {\n state.error = result.error;\n return;\n }\n state.progress = 100;\n state.step = 'done';\n };\n\n const handleNameSubmit = () => {\n if (state.step !== 'name') return;\n if (state.projectName.trim()) {\n state.step = 'type';\n }\n };\n\n const handleTypeSubmit = () => {\n if (state.step !== 'type') return;\n state.step = 'styling';\n };\n\n const handleStylingSubmit = () => {\n if (state.step !== 'styling') return;\n createProject();\n };\n\n const handleExit = () => {\n process.exit(0);\n };\n\n return () => {\n if (state.error) {\n return <ErrorScreen message={state.error} onExit={handleExit} />;\n }\n\n return (\n <box>\n <text color=\"cyan\"> ⚡ Create SignalX App</text>\n <br />\n {(() => {\n switch (state.step) {\n case 'name': return <StepName state={state} onSubmit={handleNameSubmit} />;\n case 'type': return <StepType state={state} onSubmit={handleTypeSubmit} />;\n case 'styling': return <StepStyling state={state} onSubmit={handleStylingSubmit} />;\n case 'creating': return <StepCreating state={state} />;\n case 'done': return <StepDone state={state} onExit={handleExit} />;\n }\n })()}\n </box>\n );\n };\n});\n\nfunction runHeadless(): number {\n const validTypes: ProjectType[] = ['basic', 'ssr', 'ssg', 'lynx'];\n const validStyling: Styling[] = ['none', 'tailwind', 'daisyui'];\n\n const projectName = argProjectName || 'my-sigx-app';\n const projectType: ProjectType = argType ?? 'basic';\n const styling: Styling = argStyling ?? 'none';\n\n if (!validTypes.includes(projectType)) {\n console.error(`Error: --type must be one of ${validTypes.join(', ')}`);\n return 2;\n }\n if (!validStyling.includes(styling)) {\n console.error(`Error: --styling must be one of ${validStyling.join(', ')}`);\n return 2;\n }\n\n console.log(`\\n ⚡ Creating SignalX app \"${projectName}\"`);\n console.log(` type: ${projectType}`);\n console.log(` styling: ${styling}\\n`);\n\n const result = scaffoldProject({ projectName, projectType, styling });\n if (!result.ok) {\n console.error(`Error: ${result.error}`);\n return 1;\n }\n\n console.log(` ✓ Project created\\n`);\n console.log(` Next steps:`);\n console.log(` cd ${projectName}`);\n console.log(` pnpm install`);\n console.log(` ${projectType === 'lynx' ? 'sigx dev' : 'pnpm dev'}\\n`);\n return 0;\n}\n\nexport function runCreate() {\n if (isNonInteractive) {\n process.exit(runHeadless());\n }\n defineApp(<CreateSigx />).mount({ clearConsole: true });\n // Keep process alive for TUI\n setInterval(() => { }, 10000);\n}\n"],"mappings":";;;;;;;AAMA,IAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAOzD,IAAM,UAAU,QAAQ,KAAK,MAAM,EAAE;AACrC,SAAS,QAAQ,MAAkC;CAC/C,MAAM,KAAK,QAAQ,MAAK,MAAK,EAAE,WAAW,KAAK,KAAK,GAAG,CAAC;CACxD,IAAI,IAAI,OAAO,GAAG,MAAM,KAAK,SAAS,EAAE;CACxC,MAAM,MAAM,QAAQ,QAAQ,KAAK,OAA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,IAAI,+BAA+B,YAAY,GAAG;CAC1D,QAAQ,IAAI,iBAAiB,cAAc;CAC3C,QAAQ,IAAI,iBAAiB,QAAQ,IAAI;CAEzC,MAAM,SAAS,gBAAgB;EAAE;EAAa;EAAa;EAAS,CAAC;CACrE,IAAI,CAAC,OAAO,IAAI;EACZ,QAAQ,MAAM,UAAU,OAAO,QAAQ;EACvC,OAAO;;CAGX,QAAQ,IAAI,wBAAwB;CACpC,QAAQ,IAAI,gBAAgB;CAC5B,QAAQ,IAAI,UAAU,cAAc;CACpC,QAAQ,IAAI,mBAAmB;CAC/B,QAAQ,IAAI,OAAO,gBAAgB,SAAS,aAAa,WAAW,IAAI;CACxE,OAAO;;AAGX,SAAgB,YAAY;CACxB,IAAI,kBACA,QAAQ,KAAK,aAAa,CAAC;CAE/B,UAAU,oBAAC,YAAD,EAAc,CAAA,CAAC,CAAC,MAAM,EAAE,cAAc,MAAM,CAAC;CAEvD,kBAAkB,IAAK,IAAM"}
|
|
1
|
+
{"version":3,"file":"create.js","names":[],"sources":["../../src/commands/create.ts"],"sourcesContent":["/**\n * `sigx create` — interactive scaffolder on the @sigx/terminal prompt kit,\n * with a flag-driven headless mode for CI (`--type`, `--styling`, `--yes`,\n * or any non-TTY stdio).\n */\nimport { intro, outro, note, cancel, isCancel, text, select, spinner } from '@sigx/terminal';\nimport {\n scaffoldProject,\n projectTypeOptions,\n webStylingOptions,\n lynxStylingOptions,\n type ProjectType,\n type Styling,\n} from './scaffold.js';\n\n// Parse CLI args (supports both interactive default and --flag headless mode).\nconst rawArgs = process.argv.slice(2);\nfunction getFlag(name: string): string | undefined {\n const eq = rawArgs.find(a => a.startsWith(`--${name}=`));\n if (eq) return eq.slice(name.length + 3);\n const idx = rawArgs.indexOf(`--${name}`);\n if (idx !== -1 && rawArgs[idx + 1] && !rawArgs[idx + 1].startsWith('-')) return rawArgs[idx + 1];\n return undefined;\n}\nfunction hasFlag(name: string, short?: string): boolean {\n return rawArgs.includes(`--${name}`) || (short ? rawArgs.includes(`-${short}`) : false);\n}\nconst positionalArgs = rawArgs.filter(a => !a.startsWith('-') && a !== 'create');\nconst argProjectName = positionalArgs[0] || '';\nconst argType = getFlag('type') as ProjectType | undefined;\nconst argStyling = getFlag('styling') as Styling | undefined;\nconst flagYes = hasFlag('yes', 'y');\nconst isNonInteractive = !process.stdout.isTTY || !process.stdin.isTTY || flagYes\n || Boolean(argType && argProjectName);\n\nfunction runHeadless(): number {\n const validTypes: ProjectType[] = ['basic', 'ssr', 'ssg', 'lynx'];\n const validStyling: Styling[] = ['none', 'tailwind', 'daisyui'];\n\n const projectName = argProjectName || 'my-sigx-app';\n const projectType: ProjectType = argType ?? 'basic';\n const styling: Styling = argStyling ?? 'none';\n\n if (!validTypes.includes(projectType)) {\n console.error(`Error: --type must be one of ${validTypes.join(', ')}`);\n return 2;\n }\n if (!validStyling.includes(styling)) {\n console.error(`Error: --styling must be one of ${validStyling.join(', ')}`);\n return 2;\n }\n\n console.log(`\\n ⚡ Creating SignalX app \"${projectName}\"`);\n console.log(` type: ${projectType}`);\n console.log(` styling: ${styling}\\n`);\n\n const result = scaffoldProject({ projectName, projectType, styling });\n if (!result.ok) {\n console.error(`Error: ${result.error}`);\n return 1;\n }\n\n console.log(` ✓ Project created\\n`);\n console.log(` Next steps:`);\n console.log(` cd ${projectName}`);\n console.log(` pnpm install`);\n console.log(` ${projectType === 'lynx' ? 'sigx dev' : 'pnpm dev'}\\n`);\n return 0;\n}\n\nfunction bail(): never {\n cancel('Cancelled — nothing was created.');\n process.exit(130);\n}\n\nexport async function runCreate(): Promise<void> {\n if (isNonInteractive) {\n process.exit(runHeadless());\n }\n\n intro('⚡ Create SignalX App');\n\n const projectName = await text({\n message: 'Project name',\n placeholder: 'my-sigx-app',\n initialValue: argProjectName || 'my-sigx-app',\n validate: (v: string) => (v.trim() ? undefined : 'Project name is required'),\n });\n if (isCancel(projectName)) bail();\n\n const projectType = await select<ProjectType>({\n message: 'Project type',\n initialValue: argType ?? 'basic',\n options: projectTypeOptions,\n });\n if (isCancel(projectType)) bail();\n\n const styling = await select<Styling>({\n message: 'Styling',\n initialValue: argStyling ?? 'none',\n options: projectType === 'lynx' ? lynxStylingOptions : webStylingOptions,\n });\n if (isCancel(styling)) bail();\n\n const s = spinner();\n s.start(`Scaffolding ${projectName}`);\n const result = scaffoldProject({ projectName, projectType, styling });\n if (!result.ok) {\n s.stop(result.error, 'error');\n process.exit(1);\n }\n s.stop(`Created ${projectName} (${projectType}${styling !== 'none' ? ` + ${styling}` : ''})`);\n\n note(\n `cd ${projectName}\\npnpm install\\n${projectType === 'lynx' ? 'sigx dev' : 'pnpm dev'}`,\n 'Next steps',\n );\n outro('Happy hacking!');\n process.exit(0);\n}\n"],"mappings":";;;;;;;;AAgBA,IAAM,UAAU,QAAQ,KAAK,MAAM,EAAE;AACrC,SAAS,QAAQ,MAAkC;CAC/C,MAAM,KAAK,QAAQ,MAAK,MAAK,EAAE,WAAW,KAAK,KAAK,GAAG,CAAC;CACxD,IAAI,IAAI,OAAO,GAAG,MAAM,KAAK,SAAS,EAAE;CACxC,MAAM,MAAM,QAAQ,QAAQ,KAAK,OAAO;CACxC,IAAI,QAAQ,MAAM,QAAQ,MAAM,MAAM,CAAC,QAAQ,MAAM,GAAG,WAAW,IAAI,EAAE,OAAO,QAAQ,MAAM;;AAGlG,SAAS,QAAQ,MAAc,OAAyB;CACpD,OAAO,QAAQ,SAAS,KAAK,OAAO,KAAK,QAAQ,QAAQ,SAAS,IAAI,QAAQ,GAAG;;AAGrF,IAAM,iBADiB,QAAQ,QAAO,MAAK,CAAC,EAAE,WAAW,IAAI,IAAI,MAAM,SAChD,CAAe,MAAM;AAC5C,IAAM,UAAU,QAAQ,OAAO;AAC/B,IAAM,aAAa,QAAQ,UAAU;AACrC,IAAM,UAAU,QAAQ,OAAO,IAAI;AACnC,IAAM,mBAAmB,CAAC,QAAQ,OAAO,SAAS,CAAC,QAAQ,MAAM,SAAS,WACnE,QAAQ,WAAW,eAAe;A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