@geravant/sinain 1.15.3 → 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 +30 -2
- package/onboard.js +23 -0
- package/package.json +1 -1
package/launcher.js
CHANGED
|
@@ -64,9 +64,24 @@ 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
|
-
|
|
69
|
-
|
|
78
|
+
const envExists = fs.existsSync(userEnvPath);
|
|
79
|
+
if (forceSetup || !envExists) {
|
|
80
|
+
log(envExists ? "Re-running setup wizard (--setup flag)..." : "First-time setup — running wizard...");
|
|
81
|
+
const { runOnboard } = await import("./onboard.js");
|
|
82
|
+
await runOnboard({ skipLaunchPrompt: true });
|
|
83
|
+
} else {
|
|
84
|
+
log(`Existing config found at ${DIM}${userEnvPath}${RESET} — skipping wizard. (Use ${BOLD}--setup${RESET} to re-configure.)`);
|
|
70
85
|
}
|
|
71
86
|
|
|
72
87
|
// Load user config
|
|
@@ -176,6 +191,19 @@ async function main() {
|
|
|
176
191
|
// Start overlay
|
|
177
192
|
let overlayStatus = "skipped";
|
|
178
193
|
if (!skipOverlay) {
|
|
194
|
+
// ALWAYS check for an overlay update before launching — setup-overlay's
|
|
195
|
+
// own version.json marker decides whether to skip a download (fast)
|
|
196
|
+
// or fetch a new release (slow). Previously we only ran setup-overlay
|
|
197
|
+
// when no binary existed, which meant users with a stale binary from
|
|
198
|
+
// a months-old install ran an outdated overlay forever (no flash icon,
|
|
199
|
+
// no AgentSelectorPanel, no per-lane routing UI). When --setup is
|
|
200
|
+
// passed, force-update regardless of the marker.
|
|
201
|
+
try {
|
|
202
|
+
const { downloadOverlay } = await import("./setup-overlay.js");
|
|
203
|
+
await downloadOverlay({ silent: false, forceUpdate: forceSetup });
|
|
204
|
+
} catch (e) {
|
|
205
|
+
warn(`overlay update check failed: ${e.message} — using local binary`);
|
|
206
|
+
}
|
|
179
207
|
const overlay = findOverlay();
|
|
180
208
|
if (overlay?.type === "prebuilt") {
|
|
181
209
|
// Remove macOS quarantine if present (ad-hoc signed app)
|
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
|