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