bod-cli 0.5.7 → 0.5.9
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/dist/cli.js +30 -19
- package/package.json +1 -1
- package/src/commands/deploy.ts +9 -4
- package/src/commands/init/init.ts +3 -18
- package/src/utils/resolve.ts +26 -0
package/dist/cli.js
CHANGED
|
@@ -18830,6 +18830,16 @@ function readAppNameFromYaml() {
|
|
|
18830
18830
|
function readInstanceFromYaml() {
|
|
18831
18831
|
return readYaml()?.instance;
|
|
18832
18832
|
}
|
|
18833
|
+
function resolveRepoFromYaml() {
|
|
18834
|
+
const repo = readYaml()?.repo;
|
|
18835
|
+
if (typeof repo === "string")
|
|
18836
|
+
return repo || undefined;
|
|
18837
|
+
if (repo === true) {
|
|
18838
|
+
const proc = Bun.spawnSync(["git", "remote", "get-url", "origin"]);
|
|
18839
|
+
return proc.exitCode === 0 ? proc.stdout.toString().trim() || undefined : undefined;
|
|
18840
|
+
}
|
|
18841
|
+
return;
|
|
18842
|
+
}
|
|
18833
18843
|
function readDeployModeFromYaml() {
|
|
18834
18844
|
const mode = readYaml()?.deploy;
|
|
18835
18845
|
return mode === "upload" ? "upload" : mode === "git" ? "git" : undefined;
|
|
@@ -18876,6 +18886,18 @@ function detectSiblingDeps() {
|
|
|
18876
18886
|
} catch {}
|
|
18877
18887
|
return [...paths];
|
|
18878
18888
|
}
|
|
18889
|
+
function readYamlConfig() {
|
|
18890
|
+
const yaml = readYaml();
|
|
18891
|
+
if (!yaml)
|
|
18892
|
+
return null;
|
|
18893
|
+
const configKeys = ["auth", "database", "ai", "analytics", "storage", "email", "prerender", "domain", "botProxyPaths", "dbMount"];
|
|
18894
|
+
const config = {};
|
|
18895
|
+
for (const key of configKeys) {
|
|
18896
|
+
if (yaml[key] !== undefined)
|
|
18897
|
+
config[key] = yaml[key];
|
|
18898
|
+
}
|
|
18899
|
+
return Object.keys(config).length ? config : null;
|
|
18900
|
+
}
|
|
18879
18901
|
function resolveAppName(arg) {
|
|
18880
18902
|
if (arg)
|
|
18881
18903
|
return arg;
|
|
@@ -18967,7 +18989,7 @@ function formatSize(bytes) {
|
|
|
18967
18989
|
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
18968
18990
|
}
|
|
18969
18991
|
async function uploadDeploy(client, appId, branch) {
|
|
18970
|
-
const defaultExcludes = ["node_modules", ".git", "dist"];
|
|
18992
|
+
const defaultExcludes = ["node_modules", ".git", "dist", ".env.local", ".env.*.local"];
|
|
18971
18993
|
const userExcludes = readExcludesFromYaml();
|
|
18972
18994
|
const allExcludes = [...new Set([...defaultExcludes, ...userExcludes])];
|
|
18973
18995
|
const excludeFlags = allExcludes.map((e2) => `--exclude=${e2}`);
|
|
@@ -19162,11 +19184,14 @@ var deploy_default = defineCommand2({
|
|
|
19162
19184
|
const appId = await resolveAppId(client, appName);
|
|
19163
19185
|
const branch = await detectBranch(args.branch);
|
|
19164
19186
|
const detail = await client.get(`/apps/${appId}`);
|
|
19187
|
+
const yamlConfig = readYamlConfig();
|
|
19188
|
+
if (yamlConfig) {
|
|
19189
|
+
await client.put(`/apps/${appId}`, yamlConfig).catch(() => {});
|
|
19190
|
+
}
|
|
19165
19191
|
const forceUpload = args.upload || readDeployModeFromYaml() === "upload";
|
|
19166
19192
|
let hasRepo = !!detail.repo;
|
|
19167
19193
|
if (!hasRepo && !forceUpload) {
|
|
19168
|
-
const
|
|
19169
|
-
const repo = proc.exitCode === 0 ? proc.stdout.toString().trim() : "";
|
|
19194
|
+
const repo = resolveRepoFromYaml();
|
|
19170
19195
|
if (repo) {
|
|
19171
19196
|
await client.put(`/apps/${appId}`, { repo });
|
|
19172
19197
|
console.log(source_default.dim(`Linked repo: ${repo}`));
|
|
@@ -19682,16 +19707,11 @@ var init_default = defineCommand2({
|
|
|
19682
19707
|
Bun.spawnSync(["git", "init"], { cwd, stdio: ["ignore", "ignore", "ignore"] });
|
|
19683
19708
|
Bun.spawnSync(["git", "add", "."], { cwd, stdio: ["ignore", "ignore", "ignore"] });
|
|
19684
19709
|
Bun.spawnSync(["git", "commit", "-m", "Initial commit (bod init)"], { cwd, stdio: ["ignore", "ignore", "ignore"] });
|
|
19685
|
-
let repo = "";
|
|
19686
|
-
try {
|
|
19687
|
-
const proc = Bun.spawnSync(["git", "remote", "get-url", "origin"], { cwd });
|
|
19688
|
-
repo = proc.exitCode === 0 ? proc.stdout.toString().trim() : "";
|
|
19689
|
-
} catch {}
|
|
19690
19710
|
console.log(source_default.dim("Registering app with Bodify..."));
|
|
19691
19711
|
try {
|
|
19692
19712
|
const app = await client.post("/apps", {
|
|
19693
19713
|
name: appName,
|
|
19694
|
-
repo,
|
|
19714
|
+
repo: "",
|
|
19695
19715
|
database: useDb
|
|
19696
19716
|
});
|
|
19697
19717
|
console.log(source_default.green(`✓ App registered (id: ${app.id})`));
|
|
@@ -19715,11 +19735,6 @@ var init_default = defineCommand2({
|
|
|
19715
19735
|
const detected = detectAppType(cwd);
|
|
19716
19736
|
console.log(source_default.dim(`Detected type: ${detected}`));
|
|
19717
19737
|
const appName = await esm_default2({ message: "App name:", default: folderName });
|
|
19718
|
-
let repo = "";
|
|
19719
|
-
try {
|
|
19720
|
-
const proc = Bun.spawnSync(["git", "remote", "get-url", "origin"], { cwd });
|
|
19721
|
-
repo = proc.stdout.toString().trim();
|
|
19722
|
-
} catch {}
|
|
19723
19738
|
const yamlPath = join3(cwd, "bodify.yaml");
|
|
19724
19739
|
let yamlData = {};
|
|
19725
19740
|
let yamlExisted = false;
|
|
@@ -19738,10 +19753,6 @@ var init_default = defineCommand2({
|
|
|
19738
19753
|
yamlData.database = true;
|
|
19739
19754
|
yamlDirty = true;
|
|
19740
19755
|
}
|
|
19741
|
-
if (repo) {
|
|
19742
|
-
yamlData.repo = repo;
|
|
19743
|
-
yamlDirty = true;
|
|
19744
|
-
}
|
|
19745
19756
|
yamlDirty = true;
|
|
19746
19757
|
}
|
|
19747
19758
|
if (yamlDirty) {
|
|
@@ -19754,7 +19765,7 @@ var init_default = defineCommand2({
|
|
|
19754
19765
|
try {
|
|
19755
19766
|
const app = await client.post("/apps", {
|
|
19756
19767
|
name: appName,
|
|
19757
|
-
repo,
|
|
19768
|
+
repo: "",
|
|
19758
19769
|
database: detected === "caab"
|
|
19759
19770
|
});
|
|
19760
19771
|
console.log(source_default.green(`✓ App registered (id: ${app.id})`));
|
package/package.json
CHANGED
package/src/commands/deploy.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { defineCommand } from 'citty'
|
|
|
2
2
|
import chalk from 'chalk'
|
|
3
3
|
import { loadConfig, getResolvedInstance } from '../config'
|
|
4
4
|
import { BodClient } from '../client'
|
|
5
|
-
import { resolveAppId, resolveAppName, readInstanceFromYaml, readDeployModeFromYaml, readExcludesFromYaml, detectSiblingDeps } from '../utils/resolve'
|
|
5
|
+
import { resolveAppId, resolveAppName, readInstanceFromYaml, readDeployModeFromYaml, readExcludesFromYaml, detectSiblingDeps, readYamlConfig, resolveRepoFromYaml } from '../utils/resolve'
|
|
6
6
|
|
|
7
7
|
async function detectBranch(explicit?: string): Promise<string> {
|
|
8
8
|
if (explicit) return explicit
|
|
@@ -18,7 +18,7 @@ function formatSize(bytes: number): string {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
async function uploadDeploy(client: BodClient, appId: string, branch: string) {
|
|
21
|
-
const defaultExcludes = ['node_modules', '.git', 'dist']
|
|
21
|
+
const defaultExcludes = ['node_modules', '.git', 'dist', '.env.local', '.env.*.local']
|
|
22
22
|
const userExcludes = readExcludesFromYaml()
|
|
23
23
|
const allExcludes = [...new Set([...defaultExcludes, ...userExcludes])]
|
|
24
24
|
const excludeFlags = allExcludes.map(e => `--exclude=${e}`)
|
|
@@ -236,12 +236,17 @@ export default defineCommand({
|
|
|
236
236
|
const branch = await detectBranch(args.branch)
|
|
237
237
|
const detail = await client.get<any>(`/apps/${appId}`)
|
|
238
238
|
|
|
239
|
+
// Sync bodify.yaml config (auth, database, ai, etc.) to the server
|
|
240
|
+
const yamlConfig = readYamlConfig()
|
|
241
|
+
if (yamlConfig) {
|
|
242
|
+
await client.put(`/apps/${appId}`, yamlConfig).catch(() => {})
|
|
243
|
+
}
|
|
244
|
+
|
|
239
245
|
const forceUpload = args.upload || readDeployModeFromYaml() === 'upload'
|
|
240
246
|
|
|
241
247
|
let hasRepo = !!detail.repo
|
|
242
248
|
if (!hasRepo && !forceUpload) {
|
|
243
|
-
const
|
|
244
|
-
const repo = proc.exitCode === 0 ? proc.stdout.toString().trim() : ''
|
|
249
|
+
const repo = resolveRepoFromYaml()
|
|
245
250
|
if (repo) {
|
|
246
251
|
await client.put(`/apps/${appId}`, { repo })
|
|
247
252
|
console.log(chalk.dim(`Linked repo: ${repo}`))
|
|
@@ -184,19 +184,12 @@ export default defineCommand({
|
|
|
184
184
|
Bun.spawnSync(['git', 'add', '.'], { cwd, stdio: ['ignore', 'ignore', 'ignore'] })
|
|
185
185
|
Bun.spawnSync(['git', 'commit', '-m', 'Initial commit (bod init)'], { cwd, stdio: ['ignore', 'ignore', 'ignore'] })
|
|
186
186
|
|
|
187
|
-
//
|
|
188
|
-
let repo = ''
|
|
189
|
-
try {
|
|
190
|
-
const proc = Bun.spawnSync(['git', 'remote', 'get-url', 'origin'], { cwd })
|
|
191
|
-
repo = proc.exitCode === 0 ? proc.stdout.toString().trim() : ''
|
|
192
|
-
} catch { /* no remote */ }
|
|
193
|
-
|
|
194
|
-
// Register with bodify
|
|
187
|
+
// Register with bodify (no repo for new projects — user opts in via bodify.yaml)
|
|
195
188
|
console.log(chalk.dim('Registering app with Bodify...'))
|
|
196
189
|
try {
|
|
197
190
|
const app = await client.post<any>('/apps', {
|
|
198
191
|
name: appName,
|
|
199
|
-
repo,
|
|
192
|
+
repo: '',
|
|
200
193
|
database: useDb,
|
|
201
194
|
})
|
|
202
195
|
console.log(chalk.green(`✓ App registered (id: ${app.id})`))
|
|
@@ -226,13 +219,6 @@ export default defineCommand({
|
|
|
226
219
|
|
|
227
220
|
const appName = await input({ message: 'App name:', default: folderName })
|
|
228
221
|
|
|
229
|
-
// Detect git remote
|
|
230
|
-
let repo = ''
|
|
231
|
-
try {
|
|
232
|
-
const proc = Bun.spawnSync(['git', 'remote', 'get-url', 'origin'], { cwd })
|
|
233
|
-
repo = proc.stdout.toString().trim()
|
|
234
|
-
} catch { /* no git remote */ }
|
|
235
|
-
|
|
236
222
|
// bodify.yaml — create or merge missing fields
|
|
237
223
|
const yamlPath = join(cwd, 'bodify.yaml')
|
|
238
224
|
let yamlData: Record<string, any> = {}
|
|
@@ -246,7 +232,6 @@ export default defineCommand({
|
|
|
246
232
|
if (!yamlExisted) {
|
|
247
233
|
const useDb = detected === 'caab' && await confirm({ message: 'Enable database?', default: false })
|
|
248
234
|
if (useDb) { yamlData.database = true; yamlDirty = true }
|
|
249
|
-
if (repo) { yamlData.repo = repo; yamlDirty = true }
|
|
250
235
|
yamlDirty = true
|
|
251
236
|
}
|
|
252
237
|
if (yamlDirty) {
|
|
@@ -261,7 +246,7 @@ export default defineCommand({
|
|
|
261
246
|
try {
|
|
262
247
|
const app = await client.post<any>('/apps', {
|
|
263
248
|
name: appName,
|
|
264
|
-
repo,
|
|
249
|
+
repo: '',
|
|
265
250
|
database: detected === 'caab',
|
|
266
251
|
})
|
|
267
252
|
console.log(chalk.green(`✓ App registered (id: ${app.id})`))
|
package/src/utils/resolve.ts
CHANGED
|
@@ -41,6 +41,20 @@ export function readInstanceFromYaml(): string | undefined {
|
|
|
41
41
|
return readYaml()?.instance
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/** Resolve repo from bodify.yaml:
|
|
45
|
+
* - string → use as-is
|
|
46
|
+
* - true → auto-detect from git remote
|
|
47
|
+
* - absent/false → no repo */
|
|
48
|
+
export function resolveRepoFromYaml(): string | undefined {
|
|
49
|
+
const repo = readYaml()?.repo
|
|
50
|
+
if (typeof repo === 'string') return repo || undefined
|
|
51
|
+
if (repo === true) {
|
|
52
|
+
const proc = Bun.spawnSync(['git', 'remote', 'get-url', 'origin'])
|
|
53
|
+
return proc.exitCode === 0 ? proc.stdout.toString().trim() || undefined : undefined
|
|
54
|
+
}
|
|
55
|
+
return undefined
|
|
56
|
+
}
|
|
57
|
+
|
|
44
58
|
export function readDeployModeFromYaml(): 'upload' | 'git' | undefined {
|
|
45
59
|
const mode = readYaml()?.deploy
|
|
46
60
|
return mode === 'upload' ? 'upload' : mode === 'git' ? 'git' : undefined
|
|
@@ -96,6 +110,18 @@ export function detectSiblingDeps(): string[] {
|
|
|
96
110
|
return [...paths]
|
|
97
111
|
}
|
|
98
112
|
|
|
113
|
+
/** Read deployable config fields from bodify.yaml (auth, database, ai, etc.) */
|
|
114
|
+
export function readYamlConfig(): Record<string, unknown> | null {
|
|
115
|
+
const yaml = readYaml()
|
|
116
|
+
if (!yaml) return null
|
|
117
|
+
const configKeys = ['auth', 'database', 'ai', 'analytics', 'storage', 'email', 'prerender', 'domain', 'botProxyPaths', 'dbMount']
|
|
118
|
+
const config: Record<string, unknown> = {}
|
|
119
|
+
for (const key of configKeys) {
|
|
120
|
+
if (yaml[key] !== undefined) config[key] = yaml[key]
|
|
121
|
+
}
|
|
122
|
+
return Object.keys(config).length ? config : null
|
|
123
|
+
}
|
|
124
|
+
|
|
99
125
|
/** Resolve app name from explicit arg or bodify.yaml fallback. Logs clearly when falling back. */
|
|
100
126
|
export function resolveAppName(arg: string | undefined): string {
|
|
101
127
|
if (arg) return arg
|