bod-cli 0.5.1 → 0.5.2
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 +48 -10
- package/package.json +1 -1
- package/src/commands/init/init.ts +27 -7
- package/src/commands/serve.ts +6 -1
package/dist/cli.js
CHANGED
|
@@ -19284,7 +19284,7 @@ var env_default = defineCommand2({
|
|
|
19284
19284
|
});
|
|
19285
19285
|
|
|
19286
19286
|
// src/commands/init/init.ts
|
|
19287
|
-
import { existsSync as existsSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readdirSync } from "fs";
|
|
19287
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3, readdirSync, readFileSync as readFileSync4 } from "fs";
|
|
19288
19288
|
import { basename, join as join3 } from "path";
|
|
19289
19289
|
|
|
19290
19290
|
// src/commands/init/templates.ts
|
|
@@ -19642,12 +19642,35 @@ var init_default = defineCommand2({
|
|
|
19642
19642
|
const proc = Bun.spawnSync(["git", "remote", "get-url", "origin"], { cwd });
|
|
19643
19643
|
repo = proc.stdout.toString().trim();
|
|
19644
19644
|
} catch {}
|
|
19645
|
-
|
|
19646
|
-
|
|
19647
|
-
|
|
19645
|
+
const yamlPath = join3(cwd, "bodify.yaml");
|
|
19646
|
+
let yamlData = {};
|
|
19647
|
+
let yamlExisted = false;
|
|
19648
|
+
if (existsSync3(yamlPath)) {
|
|
19649
|
+
yamlExisted = true;
|
|
19650
|
+
yamlData = $parse(readFileSync4(yamlPath, "utf8")) ?? {};
|
|
19651
|
+
}
|
|
19652
|
+
let yamlDirty = false;
|
|
19653
|
+
if (!yamlData.name) {
|
|
19654
|
+
yamlData.name = appName;
|
|
19655
|
+
yamlDirty = true;
|
|
19656
|
+
}
|
|
19657
|
+
if (!yamlExisted) {
|
|
19648
19658
|
const useDb = detected === "caab" && await esm_default5({ message: "Enable database?", default: false });
|
|
19649
|
-
|
|
19650
|
-
|
|
19659
|
+
if (useDb) {
|
|
19660
|
+
yamlData.database = true;
|
|
19661
|
+
yamlDirty = true;
|
|
19662
|
+
}
|
|
19663
|
+
if (repo) {
|
|
19664
|
+
yamlData.repo = repo;
|
|
19665
|
+
yamlDirty = true;
|
|
19666
|
+
}
|
|
19667
|
+
yamlDirty = true;
|
|
19668
|
+
}
|
|
19669
|
+
if (yamlDirty) {
|
|
19670
|
+
writeFileSync3(yamlPath, $stringify(yamlData));
|
|
19671
|
+
console.log(source_default.green(yamlExisted ? "✓ Updated bodify.yaml" : "✓ Created bodify.yaml"));
|
|
19672
|
+
} else {
|
|
19673
|
+
console.log(source_default.dim("bodify.yaml already up to date"));
|
|
19651
19674
|
}
|
|
19652
19675
|
console.log(source_default.dim("Registering app with Bodify..."));
|
|
19653
19676
|
try {
|
|
@@ -19659,6 +19682,17 @@ var init_default = defineCommand2({
|
|
|
19659
19682
|
console.log(source_default.green(`✓ App registered (id: ${app.id})`));
|
|
19660
19683
|
if (app.domain)
|
|
19661
19684
|
console.log(source_default.dim(` Domain: ${app.domain}`));
|
|
19685
|
+
let changed = false;
|
|
19686
|
+
if (app.id && !yamlData.appId) {
|
|
19687
|
+
yamlData.appId = app.id;
|
|
19688
|
+
changed = true;
|
|
19689
|
+
}
|
|
19690
|
+
if (app.domain && !yamlData.domain) {
|
|
19691
|
+
yamlData.domain = app.domain;
|
|
19692
|
+
changed = true;
|
|
19693
|
+
}
|
|
19694
|
+
if (changed)
|
|
19695
|
+
writeFileSync3(yamlPath, $stringify(yamlData));
|
|
19662
19696
|
} catch (e2) {
|
|
19663
19697
|
console.warn(source_default.yellow(`Warning: Could not register: ${e2.message}`));
|
|
19664
19698
|
}
|
|
@@ -19786,7 +19820,11 @@ var open_default = defineCommand2({
|
|
|
19786
19820
|
import { join as join4 } from "path";
|
|
19787
19821
|
import { existsSync as existsSync4 } from "fs";
|
|
19788
19822
|
function resolveBodifyServe() {
|
|
19789
|
-
const
|
|
19823
|
+
const candidates = [
|
|
19824
|
+
join4(import.meta.dir, "../../../bodify/src/serve.ts"),
|
|
19825
|
+
join4(import.meta.dir, "../../bodify/src/serve.ts")
|
|
19826
|
+
];
|
|
19827
|
+
const sibling = candidates.find(existsSync4) ?? candidates[0];
|
|
19790
19828
|
if (existsSync4(sibling))
|
|
19791
19829
|
return sibling;
|
|
19792
19830
|
const envDir = process.env.BODIFY_DIR;
|
|
@@ -19865,7 +19903,7 @@ var ssh_default = defineCommand2({
|
|
|
19865
19903
|
});
|
|
19866
19904
|
|
|
19867
19905
|
// src/commands/publish.ts
|
|
19868
|
-
import { readFileSync as
|
|
19906
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
19869
19907
|
var publish_default = defineCommand2({
|
|
19870
19908
|
meta: { name: "publish", description: "Publish a package to Bodify registry" },
|
|
19871
19909
|
args: {
|
|
@@ -19874,7 +19912,7 @@ var publish_default = defineCommand2({
|
|
|
19874
19912
|
async run({ args }) {
|
|
19875
19913
|
let pkg;
|
|
19876
19914
|
try {
|
|
19877
|
-
pkg = JSON.parse(
|
|
19915
|
+
pkg = JSON.parse(readFileSync5("package.json", "utf-8"));
|
|
19878
19916
|
} catch {
|
|
19879
19917
|
console.error(source_default.red("No package.json found in current directory"));
|
|
19880
19918
|
process.exit(1);
|
|
@@ -19896,7 +19934,7 @@ var publish_default = defineCommand2({
|
|
|
19896
19934
|
}
|
|
19897
19935
|
const tarballPath = pack.stdout.toString().trim().split(`
|
|
19898
19936
|
`).pop();
|
|
19899
|
-
const tarballData =
|
|
19937
|
+
const tarballData = readFileSync5(tarballPath);
|
|
19900
19938
|
const tarballBase64 = tarballData.toString("base64");
|
|
19901
19939
|
const distTag = args.tag || "latest";
|
|
19902
19940
|
const safeName = pkg.name.replace("/", "%2f");
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { defineCommand } from 'citty'
|
|
2
2
|
import { select, input, confirm } from '@inquirer/prompts'
|
|
3
3
|
import chalk from 'chalk'
|
|
4
|
-
import { existsSync, mkdirSync, writeFileSync, readdirSync } from 'fs'
|
|
4
|
+
import { existsSync, mkdirSync, writeFileSync, readdirSync, readFileSync } from 'fs'
|
|
5
5
|
import { basename, join } from 'path'
|
|
6
6
|
import { loadConfig, getResolvedInstance, configExists } from '../../config'
|
|
7
7
|
import { BodClient } from '../../client'
|
|
8
8
|
import { TEMPLATES, type TemplateId } from './templates'
|
|
9
|
+
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml'
|
|
9
10
|
|
|
10
11
|
type AppType = 'caab' | 'static' | 'server' | 'mixed' | 'unknown'
|
|
11
12
|
|
|
@@ -232,13 +233,27 @@ export default defineCommand({
|
|
|
232
233
|
repo = proc.stdout.toString().trim()
|
|
233
234
|
} catch { /* no git remote */ }
|
|
234
235
|
|
|
235
|
-
// bodify.yaml
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
// bodify.yaml — create or merge missing fields
|
|
237
|
+
const yamlPath = join(cwd, 'bodify.yaml')
|
|
238
|
+
let yamlData: Record<string, any> = {}
|
|
239
|
+
let yamlExisted = false
|
|
240
|
+
if (existsSync(yamlPath)) {
|
|
241
|
+
yamlExisted = true
|
|
242
|
+
yamlData = parseYaml(readFileSync(yamlPath, 'utf8')) ?? {}
|
|
243
|
+
}
|
|
244
|
+
let yamlDirty = false
|
|
245
|
+
if (!yamlData.name) { yamlData.name = appName; yamlDirty = true }
|
|
246
|
+
if (!yamlExisted) {
|
|
239
247
|
const useDb = detected === 'caab' && await confirm({ message: 'Enable database?', default: false })
|
|
240
|
-
|
|
241
|
-
|
|
248
|
+
if (useDb) { yamlData.database = true; yamlDirty = true }
|
|
249
|
+
if (repo) { yamlData.repo = repo; yamlDirty = true }
|
|
250
|
+
yamlDirty = true
|
|
251
|
+
}
|
|
252
|
+
if (yamlDirty) {
|
|
253
|
+
writeFileSync(yamlPath, stringifyYaml(yamlData))
|
|
254
|
+
console.log(chalk.green(yamlExisted ? '✓ Updated bodify.yaml' : '✓ Created bodify.yaml'))
|
|
255
|
+
} else {
|
|
256
|
+
console.log(chalk.dim('bodify.yaml already up to date'))
|
|
242
257
|
}
|
|
243
258
|
|
|
244
259
|
// Register
|
|
@@ -251,6 +266,11 @@ export default defineCommand({
|
|
|
251
266
|
})
|
|
252
267
|
console.log(chalk.green(`✓ App registered (id: ${app.id})`))
|
|
253
268
|
if (app.domain) console.log(chalk.dim(` Domain: ${app.domain}`))
|
|
269
|
+
// Persist appId + domain into bodify.yaml
|
|
270
|
+
let changed = false
|
|
271
|
+
if (app.id && !yamlData.appId) { yamlData.appId = app.id; changed = true }
|
|
272
|
+
if (app.domain && !yamlData.domain) { yamlData.domain = app.domain; changed = true }
|
|
273
|
+
if (changed) writeFileSync(yamlPath, stringifyYaml(yamlData))
|
|
254
274
|
} catch (e) {
|
|
255
275
|
console.warn(chalk.yellow(`Warning: Could not register: ${(e as Error).message}`))
|
|
256
276
|
}
|
package/src/commands/serve.ts
CHANGED
|
@@ -4,7 +4,12 @@ import { existsSync } from 'fs'
|
|
|
4
4
|
|
|
5
5
|
function resolveBodifyServe(): string {
|
|
6
6
|
// Sibling directory convention: bod-cli and bodify live side by side
|
|
7
|
-
|
|
7
|
+
// Try both source (src/commands/) and dist (dist/) layouts
|
|
8
|
+
const candidates = [
|
|
9
|
+
join(import.meta.dir, '../../../bodify/src/serve.ts'), // from src/commands/
|
|
10
|
+
join(import.meta.dir, '../../bodify/src/serve.ts'), // from dist/
|
|
11
|
+
]
|
|
12
|
+
const sibling = candidates.find(existsSync) ?? candidates[0]
|
|
8
13
|
if (existsSync(sibling)) return sibling
|
|
9
14
|
// Fallback: try global BODIFY_DIR env
|
|
10
15
|
const envDir = process.env.BODIFY_DIR
|