@geravant/sinain 1.15.4 → 1.15.5
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/launcher.js +12 -1
- package/onboard.js +23 -0
- package/package.json +1 -1
package/launcher.js
CHANGED
|
@@ -64,11 +64,22 @@ async function main() {
|
|
|
64
64
|
console.log();
|
|
65
65
|
|
|
66
66
|
// Run setup wizard on first launch (no ~/.sinain/.env) or when --setup flag is passed
|
|
67
|
+
//
|
|
68
|
+
// Delegates to onboard.js's clack-based runOnboard (Mitch's wizard from
|
|
69
|
+
// PR #43). Previously, launcher.js had its own readline-based setupWizard
|
|
70
|
+
// that diverged from `npx sinain onboard`'s flow — same package, two
|
|
71
|
+
// different setup experiences depending on entry point. This collapses
|
|
72
|
+
// both paths to a single source of truth in config-shared.js.
|
|
73
|
+
//
|
|
74
|
+
// skipLaunchPrompt: true tells runOnboard not to ask "start sinain now?"
|
|
75
|
+
// at the end — we're already inside the launcher and will continue
|
|
76
|
+
// start-up automatically once the wizard returns.
|
|
67
77
|
const userEnvPath = path.join(SINAIN_DIR, ".env");
|
|
68
78
|
const envExists = fs.existsSync(userEnvPath);
|
|
69
79
|
if (forceSetup || !envExists) {
|
|
70
80
|
log(envExists ? "Re-running setup wizard (--setup flag)..." : "First-time setup — running wizard...");
|
|
71
|
-
await
|
|
81
|
+
const { runOnboard } = await import("./onboard.js");
|
|
82
|
+
await runOnboard({ skipLaunchPrompt: true });
|
|
72
83
|
} else {
|
|
73
84
|
log(`Existing config found at ${DIM}${userEnvPath}${RESET} — skipping wizard. (Use ${BOLD}--setup${RESET} to re-configure.)`);
|
|
74
85
|
}
|
package/onboard.js
CHANGED
|
@@ -272,6 +272,15 @@ export async function runOnboard(args = {}) {
|
|
|
272
272
|
printOutro();
|
|
273
273
|
|
|
274
274
|
// ── Start? ────────────────────────────────────────────────────────────
|
|
275
|
+
//
|
|
276
|
+
// When called from launcher.js (via `sinain start --setup`), the launcher
|
|
277
|
+
// is about to start sinain itself — asking the user again is redundant.
|
|
278
|
+
// Caller passes { skipLaunchPrompt: true } in that case.
|
|
279
|
+
|
|
280
|
+
if (args.skipLaunchPrompt) {
|
|
281
|
+
p.outro("Setup complete — starting sinain...");
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
275
284
|
|
|
276
285
|
const startNow = guard(await p.confirm({
|
|
277
286
|
message: "Start sinain now?",
|
|
@@ -309,6 +318,18 @@ function printOutro() {
|
|
|
309
318
|
}
|
|
310
319
|
|
|
311
320
|
// ── CLI entry point ─────────────────────────────────────────────────────────
|
|
321
|
+
//
|
|
322
|
+
// Guarded so `import { runOnboard } from "./onboard.js"` from launcher.js
|
|
323
|
+
// (or anywhere else) doesn't trigger side effects. The CLI block runs only
|
|
324
|
+
// when this file is the program's entry point — i.e. `node onboard.js ...`
|
|
325
|
+
// or `npx @geravant/sinain onboard ...`.
|
|
326
|
+
|
|
327
|
+
const isMainModule = import.meta.url === new URL(`file://${process.argv[1]}`).href
|
|
328
|
+
|| (process.argv[1] && import.meta.url.endsWith(path.basename(process.argv[1])));
|
|
329
|
+
|
|
330
|
+
if (!isMainModule) {
|
|
331
|
+
// Imported as a module — exports are available; do not parse argv.
|
|
332
|
+
} else {
|
|
312
333
|
|
|
313
334
|
const cliArgs = process.argv.slice(2);
|
|
314
335
|
const flags = {};
|
|
@@ -359,3 +380,5 @@ if (flags.nonInteractive) {
|
|
|
359
380
|
process.exit(1);
|
|
360
381
|
});
|
|
361
382
|
}
|
|
383
|
+
|
|
384
|
+
} // end isMainModule guard
|