bosia 0.6.6 → 0.6.7
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/package.json +1 -1
- package/src/cli/block.ts +24 -6
- package/src/cli/feat.ts +11 -0
- package/src/cli/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bosia",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A fast, batteries-included fullstack framework — SSR · Svelte 5 Runes · Bun · ElysiaJS. File-based routing inspired by SvelteKit. No Node.js, no Vite, no adapters.",
|
|
6
6
|
"keywords": [
|
package/src/cli/block.ts
CHANGED
|
@@ -2,9 +2,11 @@ import { join, dirname } from "path";
|
|
|
2
2
|
import { mkdirSync, writeFileSync, existsSync } from "fs";
|
|
3
3
|
import * as p from "@clack/prompts";
|
|
4
4
|
import {
|
|
5
|
+
type InstallOptions,
|
|
5
6
|
resolveLocalRegistryOrExit,
|
|
6
7
|
readRegistryJSON,
|
|
7
8
|
readRegistryFile,
|
|
9
|
+
mergePkgJson,
|
|
8
10
|
bunAdd,
|
|
9
11
|
} from "./registry.ts";
|
|
10
12
|
import { addComponent, initAddRegistry, ensureUtils } from "./add.ts";
|
|
@@ -26,18 +28,28 @@ interface BlockMeta {
|
|
|
26
28
|
npmDeps: Record<string, string>;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
export async function runAddBlock(
|
|
31
|
+
export async function runAddBlock(
|
|
32
|
+
name: string | undefined,
|
|
33
|
+
flags: string[] = [],
|
|
34
|
+
options?: InstallOptions,
|
|
35
|
+
) {
|
|
30
36
|
if (!name || !name.includes("/")) {
|
|
31
37
|
console.error(
|
|
32
|
-
"❌ Please provide a block path.\n Usage: bun x bosia@latest add block <category>/<name> [--local]",
|
|
38
|
+
"❌ Please provide a block path.\n Usage: bun x bosia@latest add block <category>/<name> [-y] [--local]",
|
|
33
39
|
);
|
|
34
40
|
process.exit(1);
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
const local = flags.includes("--local");
|
|
44
|
+
const flagYes = flags.includes("-y") || flags.includes("--yes");
|
|
38
45
|
const registryRoot = local ? resolveLocalRegistryOrExit() : null;
|
|
39
46
|
if (local) console.log(`⬡ Using local registry: ${registryRoot}\n`);
|
|
40
47
|
|
|
48
|
+
const resolvedOptions: InstallOptions = {
|
|
49
|
+
...(options ?? {}),
|
|
50
|
+
skipPrompts: options?.skipPrompts ?? flagYes,
|
|
51
|
+
};
|
|
52
|
+
|
|
41
53
|
await initAddRegistry(registryRoot);
|
|
42
54
|
ensureUtils();
|
|
43
55
|
|
|
@@ -47,14 +59,14 @@ export async function runAddBlock(name: string | undefined, flags: string[] = []
|
|
|
47
59
|
|
|
48
60
|
// 1. Install primitive dependencies first
|
|
49
61
|
for (const dep of meta.dependencies ?? []) {
|
|
50
|
-
await addComponent(dep, false);
|
|
62
|
+
await addComponent(dep, false, resolvedOptions);
|
|
51
63
|
}
|
|
52
64
|
|
|
53
65
|
// 2. Copy block files to src/lib/blocks/<path>/
|
|
54
|
-
const cwd = process.cwd();
|
|
66
|
+
const cwd = resolvedOptions.cwd ?? process.cwd();
|
|
55
67
|
const destDir = join(cwd, "src", "lib", "blocks", name);
|
|
56
68
|
|
|
57
|
-
if (existsSync(destDir)) {
|
|
69
|
+
if (!resolvedOptions.skipPrompts && existsSync(destDir)) {
|
|
58
70
|
const replace = await p.confirm({
|
|
59
71
|
message: `Block "${name}" already exists at src/lib/blocks/${name}/. Replace it?`,
|
|
60
72
|
});
|
|
@@ -87,7 +99,13 @@ export async function runAddBlock(name: string | undefined, flags: string[] = []
|
|
|
87
99
|
|
|
88
100
|
// 4. npm deps
|
|
89
101
|
if (meta.npmDeps && Object.keys(meta.npmDeps).length > 0) {
|
|
90
|
-
|
|
102
|
+
if (resolvedOptions.skipInstall) {
|
|
103
|
+
const { addedDeps } = mergePkgJson(cwd, { deps: meta.npmDeps });
|
|
104
|
+
if (addedDeps.length > 0)
|
|
105
|
+
console.log(` 📥 Added to package.json: ${addedDeps.join(", ")}`);
|
|
106
|
+
} else {
|
|
107
|
+
await bunAdd(cwd, meta.npmDeps);
|
|
108
|
+
}
|
|
91
109
|
}
|
|
92
110
|
|
|
93
111
|
console.log(`\n✅ ${name} installed at src/lib/blocks/${name}/`);
|
package/src/cli/feat.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { join, dirname, extname } from "path";
|
|
|
2
2
|
import { mkdirSync, writeFileSync, readFileSync, existsSync } from "fs";
|
|
3
3
|
import * as p from "@clack/prompts";
|
|
4
4
|
import { addComponent, initAddRegistry } from "./add.ts";
|
|
5
|
+
import { runAddBlock } from "./block.ts";
|
|
5
6
|
import {
|
|
6
7
|
type InstallOptions,
|
|
7
8
|
resolveLocalRegistryOrExit,
|
|
@@ -46,6 +47,7 @@ interface FeatureMeta {
|
|
|
46
47
|
description: string;
|
|
47
48
|
features?: string[]; // other bosia features required
|
|
48
49
|
components: string[]; // bosia components to install via `bun x bosia@latest add`
|
|
50
|
+
blocks?: string[]; // bosia blocks to install via `bun x bosia@latest add block`
|
|
49
51
|
files: FileEntry[]; // file entries with per-file strategy
|
|
50
52
|
npmDeps: Record<string, string>;
|
|
51
53
|
npmDevDeps?: Record<string, string>;
|
|
@@ -255,6 +257,15 @@ export async function installFeature(name: string, isRoot: boolean, options?: In
|
|
|
255
257
|
console.log("");
|
|
256
258
|
}
|
|
257
259
|
|
|
260
|
+
// Install required blocks
|
|
261
|
+
if (meta.blocks && meta.blocks.length > 0) {
|
|
262
|
+
console.log("🧱 Installing required blocks...");
|
|
263
|
+
for (const blockName of meta.blocks) {
|
|
264
|
+
await runAddBlock(blockName, [], options);
|
|
265
|
+
}
|
|
266
|
+
console.log("");
|
|
267
|
+
}
|
|
268
|
+
|
|
258
269
|
// Apply each file entry per its strategy. Skip entries whose `when` clause doesn't match.
|
|
259
270
|
const createdDirs = new Set<string>();
|
|
260
271
|
for (const entry of meta.files) {
|
package/src/cli/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ async function main() {
|
|
|
41
41
|
const flags = args.filter((a) => a.startsWith("-"));
|
|
42
42
|
const sub = positional[0];
|
|
43
43
|
if (sub === "block") {
|
|
44
|
-
const blockFlags =
|
|
44
|
+
const blockFlags = flags;
|
|
45
45
|
const { runAddBlock } = await import("./block.ts");
|
|
46
46
|
await runAddBlock(positional[1], blockFlags);
|
|
47
47
|
} else if (sub === "theme") {
|