@take-out/cli 0.0.39
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/LICENSE +21 -0
- package/README.md +274 -0
- package/cli.mjs +3 -0
- package/dist/cjs/cli.cjs +71 -0
- package/dist/cjs/cli.js +70 -0
- package/dist/cjs/cli.js.map +6 -0
- package/dist/cjs/cli.native.js +79 -0
- package/dist/cjs/cli.native.js.map +6 -0
- package/dist/cjs/commands/changed.cjs +212 -0
- package/dist/cjs/commands/changed.js +214 -0
- package/dist/cjs/commands/changed.js.map +6 -0
- package/dist/cjs/commands/changed.native.js +289 -0
- package/dist/cjs/commands/changed.native.js.map +6 -0
- package/dist/cjs/commands/docs.cjs +388 -0
- package/dist/cjs/commands/docs.js +313 -0
- package/dist/cjs/commands/docs.js.map +6 -0
- package/dist/cjs/commands/docs.native.js +476 -0
- package/dist/cjs/commands/docs.native.js.map +6 -0
- package/dist/cjs/commands/env-setup.cjs +90 -0
- package/dist/cjs/commands/env-setup.js +78 -0
- package/dist/cjs/commands/env-setup.js.map +6 -0
- package/dist/cjs/commands/env-setup.native.js +85 -0
- package/dist/cjs/commands/env-setup.native.js.map +6 -0
- package/dist/cjs/commands/onboard.cjs +479 -0
- package/dist/cjs/commands/onboard.js +631 -0
- package/dist/cjs/commands/onboard.js.map +6 -0
- package/dist/cjs/commands/onboard.native.js +608 -0
- package/dist/cjs/commands/onboard.native.js.map +6 -0
- package/dist/cjs/commands/run.cjs +148 -0
- package/dist/cjs/commands/run.js +116 -0
- package/dist/cjs/commands/run.js.map +6 -0
- package/dist/cjs/commands/run.native.js +140 -0
- package/dist/cjs/commands/run.native.js.map +6 -0
- package/dist/cjs/commands/script.cjs +379 -0
- package/dist/cjs/commands/script.js +339 -0
- package/dist/cjs/commands/script.js.map +6 -0
- package/dist/cjs/commands/script.native.js +449 -0
- package/dist/cjs/commands/script.native.js.map +6 -0
- package/dist/cjs/commands/sync.cjs +190 -0
- package/dist/cjs/commands/sync.js +168 -0
- package/dist/cjs/commands/sync.js.map +6 -0
- package/dist/cjs/commands/sync.native.js +211 -0
- package/dist/cjs/commands/sync.native.js.map +6 -0
- package/dist/cjs/constants/ascii.cjs +36 -0
- package/dist/cjs/constants/ascii.js +30 -0
- package/dist/cjs/constants/ascii.js.map +6 -0
- package/dist/cjs/constants/ascii.native.js +36 -0
- package/dist/cjs/constants/ascii.native.js.map +6 -0
- package/dist/cjs/index.cjs +64 -0
- package/dist/cjs/index.js +55 -0
- package/dist/cjs/index.js.map +6 -0
- package/dist/cjs/index.native.js +94 -0
- package/dist/cjs/index.native.js.map +6 -0
- package/dist/cjs/types.cjs +16 -0
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/types.js.map +6 -0
- package/dist/cjs/types.native.js +15 -0
- package/dist/cjs/types.native.js.map +6 -0
- package/dist/cjs/utils/env-categories.cjs +272 -0
- package/dist/cjs/utils/env-categories.js +296 -0
- package/dist/cjs/utils/env-categories.js.map +6 -0
- package/dist/cjs/utils/env-categories.native.js +317 -0
- package/dist/cjs/utils/env-categories.native.js.map +6 -0
- package/dist/cjs/utils/env-setup.cjs +181 -0
- package/dist/cjs/utils/env-setup.js +190 -0
- package/dist/cjs/utils/env-setup.js.map +6 -0
- package/dist/cjs/utils/env-setup.native.js +264 -0
- package/dist/cjs/utils/env-setup.native.js.map +6 -0
- package/dist/cjs/utils/env.cjs +118 -0
- package/dist/cjs/utils/env.js +97 -0
- package/dist/cjs/utils/env.js.map +6 -0
- package/dist/cjs/utils/env.native.js +128 -0
- package/dist/cjs/utils/env.native.js.map +6 -0
- package/dist/cjs/utils/files.cjs +215 -0
- package/dist/cjs/utils/files.js +164 -0
- package/dist/cjs/utils/files.js.map +6 -0
- package/dist/cjs/utils/files.native.js +266 -0
- package/dist/cjs/utils/files.native.js.map +6 -0
- package/dist/cjs/utils/parallel-runner.cjs +99 -0
- package/dist/cjs/utils/parallel-runner.js +84 -0
- package/dist/cjs/utils/parallel-runner.js.map +6 -0
- package/dist/cjs/utils/parallel-runner.native.js +123 -0
- package/dist/cjs/utils/parallel-runner.native.js.map +6 -0
- package/dist/cjs/utils/ports.cjs +101 -0
- package/dist/cjs/utils/ports.js +81 -0
- package/dist/cjs/utils/ports.js.map +6 -0
- package/dist/cjs/utils/ports.native.js +130 -0
- package/dist/cjs/utils/ports.native.js.map +6 -0
- package/dist/cjs/utils/prerequisites.cjs +119 -0
- package/dist/cjs/utils/prerequisites.js +107 -0
- package/dist/cjs/utils/prerequisites.js.map +6 -0
- package/dist/cjs/utils/prerequisites.native.js +127 -0
- package/dist/cjs/utils/prerequisites.native.js.map +6 -0
- package/dist/cjs/utils/prompts.cjs +161 -0
- package/dist/cjs/utils/prompts.js +162 -0
- package/dist/cjs/utils/prompts.js.map +6 -0
- package/dist/cjs/utils/prompts.native.js +179 -0
- package/dist/cjs/utils/prompts.native.js.map +6 -0
- package/dist/cjs/utils/script-listing.cjs +113 -0
- package/dist/cjs/utils/script-listing.js +108 -0
- package/dist/cjs/utils/script-listing.js.map +6 -0
- package/dist/cjs/utils/script-listing.native.js +174 -0
- package/dist/cjs/utils/script-listing.native.js.map +6 -0
- package/dist/cjs/utils/sync.cjs +85 -0
- package/dist/cjs/utils/sync.js +70 -0
- package/dist/cjs/utils/sync.js.map +6 -0
- package/dist/cjs/utils/sync.native.js +84 -0
- package/dist/cjs/utils/sync.native.js.map +6 -0
- package/dist/cjs/utils/welcome.cjs +50 -0
- package/dist/cjs/utils/welcome.js +42 -0
- package/dist/cjs/utils/welcome.js.map +6 -0
- package/dist/cjs/utils/welcome.native.js +47 -0
- package/dist/cjs/utils/welcome.native.js.map +6 -0
- package/dist/esm/cli.js +79 -0
- package/dist/esm/cli.js.map +6 -0
- package/dist/esm/cli.mjs +71 -0
- package/dist/esm/cli.mjs.map +1 -0
- package/dist/esm/cli.native.js +69 -0
- package/dist/esm/cli.native.js.map +1 -0
- package/dist/esm/commands/changed.js +194 -0
- package/dist/esm/commands/changed.js.map +6 -0
- package/dist/esm/commands/changed.mjs +178 -0
- package/dist/esm/commands/changed.mjs.map +1 -0
- package/dist/esm/commands/changed.native.js +273 -0
- package/dist/esm/commands/changed.native.js.map +1 -0
- package/dist/esm/commands/docs.js +306 -0
- package/dist/esm/commands/docs.js.map +6 -0
- package/dist/esm/commands/docs.mjs +353 -0
- package/dist/esm/commands/docs.mjs.map +1 -0
- package/dist/esm/commands/docs.native.js +516 -0
- package/dist/esm/commands/docs.native.js.map +1 -0
- package/dist/esm/commands/env-setup.js +56 -0
- package/dist/esm/commands/env-setup.js.map +6 -0
- package/dist/esm/commands/env-setup.mjs +56 -0
- package/dist/esm/commands/env-setup.mjs.map +1 -0
- package/dist/esm/commands/env-setup.native.js +59 -0
- package/dist/esm/commands/env-setup.native.js.map +1 -0
- package/dist/esm/commands/onboard.js +645 -0
- package/dist/esm/commands/onboard.js.map +6 -0
- package/dist/esm/commands/onboard.mjs +445 -0
- package/dist/esm/commands/onboard.mjs.map +1 -0
- package/dist/esm/commands/onboard.native.js +584 -0
- package/dist/esm/commands/onboard.native.js.map +1 -0
- package/dist/esm/commands/run.js +95 -0
- package/dist/esm/commands/run.js.map +6 -0
- package/dist/esm/commands/run.mjs +114 -0
- package/dist/esm/commands/run.mjs.map +1 -0
- package/dist/esm/commands/run.native.js +133 -0
- package/dist/esm/commands/run.native.js.map +1 -0
- package/dist/esm/commands/script.js +338 -0
- package/dist/esm/commands/script.js.map +6 -0
- package/dist/esm/commands/script.mjs +336 -0
- package/dist/esm/commands/script.mjs.map +1 -0
- package/dist/esm/commands/script.native.js +445 -0
- package/dist/esm/commands/script.native.js.map +1 -0
- package/dist/esm/commands/sync.js +158 -0
- package/dist/esm/commands/sync.js.map +6 -0
- package/dist/esm/commands/sync.mjs +155 -0
- package/dist/esm/commands/sync.mjs.map +1 -0
- package/dist/esm/commands/sync.native.js +173 -0
- package/dist/esm/commands/sync.native.js.map +1 -0
- package/dist/esm/constants/ascii.js +14 -0
- package/dist/esm/constants/ascii.js.map +6 -0
- package/dist/esm/constants/ascii.mjs +12 -0
- package/dist/esm/constants/ascii.mjs.map +1 -0
- package/dist/esm/constants/ascii.native.js +12 -0
- package/dist/esm/constants/ascii.native.js.map +1 -0
- package/dist/esm/index.js +83 -0
- package/dist/esm/index.js.map +6 -0
- package/dist/esm/index.mjs +7 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/index.native.js +7 -0
- package/dist/esm/index.native.js.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +6 -0
- package/dist/esm/types.mjs +2 -0
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/types.native.js +2 -0
- package/dist/esm/types.native.js.map +1 -0
- package/dist/esm/utils/env-categories.js +272 -0
- package/dist/esm/utils/env-categories.js.map +6 -0
- package/dist/esm/utils/env-categories.mjs +233 -0
- package/dist/esm/utils/env-categories.mjs.map +1 -0
- package/dist/esm/utils/env-categories.native.js +246 -0
- package/dist/esm/utils/env-categories.native.js.map +1 -0
- package/dist/esm/utils/env-setup.js +173 -0
- package/dist/esm/utils/env-setup.js.map +6 -0
- package/dist/esm/utils/env-setup.mjs +146 -0
- package/dist/esm/utils/env-setup.mjs.map +1 -0
- package/dist/esm/utils/env-setup.native.js +243 -0
- package/dist/esm/utils/env-setup.native.js.map +1 -0
- package/dist/esm/utils/env.js +83 -0
- package/dist/esm/utils/env.js.map +6 -0
- package/dist/esm/utils/env.mjs +90 -0
- package/dist/esm/utils/env.mjs.map +1 -0
- package/dist/esm/utils/env.native.js +99 -0
- package/dist/esm/utils/env.native.js.map +1 -0
- package/dist/esm/utils/files.js +150 -0
- package/dist/esm/utils/files.js.map +6 -0
- package/dist/esm/utils/files.mjs +187 -0
- package/dist/esm/utils/files.mjs.map +1 -0
- package/dist/esm/utils/files.native.js +247 -0
- package/dist/esm/utils/files.native.js.map +1 -0
- package/dist/esm/utils/parallel-runner.js +69 -0
- package/dist/esm/utils/parallel-runner.js.map +6 -0
- package/dist/esm/utils/parallel-runner.mjs +76 -0
- package/dist/esm/utils/parallel-runner.mjs.map +1 -0
- package/dist/esm/utils/parallel-runner.native.js +109 -0
- package/dist/esm/utils/parallel-runner.native.js.map +1 -0
- package/dist/esm/utils/ports.js +65 -0
- package/dist/esm/utils/ports.js.map +6 -0
- package/dist/esm/utils/ports.mjs +74 -0
- package/dist/esm/utils/ports.mjs.map +1 -0
- package/dist/esm/utils/ports.native.js +93 -0
- package/dist/esm/utils/ports.native.js.map +1 -0
- package/dist/esm/utils/prerequisites.js +91 -0
- package/dist/esm/utils/prerequisites.js.map +6 -0
- package/dist/esm/utils/prerequisites.mjs +91 -0
- package/dist/esm/utils/prerequisites.mjs.map +1 -0
- package/dist/esm/utils/prerequisites.native.js +97 -0
- package/dist/esm/utils/prerequisites.native.js.map +1 -0
- package/dist/esm/utils/prompts.js +139 -0
- package/dist/esm/utils/prompts.js.map +6 -0
- package/dist/esm/utils/prompts.mjs +112 -0
- package/dist/esm/utils/prompts.mjs.map +1 -0
- package/dist/esm/utils/prompts.native.js +115 -0
- package/dist/esm/utils/prompts.native.js.map +1 -0
- package/dist/esm/utils/script-listing.js +91 -0
- package/dist/esm/utils/script-listing.js.map +6 -0
- package/dist/esm/utils/script-listing.mjs +76 -0
- package/dist/esm/utils/script-listing.mjs.map +1 -0
- package/dist/esm/utils/script-listing.native.js +151 -0
- package/dist/esm/utils/script-listing.native.js.map +1 -0
- package/dist/esm/utils/sync.js +50 -0
- package/dist/esm/utils/sync.js.map +6 -0
- package/dist/esm/utils/sync.mjs +48 -0
- package/dist/esm/utils/sync.mjs.map +1 -0
- package/dist/esm/utils/sync.native.js +53 -0
- package/dist/esm/utils/sync.native.js.map +1 -0
- package/dist/esm/utils/welcome.js +21 -0
- package/dist/esm/utils/welcome.js.map +6 -0
- package/dist/esm/utils/welcome.mjs +15 -0
- package/dist/esm/utils/welcome.mjs.map +1 -0
- package/dist/esm/utils/welcome.native.js +18 -0
- package/dist/esm/utils/welcome.native.js.map +1 -0
- package/docs/aggregates.md +579 -0
- package/docs/cloudflare-dev-tunnel.md +41 -0
- package/docs/database.md +203 -0
- package/docs/docs.md +8 -0
- package/docs/emitters.md +562 -0
- package/docs/hot-updater.md +223 -0
- package/docs/native-hot-update.md +252 -0
- package/docs/one-components.md +234 -0
- package/docs/one-hooks.md +570 -0
- package/docs/one-routes.md +660 -0
- package/docs/package-json.md +115 -0
- package/docs/react-native-navigation-flow.md +184 -0
- package/docs/scripts.md +147 -0
- package/docs/sync-prompt.md +208 -0
- package/docs/tamagui.md +478 -0
- package/docs/testing-integration.md +564 -0
- package/docs/triggers.md +450 -0
- package/docs/zero.md +719 -0
- package/package.json +76 -0
- package/scripts/seed.ts +209 -0
- package/src/cli.ts +147 -0
- package/src/commands/changed.ts +313 -0
- package/src/commands/docs.ts +582 -0
- package/src/commands/env-setup.ts +69 -0
- package/src/commands/onboard.ts +1391 -0
- package/src/commands/run.ts +173 -0
- package/src/commands/script.ts +587 -0
- package/src/commands/sync.ts +305 -0
- package/src/constants/ascii.ts +17 -0
- package/src/index.ts +63 -0
- package/src/types.ts +59 -0
- package/src/utils/env-categories.ts +245 -0
- package/src/utils/env-setup.ts +338 -0
- package/src/utils/env.ts +127 -0
- package/src/utils/files.ts +302 -0
- package/src/utils/parallel-runner.ts +129 -0
- package/src/utils/ports.ts +77 -0
- package/src/utils/prerequisites.ts +137 -0
- package/src/utils/prompts.ts +197 -0
- package/src/utils/script-listing.ts +214 -0
- package/src/utils/sync.ts +101 -0
- package/src/withOpSqliteStatic.cjs +51 -0
- package/types/cli.d.ts +7 -0
- package/types/cli.d.ts.map +1 -0
- package/types/commands/changed.d.ts +14 -0
- package/types/commands/changed.d.ts.map +1 -0
- package/types/commands/docs.d.ts +5 -0
- package/types/commands/docs.d.ts.map +1 -0
- package/types/commands/env-setup.d.ts +25 -0
- package/types/commands/env-setup.d.ts.map +1 -0
- package/types/commands/onboard.d.ts +16 -0
- package/types/commands/onboard.d.ts.map +1 -0
- package/types/commands/run.d.ts +8 -0
- package/types/commands/run.d.ts.map +1 -0
- package/types/commands/script.d.ts +28 -0
- package/types/commands/script.d.ts.map +1 -0
- package/types/commands/sync.d.ts +5 -0
- package/types/commands/sync.d.ts.map +1 -0
- package/types/constants/ascii.d.ts +6 -0
- package/types/constants/ascii.d.ts.map +1 -0
- package/types/index.d.ts +12 -0
- package/types/index.d.ts.map +1 -0
- package/types/types.d.ts +54 -0
- package/types/types.d.ts.map +1 -0
- package/types/utils/env-categories.d.ts +8 -0
- package/types/utils/env-categories.d.ts.map +1 -0
- package/types/utils/env-setup.d.ts +10 -0
- package/types/utils/env-setup.d.ts.map +1 -0
- package/types/utils/env.d.ts +19 -0
- package/types/utils/env.d.ts.map +1 -0
- package/types/utils/files.d.ts +47 -0
- package/types/utils/files.d.ts.map +1 -0
- package/types/utils/parallel-runner.d.ts +15 -0
- package/types/utils/parallel-runner.d.ts.map +1 -0
- package/types/utils/ports.d.ts +16 -0
- package/types/utils/ports.d.ts.map +1 -0
- package/types/utils/prerequisites.d.ts +11 -0
- package/types/utils/prerequisites.d.ts.map +1 -0
- package/types/utils/prompts.d.ts +30 -0
- package/types/utils/prompts.d.ts.map +1 -0
- package/types/utils/script-listing.d.ts +7 -0
- package/types/utils/script-listing.d.ts.map +1 -0
- package/types/utils/sync.d.ts +16 -0
- package/types/utils/sync.d.ts.map +1 -0
- package/types/utils/welcome.d.ts +6 -0
- package/types/utils/welcome.d.ts.map +1 -0
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { randomBytes } from "crypto";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "fs";
|
|
4
|
+
import { homedir } from "os";
|
|
5
|
+
import { resolve } from "path";
|
|
6
|
+
import { defineCommand } from "citty";
|
|
7
|
+
import pc from "picocolors";
|
|
8
|
+
import { copyEnvFile, createEnvLocal, envFileExists, updateEnvVariable } from "../utils/env.native.js";
|
|
9
|
+
import { setupProductionEnv } from "../utils/env-setup.native.js";
|
|
10
|
+
import { ejectFromMonorepo, markOnboarded, updateAppConfig, updatePackageJson, updatePackageJsonEnv } from "../utils/files.native.js";
|
|
11
|
+
import { checkAllPorts, getConflictingPorts } from "../utils/ports.native.js";
|
|
12
|
+
import { checkAllPrerequisites, hasRequiredPrerequisites } from "../utils/prerequisites.native.js";
|
|
13
|
+
import { confirmContinue, displayOutro, displayPortConflicts, displayPrerequisites, displayWelcome, promptText, promptSelect, promptStartStep, showError, showInfo, showSpinner, showStep, showSuccess, showWarning } from "../utils/prompts.native.js";
|
|
14
|
+
var onboardCommand = defineCommand({
|
|
15
|
+
meta: {
|
|
16
|
+
name: "onboard",
|
|
17
|
+
description: "Interactive onboarding for Takeout starter kit"
|
|
18
|
+
},
|
|
19
|
+
args: {
|
|
20
|
+
skip: {
|
|
21
|
+
type: "boolean",
|
|
22
|
+
description: "Skip onboarding entirely",
|
|
23
|
+
default: !1
|
|
24
|
+
},
|
|
25
|
+
defaults: {
|
|
26
|
+
type: "boolean",
|
|
27
|
+
description: "Run with defaults (non-interactive)",
|
|
28
|
+
default: !1
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async run(param) {
|
|
32
|
+
var {
|
|
33
|
+
args
|
|
34
|
+
} = param,
|
|
35
|
+
cwd = process.cwd();
|
|
36
|
+
if (args.skip) {
|
|
37
|
+
showInfo("Skipping onboarding (--skip flag)");
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (args.defaults) {
|
|
41
|
+
showInfo("Running onboarding with defaults (--defaults flag)"), console.info();
|
|
42
|
+
var hasEnv = envFileExists(cwd, ".env");
|
|
43
|
+
if (hasEnv) showInfo(".env already exists, skipping");else {
|
|
44
|
+
var copyResult = copyEnvFile(cwd, ".env.development", ".env");
|
|
45
|
+
if (copyResult.success) showSuccess("Created .env from .env.development");else {
|
|
46
|
+
showError(`Failed to create .env: ${copyResult.error}`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
createEnvLocal(cwd), showSuccess("Created .env.local for personal overrides");
|
|
50
|
+
}
|
|
51
|
+
markOnboarded(cwd), showSuccess("Onboarding complete with defaults"), console.info(), showInfo("Next steps:"), console.info(" bun backend # start docker services"), console.info(" bun dev # start web dev server");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
displayWelcome();
|
|
55
|
+
var savedState = loadOnboardState(cwd),
|
|
56
|
+
startStep;
|
|
57
|
+
if (savedState) {
|
|
58
|
+
console.info(), showInfo(`Found incomplete setup from previous session (${savedState.step})`);
|
|
59
|
+
var shouldResume = await confirmContinue("Resume from where you left off?", !0);
|
|
60
|
+
shouldResume ? startStep = savedState.step : (clearOnboardState(cwd), startStep = await promptStartStep());
|
|
61
|
+
} else startStep = await promptStartStep();
|
|
62
|
+
if (startStep === "cancel") {
|
|
63
|
+
displayOutro("Setup cancelled");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (startStep === "eject") {
|
|
67
|
+
showStep("Monorepo Ejection"), console.info(), console.info(pc.gray("We've included a variety of packages we found useful building apps with this stack:")), console.info(pc.gray(" \u2022 @take-out/cli - CLI tools and onboarding")), console.info(pc.gray(" \u2022 @take-out/helpers - Utility functions")), console.info(pc.gray(" \u2022 @take-out/hooks - React hooks")), console.info(pc.gray(" \u2022 @take-out/postgres - Database utilities")), console.info(pc.gray(" \u2022 @take-out/scripts - Build and dev scripts")), console.info(pc.gray(" \u2022 @take-out/better-auth-utils - Auth helpers")), console.info();
|
|
68
|
+
var shouldEject = await confirmContinue("Eject from monorepo setup? (removes ./packages, uses published versions)", !0);
|
|
69
|
+
if (shouldEject) {
|
|
70
|
+
var _dryResult_packages,
|
|
71
|
+
_dryResult_warnings,
|
|
72
|
+
dryResult = await ejectFromMonorepo(cwd, {
|
|
73
|
+
dryRun: !0
|
|
74
|
+
});
|
|
75
|
+
if (!dryResult.success) {
|
|
76
|
+
showError(`Cannot eject: ${dryResult.error}`), clearOnboardState(cwd);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
console.info(), showInfo(`Found ${(_dryResult_packages = dryResult.packages) === null || _dryResult_packages === void 0 ? void 0 : _dryResult_packages.length} packages to convert:`);
|
|
80
|
+
var _iteratorNormalCompletion = !0,
|
|
81
|
+
_didIteratorError = !1,
|
|
82
|
+
_iteratorError = void 0;
|
|
83
|
+
try {
|
|
84
|
+
for (var _iterator = (dryResult.packages || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
85
|
+
var pkg = _step.value;
|
|
86
|
+
console.info(pc.gray(` \u2022 ${pkg.name}@${pkg.version}`));
|
|
87
|
+
}
|
|
88
|
+
} catch (err) {
|
|
89
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
90
|
+
} finally {
|
|
91
|
+
try {
|
|
92
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
93
|
+
} finally {
|
|
94
|
+
if (_didIteratorError) throw _iteratorError;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!((_dryResult_warnings = dryResult.warnings) === null || _dryResult_warnings === void 0) && _dryResult_warnings.length) {
|
|
98
|
+
var _iteratorNormalCompletion1 = !0,
|
|
99
|
+
_didIteratorError1 = !1,
|
|
100
|
+
_iteratorError1 = void 0;
|
|
101
|
+
try {
|
|
102
|
+
for (var _iterator1 = dryResult.warnings[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
|
103
|
+
var warn = _step1.value;
|
|
104
|
+
showWarning(warn);
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
_didIteratorError1 = !0, _iteratorError1 = err;
|
|
108
|
+
} finally {
|
|
109
|
+
try {
|
|
110
|
+
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
|
111
|
+
} finally {
|
|
112
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
console.info();
|
|
117
|
+
var confirmEject = await confirmContinue("Proceed with ejection?", !0);
|
|
118
|
+
if (!confirmEject) {
|
|
119
|
+
showInfo("Eject cancelled"), clearOnboardState(cwd), displayOutro("Done!");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
var spinner = showSpinner("Ejecting from monorepo..."),
|
|
123
|
+
result = await ejectFromMonorepo(cwd);
|
|
124
|
+
if (result.success) {
|
|
125
|
+
spinner.stop("Ejected from monorepo"), showSuccess("\u2713 Removed ./packages directory"), showSuccess("\u2713 Updated package.json to use published versions"), showSuccess("\u2713 Installed published packages");
|
|
126
|
+
try {
|
|
127
|
+
execSync('git add -A && git commit -m "ejected from monorepo"', {
|
|
128
|
+
cwd,
|
|
129
|
+
stdio: "ignore"
|
|
130
|
+
}), showSuccess("\u2713 Committed eject changes");
|
|
131
|
+
} catch {
|
|
132
|
+
showWarning("Git commit skipped (not a git repo or no changes)");
|
|
133
|
+
}
|
|
134
|
+
console.info(), showInfo("You can now upgrade packages with: bun up takeout");
|
|
135
|
+
} else {
|
|
136
|
+
var _result_error;
|
|
137
|
+
spinner.stop("Ejection failed"), showError(`Failed to eject: ${result.error}`), !((_result_error = result.error) === null || _result_error === void 0) && _result_error.includes("install failed") && (showInfo('You may be able to fix this by running "bun install" manually'), showInfo('Or restore the repo from git with "git checkout ."'));
|
|
138
|
+
}
|
|
139
|
+
} else showInfo("Eject cancelled");
|
|
140
|
+
clearOnboardState(cwd), displayOutro("Done!");
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (startStep === "prerequisites" || startStep === "full") {
|
|
144
|
+
saveOnboardState(cwd, {
|
|
145
|
+
step: "prerequisites",
|
|
146
|
+
timestamp: Date.now()
|
|
147
|
+
}), showStep("Checking prerequisites..."), console.info();
|
|
148
|
+
var checks = checkAllPrerequisites();
|
|
149
|
+
displayPrerequisites(checks);
|
|
150
|
+
var hasRequired = hasRequiredPrerequisites(checks);
|
|
151
|
+
if (!hasRequired) {
|
|
152
|
+
showWarning("Some required prerequisites are missing. You can continue, but setup may fail.");
|
|
153
|
+
var shouldContinue = await confirmContinue("Continue anyway?", !1);
|
|
154
|
+
if (!shouldContinue) {
|
|
155
|
+
displayOutro("Setup cancelled. Install prerequisites and try again.");
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
console.info();
|
|
160
|
+
}
|
|
161
|
+
if (startStep === "prerequisites" || startStep === "identity" || startStep === "full") {
|
|
162
|
+
saveOnboardState(cwd, {
|
|
163
|
+
step: "identity",
|
|
164
|
+
timestamp: Date.now()
|
|
165
|
+
}), showStep("Configuring project identity..."), console.info();
|
|
166
|
+
var shouldCustomize = await confirmContinue("Customize project name and bundle identifier?", !1);
|
|
167
|
+
shouldCustomize ? await customizeProject(cwd) : showInfo("Keeping default project configuration"), console.info();
|
|
168
|
+
}
|
|
169
|
+
if (startStep === "prerequisites" || startStep === "identity" || startStep === "ports" || startStep === "full") {
|
|
170
|
+
saveOnboardState(cwd, {
|
|
171
|
+
step: "ports",
|
|
172
|
+
timestamp: Date.now()
|
|
173
|
+
}), showStep("Configuring web server port..."), console.info(), showInfo("Default web port: 8081 (TAMA in T9)");
|
|
174
|
+
var shouldCustomizePort = await confirmContinue("Customize web server port?", !1);
|
|
175
|
+
if (shouldCustomizePort) {
|
|
176
|
+
var newPort = await promptText("Web server port:", "8081", "3000, 8080, 8081, etc.");
|
|
177
|
+
newPort && newPort !== "8081" && (await replacePortInProject(cwd, "8081", newPort), showSuccess(`\u2713 Updated web server port to ${newPort}`));
|
|
178
|
+
} else showInfo("Keeping default port 8081");
|
|
179
|
+
console.info(), showStep("Checking service ports..."), console.info();
|
|
180
|
+
var portChecks = checkAllPorts(),
|
|
181
|
+
conflicts = getConflictingPorts(portChecks);
|
|
182
|
+
conflicts.length > 0 && (displayPortConflicts(conflicts), showWarning("Some ports are already in use. You may need to stop other services.")), console.info();
|
|
183
|
+
}
|
|
184
|
+
if (startStep === "prerequisites" || startStep === "identity" || startStep === "ports" || startStep === "full") {
|
|
185
|
+
saveOnboardState(cwd, {
|
|
186
|
+
step: "ci-runners",
|
|
187
|
+
timestamp: Date.now()
|
|
188
|
+
}), showStep("Configuring CI/CD runners..."), console.info();
|
|
189
|
+
var shouldConfigureCI = await confirmContinue("Configure GitHub Actions CI runners?", !0);
|
|
190
|
+
shouldConfigureCI ? await configureCIRunners(cwd) : (showInfo("Skipping CI runner configuration"), showWarning("Default CI uses ARM64 Docker builds. If not using ARM runners, update scripts/web/build-docker.ts")), console.info();
|
|
191
|
+
}
|
|
192
|
+
if (startStep !== "production" && (showStep("Development setup complete!"), console.info(), showSuccess("\u2713 Environment configured"), showSuccess("\u2713 Project ready for development"), markOnboarded(cwd), console.info(), showInfo("Next steps (run in separate terminals):"), console.info(), console.info(" bun backend # start docker services first"), console.info(" bun dev # start web dev server"), console.info(), console.info(" bun ios # build iOS dev app"), console.info(" bun android # build Android dev app"), console.info(" bun tko docs list # view Takeout docs"), console.info()), startStep !== "production") {
|
|
193
|
+
console.info(), showStep("Monorepo Setup"), console.info(), console.info(pc.gray("We've included a variety of packages we found useful building apps with this stack:")), console.info(pc.gray(" \u2022 @take-out/cli - CLI tools and onboarding")), console.info(pc.gray(" \u2022 @take-out/helpers - Utility functions")), console.info(pc.gray(" \u2022 @take-out/hooks - React hooks")), console.info(pc.gray(" \u2022 @take-out/postgres - Database utilities")), console.info(pc.gray(" \u2022 @take-out/scripts - Build and dev scripts")), console.info(pc.gray(" \u2022 @take-out/better-auth-utils - Auth helpers")), console.info(), console.info(pc.gray("These packages are included locally for two reasons:")), console.info(pc.gray(" 1. You can see their source and decide if you want to keep them")), console.info(pc.gray(" 2. Anyone can easily submit fixes or improvements back to our repo")), console.info(), console.info(pc.gray("Over time we'll publish new versions. You can sync with 'bun tko sync' (monorepo)")), console.info(pc.gray("or if you eject, use 'bun up takeout' for package updates.")), console.info();
|
|
194
|
+
var shouldEject1 = await confirmContinue("Eject from monorepo setup? (removes ./packages, uses published versions)", !1);
|
|
195
|
+
if (shouldEject1) {
|
|
196
|
+
var dryResult1 = await ejectFromMonorepo(cwd, {
|
|
197
|
+
dryRun: !0
|
|
198
|
+
});
|
|
199
|
+
if (!dryResult1.success) showError(`Cannot eject: ${dryResult1.error}`);else {
|
|
200
|
+
var _dryResult_packages1, _dryResult_warnings1;
|
|
201
|
+
console.info(), showInfo(`Found ${(_dryResult_packages1 = dryResult1.packages) === null || _dryResult_packages1 === void 0 ? void 0 : _dryResult_packages1.length} packages to convert:`);
|
|
202
|
+
var _iteratorNormalCompletion2 = !0,
|
|
203
|
+
_didIteratorError2 = !1,
|
|
204
|
+
_iteratorError2 = void 0;
|
|
205
|
+
try {
|
|
206
|
+
for (var _iterator2 = (dryResult1.packages || [])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = !0) {
|
|
207
|
+
var pkg1 = _step2.value;
|
|
208
|
+
console.info(pc.gray(` \u2022 ${pkg1.name}@${pkg1.version}`));
|
|
209
|
+
}
|
|
210
|
+
} catch (err) {
|
|
211
|
+
_didIteratorError2 = !0, _iteratorError2 = err;
|
|
212
|
+
} finally {
|
|
213
|
+
try {
|
|
214
|
+
!_iteratorNormalCompletion2 && _iterator2.return != null && _iterator2.return();
|
|
215
|
+
} finally {
|
|
216
|
+
if (_didIteratorError2) throw _iteratorError2;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (!((_dryResult_warnings1 = dryResult1.warnings) === null || _dryResult_warnings1 === void 0) && _dryResult_warnings1.length) {
|
|
220
|
+
var _iteratorNormalCompletion3 = !0,
|
|
221
|
+
_didIteratorError3 = !1,
|
|
222
|
+
_iteratorError3 = void 0;
|
|
223
|
+
try {
|
|
224
|
+
for (var _iterator3 = dryResult1.warnings[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = !0) {
|
|
225
|
+
var warn1 = _step3.value;
|
|
226
|
+
showWarning(warn1);
|
|
227
|
+
}
|
|
228
|
+
} catch (err) {
|
|
229
|
+
_didIteratorError3 = !0, _iteratorError3 = err;
|
|
230
|
+
} finally {
|
|
231
|
+
try {
|
|
232
|
+
!_iteratorNormalCompletion3 && _iterator3.return != null && _iterator3.return();
|
|
233
|
+
} finally {
|
|
234
|
+
if (_didIteratorError3) throw _iteratorError3;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
console.info();
|
|
239
|
+
var confirmEject1 = await confirmContinue("Proceed with ejection?", !0);
|
|
240
|
+
if (confirmEject1) {
|
|
241
|
+
var spinner1 = showSpinner("Ejecting from monorepo..."),
|
|
242
|
+
result1 = await ejectFromMonorepo(cwd);
|
|
243
|
+
if (result1.success) {
|
|
244
|
+
spinner1.stop("Ejected from monorepo"), showSuccess("\u2713 Removed ./packages directory"), showSuccess("\u2713 Updated package.json to use published versions"), showSuccess("\u2713 Installed published packages");
|
|
245
|
+
try {
|
|
246
|
+
execSync('git add -A && git commit -m "ejected from monorepo"', {
|
|
247
|
+
cwd,
|
|
248
|
+
stdio: "ignore"
|
|
249
|
+
}), showSuccess("\u2713 Committed eject changes");
|
|
250
|
+
} catch {
|
|
251
|
+
showWarning("Git commit skipped (not a git repo or no changes)");
|
|
252
|
+
}
|
|
253
|
+
console.info(), showInfo("You can now upgrade packages with: bun up takeout");
|
|
254
|
+
} else {
|
|
255
|
+
var _result_error1;
|
|
256
|
+
spinner1.stop("Ejection failed"), showError(`Failed to eject: ${result1.error}`), !((_result_error1 = result1.error) === null || _result_error1 === void 0) && _result_error1.includes("install failed") && (showInfo('You may be able to fix this by running "bun install" manually'), showInfo('Or restore the repo from git with "git checkout ."'));
|
|
257
|
+
}
|
|
258
|
+
} else showInfo("Keeping monorepo setup - you can customize packages locally"), showInfo('Run "bun tko sync" to sync with upstream Takeout updates later');
|
|
259
|
+
}
|
|
260
|
+
} else showInfo("Keeping monorepo setup - you can customize packages locally"), showInfo('Run "bun tko sync" to sync with upstream Takeout updates later');
|
|
261
|
+
console.info();
|
|
262
|
+
}
|
|
263
|
+
if (startStep === "full" || startStep === "production") {
|
|
264
|
+
saveOnboardState(cwd, {
|
|
265
|
+
step: "production",
|
|
266
|
+
timestamp: Date.now()
|
|
267
|
+
}), console.info(), showStep("Production deployment setup"), console.info();
|
|
268
|
+
var setupProd = startStep === "production";
|
|
269
|
+
startStep === "full" && (setupProd = await confirmContinue("Set up production deployment?", !1)), setupProd ? await setupProductionDeployment(cwd) : (showInfo("Skipping production setup"), showInfo("You can set up production later with: bun tko onboard --production"));
|
|
270
|
+
}
|
|
271
|
+
clearOnboardState(cwd), console.info(), displayOutro("Happy coding! \u{1F680}");
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
async function customizeProject(cwd) {
|
|
275
|
+
var projectName = await promptText("Project name:", "takeout", "my-awesome-app"),
|
|
276
|
+
slug = await promptText("Project slug (URL-friendly):", projectName.toLowerCase().replace(/\s+/g, "-"), "my-awesome-app"),
|
|
277
|
+
bundleId = await promptText("Bundle identifier:", `com.${slug}.app`, "com.example.app"),
|
|
278
|
+
domain = await promptText("Development domain:", "localhost:8081", "localhost:8081"),
|
|
279
|
+
pkgResult = updatePackageJson(cwd, {
|
|
280
|
+
name: projectName,
|
|
281
|
+
description: `${projectName} - Built with Takeout starter kit`
|
|
282
|
+
});
|
|
283
|
+
pkgResult.success ? showSuccess("Updated package.json") : showError(`Failed to update package.json: ${pkgResult.error}`);
|
|
284
|
+
var configResult = updateAppConfig(cwd, {
|
|
285
|
+
name: projectName,
|
|
286
|
+
slug,
|
|
287
|
+
bundleId
|
|
288
|
+
});
|
|
289
|
+
configResult.success ? showSuccess("Updated app.config.ts") : showError(`Failed to update app.config.ts: ${configResult.error}`);
|
|
290
|
+
var serverUrl = `http://${domain}`;
|
|
291
|
+
updateEnvVariable(cwd, "BETTER_AUTH_URL", serverUrl), updateEnvVariable(cwd, "ONE_SERVER_URL", serverUrl), showSuccess("Updated environment URLs");
|
|
292
|
+
}
|
|
293
|
+
async function setupProductionDeployment(cwd) {
|
|
294
|
+
var platform = await promptSelect("Choose deployment platform:", [{
|
|
295
|
+
value: "uncloud",
|
|
296
|
+
label: "Uncloud",
|
|
297
|
+
hint: "Simpler and quicker (~10 minutes setup)"
|
|
298
|
+
}, {
|
|
299
|
+
value: "sst",
|
|
300
|
+
label: "AWS SST",
|
|
301
|
+
hint: "Proven and reliable (~1 hour setup)"
|
|
302
|
+
}]);
|
|
303
|
+
if (platform === "cancel") {
|
|
304
|
+
showInfo("Skipping production setup");
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
console.info(), platform === "uncloud" ? await setupUncloudDeployment(cwd) : await setupSSTDeployment(cwd);
|
|
308
|
+
}
|
|
309
|
+
async function setupUncloudDeployment(cwd) {
|
|
310
|
+
showInfo("Setting up Uncloud deployment"), console.info(), console.info(pc.gray(`Uncloud provides:
|
|
311
|
+
\u2022 Managed PostgreSQL with logical replication
|
|
312
|
+
\u2022 Free subdomain (your-app.uncld.dev)
|
|
313
|
+
\u2022 Automatic SSL certificates
|
|
314
|
+
\u2022 Easy scaling`)), console.info(), console.info(), showInfo("Server Architecture"), console.info(pc.gray("Docker images must match your server CPU architecture")), console.info();
|
|
315
|
+
var architecture = await promptSelect("What CPU architecture is your deployment server?", [{
|
|
316
|
+
value: "amd64",
|
|
317
|
+
label: "AMD64/x86_64 (Intel/AMD)",
|
|
318
|
+
hint: "Most VPS providers (DigitalOcean, Linode, Vultr)"
|
|
319
|
+
}, {
|
|
320
|
+
value: "arm64",
|
|
321
|
+
label: "ARM64 (Apple Silicon)",
|
|
322
|
+
hint: "Hetzner ARM, Oracle ARM, Bare metal ARM servers"
|
|
323
|
+
}]);
|
|
324
|
+
if (architecture === "cancel") {
|
|
325
|
+
showInfo("Skipping production setup");
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
var deploymentArch = architecture === "arm64" ? "linux/arm64" : "linux/amd64";
|
|
329
|
+
console.info(), showInfo(`Will build Docker images for: ${deploymentArch}`), console.info();
|
|
330
|
+
var appConstantsPath = resolve(cwd, "src/constants/app.ts"),
|
|
331
|
+
defaultAppName = "my-app";
|
|
332
|
+
try {
|
|
333
|
+
var appConstants = readFileSync(appConstantsPath, "utf-8"),
|
|
334
|
+
appNameMatch = appConstants.match(/APP_NAME_LOWERCASE\s*=\s*['"](.+?)['"]/);
|
|
335
|
+
appNameMatch?.[1] && (defaultAppName = appNameMatch[1]);
|
|
336
|
+
} catch {}
|
|
337
|
+
var useFreeSubdomain = await confirmContinue("Use free Uncloud subdomain?", !0),
|
|
338
|
+
domain,
|
|
339
|
+
zeroUrl;
|
|
340
|
+
if (useFreeSubdomain) {
|
|
341
|
+
var appName = await promptText("App name for subdomain:", defaultAppName, defaultAppName);
|
|
342
|
+
domain = `https://${appName}.uncld.dev`, zeroUrl = `https://zero-${appName}.uncld.dev`;
|
|
343
|
+
} else domain = await promptText("Enter your custom domain:", void 0, "https://yourapp.com"), zeroUrl = await promptText("Enter your Zero sync domain:", void 0, "https://zero.yourapp.com"), console.info(), showWarning("Custom domain setup requires DNS configuration after deployment"), console.info(pc.gray("See: https://uncloud.run/docs/domains"));
|
|
344
|
+
console.info(), showInfo("Database Configuration"), console.info(), console.info(pc.gray("PostgreSQL database with logical replication enabled")), console.info(pc.gray("Zero sync requires 3 databases on the same host:")), console.info(pc.gray(" \u2022 Main database (your app data)")), console.info(pc.gray(" \u2022 Two Zero databases (for sync infrastructure)")), console.info(), console.info(pc.gray("Use a managed database (DigitalOcean, Render, Supabase, etc.)")), console.info(pc.gray("The deployment will automatically create the Zero databases")), console.info();
|
|
345
|
+
var dbUser = await promptText("Database username:", void 0, "postgres"),
|
|
346
|
+
dbPassword = await promptText("Database password:", void 0, ""),
|
|
347
|
+
dbHost = await promptText("Database host (e.g., db-xxx.ondigitalocean.com):", void 0, "localhost"),
|
|
348
|
+
dbPort = await promptText("Database port:", "5432", "5432"),
|
|
349
|
+
dbName = await promptText("Main database name (will derive Zero databases from this):", "postgres", "postgres"),
|
|
350
|
+
dbUrl = `postgresql://${dbUser}:${dbPassword}@${dbHost}:${dbPort}/${dbName}`;
|
|
351
|
+
console.info();
|
|
352
|
+
var authSecret = randomBytes(32).toString("hex"),
|
|
353
|
+
envFile = ".env.production";
|
|
354
|
+
updateEnvVariable(cwd, "DEPLOYMENT_PLATFORM", "uncloud", envFile), updateEnvVariable(cwd, "DEPLOYMENT_ARCH", deploymentArch, envFile), updateEnvVariable(cwd, "DEPLOY_DB", dbUrl, envFile), updateEnvVariable(cwd, "BETTER_AUTH_SECRET", authSecret, envFile), updateEnvVariable(cwd, "BETTER_AUTH_URL", domain, envFile), updateEnvVariable(cwd, "ONE_SERVER_URL", domain, envFile), updateEnvVariable(cwd, "VITE_PUBLIC_ZERO_SERVER", zeroUrl, envFile);
|
|
355
|
+
var dbBase = dbUrl.split("/").slice(0, -1).join("/"),
|
|
356
|
+
zeroCvrDb = `${dbBase}/zero_cvr`,
|
|
357
|
+
zeroChangeDb = `${dbBase}/zero_cdb`;
|
|
358
|
+
updateEnvVariable(cwd, "ZERO_UPSTREAM_DB", dbUrl, envFile), updateEnvVariable(cwd, "ZERO_CVR_DB", zeroCvrDb, envFile), updateEnvVariable(cwd, "ZERO_CHANGE_DB", zeroChangeDb, envFile), updateEnvVariable(cwd, "ZERO_UPSTREAM_DB", dbUrl, ".env"), updateEnvVariable(cwd, "ZERO_CVR_DB", zeroCvrDb, ".env"), updateEnvVariable(cwd, "ZERO_CHANGE_DB", zeroChangeDb, ".env");
|
|
359
|
+
var deployHost = new URL(domain).hostname;
|
|
360
|
+
updateEnvVariable(cwd, "DEPLOY_HOST", deployHost, envFile), updateEnvVariable(cwd, "DEPLOY_USER", "root", envFile), console.info(), showInfo("SSH Key Configuration"), console.info(pc.gray("Deployment requires SSH access to your server")), console.info();
|
|
361
|
+
var sshKeyPath = await promptText("Path to SSH private key:", `${homedir()}/.ssh/id_rsa`, `${homedir()}/.ssh/id_rsa`);
|
|
362
|
+
sshKeyPath && (existsSync(sshKeyPath) ? (updateEnvVariable(cwd, "DEPLOY_SSH_KEY", sshKeyPath, envFile), showSuccess(`\u2713 SSH key configured: ${sshKeyPath}`), console.info(), showInfo(pc.gray("For CI/CD, you'll need to add the SSH private key content as a GitHub secret")), showInfo(pc.gray("The sync script will help with this"))) : (showWarning(`SSH key not found at: ${sshKeyPath}`), showInfo("You can add DEPLOY_SSH_KEY to .env.production manually later"))), console.info(), showSuccess(`\u2713 Saved configuration to ${envFile}`), console.info(), showInfo("Custom Domain Setup (Optional)"), console.info(pc.gray("By default, your app will use:")), console.info(pc.gray(` ${deployHost} (cluster subdomain from Uncloud DNS)`)), console.info(), console.info(pc.gray("You can optionally configure custom domains (e.g., app.yourdomain.com) by:")), console.info(pc.gray(" 1. Adding CNAME records in your DNS provider")), console.info(pc.gray(" 2. Pointing to your cluster subdomain")), console.info(pc.gray(" 3. Setting WEB_DOMAIN and ZERO_DOMAIN in .env.production")), console.info();
|
|
363
|
+
var configureCustomDomain = await confirmContinue("Configure custom domain now?", !1);
|
|
364
|
+
if (configureCustomDomain) {
|
|
365
|
+
console.info(), console.info(pc.gray("First, run: uc dns reserve")), console.info(pc.gray("This will give you a cluster subdomain like: abc123.cluster.uncld.dev")), console.info();
|
|
366
|
+
var clusterSubdomain = await promptText("Enter your cluster subdomain from uc dns show:", "", "");
|
|
367
|
+
if (clusterSubdomain) {
|
|
368
|
+
console.info(), showInfo("DNS Setup Instructions:"), console.info(pc.gray("Add these CNAME records in your DNS provider (e.g., Cloudflare):")), console.info();
|
|
369
|
+
var webDomain = await promptText("Custom domain for web app (e.g., app.yourdomain.com):", "", ""),
|
|
370
|
+
zeroDomain = await promptText("Custom domain for zero sync (e.g., zero.yourdomain.com):", "", "");
|
|
371
|
+
if (webDomain) {
|
|
372
|
+
console.info(), console.info(pc.cyan(` CNAME: ${webDomain} \u2192 ${clusterSubdomain}`)), zeroDomain && console.info(pc.cyan(` CNAME: ${zeroDomain} \u2192 ${clusterSubdomain}`)), console.info(), console.info(pc.yellow('\u26A0\uFE0F Set DNS to "DNS only" mode (gray cloud), not proxied')), console.info(), updateEnvVariable(cwd, "WEB_DOMAIN", webDomain, envFile), updateEnvVariable(cwd, "BETTER_AUTH_URL", `https://${webDomain}`, envFile), updateEnvVariable(cwd, "ONE_SERVER_URL", `https://${webDomain}`, envFile), zeroDomain && (updateEnvVariable(cwd, "ZERO_DOMAIN", zeroDomain, envFile), updateEnvVariable(cwd, "VITE_PUBLIC_ZERO_SERVER", `https://${zeroDomain}`, envFile)), showSuccess("\u2713 Custom domains configured"), console.info(), showInfo(pc.gray("DNS propagation typically takes 5-30 minutes")), console.info(), showInfo("SSL Certificate Options"), console.info(pc.gray("By default, Caddy will use Let's Encrypt for SSL certificates.")), console.info(pc.gray("If using Cloudflare, you can use Origin CA instead to:")), console.info(pc.gray(" \u2022 Bypass Let's Encrypt rate limits")), console.info(pc.gray(" \u2022 Enable Cloudflare proxy (DDoS protection, caching)")), console.info();
|
|
373
|
+
var useOriginCA = await confirmContinue("Use Cloudflare Origin CA? (requires Cloudflare account)", !1);
|
|
374
|
+
if (useOriginCA) {
|
|
375
|
+
console.info(), showInfo("Cloudflare Origin CA Setup"), console.info(pc.gray("1. Go to Cloudflare Dashboard \u2192 SSL/TLS \u2192 Origin Server")), console.info(pc.gray('2. Click "Create Certificate"')), console.info(pc.gray(`3. Add hostnames: ${webDomain}${zeroDomain ? `, ${zeroDomain}` : ""}`)), console.info(pc.gray("4. Choose 15 year validity")), console.info(pc.gray("5. Save certificate to: certs/origin.pem")), console.info(pc.gray("6. Save private key to: certs/origin.key")), console.info();
|
|
376
|
+
var certPath = await promptText("Path to Origin CA certificate:", "certs/origin.pem", "certs/origin.pem"),
|
|
377
|
+
keyPath = await promptText("Path to Origin CA private key:", "certs/origin.key", "certs/origin.key");
|
|
378
|
+
certPath && keyPath && (updateEnvVariable(cwd, "ORIGIN_CA_CERT", certPath, envFile), updateEnvVariable(cwd, "ORIGIN_CA_KEY", keyPath, envFile), showSuccess("\u2713 Origin CA configured"), console.info(pc.gray(" Caddyfile will be auto-generated during deploy")), console.info(), console.info(pc.yellow("Important: In Cloudflare Dashboard:")), console.info(pc.yellow(" 1. Enable proxy (orange cloud) for your domains")), console.info(pc.yellow(' 2. Set SSL mode to "Full (strict)"')));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
console.info(), showInfo("Updating package.json env section for Uncloud deployment...");
|
|
384
|
+
var envUpdateResult = updatePackageJsonEnv(cwd, "uncloud");
|
|
385
|
+
envUpdateResult.success ? showSuccess("\u2713 Removed SST-specific environment variables from package.json") : showWarning(`Failed to update package.json env: ${envUpdateResult.error}`), console.info(), showInfo("Updating GitHub workflow with environment variables...");
|
|
386
|
+
try {
|
|
387
|
+
execSync("bun env:update", {
|
|
388
|
+
cwd,
|
|
389
|
+
stdio: "ignore"
|
|
390
|
+
}), showSuccess("\u2713 GitHub workflow updated");
|
|
391
|
+
} catch {
|
|
392
|
+
showWarning("Failed to update GitHub workflow (non-critical)");
|
|
393
|
+
}
|
|
394
|
+
console.info();
|
|
395
|
+
var syncToGitHub = await confirmContinue("Sync environment to GitHub secrets for CI/CD?", !0);
|
|
396
|
+
if (syncToGitHub) try {
|
|
397
|
+
execSync("bun scripts/env/sync-to-github.ts --yes", {
|
|
398
|
+
cwd,
|
|
399
|
+
stdio: "inherit"
|
|
400
|
+
});
|
|
401
|
+
} catch {
|
|
402
|
+
showWarning("Failed to sync to GitHub (you can do this later)"), showInfo("Run manually: bun scripts/env/sync-to-github.ts");
|
|
403
|
+
} else showInfo("You can sync later with: bun scripts/env/sync-to-github.ts");
|
|
404
|
+
console.info(), showStep("Ready to deploy!"), console.info(), console.info(pc.bold("Next steps:")), console.info(), console.info(pc.cyan("1. Install Uncloud CLI (if not already installed):")), console.info(pc.gray(" npm install -g uncloud-cli")), console.info(), console.info(pc.cyan("2. Login to Uncloud:")), console.info(pc.gray(" uncloud login")), console.info(), console.info(pc.cyan("3. Deploy your app:")), console.info(pc.gray(" bun tko uncloud deploy-prod")), console.info(), console.info(pc.cyan("Or push to main branch for automatic CI/CD deployment:")), console.info(pc.gray(" git push origin main")), console.info(), console.info(pc.bold("scaling to multiple machines:")), console.info(pc.gray(" uc machine add --name server-2 root@IP")), console.info(pc.gray(" uc scale web 3 # run 3 instances")), console.info(), console.info(pc.gray("view detailed guide: bun tko docs read deployment-uncloud")), console.info(pc.gray("or see: docs/deployment-uncloud.md"));
|
|
405
|
+
}
|
|
406
|
+
async function setupSSTDeployment(cwd) {
|
|
407
|
+
showInfo("Setting up AWS SST deployment"), console.info(), showWarning("AWS setup takes approximately 30 minutes"), console.info(), console.info(pc.gray(`SST provides:
|
|
408
|
+
\u2022 AWS infrastructure (ECS, Aurora, ALB)
|
|
409
|
+
\u2022 Auto-scaling
|
|
410
|
+
\u2022 Full control over resources
|
|
411
|
+
\u2022 Higher setup complexity`)), console.info(), console.info(), showInfo("AWS ECS Architecture"), console.info(pc.gray("AWS Graviton (ARM64) is ~40% cheaper than x86_64")), console.info(pc.gray("Both have excellent performance, ARM recommended for cost savings")), console.info();
|
|
412
|
+
var architecture = await promptSelect("What CPU architecture for AWS ECS?", [{
|
|
413
|
+
value: "arm64",
|
|
414
|
+
label: "ARM64 (Graviton) - Recommended",
|
|
415
|
+
hint: "Significantly cheaper, excellent performance"
|
|
416
|
+
}, {
|
|
417
|
+
value: "amd64",
|
|
418
|
+
label: "AMD64/x86_64 (Intel/AMD)",
|
|
419
|
+
hint: "Standard option if you need specific x86 dependencies"
|
|
420
|
+
}]);
|
|
421
|
+
if (architecture === "cancel") {
|
|
422
|
+
showInfo("Skipping AWS setup");
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
var deploymentArch = architecture === "arm64" ? "linux/arm64" : "linux/amd64";
|
|
426
|
+
console.info(), showInfo(`Will build Docker images for: ${deploymentArch}`), console.info();
|
|
427
|
+
var shouldContinue = await confirmContinue("Continue with AWS SST setup? (requires AWS account)", !1);
|
|
428
|
+
if (!shouldContinue) {
|
|
429
|
+
showInfo("Skipping AWS setup"), showInfo("You can set up AWS later with: bun tko env:setup --category aws");
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
await setupProductionEnv(cwd, {
|
|
433
|
+
onlyCategory: "aws",
|
|
434
|
+
envFile: ".env.production",
|
|
435
|
+
interactive: !0
|
|
436
|
+
});
|
|
437
|
+
var envFile = ".env.production";
|
|
438
|
+
updateEnvVariable(cwd, "DEPLOYMENT_PLATFORM", "sst", envFile), updateEnvVariable(cwd, "DEPLOYMENT_ARCH", deploymentArch, envFile), console.info(), showInfo("Updating sst.config.ts architecture...");
|
|
439
|
+
try {
|
|
440
|
+
var sstConfigPath = resolve(cwd, "sst.config.ts"),
|
|
441
|
+
sstConfig = readFileSync(sstConfigPath, "utf-8"),
|
|
442
|
+
archValue = architecture === "arm64" ? "arm64" : "x86_64";
|
|
443
|
+
sstConfig = sstConfig.replace(/architecture:\s*['"]arm64['"]/g, `architecture: '${archValue}'`), sstConfig = sstConfig.replace(/architecture:\s*['"]x86_64['"]/g, `architecture: '${archValue}'`), writeFileSync(sstConfigPath, sstConfig), showSuccess(`\u2713 Updated sst.config.ts to use ${archValue}`);
|
|
444
|
+
} catch {
|
|
445
|
+
showWarning("Could not update sst.config.ts (you can update manually)");
|
|
446
|
+
}
|
|
447
|
+
console.info(), showInfo("Updating package.json env section for SST deployment...");
|
|
448
|
+
var envUpdateResult = updatePackageJsonEnv(cwd, "sst");
|
|
449
|
+
envUpdateResult.success ? showSuccess("\u2713 Removed Uncloud-specific environment variables from package.json") : showWarning(`Failed to update package.json env: ${envUpdateResult.error}`), console.info(), showInfo("Updating GitHub workflow with environment variables...");
|
|
450
|
+
try {
|
|
451
|
+
execSync("bun env:update", {
|
|
452
|
+
cwd,
|
|
453
|
+
stdio: "ignore"
|
|
454
|
+
}), showSuccess("\u2713 GitHub workflow updated");
|
|
455
|
+
} catch {
|
|
456
|
+
showWarning("Failed to update GitHub workflow (non-critical)");
|
|
457
|
+
}
|
|
458
|
+
console.info();
|
|
459
|
+
var syncToGitHub = await confirmContinue("Sync environment to GitHub secrets for CI/CD?", !0);
|
|
460
|
+
if (syncToGitHub) try {
|
|
461
|
+
execSync("bun scripts/env/sync-to-github.ts --yes", {
|
|
462
|
+
cwd,
|
|
463
|
+
stdio: "inherit"
|
|
464
|
+
});
|
|
465
|
+
} catch {
|
|
466
|
+
showWarning("Failed to sync to GitHub (you can do this later)"), showInfo("Run manually: bun scripts/env/sync-to-github.ts");
|
|
467
|
+
} else showInfo("You can sync later with: bun scripts/env/sync-to-github.ts");
|
|
468
|
+
console.info(), showInfo("For complete AWS deployment guide, see: https://docs.yourapp.com/deployment/sst");
|
|
469
|
+
}
|
|
470
|
+
async function configureCIRunners(cwd) {
|
|
471
|
+
showInfo("GitHub Actions CI/CD Runner Configuration"), console.info(), console.info(pc.gray(`Your project uses ARM64 (Apple Silicon) architecture for Docker builds.
|
|
472
|
+
GitHub Actions requires compatible runners for CI/CD to work properly.`)), console.info();
|
|
473
|
+
var runnerChoice = await promptSelect("Choose your CI runner configuration:", [{
|
|
474
|
+
value: "warp",
|
|
475
|
+
label: "Warp Runners (Recommended)",
|
|
476
|
+
hint: "Fast ARM64 runners, cheaper than GitHub ($0.005/min)"
|
|
477
|
+
}, {
|
|
478
|
+
value: "github-arm",
|
|
479
|
+
label: "GitHub ARM Runners",
|
|
480
|
+
hint: "Native ARM64, requires GitHub Teams/Enterprise ($0.16/min)"
|
|
481
|
+
}, {
|
|
482
|
+
value: "github-x64",
|
|
483
|
+
label: "GitHub x64 Runners (Free)",
|
|
484
|
+
hint: "Requires changing Docker builds to x64 architecture"
|
|
485
|
+
}, {
|
|
486
|
+
value: "skip",
|
|
487
|
+
label: "Configure Later",
|
|
488
|
+
hint: "Skip for now (CI will fail until configured)"
|
|
489
|
+
}]);
|
|
490
|
+
if (runnerChoice === "cancel" || runnerChoice === "skip") {
|
|
491
|
+
showInfo("Skipping CI runner configuration"), showWarning("CI/CD will fail until you configure runners. Update .github/workflows/ci.yml");
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
var ciConfigPath = resolve(cwd, ".github/workflows/ci.yml"),
|
|
495
|
+
dockerBuildPath = resolve(cwd, "scripts/web/build-docker.ts");
|
|
496
|
+
try {
|
|
497
|
+
var ciContent = readFileSync(ciConfigPath, "utf-8"),
|
|
498
|
+
dockerContent = readFileSync(dockerBuildPath, "utf-8");
|
|
499
|
+
runnerChoice === "warp" ? (console.info(), showStep("Setting up Warp runners"), console.info(), console.info(pc.cyan("1. Sign up for Warp Build (if not already):")), console.info(pc.gray(" https://www.warpbuild.com")), console.info(), console.info(pc.cyan("2. Install Warp GitHub App:")), console.info(pc.gray(" https://github.com/apps/warp-build")), console.info(), console.info(pc.cyan("3. Grant access to your repository")), console.info(), showSuccess("\u2713 CI configuration already set for Warp runners"), showInfo("Warp uses ARM64 runners matching your local architecture")) : runnerChoice === "github-arm" ? (ciContent = ciContent.replace(/runs-on:.*warp-ubuntu-latest-arm64.*/, "runs-on: ubuntu-24.04-arm"), writeFileSync(ciConfigPath, ciContent), console.info(), showSuccess("\u2713 Updated CI to use GitHub ARM runners"), showWarning("Note: GitHub ARM runners require Teams or Enterprise plan"), showInfo("Pricing: $0.16/minute for ARM runners")) : runnerChoice === "github-x64" && (ciContent = ciContent.replace(/runs-on:.*warp-ubuntu-latest-arm64.*/, "runs-on: ubuntu-latest"), writeFileSync(ciConfigPath, ciContent), dockerContent = dockerContent.replace("linux/arm64", "linux/amd64"), writeFileSync(dockerBuildPath, dockerContent), console.info(), showSuccess("\u2713 Updated CI to use free GitHub x64 runners"), showSuccess("\u2713 Updated Docker builds to x64 architecture"), showWarning("Note: Docker images built on x64 won't run on ARM64 machines without emulation")), console.info(), showInfo("CI runner configuration complete");
|
|
500
|
+
} catch {
|
|
501
|
+
showError("Failed to update CI configuration"), showInfo("Please manually update .github/workflows/ci.yml and scripts/web/build-docker.ts");
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
async function replacePortInProject(cwd, oldPort, newPort) {
|
|
505
|
+
var spinner = showSpinner(`Replacing port ${oldPort} with ${newPort} throughout project...`),
|
|
506
|
+
excludeDirs = /* @__PURE__ */new Set(["node_modules", ".git", "dist", "build", ".next", ".turbo", "types"]),
|
|
507
|
+
includeExts = /* @__PURE__ */new Set([".ts", ".tsx", ".js", ".jsx", ".json", ".md", ".yml", ".yaml"]);
|
|
508
|
+
async function processDir(dir) {
|
|
509
|
+
var {
|
|
510
|
+
readdirSync,
|
|
511
|
+
statSync
|
|
512
|
+
} = await import("fs"),
|
|
513
|
+
{
|
|
514
|
+
join,
|
|
515
|
+
extname,
|
|
516
|
+
basename
|
|
517
|
+
} = await import("path"),
|
|
518
|
+
entries = readdirSync(dir),
|
|
519
|
+
_iteratorNormalCompletion = !0,
|
|
520
|
+
_didIteratorError = !1,
|
|
521
|
+
_iteratorError = void 0;
|
|
522
|
+
try {
|
|
523
|
+
for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
524
|
+
var entry = _step.value,
|
|
525
|
+
fullPath = join(dir, entry);
|
|
526
|
+
try {
|
|
527
|
+
var stat = statSync(fullPath);
|
|
528
|
+
if (stat.isDirectory()) excludeDirs.has(entry) || (await processDir(fullPath));else if (stat.isFile()) {
|
|
529
|
+
var ext = extname(entry),
|
|
530
|
+
name = basename(entry);
|
|
531
|
+
if (includeExts.has(ext) || name.startsWith(".env")) {
|
|
532
|
+
var content = readFileSync(fullPath, "utf-8");
|
|
533
|
+
if (content.includes(oldPort)) {
|
|
534
|
+
var newContent = content.split(oldPort).join(newPort);
|
|
535
|
+
writeFileSync(fullPath, newContent, "utf-8");
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
} catch {}
|
|
540
|
+
}
|
|
541
|
+
} catch (err) {
|
|
542
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
543
|
+
} finally {
|
|
544
|
+
try {
|
|
545
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
546
|
+
} finally {
|
|
547
|
+
if (_didIteratorError) throw _iteratorError;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
try {
|
|
552
|
+
await processDir(cwd), spinner.stop(`Port updated from ${oldPort} to ${newPort}`);
|
|
553
|
+
} catch (error) {
|
|
554
|
+
throw spinner.stop("Port replacement failed"), showError("Failed to replace port. You may need to update manually."), error;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
function getStatePath(cwd) {
|
|
558
|
+
return resolve(cwd, "node_modules/.takeout/onboard-state.json");
|
|
559
|
+
}
|
|
560
|
+
function saveOnboardState(cwd, state) {
|
|
561
|
+
var statePath = getStatePath(cwd),
|
|
562
|
+
stateDir = resolve(cwd, "node_modules/.takeout");
|
|
563
|
+
existsSync(stateDir) || mkdirSync(stateDir, {
|
|
564
|
+
recursive: !0
|
|
565
|
+
}), writeFileSync(statePath, JSON.stringify(state, null, 2));
|
|
566
|
+
}
|
|
567
|
+
function loadOnboardState(cwd) {
|
|
568
|
+
var statePath = getStatePath(cwd);
|
|
569
|
+
if (!existsSync(statePath)) return null;
|
|
570
|
+
try {
|
|
571
|
+
var content = readFileSync(statePath, "utf-8");
|
|
572
|
+
return JSON.parse(content);
|
|
573
|
+
} catch {
|
|
574
|
+
return null;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
function clearOnboardState(cwd) {
|
|
578
|
+
var statePath = getStatePath(cwd);
|
|
579
|
+
if (existsSync(statePath)) try {
|
|
580
|
+
unlinkSync(statePath);
|
|
581
|
+
} catch {}
|
|
582
|
+
}
|
|
583
|
+
export { onboardCommand };
|
|
584
|
+
//# sourceMappingURL=onboard.native.js.map
|