buntic 0.3.0 → 0.3.1
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 +1 -1
- package/README.md +38 -38
- package/dist/cli.js +118 -123
- package/dist/config.d.ts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +122 -128
- package/dist/router/routes.d.ts +1 -1
- package/dist/runtime.d.ts +8 -9
- package/dist/server/dev-helpers.d.ts +1 -1
- package/dist/storage/oras/adapter.d.ts +2 -2
- package/dist/template/scoped-css.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/utils/html.d.ts +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/package.json +7 -7
- package/templates/blank/_gitignore +2 -2
- package/templates/blank/{bustatic.config.ts → buntic.config.ts} +2 -2
- package/templates/blank/src/pages/index.html +2 -2
- package/templates/blank/tsconfig.json +4 -9
- package/templates/simple/README.md +6 -6
- package/templates/simple/_gitignore +2 -2
- package/templates/simple/{bustatic.config.ts → buntic.config.ts} +2 -2
- package/templates/simple/src/components/footer.html +1 -1
- package/templates/simple/src/data/site.json +3 -3
- package/templates/simple/src/pages/about.html +1 -1
- package/templates/simple/src/pages/contact.html +1 -1
- package/templates/simple/tsconfig.json +4 -9
- package/templates/skills/{bustatic → buntic}/SKILL.md +33 -33
- package/templates/skills/{bustatic → buntic}/examples/README.md +4 -4
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ function getPackageRoot() {
|
|
|
22
22
|
if (existsSync(pkgPath)) {
|
|
23
23
|
try {
|
|
24
24
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
25
|
-
if (
|
|
25
|
+
if (pkg?.name === "buntic") {
|
|
26
26
|
return current;
|
|
27
27
|
}
|
|
28
28
|
} catch {}
|
|
@@ -48,10 +48,10 @@ function getSelfEntryPath() {
|
|
|
48
48
|
}
|
|
49
49
|
return distEntry;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function hasLocalBunticPackage(startDir) {
|
|
52
52
|
let current = resolve(startDir);
|
|
53
53
|
while (true) {
|
|
54
|
-
if (existsSync(join(current, "node_modules", "
|
|
54
|
+
if (existsSync(join(current, "node_modules", "buntic", "package.json"))) {
|
|
55
55
|
return true;
|
|
56
56
|
}
|
|
57
57
|
const parent = dirname(current);
|
|
@@ -61,27 +61,23 @@ function hasLocalBustaticPackage(startDir) {
|
|
|
61
61
|
current = parent;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function registerBunticModuleResolver(projectDir) {
|
|
65
65
|
if (resolverRegistered)
|
|
66
66
|
return;
|
|
67
|
-
if (projectDir &&
|
|
67
|
+
if (projectDir && hasLocalBunticPackage(projectDir))
|
|
68
68
|
return;
|
|
69
69
|
resolverRegistered = true;
|
|
70
70
|
const selfEntry = getSelfEntryPath();
|
|
71
71
|
Bun.plugin({
|
|
72
|
-
name: "
|
|
72
|
+
name: "buntic-global-self-resolver",
|
|
73
73
|
setup(build) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
registerAlias("bun-bustatic");
|
|
84
|
-
registerAlias("bustatic");
|
|
74
|
+
build.module("buntic", async () => {
|
|
75
|
+
const mod = await import(selfEntry);
|
|
76
|
+
return {
|
|
77
|
+
exports: { ...mod },
|
|
78
|
+
loader: "object"
|
|
79
|
+
};
|
|
80
|
+
});
|
|
85
81
|
}
|
|
86
82
|
});
|
|
87
83
|
}
|
|
@@ -102,7 +98,7 @@ function copyDeclarationFiles(srcDir, destDir) {
|
|
|
102
98
|
}
|
|
103
99
|
function syncProjectTypes(projectRoot) {
|
|
104
100
|
const absRoot = resolve(projectRoot);
|
|
105
|
-
if (
|
|
101
|
+
if (hasLocalBunticPackage(absRoot)) {
|
|
106
102
|
return false;
|
|
107
103
|
}
|
|
108
104
|
const pkgRoot = getPackageRoot();
|
|
@@ -112,17 +108,17 @@ function syncProjectTypes(projectRoot) {
|
|
|
112
108
|
if (pkg?.version)
|
|
113
109
|
version = pkg.version;
|
|
114
110
|
} catch {}
|
|
115
|
-
const
|
|
116
|
-
const typesDir = join(
|
|
111
|
+
const bunticDir = join(absRoot, ".buntic");
|
|
112
|
+
const typesDir = join(bunticDir, "types");
|
|
117
113
|
const typesEntry = join(typesDir, "index.d.ts");
|
|
118
|
-
const versionMarkerPath = join(
|
|
114
|
+
const versionMarkerPath = join(bunticDir, ".types-version");
|
|
119
115
|
const distDir = join(pkgRoot, "dist");
|
|
120
116
|
const hasBuiltTypes = existsSync(join(distDir, "index.d.ts"));
|
|
121
117
|
const expectedMarker = `${version}:${hasBuiltTypes ? "dist" : "src"}`;
|
|
122
118
|
if (existsSync(typesEntry) && existsSync(versionMarkerPath) && readFileSync(versionMarkerPath, "utf8").trim() === expectedMarker) {
|
|
123
119
|
return false;
|
|
124
120
|
}
|
|
125
|
-
mkdirSync(
|
|
121
|
+
mkdirSync(bunticDir, { recursive: true });
|
|
126
122
|
if (existsSync(typesDir)) {
|
|
127
123
|
rmSync(typesDir, { recursive: true, force: true });
|
|
128
124
|
}
|
|
@@ -131,7 +127,7 @@ function syncProjectTypes(projectRoot) {
|
|
|
131
127
|
copyDeclarationFiles(distDir, typesDir);
|
|
132
128
|
} else {
|
|
133
129
|
const srcIndex = join(pkgRoot, "src", "index.ts").replace(/\\/g, "/");
|
|
134
|
-
writeFileSync(typesEntry, `// Auto-generated by
|
|
130
|
+
writeFileSync(typesEntry, `// Auto-generated by Buntic (source dev fallback).
|
|
135
131
|
export * from "${srcIndex}";
|
|
136
132
|
`, "utf8");
|
|
137
133
|
}
|
|
@@ -139,10 +135,8 @@ export * from "${srcIndex}";
|
|
|
139
135
|
`, "utf8");
|
|
140
136
|
return true;
|
|
141
137
|
}
|
|
142
|
-
var resolverRegistered = false
|
|
143
|
-
var init_runtime =
|
|
144
|
-
PACKAGE_NAMES = new Set(["buntic", "bun-bustatic", "bustatic"]);
|
|
145
|
-
});
|
|
138
|
+
var resolverRegistered = false;
|
|
139
|
+
var init_runtime = () => {};
|
|
146
140
|
|
|
147
141
|
// src/config.ts
|
|
148
142
|
import { resolve as resolve2, join as join2, dirname as dirname2, basename } from "path";
|
|
@@ -154,13 +148,13 @@ function findProjectRoot(cliTarget, startCwd = process.cwd()) {
|
|
|
154
148
|
if (cliTarget && cliTarget !== ".") {
|
|
155
149
|
const target = resolve2(startCwd, cliTarget);
|
|
156
150
|
if (!existsSync2(target)) {
|
|
157
|
-
throw new Error(`[
|
|
151
|
+
throw new Error(`[Buntic] Specified project directory does not exist: "${target}"`);
|
|
158
152
|
}
|
|
159
153
|
return target;
|
|
160
154
|
}
|
|
161
155
|
let current = resolve2(startCwd);
|
|
162
156
|
while (true) {
|
|
163
|
-
const hasConfig = existsSync2(join2(current, "
|
|
157
|
+
const hasConfig = existsSync2(join2(current, "buntic.config.ts")) || existsSync2(join2(current, "buntic.config.js")) || existsSync2(join2(current, "buntic.config.json"));
|
|
164
158
|
if (hasConfig) {
|
|
165
159
|
return current;
|
|
166
160
|
}
|
|
@@ -181,27 +175,27 @@ function findProjectRoot(cliTarget, startCwd = process.cwd()) {
|
|
|
181
175
|
}
|
|
182
176
|
current = parent;
|
|
183
177
|
}
|
|
184
|
-
throw new Error(`[
|
|
178
|
+
throw new Error(`[Buntic Error]: Could not find a Buntic project root.
|
|
185
179
|
` + ` Searched in: ${startCwd} (and parent directories)
|
|
186
180
|
|
|
187
181
|
` + `\uD83D\uDC49 How to fix this:
|
|
188
182
|
` + ` 1. Ensure you have a "pages/" or "src/pages/" directory with at least one .html file.
|
|
189
183
|
` + ` 2. Or pass the project path explicitly:
|
|
190
|
-
` + ` $
|
|
191
|
-
` + ` 3. Or create a "
|
|
184
|
+
` + ` $ buntic dev <directory> (e.g. buntic dev examples/simple)
|
|
185
|
+
` + ` 3. Or create a "buntic.config.ts" / "buntic.config.json" configuration file (or run "buntic init").`);
|
|
192
186
|
}
|
|
193
187
|
async function resolveConfig(cliRootDir = ".", overrides = {}) {
|
|
194
188
|
const root = findProjectRoot(cliRootDir);
|
|
195
189
|
let userConfig = {};
|
|
196
|
-
const tsConfigPath = join2(root, "
|
|
197
|
-
const jsConfigPath = join2(root, "
|
|
198
|
-
const jsonConfigPath = join2(root, "
|
|
190
|
+
const tsConfigPath = join2(root, "buntic.config.ts");
|
|
191
|
+
const jsConfigPath = join2(root, "buntic.config.js");
|
|
192
|
+
const jsonConfigPath = join2(root, "buntic.config.json");
|
|
199
193
|
if (existsSync2(tsConfigPath)) {
|
|
200
|
-
|
|
194
|
+
registerBunticModuleResolver(root);
|
|
201
195
|
const mod = await import(tsConfigPath);
|
|
202
196
|
userConfig = mod.default || mod;
|
|
203
197
|
} else if (existsSync2(jsConfigPath)) {
|
|
204
|
-
|
|
198
|
+
registerBunticModuleResolver(root);
|
|
205
199
|
const mod = await import(jsConfigPath);
|
|
206
200
|
userConfig = mod.default || mod;
|
|
207
201
|
} else if (existsSync2(jsonConfigPath)) {
|
|
@@ -234,7 +228,7 @@ async function resolveConfig(cliRootDir = ".", overrides = {}) {
|
|
|
234
228
|
dataDir: resolve2(root, merged.dataDir ?? pickDir("data")),
|
|
235
229
|
publicDir: resolve2(root, merged.publicDir ?? pickDir("public", true)),
|
|
236
230
|
storageDir: resolve2(root, merged.storageDir ?? pickDir("storage")),
|
|
237
|
-
cacheDir: resolve2(root, merged.cacheDir ?? ".
|
|
231
|
+
cacheDir: resolve2(root, merged.cacheDir ?? ".buntic/cache/images"),
|
|
238
232
|
outDir: resolve2(root, merged.outDir ?? "dist"),
|
|
239
233
|
port: merged.port ?? 3000,
|
|
240
234
|
minify: merged.minify ?? true,
|
|
@@ -314,10 +308,10 @@ function getErrorMessage(err) {
|
|
|
314
308
|
return String(err);
|
|
315
309
|
}
|
|
316
310
|
}
|
|
317
|
-
function logWarn(message, label = "
|
|
311
|
+
function logWarn(message, label = "Buntic Warning") {
|
|
318
312
|
console.warn(`\x1B[33m\u26A0 [${label}]\x1B[0m ${message}`);
|
|
319
313
|
}
|
|
320
|
-
function logError(message, err, label = "
|
|
314
|
+
function logError(message, err, label = "Buntic Error") {
|
|
321
315
|
if (err !== undefined) {
|
|
322
316
|
console.error(`\x1B[31m[${label}]\x1B[0m ${message}:`, getErrorMessage(err));
|
|
323
317
|
} else {
|
|
@@ -370,13 +364,13 @@ class WebComponentRegistry {
|
|
|
370
364
|
const expectedTag = filenameToTagName(filePath);
|
|
371
365
|
if (!expectedTag) {
|
|
372
366
|
if (content && /(?:customElements\.define|@customElement)\s*\(\s*["']([a-z0-9-]+)["']/i.test(content)) {
|
|
373
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
367
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Warning]\x1B[0m Web Component file "${filePath}" does not match naming convention (must be hyphenated kebab-case like "my-button.ts" or PascalCase like "MyButton.ts"). Registration skipped.`);
|
|
374
368
|
}
|
|
375
369
|
return [];
|
|
376
370
|
}
|
|
377
371
|
const validation = this.validateTagName(expectedTag);
|
|
378
372
|
if (!validation.valid) {
|
|
379
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
373
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Warning]\x1B[0m Skipping invalid Custom Element tag "${expectedTag}" in ${filePath}: ${validation.reason}`);
|
|
380
374
|
return [];
|
|
381
375
|
}
|
|
382
376
|
if (content) {
|
|
@@ -387,13 +381,13 @@ class WebComponentRegistry {
|
|
|
387
381
|
declaredTags.add(match[1].toLowerCase());
|
|
388
382
|
}
|
|
389
383
|
if (declaredTags.size > 1) {
|
|
390
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
384
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Warning]\x1B[0m File "${filePath}" declares multiple Custom Elements (${Array.from(declaredTags).map((t) => `<${t}>`).join(", ")}). Buntic strictly enforces 1 Web Component per file. File skipped.`);
|
|
391
385
|
return [];
|
|
392
386
|
}
|
|
393
387
|
if (declaredTags.size === 1) {
|
|
394
388
|
const declaredTag = Array.from(declaredTags)[0];
|
|
395
389
|
if (declaredTag !== expectedTag) {
|
|
396
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
390
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Warning]\x1B[0m Tag "<${declaredTag}>" in "${filePath}" does not match filename. Expected tag "<${expectedTag}>" for file "${basename2(filePath)}". Registration skipped.`);
|
|
397
391
|
return [];
|
|
398
392
|
}
|
|
399
393
|
}
|
|
@@ -405,7 +399,7 @@ class WebComponentRegistry {
|
|
|
405
399
|
conflictFiles.push(filePath);
|
|
406
400
|
}
|
|
407
401
|
this.conflicts.set(expectedTag, conflictFiles);
|
|
408
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
402
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Collision Warning]\x1B[0m Tag "<${expectedTag}>" in ${filePath} conflicts with definition in ${existingFile}.`);
|
|
409
403
|
return [];
|
|
410
404
|
}
|
|
411
405
|
this.tagToFile.set(expectedTag, filePath);
|
|
@@ -462,7 +456,7 @@ ${c.files.map((f) => ` - ${f}`).join(`
|
|
|
462
456
|
`)}`).join(`
|
|
463
457
|
|
|
464
458
|
`);
|
|
465
|
-
throw new Error(`[
|
|
459
|
+
throw new Error(`[Buntic Conflict Error]: Tag collision detected between Web Components:
|
|
466
460
|
${details}
|
|
467
461
|
|
|
468
462
|
` + `\uD83D\uDC49 Each Custom Element tag must be uniquely defined.`);
|
|
@@ -1214,7 +1208,7 @@ async function resolvePageCss(options) {
|
|
|
1214
1208
|
} catch {
|
|
1215
1209
|
cssContent = await Bun.file(cssFilePath).text();
|
|
1216
1210
|
}
|
|
1217
|
-
const styleBlock = `<style id="
|
|
1211
|
+
const styleBlock = `<style id="__buntic_global">
|
|
1218
1212
|
${cssContent}
|
|
1219
1213
|
</style>`;
|
|
1220
1214
|
result = replaceLiteral(result, fullTag, styleBlock);
|
|
@@ -1222,15 +1216,15 @@ ${cssContent}
|
|
|
1222
1216
|
}
|
|
1223
1217
|
}
|
|
1224
1218
|
const headMatch = result.match(/<head[\s\S]*?<\/head>/i);
|
|
1225
|
-
const headHasGlobalStyle = headMatch ? headMatch[0].includes('id="
|
|
1219
|
+
const headHasGlobalStyle = headMatch ? headMatch[0].includes('id="__buntic_global"') : false;
|
|
1226
1220
|
if (!hadManualGlobalLink && !headHasGlobalStyle && globalCssContent) {
|
|
1227
|
-
const globalTag = ` <style id="
|
|
1221
|
+
const globalTag = ` <style id="__buntic_global">
|
|
1228
1222
|
${globalCssContent}
|
|
1229
1223
|
</style>`;
|
|
1230
1224
|
result = injectIntoHead(result, globalTag, "prepend");
|
|
1231
1225
|
}
|
|
1232
1226
|
if (hasScopedRules) {
|
|
1233
|
-
const scopedTag = ` <style id="
|
|
1227
|
+
const scopedTag = ` <style id="__buntic_scoped">
|
|
1234
1228
|
${scopedCssText}
|
|
1235
1229
|
</style>`;
|
|
1236
1230
|
result = injectIntoHead(result, scopedTag, "append");
|
|
@@ -1370,7 +1364,7 @@ async function loadGlobalData(config, vfs) {
|
|
|
1370
1364
|
}
|
|
1371
1365
|
}
|
|
1372
1366
|
} catch (err) {
|
|
1373
|
-
if (err instanceof Error && err.message.includes("[
|
|
1367
|
+
if (err instanceof Error && err.message.includes("[Buntic Error]")) {
|
|
1374
1368
|
throw err;
|
|
1375
1369
|
}
|
|
1376
1370
|
}
|
|
@@ -1475,7 +1469,7 @@ async function resolveWebComponentsInHtml(options) {
|
|
|
1475
1469
|
if (globalRoot.root) {
|
|
1476
1470
|
if (config.cssStrategy === "inline") {
|
|
1477
1471
|
const globalCss = await cssGraph.flattenCss(globalRoot.root, vfs);
|
|
1478
|
-
globalCssBlock = `<style data-
|
|
1472
|
+
globalCssBlock = `<style data-buntic="global">
|
|
1479
1473
|
${globalCss.trim()}
|
|
1480
1474
|
</style>`;
|
|
1481
1475
|
} else if (globalRoot.relativeRoot) {
|
|
@@ -1555,7 +1549,7 @@ ${siblingCss.trim()}
|
|
|
1555
1549
|
const extracted = extractScopedStyles(rawHtml, scopeRegistry);
|
|
1556
1550
|
rawHtml = extracted.html;
|
|
1557
1551
|
if (extracted.scopedRules.length > 0) {
|
|
1558
|
-
scopedDsdCssBlock = `<style data-
|
|
1552
|
+
scopedDsdCssBlock = `<style data-buntic="dsd-scoped">
|
|
1559
1553
|
${extracted.scopedRules.join(`
|
|
1560
1554
|
|
|
1561
1555
|
`)}
|
|
@@ -1694,7 +1688,7 @@ function isIgnoredPath(filePathOrName) {
|
|
|
1694
1688
|
const normalized = filePathOrName.replace(/\\/g, "/");
|
|
1695
1689
|
const segments = normalized.split("/");
|
|
1696
1690
|
for (const seg of segments) {
|
|
1697
|
-
if (seg === "node_modules" || seg === ".git" || seg === ".agents" || seg === "dist" || seg.startsWith(".
|
|
1691
|
+
if (seg === "node_modules" || seg === ".git" || seg === ".agents" || seg === "dist" || seg.startsWith(".buntic")) {
|
|
1698
1692
|
return true;
|
|
1699
1693
|
}
|
|
1700
1694
|
}
|
|
@@ -1955,7 +1949,7 @@ class TemplateEngine {
|
|
|
1955
1949
|
const globalRoot = this.cssGraph.getGlobalRoot();
|
|
1956
1950
|
if (globalRoot.conflicts.length > 1) {
|
|
1957
1951
|
const relConflicts = globalRoot.conflicts.map((c) => relative5(this.config.root, c));
|
|
1958
|
-
logWarn(`Multiple orphan global CSS roots detected: ${relConflicts.map((c) => `"${c}"`).join(", ")}. Please link them via @import in a single root file or co-locate them with a component/page.`, "
|
|
1952
|
+
logWarn(`Multiple orphan global CSS roots detected: ${relConflicts.map((c) => `"${c}"`).join(", ")}. Please link them via @import in a single root file or co-locate them with a component/page.`, "Buntic Conflict Warning");
|
|
1959
1953
|
}
|
|
1960
1954
|
let processedHtml = pageHtml;
|
|
1961
1955
|
if (currentFile && currentFile.endsWith(".html")) {
|
|
@@ -2023,7 +2017,7 @@ class TemplateEngine {
|
|
|
2023
2017
|
const innerContent = layoutMatch[2];
|
|
2024
2018
|
const layoutFilePath = this.resolveFilePath(layoutRawSrc, currentFile, this.config.layoutsDir);
|
|
2025
2019
|
if (!this.vfs.hasFile(layoutFilePath) && !existsSync7(layoutFilePath)) {
|
|
2026
|
-
throw new Error(`[
|
|
2020
|
+
throw new Error(`[Buntic] Layout not found: "${layoutRawSrc}" at ${layoutFilePath}`);
|
|
2027
2021
|
}
|
|
2028
2022
|
const layoutTemplate = await this.vfs.readText(layoutFilePath);
|
|
2029
2023
|
let resolvedInner = await this.resolveEach(innerContent, context, currentFile);
|
|
@@ -2059,7 +2053,7 @@ class TemplateEngine {
|
|
|
2059
2053
|
}
|
|
2060
2054
|
async resolveEach(html, context, currentFile, depth = 0) {
|
|
2061
2055
|
if (depth > 10) {
|
|
2062
|
-
console.warn("[
|
|
2056
|
+
console.warn("[Buntic] Maximum <each> recursion depth (10) reached.");
|
|
2063
2057
|
return html;
|
|
2064
2058
|
}
|
|
2065
2059
|
const eachRegex = /<each\s+([^>]+?)>([\s\S]*?)<\/each>/gis;
|
|
@@ -2077,16 +2071,16 @@ class TemplateEngine {
|
|
|
2077
2071
|
if (attrs.src) {
|
|
2078
2072
|
const filePath = this.resolveFilePath(attrs.src, currentFile, this.config.dataDir);
|
|
2079
2073
|
if (!this.vfs.hasFile(filePath) && !existsSync7(filePath)) {
|
|
2080
|
-
throw new Error(`[
|
|
2074
|
+
throw new Error(`[Buntic] <each> data file not found: "${attrs.src}" at ${filePath}`);
|
|
2081
2075
|
}
|
|
2082
2076
|
items = await this.vfs.readJson(filePath);
|
|
2083
2077
|
} else if (attrs.in) {
|
|
2084
2078
|
items = getNestedValue(context, attrs.in);
|
|
2085
2079
|
} else {
|
|
2086
|
-
throw new Error(`[
|
|
2080
|
+
throw new Error(`[Buntic] <each> tag requires either a "src" or "in" attribute.`);
|
|
2087
2081
|
}
|
|
2088
2082
|
if (!Array.isArray(items)) {
|
|
2089
|
-
throw new Error(`[
|
|
2083
|
+
throw new Error(`[Buntic] <each> source "${attrs.src || attrs.in}" did not resolve to an array.`);
|
|
2090
2084
|
}
|
|
2091
2085
|
const renderedItems = [];
|
|
2092
2086
|
for (const entry of items) {
|
|
@@ -2116,7 +2110,7 @@ class TemplateEngine {
|
|
|
2116
2110
|
}
|
|
2117
2111
|
async resolveComponents(html, context, currentFile, depth = 0) {
|
|
2118
2112
|
if (depth > 10) {
|
|
2119
|
-
console.warn("[
|
|
2113
|
+
console.warn("[Buntic] Maximum component recursion depth (10) reached. Check for circular component includes.");
|
|
2120
2114
|
return html;
|
|
2121
2115
|
}
|
|
2122
2116
|
const componentRegex = /<component\s+([^>]+?)(?:\s*\/>|>(.*?)<\/component>)/gis;
|
|
@@ -2139,7 +2133,7 @@ class TemplateEngine {
|
|
|
2139
2133
|
for (const item of matches) {
|
|
2140
2134
|
const compPath = this.resolveFilePath(item.src, currentFile, this.config.componentsDir);
|
|
2141
2135
|
if (!this.vfs.hasFile(compPath) && !existsSync7(compPath)) {
|
|
2142
|
-
throw new Error(`[
|
|
2136
|
+
throw new Error(`[Buntic] Component not found: "${item.src}" at ${compPath}`);
|
|
2143
2137
|
}
|
|
2144
2138
|
const ext = extname3(compPath).toLowerCase();
|
|
2145
2139
|
if (ext === ".ts" || ext === ".js" || ext === ".tsx" || ext === ".jsx") {
|
|
@@ -2203,7 +2197,7 @@ class TemplateEngine {
|
|
|
2203
2197
|
tag = filenameToTagName(compPath) || undefined;
|
|
2204
2198
|
}
|
|
2205
2199
|
if (!tag) {
|
|
2206
|
-
throw new Error(`[
|
|
2200
|
+
throw new Error(`[Buntic] Could not determine Custom Element tag name for Web Component file "${rawSrc}". ` + `Ensure the filename follows kebab-case (e.g. "my-element.ts") or PascalCase (e.g. "MyElement.ts").`);
|
|
2207
2201
|
}
|
|
2208
2202
|
const attrEntries = Object.entries(props).filter(([k]) => k !== "src");
|
|
2209
2203
|
const attrString = attrEntries.length > 0 ? " " + attrEntries.map(([k, v]) => `${k}="${v}"`).join(" ") : "";
|
|
@@ -2384,15 +2378,15 @@ function validateRouteParams(requiredTokens, params, loaderPath) {
|
|
|
2384
2378
|
for (const token of requiredTokens) {
|
|
2385
2379
|
const rawVal = params[token];
|
|
2386
2380
|
if (rawVal === undefined || rawVal === null) {
|
|
2387
|
-
throw new Error(`[
|
|
2381
|
+
throw new Error(`[Buntic Error]: Missing required route parameter "${token}" in loader "${loaderPath}".
|
|
2388
2382
|
Provided parameters: ${JSON.stringify(params)}`);
|
|
2389
2383
|
}
|
|
2390
2384
|
const strVal = String(rawVal).trim();
|
|
2391
2385
|
if (strVal === "") {
|
|
2392
|
-
throw new Error(`[
|
|
2386
|
+
throw new Error(`[Buntic Error]: Route parameter "${token}" in loader "${loaderPath}" cannot be an empty string.`);
|
|
2393
2387
|
}
|
|
2394
2388
|
if (/[\/\\?#\0]/.test(strVal)) {
|
|
2395
|
-
throw new Error(`[
|
|
2389
|
+
throw new Error(`[Buntic Error]: Route parameter "${token}" with value "${strVal}" in "${loaderPath}" contains invalid characters (/ \\ ? #).`);
|
|
2396
2390
|
}
|
|
2397
2391
|
cleanParams[token] = strVal;
|
|
2398
2392
|
}
|
|
@@ -2439,7 +2433,7 @@ function buildCleanUrl(patternRelPath, params) {
|
|
|
2439
2433
|
}
|
|
2440
2434
|
function registerRouteOrThrow(urlRegistry, urlPath, sourceDesc) {
|
|
2441
2435
|
if (urlRegistry.has(urlPath)) {
|
|
2442
|
-
throw new Error(`[
|
|
2436
|
+
throw new Error(`[Buntic Collision Error]: Duplicate route generated for "${urlPath}".
|
|
2443
2437
|
- First generated by: ${urlRegistry.get(urlPath)}
|
|
2444
2438
|
- Conflicting with: ${sourceDesc}`);
|
|
2445
2439
|
}
|
|
@@ -2483,7 +2477,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
2483
2477
|
} = options;
|
|
2484
2478
|
if (!loaderPath) {
|
|
2485
2479
|
const expected = relPattern.replace(/\.html$/, ".data.ts");
|
|
2486
|
-
throw new Error(`[
|
|
2480
|
+
throw new Error(`[Buntic Error]: Dynamic page "${relPattern}" contains parameter(s) [${tokens.join(", ")}], but no co-located loader was found.
|
|
2487
2481
|
` + `\uD83D\uDC49 Create "${expected}" exporting a default async function or getStaticPaths().`);
|
|
2488
2482
|
}
|
|
2489
2483
|
const relLoader = relative7(config.root, loaderPath);
|
|
@@ -2497,7 +2491,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
2497
2491
|
}
|
|
2498
2492
|
const handler = mod.default ?? mod.getStaticPaths;
|
|
2499
2493
|
if (typeof handler !== "function") {
|
|
2500
|
-
throw new Error(`[
|
|
2494
|
+
throw new Error(`[Buntic Error]: Loader "${relLoader}" must export a default function ("export default async function") or "getStaticPaths".`);
|
|
2501
2495
|
}
|
|
2502
2496
|
const basePattern = relPattern.split(sep2).join("/").replace(/\.html$/, "");
|
|
2503
2497
|
const lastSlash = basePattern.lastIndexOf("/");
|
|
@@ -2514,7 +2508,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
2514
2508
|
throw err;
|
|
2515
2509
|
}
|
|
2516
2510
|
if (!Array.isArray(pathsResult)) {
|
|
2517
|
-
throw new Error(`[
|
|
2511
|
+
throw new Error(`[Buntic Error]: Dynamic loader "${relLoader}" must return an Array of path objects ({ params, props }). Received: ${typeof pathsResult}.`);
|
|
2518
2512
|
}
|
|
2519
2513
|
if (pathsResult.length === 0) {
|
|
2520
2514
|
logWarn(`Dynamic loader "${relLoader}" returned 0 paths. No pages generated for "${relPattern}".`);
|
|
@@ -2524,7 +2518,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
2524
2518
|
for (let i = 0;i < pathsResult.length; i++) {
|
|
2525
2519
|
const item = pathsResult[i];
|
|
2526
2520
|
if (!item || typeof item !== "object" || !item.params || typeof item.params !== "object") {
|
|
2527
|
-
throw new Error(`[
|
|
2521
|
+
throw new Error(`[Buntic Error]: Item at index ${i} in loader "${relLoader}" must be an object with a "params" property.
|
|
2528
2522
|
Received: ${JSON.stringify(item)}`);
|
|
2529
2523
|
}
|
|
2530
2524
|
const cleanParams = validateRouteParams(tokens, item.params, relLoader);
|
|
@@ -2850,15 +2844,15 @@ class StorageManager {
|
|
|
2850
2844
|
const available = this.getAvailableStorages();
|
|
2851
2845
|
if (!targetStorage) {
|
|
2852
2846
|
if (available.length === 0) {
|
|
2853
|
-
throw new Error(`[
|
|
2847
|
+
throw new Error(`[Buntic Error] No storage loaders found in "${this.config.storageDir}".
|
|
2854
2848
|
` + `\uD83D\uDC49 Create a storage loader (e.g. "${join12(this.config.storageDir, "s3.ts")}") to handle key "${key}".`);
|
|
2855
2849
|
}
|
|
2856
|
-
throw new Error(`[
|
|
2857
|
-
` + `\uD83D\uDC49 Specify storage="..." in your tag or set "defaultStorage" in
|
|
2850
|
+
throw new Error(`[Buntic Error] Multiple storage loaders detected ([${available.join(", ")}]), but no storage name was specified for key "${key}".
|
|
2851
|
+
` + `\uD83D\uDC49 Specify storage="..." in your tag or set "defaultStorage" in buntic.config.ts.`);
|
|
2858
2852
|
}
|
|
2859
2853
|
const storage = this.storages.get(targetStorage);
|
|
2860
2854
|
if (!storage) {
|
|
2861
|
-
throw new Error(`[
|
|
2855
|
+
throw new Error(`[Buntic Error] Storage loader "${targetStorage}" not found in "${this.config.storageDir}".
|
|
2862
2856
|
Available storages: [${available.join(", ")}]`);
|
|
2863
2857
|
}
|
|
2864
2858
|
try {
|
|
@@ -2872,7 +2866,7 @@ class StorageManager {
|
|
|
2872
2866
|
}
|
|
2873
2867
|
async function normalizeStorageResult(result, key, storageName) {
|
|
2874
2868
|
if (!result) {
|
|
2875
|
-
throw new Error(`[
|
|
2869
|
+
throw new Error(`[Buntic Error] Storage loader "${storageName}" returned null/undefined for key "${key}".`);
|
|
2876
2870
|
}
|
|
2877
2871
|
if (result instanceof Response) {
|
|
2878
2872
|
const arrayBuf = await result.arrayBuffer();
|
|
@@ -2926,7 +2920,7 @@ async function normalizeStorageResult(result, key, storageName) {
|
|
|
2926
2920
|
bytes: new Uint8Array(result)
|
|
2927
2921
|
};
|
|
2928
2922
|
}
|
|
2929
|
-
throw new Error(`[
|
|
2923
|
+
throw new Error(`[Buntic Error] Unsupported return type from storage loader "${storageName}" for key "${key}".
|
|
2930
2924
|
Expected Uint8Array, ArrayBuffer, Response, BunFile or { bytes, etag?, contentType? }. Received: ${typeof result}`);
|
|
2931
2925
|
}
|
|
2932
2926
|
var init_loader = () => {};
|
|
@@ -2964,7 +2958,7 @@ class PhotoProcessor {
|
|
|
2964
2958
|
const key = attrs.key;
|
|
2965
2959
|
const storage = attrs.storage;
|
|
2966
2960
|
if (!src && !key) {
|
|
2967
|
-
throw new Error(`[
|
|
2961
|
+
throw new Error(`[Buntic Error] <photo> tag must have a "src" (for local files) or a "key" (for remote storage) in "${templatePath}".
|
|
2968
2962
|
` + ` Found: ${match.fullMatch}`);
|
|
2969
2963
|
}
|
|
2970
2964
|
const widths = attrs.widths ? attrs.widths.split(",").map((w) => parseInt(w.trim(), 10)).filter((w) => !isNaN(w) && w > 0) : undefined;
|
|
@@ -3004,7 +2998,7 @@ class PhotoProcessor {
|
|
|
3004
2998
|
}
|
|
3005
2999
|
const localPath = resolveLocalAssetPath(this.config, src, templatePath);
|
|
3006
3000
|
if (!existsSync12(localPath)) {
|
|
3007
|
-
throw new Error(`[
|
|
3001
|
+
throw new Error(`[Buntic Error] Local image file "${src}" referenced in <photo> not found.
|
|
3008
3002
|
` + ` Looked in: "${localPath}"
|
|
3009
3003
|
` + ` Referenced in: "${templatePath}"`);
|
|
3010
3004
|
}
|
|
@@ -3128,7 +3122,7 @@ class SeoMetadataEngine {
|
|
|
3128
3122
|
imgHeight = processed.height;
|
|
3129
3123
|
}
|
|
3130
3124
|
} catch (err) {
|
|
3131
|
-
logWarn(`Failed to process social image in "${templatePath}": ${getErrorMessage(err)}`, "
|
|
3125
|
+
logWarn(`Failed to process social image in "${templatePath}": ${getErrorMessage(err)}`, "Buntic SEO Warning");
|
|
3132
3126
|
}
|
|
3133
3127
|
}
|
|
3134
3128
|
const metaTags = this.generateMetaTagsHtml({
|
|
@@ -3458,14 +3452,14 @@ function detectPublicCollisions(config, routes) {
|
|
|
3458
3452
|
collisions.push({
|
|
3459
3453
|
type: "reserved-dir",
|
|
3460
3454
|
publicPath: relative8(config.root, join17(config.publicDir, relFile)),
|
|
3461
|
-
conflictWith: "assets/images/ (Reserved for
|
|
3455
|
+
conflictWith: "assets/images/ (Reserved for Buntic <photo> image optimization)",
|
|
3462
3456
|
outputPath: relFile
|
|
3463
3457
|
});
|
|
3464
3458
|
} else if (relFile.startsWith("assets/seo/") || relFile === "assets/seo") {
|
|
3465
3459
|
collisions.push({
|
|
3466
3460
|
type: "reserved-dir",
|
|
3467
3461
|
publicPath: relative8(config.root, join17(config.publicDir, relFile)),
|
|
3468
|
-
conflictWith: "assets/seo/ (Reserved for
|
|
3462
|
+
conflictWith: "assets/seo/ (Reserved for Buntic <seo> social cards)",
|
|
3469
3463
|
outputPath: relFile
|
|
3470
3464
|
});
|
|
3471
3465
|
}
|
|
@@ -3483,7 +3477,7 @@ function assertNoPublicCollisions(config, routes) {
|
|
|
3483
3477
|
return ` - Public file "${c.publicPath}" conflicts with reserved internal path "${c.conflictWith}".`;
|
|
3484
3478
|
}).join(`
|
|
3485
3479
|
`);
|
|
3486
|
-
throw new Error(`[
|
|
3480
|
+
throw new Error(`[Buntic Collision Error]: Conflict detected between public/ files and build output:
|
|
3487
3481
|
` + details + `
|
|
3488
3482
|
|
|
3489
3483
|
\uD83D\uDC49 Action: Remove or rename conflicting files in "public/" or adjust page routes in "pages/".`);
|
|
@@ -3515,17 +3509,17 @@ class Builder {
|
|
|
3515
3509
|
this.engine.assertNoWebComponentConflicts();
|
|
3516
3510
|
this.engine.clearUsedWebComponents();
|
|
3517
3511
|
if (!existsSync18(this.config.pagesDir)) {
|
|
3518
|
-
throw new Error(`[
|
|
3512
|
+
throw new Error(`[Buntic] Pages directory not found at: ${this.config.pagesDir}`);
|
|
3519
3513
|
}
|
|
3520
3514
|
const globalData = await this.engine.loadData();
|
|
3521
3515
|
const routes = await resolveAllRoutes(this.config, globalData);
|
|
3522
3516
|
if (routes.length === 0) {
|
|
3523
|
-
console.warn(`[
|
|
3517
|
+
console.warn(`[Buntic] No HTML pages found in: ${this.config.pagesDir}`);
|
|
3524
3518
|
return { success: true, pagesCount: 0, outputFiles: [], durationMs: 0 };
|
|
3525
3519
|
}
|
|
3526
3520
|
assertNoPublicCollisions(this.config, routes);
|
|
3527
3521
|
this.prepareEmptyDir(this.config.outDir);
|
|
3528
|
-
const stagingDir = join18(this.config.root, ".
|
|
3522
|
+
const stagingDir = join18(this.config.root, ".buntic-staging");
|
|
3529
3523
|
this.prepareEmptyDir(stagingDir);
|
|
3530
3524
|
try {
|
|
3531
3525
|
const stagedEntrypoints = await this.stagePages(routes, stagingDir);
|
|
@@ -3598,7 +3592,7 @@ class Builder {
|
|
|
3598
3592
|
for (const log of buildResult.logs) {
|
|
3599
3593
|
console.error(log);
|
|
3600
3594
|
}
|
|
3601
|
-
throw new Error("[
|
|
3595
|
+
throw new Error("[Buntic] Bun.build bundling failed.");
|
|
3602
3596
|
}
|
|
3603
3597
|
return buildResult.outputs.map((o) => o.path);
|
|
3604
3598
|
}
|
|
@@ -3656,7 +3650,7 @@ class Builder {
|
|
|
3656
3650
|
normalizeRootPaths(html, stagedFilePath, stagingDir) {
|
|
3657
3651
|
const fromDir = dirname9(stagedFilePath);
|
|
3658
3652
|
return html.replace(/(href|src)=["']\/([^"']+)["']/gi, (match, attr, path) => {
|
|
3659
|
-
if (path.startsWith("/") || path.startsWith("http:") || path.startsWith("https:") || path.startsWith("
|
|
3653
|
+
if (path.startsWith("/") || path.startsWith("http:") || path.startsWith("https:") || path.startsWith("_buntic") || path.startsWith("assets/images/") || path.startsWith("assets/seo/")) {
|
|
3660
3654
|
return match;
|
|
3661
3655
|
}
|
|
3662
3656
|
const targetInRoot = join18(this.config.root, path);
|
|
@@ -3838,7 +3832,7 @@ function renderNotFoundResponse(pathname, routes) {
|
|
|
3838
3832
|
<!doctype html>
|
|
3839
3833
|
<html>
|
|
3840
3834
|
<head>
|
|
3841
|
-
<title>404 - Not Found |
|
|
3835
|
+
<title>404 - Not Found | Buntic Dev</title>
|
|
3842
3836
|
<style>
|
|
3843
3837
|
body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #f8fafc; padding: 3rem; }
|
|
3844
3838
|
.card { max-width: 650px; margin: 0 auto; background: #1e293b; padding: 2rem; border-radius: 12px; border: 1px solid #334155; }
|
|
@@ -3864,13 +3858,13 @@ function renderNotFoundResponse(pathname, routes) {
|
|
|
3864
3858
|
});
|
|
3865
3859
|
}
|
|
3866
3860
|
var LIVE_RELOAD_SCRIPT = `
|
|
3867
|
-
<script id="
|
|
3861
|
+
<script id="__buntic_live_reload">
|
|
3868
3862
|
(() => {
|
|
3869
3863
|
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
3870
|
-
const ws = new WebSocket(\`\${protocol}//\${location.host}/
|
|
3864
|
+
const ws = new WebSocket(\`\${protocol}//\${location.host}/_buntic/ws\`);
|
|
3871
3865
|
ws.onmessage = (event) => {
|
|
3872
3866
|
if (event.data === 'reload') {
|
|
3873
|
-
console.log('[
|
|
3867
|
+
console.log('[buntic] Change detected. Reloading...');
|
|
3874
3868
|
location.reload();
|
|
3875
3869
|
}
|
|
3876
3870
|
};
|
|
@@ -3903,9 +3897,9 @@ function startDevServer(config) {
|
|
|
3903
3897
|
const collisions = detectPublicCollisions(config, routes);
|
|
3904
3898
|
for (const c of collisions) {
|
|
3905
3899
|
if (c.type === "route") {
|
|
3906
|
-
logWarn(`Public file "${c.publicPath}" conflicts with page template "${c.conflictWith}" (both resolve to "${c.outputPath}").`, "
|
|
3900
|
+
logWarn(`Public file "${c.publicPath}" conflicts with page template "${c.conflictWith}" (both resolve to "${c.outputPath}").`, "Buntic Collision Warning");
|
|
3907
3901
|
} else {
|
|
3908
|
-
logWarn(`Public file "${c.publicPath}" conflicts with reserved internal path "${c.conflictWith}".`, "
|
|
3902
|
+
logWarn(`Public file "${c.publicPath}" conflicts with reserved internal path "${c.conflictWith}".`, "Buntic Collision Warning");
|
|
3909
3903
|
}
|
|
3910
3904
|
}
|
|
3911
3905
|
} catch {}
|
|
@@ -3952,7 +3946,7 @@ function startDevServer(config) {
|
|
|
3952
3946
|
} catch {
|
|
3953
3947
|
return new Response("Bad Request", { status: 400 });
|
|
3954
3948
|
}
|
|
3955
|
-
if (pathname === "/
|
|
3949
|
+
if (pathname === "/_buntic/ws") {
|
|
3956
3950
|
if (srv.upgrade(req))
|
|
3957
3951
|
return;
|
|
3958
3952
|
return new Response("WebSocket upgrade failed", { status: 400 });
|
|
@@ -3998,7 +3992,7 @@ function startDevServer(config) {
|
|
|
3998
3992
|
seoEngine
|
|
3999
3993
|
});
|
|
4000
3994
|
} catch (err) {
|
|
4001
|
-
return renderErrorResponse("[
|
|
3995
|
+
return renderErrorResponse("[Buntic Template Error]", err);
|
|
4002
3996
|
}
|
|
4003
3997
|
}
|
|
4004
3998
|
try {
|
|
@@ -4019,7 +4013,7 @@ function startDevServer(config) {
|
|
|
4019
4013
|
});
|
|
4020
4014
|
}
|
|
4021
4015
|
} catch (err) {
|
|
4022
|
-
return renderErrorResponse("[
|
|
4016
|
+
return renderErrorResponse("[Buntic Dynamic Route Error]", err);
|
|
4023
4017
|
}
|
|
4024
4018
|
if (engine.generatedPageStyles.has(pathname)) {
|
|
4025
4019
|
const css = engine.generatedPageStyles.get(pathname);
|
|
@@ -4669,7 +4663,7 @@ class OrasClient {
|
|
|
4669
4663
|
const title = layer.annotations?.[ANNOTATIONS.TITLE] || layer.digest.replace("sha256:", "");
|
|
4670
4664
|
const outPath = join13(options.outdir, title);
|
|
4671
4665
|
if (!isPathInside(options.outdir, outPath) || outPath === join13(options.outdir)) {
|
|
4672
|
-
throw new Error(`[
|
|
4666
|
+
throw new Error(`[Buntic Security Error] Unsafe OCI layer title "${title}" escapes output directory "${options.outdir}".`);
|
|
4673
4667
|
}
|
|
4674
4668
|
const res = await this.getBlobStream(ref, layer.digest);
|
|
4675
4669
|
if (!res.body) {
|
|
@@ -4742,7 +4736,7 @@ function createOrasStorage(options) {
|
|
|
4742
4736
|
ref.tag = defaultTag;
|
|
4743
4737
|
}
|
|
4744
4738
|
if (ref.repository !== ref.repository.toLowerCase()) {
|
|
4745
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
4739
|
+
console.warn(`\x1B[33m\u26A0 [Buntic ORAS Warning]\x1B[0m OCI repository names must be lowercase. Converting "${ref.repository}" to "${ref.repository.toLowerCase()}".`);
|
|
4746
4740
|
ref.repository = ref.repository.toLowerCase();
|
|
4747
4741
|
}
|
|
4748
4742
|
const artifact = await client.getArtifactStream(ref, ref.subpath);
|
|
@@ -4789,7 +4783,7 @@ function copyTemplateDirectory(srcDir, destDir) {
|
|
|
4789
4783
|
function initProject(options = {}) {
|
|
4790
4784
|
const templateName = options.template || "blank";
|
|
4791
4785
|
if (!AVAILABLE_TEMPLATES.includes(templateName)) {
|
|
4792
|
-
throw new Error(`[
|
|
4786
|
+
throw new Error(`[Buntic] Unknown template "${options.template}". Available templates: ${AVAILABLE_TEMPLATES.join(", ")}.`);
|
|
4793
4787
|
}
|
|
4794
4788
|
const targetDir = resolve8(process.cwd(), options.targetDir || ".");
|
|
4795
4789
|
const includeSkills = options.includeSkills ?? true;
|
|
@@ -4797,22 +4791,22 @@ function initProject(options = {}) {
|
|
|
4797
4791
|
const pkgRoot = getPackageRoot();
|
|
4798
4792
|
const templateDir = join21(pkgRoot, "templates", templateName);
|
|
4799
4793
|
if (!existsSync21(templateDir)) {
|
|
4800
|
-
throw new Error(`[
|
|
4794
|
+
throw new Error(`[Buntic] Template directory not found: "${templateDir}"`);
|
|
4801
4795
|
}
|
|
4802
4796
|
if (existsSync21(targetDir) && !force) {
|
|
4803
4797
|
const existingEntries = readdirSync6(targetDir).filter((name) => name !== ".git" && name !== ".DS_Store");
|
|
4804
4798
|
if (existingEntries.length > 0) {
|
|
4805
|
-
throw new Error(`[
|
|
4806
|
-
` + ` Pass a new directory name (e.g. "
|
|
4799
|
+
throw new Error(`[Buntic] Target directory "${targetDir}" is not empty.
|
|
4800
|
+
` + ` Pass a new directory name (e.g. "buntic init my-site") or use --force to initialize anyway.`);
|
|
4807
4801
|
}
|
|
4808
4802
|
}
|
|
4809
4803
|
mkdirSync4(targetDir, { recursive: true });
|
|
4810
4804
|
let filesCopied = copyTemplateDirectory(templateDir, targetDir);
|
|
4811
4805
|
let skillsDir = null;
|
|
4812
4806
|
if (includeSkills) {
|
|
4813
|
-
const srcSkillsDir = join21(pkgRoot, "templates", "skills", "
|
|
4807
|
+
const srcSkillsDir = join21(pkgRoot, "templates", "skills", "buntic");
|
|
4814
4808
|
if (existsSync21(srcSkillsDir)) {
|
|
4815
|
-
skillsDir = join21(targetDir, ".agents", "skills", "
|
|
4809
|
+
skillsDir = join21(targetDir, ".agents", "skills", "buntic");
|
|
4816
4810
|
filesCopied += copyTemplateDirectory(srcSkillsDir, skillsDir);
|
|
4817
4811
|
}
|
|
4818
4812
|
}
|
|
@@ -4837,11 +4831,11 @@ import { existsSync as existsSync22, rmSync as rmSync4 } from "fs";
|
|
|
4837
4831
|
import { relative as relative10 } from "path";
|
|
4838
4832
|
init_runtime();
|
|
4839
4833
|
async function runCLI(args) {
|
|
4840
|
-
|
|
4834
|
+
registerBunticModuleResolver();
|
|
4841
4835
|
const command = args[0] || "help";
|
|
4842
4836
|
if (command === "--version" || command === "-v") {
|
|
4843
4837
|
const pkg = await Bun.file(`${getPackageRoot()}/package.json`).json();
|
|
4844
|
-
console.log(`
|
|
4838
|
+
console.log(`buntic v${pkg.version}`);
|
|
4845
4839
|
return;
|
|
4846
4840
|
}
|
|
4847
4841
|
if (command === "help" || command === "--help" || command === "-h") {
|
|
@@ -4899,25 +4893,25 @@ async function runCLI(args) {
|
|
|
4899
4893
|
});
|
|
4900
4894
|
const relTarget = relative10(process.cwd(), result.targetDir) || ".";
|
|
4901
4895
|
console.log(`
|
|
4902
|
-
\u26A1 \x1B[36m[
|
|
4896
|
+
\u26A1 \x1B[36m[Buntic]\x1B[0m Initialized new project (\x1B[33m${result.template}\x1B[0m) in: \x1B[32m${result.targetDir}\x1B[0m`);
|
|
4903
4897
|
console.log(` \u2714 Created ${result.filesCopied} file(s) (no package.json required)`);
|
|
4904
4898
|
if (result.skillsDir) {
|
|
4905
|
-
console.log(` \u2714 Installed
|
|
4899
|
+
console.log(` \u2714 Installed Buntic agent skill in .agents/skills/buntic`);
|
|
4906
4900
|
}
|
|
4907
|
-
console.log(` \u2714 Generated TypeScript definitions in .
|
|
4901
|
+
console.log(` \u2714 Generated TypeScript definitions in .buntic/types/`);
|
|
4908
4902
|
console.log(`
|
|
4909
4903
|
\x1B[1mNext steps:\x1B[0m`);
|
|
4910
4904
|
if (relTarget !== ".") {
|
|
4911
4905
|
console.log(` cd ${relTarget}`);
|
|
4912
4906
|
}
|
|
4913
|
-
console.log(`
|
|
4907
|
+
console.log(` buntic dev
|
|
4914
4908
|
`);
|
|
4915
4909
|
return;
|
|
4916
4910
|
}
|
|
4917
4911
|
if (command === "clean") {
|
|
4918
4912
|
const config = await resolveConfig(targetDir);
|
|
4919
4913
|
console.log(`
|
|
4920
|
-
\uD83E\uDDF9 \x1B[36m[
|
|
4914
|
+
\uD83E\uDDF9 \x1B[36m[Buntic]\x1B[0m Cleaning build and cache directories for: \x1B[33m${config.root}\x1B[0m`);
|
|
4921
4915
|
if (existsSync22(config.outDir)) {
|
|
4922
4916
|
rmSync4(config.outDir, { recursive: true, force: true });
|
|
4923
4917
|
console.log(` \u2714 Removed ${config.outDir}`);
|
|
@@ -4938,14 +4932,14 @@ async function runCLI(args) {
|
|
|
4938
4932
|
console.log(`\x1B[32m\u2714\x1B[0m Cache cleaned.`);
|
|
4939
4933
|
}
|
|
4940
4934
|
console.log(`
|
|
4941
|
-
\uD83D\uDE80 \x1B[36m[
|
|
4935
|
+
\uD83D\uDE80 \x1B[36m[Buntic]\x1B[0m Starting dev server for: \x1B[33m${config.root}\x1B[0m`);
|
|
4942
4936
|
const devInstance = startDevServer(config);
|
|
4943
4937
|
console.log(` \u279C Local: \x1B[32mhttp://localhost:${devInstance.port}/\x1B[0m`);
|
|
4944
4938
|
console.log(` \u279C Live reload enabled via WebSockets.
|
|
4945
4939
|
`);
|
|
4946
4940
|
process.on("SIGINT", () => {
|
|
4947
4941
|
console.log(`
|
|
4948
|
-
\x1B[33m[
|
|
4942
|
+
\x1B[33m[Buntic]\x1B[0m Shutting down server...`);
|
|
4949
4943
|
devInstance.stop();
|
|
4950
4944
|
process.exit(0);
|
|
4951
4945
|
});
|
|
@@ -4953,7 +4947,7 @@ async function runCLI(args) {
|
|
|
4953
4947
|
const config = await resolveConfig(targetDir, { outDir });
|
|
4954
4948
|
syncProjectTypes(config.root);
|
|
4955
4949
|
console.log(`
|
|
4956
|
-
\uD83D\uDCE6 \x1B[36m[
|
|
4950
|
+
\uD83D\uDCE6 \x1B[36m[Buntic]\x1B[0m Building static site for: \x1B[33m${config.root}\x1B[0m`);
|
|
4957
4951
|
const builder = new Builder(config);
|
|
4958
4952
|
const result = await builder.build({ cleanCache });
|
|
4959
4953
|
console.log(`\x1B[32m\u2714\x1B[0m Successfully built ${result.pagesCount} page(s) in ${result.durationMs}ms`);
|
|
@@ -4973,21 +4967,21 @@ async function runCLI(args) {
|
|
|
4973
4967
|
}
|
|
4974
4968
|
function printHelp() {
|
|
4975
4969
|
console.log(`
|
|
4976
|
-
\x1B[
|
|
4970
|
+
\x1B[1mBuntic\x1B[0m - Lightweight zero-dependency static site generator for Bun
|
|
4977
4971
|
|
|
4978
4972
|
\x1B[1mUSAGE:\x1B[0m
|
|
4979
|
-
|
|
4973
|
+
buntic <command> [directory] [options]
|
|
4980
4974
|
|
|
4981
4975
|
\x1B[1mCOMMANDS:\x1B[0m
|
|
4982
|
-
init [dir] Initialize a new
|
|
4976
|
+
init [dir] Initialize a new Buntic project (zero package.json)
|
|
4983
4977
|
dev [dir] Start the development server with live reload
|
|
4984
4978
|
build [dir] Build the static site for production into dist/
|
|
4985
|
-
clean [dir] Remove dist/ and .
|
|
4979
|
+
clean [dir] Remove dist/ and .buntic/cache/ directories
|
|
4986
4980
|
help Show this help message
|
|
4987
4981
|
|
|
4988
4982
|
\x1B[1mOPTIONS:\x1B[0m
|
|
4989
4983
|
-t, --template <name> Template for init: ${AVAILABLE_TEMPLATES.join(", ")} (default: blank)
|
|
4990
|
-
--no-skills Skip installing agent skills in .agents/skills/
|
|
4984
|
+
--no-skills Skip installing agent skills in .agents/skills/buntic
|
|
4991
4985
|
-f, --force Allow init in a non-empty directory
|
|
4992
4986
|
-p, --port <port> Port to run dev server on (default: 3000)
|
|
4993
4987
|
-o, --outdir <dir> Output directory for build (default: dist)
|
|
@@ -4996,13 +4990,13 @@ function printHelp() {
|
|
|
4996
4990
|
-h, --help Show help
|
|
4997
4991
|
|
|
4998
4992
|
\x1B[1mEXAMPLES:\x1B[0m
|
|
4999
|
-
$
|
|
5000
|
-
$
|
|
5001
|
-
$
|
|
5002
|
-
$
|
|
5003
|
-
$
|
|
5004
|
-
$
|
|
5005
|
-
$
|
|
4993
|
+
$ buntic init mi-sitio
|
|
4994
|
+
$ buntic init mi-sitio --template simple
|
|
4995
|
+
$ buntic dev
|
|
4996
|
+
$ buntic dev my-site --port 8080
|
|
4997
|
+
$ buntic build
|
|
4998
|
+
$ buntic build my-site --outdir ./public_html --clean-cache
|
|
4999
|
+
$ buntic clean
|
|
5006
5000
|
`);
|
|
5007
5001
|
}
|
|
5008
5002
|
|
|
@@ -5056,7 +5050,7 @@ export {
|
|
|
5056
5050
|
parseEnvContent,
|
|
5057
5051
|
parseOciReference,
|
|
5058
5052
|
parseWwwAuthenticate,
|
|
5059
|
-
|
|
5053
|
+
registerBunticModuleResolver,
|
|
5060
5054
|
resolveAllRoutes,
|
|
5061
5055
|
resolveConfig,
|
|
5062
5056
|
runCLI,
|