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/cli.js
CHANGED
|
@@ -14,7 +14,6 @@ import { existsSync, mkdirSync, readdirSync, cpSync, rmSync, readFileSync, write
|
|
|
14
14
|
import { dirname, join, resolve } from "path";
|
|
15
15
|
import { fileURLToPath } from "url";
|
|
16
16
|
var resolverRegistered = false;
|
|
17
|
-
var PACKAGE_NAMES = new Set(["buntic", "bun-bustatic", "bustatic"]);
|
|
18
17
|
function getPackageRoot() {
|
|
19
18
|
let current = dirname(fileURLToPath(import.meta.url));
|
|
20
19
|
while (true) {
|
|
@@ -22,7 +21,7 @@ function getPackageRoot() {
|
|
|
22
21
|
if (existsSync(pkgPath)) {
|
|
23
22
|
try {
|
|
24
23
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
25
|
-
if (
|
|
24
|
+
if (pkg?.name === "buntic") {
|
|
26
25
|
return current;
|
|
27
26
|
}
|
|
28
27
|
} catch {}
|
|
@@ -48,10 +47,10 @@ function getSelfEntryPath() {
|
|
|
48
47
|
}
|
|
49
48
|
return distEntry;
|
|
50
49
|
}
|
|
51
|
-
function
|
|
50
|
+
function hasLocalBunticPackage(startDir) {
|
|
52
51
|
let current = resolve(startDir);
|
|
53
52
|
while (true) {
|
|
54
|
-
if (existsSync(join(current, "node_modules", "
|
|
53
|
+
if (existsSync(join(current, "node_modules", "buntic", "package.json"))) {
|
|
55
54
|
return true;
|
|
56
55
|
}
|
|
57
56
|
const parent = dirname(current);
|
|
@@ -61,27 +60,23 @@ function hasLocalBustaticPackage(startDir) {
|
|
|
61
60
|
current = parent;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
|
-
function
|
|
63
|
+
function registerBunticModuleResolver(projectDir) {
|
|
65
64
|
if (resolverRegistered)
|
|
66
65
|
return;
|
|
67
|
-
if (projectDir &&
|
|
66
|
+
if (projectDir && hasLocalBunticPackage(projectDir))
|
|
68
67
|
return;
|
|
69
68
|
resolverRegistered = true;
|
|
70
69
|
const selfEntry = getSelfEntryPath();
|
|
71
70
|
Bun.plugin({
|
|
72
|
-
name: "
|
|
71
|
+
name: "buntic-global-self-resolver",
|
|
73
72
|
setup(build) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
registerAlias("bun-bustatic");
|
|
84
|
-
registerAlias("bustatic");
|
|
73
|
+
build.module("buntic", async () => {
|
|
74
|
+
const mod = await import(selfEntry);
|
|
75
|
+
return {
|
|
76
|
+
exports: { ...mod },
|
|
77
|
+
loader: "object"
|
|
78
|
+
};
|
|
79
|
+
});
|
|
85
80
|
}
|
|
86
81
|
});
|
|
87
82
|
}
|
|
@@ -102,7 +97,7 @@ function copyDeclarationFiles(srcDir, destDir) {
|
|
|
102
97
|
}
|
|
103
98
|
function syncProjectTypes(projectRoot) {
|
|
104
99
|
const absRoot = resolve(projectRoot);
|
|
105
|
-
if (
|
|
100
|
+
if (hasLocalBunticPackage(absRoot)) {
|
|
106
101
|
return false;
|
|
107
102
|
}
|
|
108
103
|
const pkgRoot = getPackageRoot();
|
|
@@ -112,17 +107,17 @@ function syncProjectTypes(projectRoot) {
|
|
|
112
107
|
if (pkg?.version)
|
|
113
108
|
version = pkg.version;
|
|
114
109
|
} catch {}
|
|
115
|
-
const
|
|
116
|
-
const typesDir = join(
|
|
110
|
+
const bunticDir = join(absRoot, ".buntic");
|
|
111
|
+
const typesDir = join(bunticDir, "types");
|
|
117
112
|
const typesEntry = join(typesDir, "index.d.ts");
|
|
118
|
-
const versionMarkerPath = join(
|
|
113
|
+
const versionMarkerPath = join(bunticDir, ".types-version");
|
|
119
114
|
const distDir = join(pkgRoot, "dist");
|
|
120
115
|
const hasBuiltTypes = existsSync(join(distDir, "index.d.ts"));
|
|
121
116
|
const expectedMarker = `${version}:${hasBuiltTypes ? "dist" : "src"}`;
|
|
122
117
|
if (existsSync(typesEntry) && existsSync(versionMarkerPath) && readFileSync(versionMarkerPath, "utf8").trim() === expectedMarker) {
|
|
123
118
|
return false;
|
|
124
119
|
}
|
|
125
|
-
mkdirSync(
|
|
120
|
+
mkdirSync(bunticDir, { recursive: true });
|
|
126
121
|
if (existsSync(typesDir)) {
|
|
127
122
|
rmSync(typesDir, { recursive: true, force: true });
|
|
128
123
|
}
|
|
@@ -131,7 +126,7 @@ function syncProjectTypes(projectRoot) {
|
|
|
131
126
|
copyDeclarationFiles(distDir, typesDir);
|
|
132
127
|
} else {
|
|
133
128
|
const srcIndex = join(pkgRoot, "src", "index.ts").replace(/\\/g, "/");
|
|
134
|
-
writeFileSync(typesEntry, `// Auto-generated by
|
|
129
|
+
writeFileSync(typesEntry, `// Auto-generated by Buntic (source dev fallback).
|
|
135
130
|
export * from "${srcIndex}";
|
|
136
131
|
`, "utf8");
|
|
137
132
|
}
|
|
@@ -145,13 +140,13 @@ function findProjectRoot(cliTarget, startCwd = process.cwd()) {
|
|
|
145
140
|
if (cliTarget && cliTarget !== ".") {
|
|
146
141
|
const target = resolve2(startCwd, cliTarget);
|
|
147
142
|
if (!existsSync2(target)) {
|
|
148
|
-
throw new Error(`[
|
|
143
|
+
throw new Error(`[Buntic] Specified project directory does not exist: "${target}"`);
|
|
149
144
|
}
|
|
150
145
|
return target;
|
|
151
146
|
}
|
|
152
147
|
let current = resolve2(startCwd);
|
|
153
148
|
while (true) {
|
|
154
|
-
const hasConfig = existsSync2(join2(current, "
|
|
149
|
+
const hasConfig = existsSync2(join2(current, "buntic.config.ts")) || existsSync2(join2(current, "buntic.config.js")) || existsSync2(join2(current, "buntic.config.json"));
|
|
155
150
|
if (hasConfig) {
|
|
156
151
|
return current;
|
|
157
152
|
}
|
|
@@ -172,27 +167,27 @@ function findProjectRoot(cliTarget, startCwd = process.cwd()) {
|
|
|
172
167
|
}
|
|
173
168
|
current = parent;
|
|
174
169
|
}
|
|
175
|
-
throw new Error(`[
|
|
170
|
+
throw new Error(`[Buntic Error]: Could not find a Buntic project root.
|
|
176
171
|
` + ` Searched in: ${startCwd} (and parent directories)
|
|
177
172
|
|
|
178
173
|
` + `\uD83D\uDC49 How to fix this:
|
|
179
174
|
` + ` 1. Ensure you have a "pages/" or "src/pages/" directory with at least one .html file.
|
|
180
175
|
` + ` 2. Or pass the project path explicitly:
|
|
181
|
-
` + ` $
|
|
182
|
-
` + ` 3. Or create a "
|
|
176
|
+
` + ` $ buntic dev <directory> (e.g. buntic dev examples/simple)
|
|
177
|
+
` + ` 3. Or create a "buntic.config.ts" / "buntic.config.json" configuration file (or run "buntic init").`);
|
|
183
178
|
}
|
|
184
179
|
async function resolveConfig(cliRootDir = ".", overrides = {}) {
|
|
185
180
|
const root = findProjectRoot(cliRootDir);
|
|
186
181
|
let userConfig = {};
|
|
187
|
-
const tsConfigPath = join2(root, "
|
|
188
|
-
const jsConfigPath = join2(root, "
|
|
189
|
-
const jsonConfigPath = join2(root, "
|
|
182
|
+
const tsConfigPath = join2(root, "buntic.config.ts");
|
|
183
|
+
const jsConfigPath = join2(root, "buntic.config.js");
|
|
184
|
+
const jsonConfigPath = join2(root, "buntic.config.json");
|
|
190
185
|
if (existsSync2(tsConfigPath)) {
|
|
191
|
-
|
|
186
|
+
registerBunticModuleResolver(root);
|
|
192
187
|
const mod = await import(tsConfigPath);
|
|
193
188
|
userConfig = mod.default || mod;
|
|
194
189
|
} else if (existsSync2(jsConfigPath)) {
|
|
195
|
-
|
|
190
|
+
registerBunticModuleResolver(root);
|
|
196
191
|
const mod = await import(jsConfigPath);
|
|
197
192
|
userConfig = mod.default || mod;
|
|
198
193
|
} else if (existsSync2(jsonConfigPath)) {
|
|
@@ -225,7 +220,7 @@ async function resolveConfig(cliRootDir = ".", overrides = {}) {
|
|
|
225
220
|
dataDir: resolve2(root, merged.dataDir ?? pickDir("data")),
|
|
226
221
|
publicDir: resolve2(root, merged.publicDir ?? pickDir("public", true)),
|
|
227
222
|
storageDir: resolve2(root, merged.storageDir ?? pickDir("storage")),
|
|
228
|
-
cacheDir: resolve2(root, merged.cacheDir ?? ".
|
|
223
|
+
cacheDir: resolve2(root, merged.cacheDir ?? ".buntic/cache/images"),
|
|
229
224
|
outDir: resolve2(root, merged.outDir ?? "dist"),
|
|
230
225
|
port: merged.port ?? 3000,
|
|
231
226
|
minify: merged.minify ?? true,
|
|
@@ -450,10 +445,10 @@ function getErrorMessage(err) {
|
|
|
450
445
|
return String(err);
|
|
451
446
|
}
|
|
452
447
|
}
|
|
453
|
-
function logWarn(message, label = "
|
|
448
|
+
function logWarn(message, label = "Buntic Warning") {
|
|
454
449
|
console.warn(`\x1B[33m\u26A0 [${label}]\x1B[0m ${message}`);
|
|
455
450
|
}
|
|
456
|
-
function logError(message, err, label = "
|
|
451
|
+
function logError(message, err, label = "Buntic Error") {
|
|
457
452
|
if (err !== undefined) {
|
|
458
453
|
console.error(`\x1B[31m[${label}]\x1B[0m ${message}:`, getErrorMessage(err));
|
|
459
454
|
} else {
|
|
@@ -528,15 +523,15 @@ class StorageManager {
|
|
|
528
523
|
const available = this.getAvailableStorages();
|
|
529
524
|
if (!targetStorage) {
|
|
530
525
|
if (available.length === 0) {
|
|
531
|
-
throw new Error(`[
|
|
526
|
+
throw new Error(`[Buntic Error] No storage loaders found in "${this.config.storageDir}".
|
|
532
527
|
` + `\uD83D\uDC49 Create a storage loader (e.g. "${join4(this.config.storageDir, "s3.ts")}") to handle key "${key}".`);
|
|
533
528
|
}
|
|
534
|
-
throw new Error(`[
|
|
535
|
-
` + `\uD83D\uDC49 Specify storage="..." in your tag or set "defaultStorage" in
|
|
529
|
+
throw new Error(`[Buntic Error] Multiple storage loaders detected ([${available.join(", ")}]), but no storage name was specified for key "${key}".
|
|
530
|
+
` + `\uD83D\uDC49 Specify storage="..." in your tag or set "defaultStorage" in buntic.config.ts.`);
|
|
536
531
|
}
|
|
537
532
|
const storage = this.storages.get(targetStorage);
|
|
538
533
|
if (!storage) {
|
|
539
|
-
throw new Error(`[
|
|
534
|
+
throw new Error(`[Buntic Error] Storage loader "${targetStorage}" not found in "${this.config.storageDir}".
|
|
540
535
|
Available storages: [${available.join(", ")}]`);
|
|
541
536
|
}
|
|
542
537
|
try {
|
|
@@ -550,7 +545,7 @@ class StorageManager {
|
|
|
550
545
|
}
|
|
551
546
|
async function normalizeStorageResult(result, key, storageName) {
|
|
552
547
|
if (!result) {
|
|
553
|
-
throw new Error(`[
|
|
548
|
+
throw new Error(`[Buntic Error] Storage loader "${storageName}" returned null/undefined for key "${key}".`);
|
|
554
549
|
}
|
|
555
550
|
if (result instanceof Response) {
|
|
556
551
|
const arrayBuf = await result.arrayBuffer();
|
|
@@ -604,7 +599,7 @@ async function normalizeStorageResult(result, key, storageName) {
|
|
|
604
599
|
bytes: new Uint8Array(result)
|
|
605
600
|
};
|
|
606
601
|
}
|
|
607
|
-
throw new Error(`[
|
|
602
|
+
throw new Error(`[Buntic Error] Unsupported return type from storage loader "${storageName}" for key "${key}".
|
|
608
603
|
Expected Uint8Array, ArrayBuffer, Response, BunFile or { bytes, etag?, contentType? }. Received: ${typeof result}`);
|
|
609
604
|
}
|
|
610
605
|
|
|
@@ -761,7 +756,7 @@ class PhotoProcessor {
|
|
|
761
756
|
const key = attrs.key;
|
|
762
757
|
const storage = attrs.storage;
|
|
763
758
|
if (!src && !key) {
|
|
764
|
-
throw new Error(`[
|
|
759
|
+
throw new Error(`[Buntic Error] <photo> tag must have a "src" (for local files) or a "key" (for remote storage) in "${templatePath}".
|
|
765
760
|
` + ` Found: ${match.fullMatch}`);
|
|
766
761
|
}
|
|
767
762
|
const widths = attrs.widths ? attrs.widths.split(",").map((w) => parseInt(w.trim(), 10)).filter((w) => !isNaN(w) && w > 0) : undefined;
|
|
@@ -801,7 +796,7 @@ class PhotoProcessor {
|
|
|
801
796
|
}
|
|
802
797
|
const localPath = resolveLocalAssetPath(this.config, src, templatePath);
|
|
803
798
|
if (!existsSync6(localPath)) {
|
|
804
|
-
throw new Error(`[
|
|
799
|
+
throw new Error(`[Buntic Error] Local image file "${src}" referenced in <photo> not found.
|
|
805
800
|
` + ` Looked in: "${localPath}"
|
|
806
801
|
` + ` Referenced in: "${templatePath}"`);
|
|
807
802
|
}
|
|
@@ -936,15 +931,15 @@ function validateRouteParams(requiredTokens, params, loaderPath) {
|
|
|
936
931
|
for (const token of requiredTokens) {
|
|
937
932
|
const rawVal = params[token];
|
|
938
933
|
if (rawVal === undefined || rawVal === null) {
|
|
939
|
-
throw new Error(`[
|
|
934
|
+
throw new Error(`[Buntic Error]: Missing required route parameter "${token}" in loader "${loaderPath}".
|
|
940
935
|
Provided parameters: ${JSON.stringify(params)}`);
|
|
941
936
|
}
|
|
942
937
|
const strVal = String(rawVal).trim();
|
|
943
938
|
if (strVal === "") {
|
|
944
|
-
throw new Error(`[
|
|
939
|
+
throw new Error(`[Buntic Error]: Route parameter "${token}" in loader "${loaderPath}" cannot be an empty string.`);
|
|
945
940
|
}
|
|
946
941
|
if (/[\/\\?#\0]/.test(strVal)) {
|
|
947
|
-
throw new Error(`[
|
|
942
|
+
throw new Error(`[Buntic Error]: Route parameter "${token}" with value "${strVal}" in "${loaderPath}" contains invalid characters (/ \\ ? #).`);
|
|
948
943
|
}
|
|
949
944
|
cleanParams[token] = strVal;
|
|
950
945
|
}
|
|
@@ -991,7 +986,7 @@ function buildCleanUrl(patternRelPath, params) {
|
|
|
991
986
|
}
|
|
992
987
|
function registerRouteOrThrow(urlRegistry, urlPath, sourceDesc) {
|
|
993
988
|
if (urlRegistry.has(urlPath)) {
|
|
994
|
-
throw new Error(`[
|
|
989
|
+
throw new Error(`[Buntic Collision Error]: Duplicate route generated for "${urlPath}".
|
|
995
990
|
- First generated by: ${urlRegistry.get(urlPath)}
|
|
996
991
|
- Conflicting with: ${sourceDesc}`);
|
|
997
992
|
}
|
|
@@ -1035,7 +1030,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
1035
1030
|
} = options;
|
|
1036
1031
|
if (!loaderPath) {
|
|
1037
1032
|
const expected = relPattern.replace(/\.html$/, ".data.ts");
|
|
1038
|
-
throw new Error(`[
|
|
1033
|
+
throw new Error(`[Buntic Error]: Dynamic page "${relPattern}" contains parameter(s) [${tokens.join(", ")}], but no co-located loader was found.
|
|
1039
1034
|
` + `\uD83D\uDC49 Create "${expected}" exporting a default async function or getStaticPaths().`);
|
|
1040
1035
|
}
|
|
1041
1036
|
const relLoader = relative2(config.root, loaderPath);
|
|
@@ -1049,7 +1044,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
1049
1044
|
}
|
|
1050
1045
|
const handler = mod.default ?? mod.getStaticPaths;
|
|
1051
1046
|
if (typeof handler !== "function") {
|
|
1052
|
-
throw new Error(`[
|
|
1047
|
+
throw new Error(`[Buntic Error]: Loader "${relLoader}" must export a default function ("export default async function") or "getStaticPaths".`);
|
|
1053
1048
|
}
|
|
1054
1049
|
const basePattern = relPattern.split(sep2).join("/").replace(/\.html$/, "");
|
|
1055
1050
|
const lastSlash = basePattern.lastIndexOf("/");
|
|
@@ -1066,7 +1061,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
1066
1061
|
throw err;
|
|
1067
1062
|
}
|
|
1068
1063
|
if (!Array.isArray(pathsResult)) {
|
|
1069
|
-
throw new Error(`[
|
|
1064
|
+
throw new Error(`[Buntic Error]: Dynamic loader "${relLoader}" must return an Array of path objects ({ params, props }). Received: ${typeof pathsResult}.`);
|
|
1070
1065
|
}
|
|
1071
1066
|
if (pathsResult.length === 0) {
|
|
1072
1067
|
logWarn(`Dynamic loader "${relLoader}" returned 0 paths. No pages generated for "${relPattern}".`);
|
|
@@ -1076,7 +1071,7 @@ async function resolveDynamicRoutes(options) {
|
|
|
1076
1071
|
for (let i = 0;i < pathsResult.length; i++) {
|
|
1077
1072
|
const item = pathsResult[i];
|
|
1078
1073
|
if (!item || typeof item !== "object" || !item.params || typeof item.params !== "object") {
|
|
1079
|
-
throw new Error(`[
|
|
1074
|
+
throw new Error(`[Buntic Error]: Item at index ${i} in loader "${relLoader}" must be an object with a "params" property.
|
|
1080
1075
|
Received: ${JSON.stringify(item)}`);
|
|
1081
1076
|
}
|
|
1082
1077
|
const cleanParams = validateRouteParams(tokens, item.params, relLoader);
|
|
@@ -1310,7 +1305,7 @@ class SeoMetadataEngine {
|
|
|
1310
1305
|
imgHeight = processed.height;
|
|
1311
1306
|
}
|
|
1312
1307
|
} catch (err) {
|
|
1313
|
-
logWarn(`Failed to process social image in "${templatePath}": ${getErrorMessage(err)}`, "
|
|
1308
|
+
logWarn(`Failed to process social image in "${templatePath}": ${getErrorMessage(err)}`, "Buntic SEO Warning");
|
|
1314
1309
|
}
|
|
1315
1310
|
}
|
|
1316
1311
|
const metaTags = this.generateMetaTagsHtml({
|
|
@@ -1549,13 +1544,13 @@ class WebComponentRegistry {
|
|
|
1549
1544
|
const expectedTag = filenameToTagName(filePath);
|
|
1550
1545
|
if (!expectedTag) {
|
|
1551
1546
|
if (content && /(?:customElements\.define|@customElement)\s*\(\s*["']([a-z0-9-]+)["']/i.test(content)) {
|
|
1552
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
1547
|
+
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.`);
|
|
1553
1548
|
}
|
|
1554
1549
|
return [];
|
|
1555
1550
|
}
|
|
1556
1551
|
const validation = this.validateTagName(expectedTag);
|
|
1557
1552
|
if (!validation.valid) {
|
|
1558
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
1553
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Warning]\x1B[0m Skipping invalid Custom Element tag "${expectedTag}" in ${filePath}: ${validation.reason}`);
|
|
1559
1554
|
return [];
|
|
1560
1555
|
}
|
|
1561
1556
|
if (content) {
|
|
@@ -1566,13 +1561,13 @@ class WebComponentRegistry {
|
|
|
1566
1561
|
declaredTags.add(match[1].toLowerCase());
|
|
1567
1562
|
}
|
|
1568
1563
|
if (declaredTags.size > 1) {
|
|
1569
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
1564
|
+
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.`);
|
|
1570
1565
|
return [];
|
|
1571
1566
|
}
|
|
1572
1567
|
if (declaredTags.size === 1) {
|
|
1573
1568
|
const declaredTag = Array.from(declaredTags)[0];
|
|
1574
1569
|
if (declaredTag !== expectedTag) {
|
|
1575
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
1570
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Warning]\x1B[0m Tag "<${declaredTag}>" in "${filePath}" does not match filename. Expected tag "<${expectedTag}>" for file "${basename3(filePath)}". Registration skipped.`);
|
|
1576
1571
|
return [];
|
|
1577
1572
|
}
|
|
1578
1573
|
}
|
|
@@ -1584,7 +1579,7 @@ class WebComponentRegistry {
|
|
|
1584
1579
|
conflictFiles.push(filePath);
|
|
1585
1580
|
}
|
|
1586
1581
|
this.conflicts.set(expectedTag, conflictFiles);
|
|
1587
|
-
console.warn(`\x1B[33m\u26A0 [
|
|
1582
|
+
console.warn(`\x1B[33m\u26A0 [Buntic Collision Warning]\x1B[0m Tag "<${expectedTag}>" in ${filePath} conflicts with definition in ${existingFile}.`);
|
|
1588
1583
|
return [];
|
|
1589
1584
|
}
|
|
1590
1585
|
this.tagToFile.set(expectedTag, filePath);
|
|
@@ -1641,7 +1636,7 @@ ${c.files.map((f) => ` - ${f}`).join(`
|
|
|
1641
1636
|
`)}`).join(`
|
|
1642
1637
|
|
|
1643
1638
|
`);
|
|
1644
|
-
throw new Error(`[
|
|
1639
|
+
throw new Error(`[Buntic Conflict Error]: Tag collision detected between Web Components:
|
|
1645
1640
|
${details}
|
|
1646
1641
|
|
|
1647
1642
|
` + `\uD83D\uDC49 Each Custom Element tag must be uniquely defined.`);
|
|
@@ -2371,7 +2366,7 @@ async function resolvePageCss(options) {
|
|
|
2371
2366
|
} catch {
|
|
2372
2367
|
cssContent = await Bun.file(cssFilePath).text();
|
|
2373
2368
|
}
|
|
2374
|
-
const styleBlock = `<style id="
|
|
2369
|
+
const styleBlock = `<style id="__buntic_global">
|
|
2375
2370
|
${cssContent}
|
|
2376
2371
|
</style>`;
|
|
2377
2372
|
result = replaceLiteral(result, fullTag, styleBlock);
|
|
@@ -2379,15 +2374,15 @@ ${cssContent}
|
|
|
2379
2374
|
}
|
|
2380
2375
|
}
|
|
2381
2376
|
const headMatch = result.match(/<head[\s\S]*?<\/head>/i);
|
|
2382
|
-
const headHasGlobalStyle = headMatch ? headMatch[0].includes('id="
|
|
2377
|
+
const headHasGlobalStyle = headMatch ? headMatch[0].includes('id="__buntic_global"') : false;
|
|
2383
2378
|
if (!hadManualGlobalLink && !headHasGlobalStyle && globalCssContent) {
|
|
2384
|
-
const globalTag = ` <style id="
|
|
2379
|
+
const globalTag = ` <style id="__buntic_global">
|
|
2385
2380
|
${globalCssContent}
|
|
2386
2381
|
</style>`;
|
|
2387
2382
|
result = injectIntoHead(result, globalTag, "prepend");
|
|
2388
2383
|
}
|
|
2389
2384
|
if (hasScopedRules) {
|
|
2390
|
-
const scopedTag = ` <style id="
|
|
2385
|
+
const scopedTag = ` <style id="__buntic_scoped">
|
|
2391
2386
|
${scopedCssText}
|
|
2392
2387
|
</style>`;
|
|
2393
2388
|
result = injectIntoHead(result, scopedTag, "append");
|
|
@@ -2523,7 +2518,7 @@ async function loadGlobalData(config, vfs) {
|
|
|
2523
2518
|
}
|
|
2524
2519
|
}
|
|
2525
2520
|
} catch (err) {
|
|
2526
|
-
if (err instanceof Error && err.message.includes("[
|
|
2521
|
+
if (err instanceof Error && err.message.includes("[Buntic Error]")) {
|
|
2527
2522
|
throw err;
|
|
2528
2523
|
}
|
|
2529
2524
|
}
|
|
@@ -2625,7 +2620,7 @@ async function resolveWebComponentsInHtml(options) {
|
|
|
2625
2620
|
if (globalRoot.root) {
|
|
2626
2621
|
if (config.cssStrategy === "inline") {
|
|
2627
2622
|
const globalCss = await cssGraph.flattenCss(globalRoot.root, vfs);
|
|
2628
|
-
globalCssBlock = `<style data-
|
|
2623
|
+
globalCssBlock = `<style data-buntic="global">
|
|
2629
2624
|
${globalCss.trim()}
|
|
2630
2625
|
</style>`;
|
|
2631
2626
|
} else if (globalRoot.relativeRoot) {
|
|
@@ -2705,7 +2700,7 @@ ${siblingCss.trim()}
|
|
|
2705
2700
|
const extracted = extractScopedStyles(rawHtml, scopeRegistry);
|
|
2706
2701
|
rawHtml = extracted.html;
|
|
2707
2702
|
if (extracted.scopedRules.length > 0) {
|
|
2708
|
-
scopedDsdCssBlock = `<style data-
|
|
2703
|
+
scopedDsdCssBlock = `<style data-buntic="dsd-scoped">
|
|
2709
2704
|
${extracted.scopedRules.join(`
|
|
2710
2705
|
|
|
2711
2706
|
`)}
|
|
@@ -2837,7 +2832,7 @@ function isIgnoredPath(filePathOrName) {
|
|
|
2837
2832
|
const normalized = filePathOrName.replace(/\\/g, "/");
|
|
2838
2833
|
const segments = normalized.split("/");
|
|
2839
2834
|
for (const seg of segments) {
|
|
2840
|
-
if (seg === "node_modules" || seg === ".git" || seg === ".agents" || seg === "dist" || seg.startsWith(".
|
|
2835
|
+
if (seg === "node_modules" || seg === ".git" || seg === ".agents" || seg === "dist" || seg.startsWith(".buntic")) {
|
|
2841
2836
|
return true;
|
|
2842
2837
|
}
|
|
2843
2838
|
}
|
|
@@ -3092,7 +3087,7 @@ class TemplateEngine {
|
|
|
3092
3087
|
const globalRoot = this.cssGraph.getGlobalRoot();
|
|
3093
3088
|
if (globalRoot.conflicts.length > 1) {
|
|
3094
3089
|
const relConflicts = globalRoot.conflicts.map((c) => relative7(this.config.root, c));
|
|
3095
|
-
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.`, "
|
|
3090
|
+
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");
|
|
3096
3091
|
}
|
|
3097
3092
|
let processedHtml = pageHtml;
|
|
3098
3093
|
if (currentFile && currentFile.endsWith(".html")) {
|
|
@@ -3160,7 +3155,7 @@ class TemplateEngine {
|
|
|
3160
3155
|
const innerContent = layoutMatch[2];
|
|
3161
3156
|
const layoutFilePath = this.resolveFilePath(layoutRawSrc, currentFile, this.config.layoutsDir);
|
|
3162
3157
|
if (!this.vfs.hasFile(layoutFilePath) && !existsSync16(layoutFilePath)) {
|
|
3163
|
-
throw new Error(`[
|
|
3158
|
+
throw new Error(`[Buntic] Layout not found: "${layoutRawSrc}" at ${layoutFilePath}`);
|
|
3164
3159
|
}
|
|
3165
3160
|
const layoutTemplate = await this.vfs.readText(layoutFilePath);
|
|
3166
3161
|
let resolvedInner = await this.resolveEach(innerContent, context, currentFile);
|
|
@@ -3196,7 +3191,7 @@ class TemplateEngine {
|
|
|
3196
3191
|
}
|
|
3197
3192
|
async resolveEach(html, context, currentFile, depth = 0) {
|
|
3198
3193
|
if (depth > 10) {
|
|
3199
|
-
console.warn("[
|
|
3194
|
+
console.warn("[Buntic] Maximum <each> recursion depth (10) reached.");
|
|
3200
3195
|
return html;
|
|
3201
3196
|
}
|
|
3202
3197
|
const eachRegex = /<each\s+([^>]+?)>([\s\S]*?)<\/each>/gis;
|
|
@@ -3214,16 +3209,16 @@ class TemplateEngine {
|
|
|
3214
3209
|
if (attrs.src) {
|
|
3215
3210
|
const filePath = this.resolveFilePath(attrs.src, currentFile, this.config.dataDir);
|
|
3216
3211
|
if (!this.vfs.hasFile(filePath) && !existsSync16(filePath)) {
|
|
3217
|
-
throw new Error(`[
|
|
3212
|
+
throw new Error(`[Buntic] <each> data file not found: "${attrs.src}" at ${filePath}`);
|
|
3218
3213
|
}
|
|
3219
3214
|
items = await this.vfs.readJson(filePath);
|
|
3220
3215
|
} else if (attrs.in) {
|
|
3221
3216
|
items = getNestedValue(context, attrs.in);
|
|
3222
3217
|
} else {
|
|
3223
|
-
throw new Error(`[
|
|
3218
|
+
throw new Error(`[Buntic] <each> tag requires either a "src" or "in" attribute.`);
|
|
3224
3219
|
}
|
|
3225
3220
|
if (!Array.isArray(items)) {
|
|
3226
|
-
throw new Error(`[
|
|
3221
|
+
throw new Error(`[Buntic] <each> source "${attrs.src || attrs.in}" did not resolve to an array.`);
|
|
3227
3222
|
}
|
|
3228
3223
|
const renderedItems = [];
|
|
3229
3224
|
for (const entry of items) {
|
|
@@ -3253,7 +3248,7 @@ class TemplateEngine {
|
|
|
3253
3248
|
}
|
|
3254
3249
|
async resolveComponents(html, context, currentFile, depth = 0) {
|
|
3255
3250
|
if (depth > 10) {
|
|
3256
|
-
console.warn("[
|
|
3251
|
+
console.warn("[Buntic] Maximum component recursion depth (10) reached. Check for circular component includes.");
|
|
3257
3252
|
return html;
|
|
3258
3253
|
}
|
|
3259
3254
|
const componentRegex = /<component\s+([^>]+?)(?:\s*\/>|>(.*?)<\/component>)/gis;
|
|
@@ -3276,7 +3271,7 @@ class TemplateEngine {
|
|
|
3276
3271
|
for (const item of matches) {
|
|
3277
3272
|
const compPath = this.resolveFilePath(item.src, currentFile, this.config.componentsDir);
|
|
3278
3273
|
if (!this.vfs.hasFile(compPath) && !existsSync16(compPath)) {
|
|
3279
|
-
throw new Error(`[
|
|
3274
|
+
throw new Error(`[Buntic] Component not found: "${item.src}" at ${compPath}`);
|
|
3280
3275
|
}
|
|
3281
3276
|
const ext = extname4(compPath).toLowerCase();
|
|
3282
3277
|
if (ext === ".ts" || ext === ".js" || ext === ".tsx" || ext === ".jsx") {
|
|
@@ -3340,7 +3335,7 @@ class TemplateEngine {
|
|
|
3340
3335
|
tag = filenameToTagName(compPath) || undefined;
|
|
3341
3336
|
}
|
|
3342
3337
|
if (!tag) {
|
|
3343
|
-
throw new Error(`[
|
|
3338
|
+
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").`);
|
|
3344
3339
|
}
|
|
3345
3340
|
const attrEntries = Object.entries(props).filter(([k]) => k !== "src");
|
|
3346
3341
|
const attrString = attrEntries.length > 0 ? " " + attrEntries.map(([k, v]) => `${k}="${v}"`).join(" ") : "";
|
|
@@ -3394,14 +3389,14 @@ function detectPublicCollisions(config, routes) {
|
|
|
3394
3389
|
collisions.push({
|
|
3395
3390
|
type: "reserved-dir",
|
|
3396
3391
|
publicPath: relative8(config.root, join16(config.publicDir, relFile)),
|
|
3397
|
-
conflictWith: "assets/images/ (Reserved for
|
|
3392
|
+
conflictWith: "assets/images/ (Reserved for Buntic <photo> image optimization)",
|
|
3398
3393
|
outputPath: relFile
|
|
3399
3394
|
});
|
|
3400
3395
|
} else if (relFile.startsWith("assets/seo/") || relFile === "assets/seo") {
|
|
3401
3396
|
collisions.push({
|
|
3402
3397
|
type: "reserved-dir",
|
|
3403
3398
|
publicPath: relative8(config.root, join16(config.publicDir, relFile)),
|
|
3404
|
-
conflictWith: "assets/seo/ (Reserved for
|
|
3399
|
+
conflictWith: "assets/seo/ (Reserved for Buntic <seo> social cards)",
|
|
3405
3400
|
outputPath: relFile
|
|
3406
3401
|
});
|
|
3407
3402
|
}
|
|
@@ -3419,7 +3414,7 @@ function assertNoPublicCollisions(config, routes) {
|
|
|
3419
3414
|
return ` - Public file "${c.publicPath}" conflicts with reserved internal path "${c.conflictWith}".`;
|
|
3420
3415
|
}).join(`
|
|
3421
3416
|
`);
|
|
3422
|
-
throw new Error(`[
|
|
3417
|
+
throw new Error(`[Buntic Collision Error]: Conflict detected between public/ files and build output:
|
|
3423
3418
|
` + details + `
|
|
3424
3419
|
|
|
3425
3420
|
\uD83D\uDC49 Action: Remove or rename conflicting files in "public/" or adjust page routes in "pages/".`);
|
|
@@ -3445,17 +3440,17 @@ class Builder {
|
|
|
3445
3440
|
this.engine.assertNoWebComponentConflicts();
|
|
3446
3441
|
this.engine.clearUsedWebComponents();
|
|
3447
3442
|
if (!existsSync18(this.config.pagesDir)) {
|
|
3448
|
-
throw new Error(`[
|
|
3443
|
+
throw new Error(`[Buntic] Pages directory not found at: ${this.config.pagesDir}`);
|
|
3449
3444
|
}
|
|
3450
3445
|
const globalData = await this.engine.loadData();
|
|
3451
3446
|
const routes = await resolveAllRoutes(this.config, globalData);
|
|
3452
3447
|
if (routes.length === 0) {
|
|
3453
|
-
console.warn(`[
|
|
3448
|
+
console.warn(`[Buntic] No HTML pages found in: ${this.config.pagesDir}`);
|
|
3454
3449
|
return { success: true, pagesCount: 0, outputFiles: [], durationMs: 0 };
|
|
3455
3450
|
}
|
|
3456
3451
|
assertNoPublicCollisions(this.config, routes);
|
|
3457
3452
|
this.prepareEmptyDir(this.config.outDir);
|
|
3458
|
-
const stagingDir = join17(this.config.root, ".
|
|
3453
|
+
const stagingDir = join17(this.config.root, ".buntic-staging");
|
|
3459
3454
|
this.prepareEmptyDir(stagingDir);
|
|
3460
3455
|
try {
|
|
3461
3456
|
const stagedEntrypoints = await this.stagePages(routes, stagingDir);
|
|
@@ -3528,7 +3523,7 @@ class Builder {
|
|
|
3528
3523
|
for (const log of buildResult.logs) {
|
|
3529
3524
|
console.error(log);
|
|
3530
3525
|
}
|
|
3531
|
-
throw new Error("[
|
|
3526
|
+
throw new Error("[Buntic] Bun.build bundling failed.");
|
|
3532
3527
|
}
|
|
3533
3528
|
return buildResult.outputs.map((o) => o.path);
|
|
3534
3529
|
}
|
|
@@ -3586,7 +3581,7 @@ class Builder {
|
|
|
3586
3581
|
normalizeRootPaths(html, stagedFilePath, stagingDir) {
|
|
3587
3582
|
const fromDir = dirname9(stagedFilePath);
|
|
3588
3583
|
return html.replace(/(href|src)=["']\/([^"']+)["']/gi, (match, attr, path) => {
|
|
3589
|
-
if (path.startsWith("/") || path.startsWith("http:") || path.startsWith("https:") || path.startsWith("
|
|
3584
|
+
if (path.startsWith("/") || path.startsWith("http:") || path.startsWith("https:") || path.startsWith("_buntic") || path.startsWith("assets/images/") || path.startsWith("assets/seo/")) {
|
|
3590
3585
|
return match;
|
|
3591
3586
|
}
|
|
3592
3587
|
const targetInRoot = join17(this.config.root, path);
|
|
@@ -3625,13 +3620,13 @@ import { join as join19, resolve as resolve7 } from "path";
|
|
|
3625
3620
|
import { existsSync as existsSync19, statSync as statSync7 } from "fs";
|
|
3626
3621
|
import { join as join18 } from "path";
|
|
3627
3622
|
var LIVE_RELOAD_SCRIPT = `
|
|
3628
|
-
<script id="
|
|
3623
|
+
<script id="__buntic_live_reload">
|
|
3629
3624
|
(() => {
|
|
3630
3625
|
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
3631
|
-
const ws = new WebSocket(\`\${protocol}//\${location.host}/
|
|
3626
|
+
const ws = new WebSocket(\`\${protocol}//\${location.host}/_buntic/ws\`);
|
|
3632
3627
|
ws.onmessage = (event) => {
|
|
3633
3628
|
if (event.data === 'reload') {
|
|
3634
|
-
console.log('[
|
|
3629
|
+
console.log('[buntic] Change detected. Reloading...');
|
|
3635
3630
|
location.reload();
|
|
3636
3631
|
}
|
|
3637
3632
|
};
|
|
@@ -3779,7 +3774,7 @@ function renderNotFoundResponse(pathname, routes) {
|
|
|
3779
3774
|
<!doctype html>
|
|
3780
3775
|
<html>
|
|
3781
3776
|
<head>
|
|
3782
|
-
<title>404 - Not Found |
|
|
3777
|
+
<title>404 - Not Found | Buntic Dev</title>
|
|
3783
3778
|
<style>
|
|
3784
3779
|
body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #f8fafc; padding: 3rem; }
|
|
3785
3780
|
.card { max-width: 650px; margin: 0 auto; background: #1e293b; padding: 2rem; border-radius: 12px; border: 1px solid #334155; }
|
|
@@ -3818,9 +3813,9 @@ function startDevServer(config) {
|
|
|
3818
3813
|
const collisions = detectPublicCollisions(config, routes);
|
|
3819
3814
|
for (const c of collisions) {
|
|
3820
3815
|
if (c.type === "route") {
|
|
3821
|
-
logWarn(`Public file "${c.publicPath}" conflicts with page template "${c.conflictWith}" (both resolve to "${c.outputPath}").`, "
|
|
3816
|
+
logWarn(`Public file "${c.publicPath}" conflicts with page template "${c.conflictWith}" (both resolve to "${c.outputPath}").`, "Buntic Collision Warning");
|
|
3822
3817
|
} else {
|
|
3823
|
-
logWarn(`Public file "${c.publicPath}" conflicts with reserved internal path "${c.conflictWith}".`, "
|
|
3818
|
+
logWarn(`Public file "${c.publicPath}" conflicts with reserved internal path "${c.conflictWith}".`, "Buntic Collision Warning");
|
|
3824
3819
|
}
|
|
3825
3820
|
}
|
|
3826
3821
|
} catch {}
|
|
@@ -3867,7 +3862,7 @@ function startDevServer(config) {
|
|
|
3867
3862
|
} catch {
|
|
3868
3863
|
return new Response("Bad Request", { status: 400 });
|
|
3869
3864
|
}
|
|
3870
|
-
if (pathname === "/
|
|
3865
|
+
if (pathname === "/_buntic/ws") {
|
|
3871
3866
|
if (srv.upgrade(req))
|
|
3872
3867
|
return;
|
|
3873
3868
|
return new Response("WebSocket upgrade failed", { status: 400 });
|
|
@@ -3913,7 +3908,7 @@ function startDevServer(config) {
|
|
|
3913
3908
|
seoEngine
|
|
3914
3909
|
});
|
|
3915
3910
|
} catch (err) {
|
|
3916
|
-
return renderErrorResponse("[
|
|
3911
|
+
return renderErrorResponse("[Buntic Template Error]", err);
|
|
3917
3912
|
}
|
|
3918
3913
|
}
|
|
3919
3914
|
try {
|
|
@@ -3934,7 +3929,7 @@ function startDevServer(config) {
|
|
|
3934
3929
|
});
|
|
3935
3930
|
}
|
|
3936
3931
|
} catch (err) {
|
|
3937
|
-
return renderErrorResponse("[
|
|
3932
|
+
return renderErrorResponse("[Buntic Dynamic Route Error]", err);
|
|
3938
3933
|
}
|
|
3939
3934
|
if (engine.generatedPageStyles.has(pathname)) {
|
|
3940
3935
|
const css = engine.generatedPageStyles.get(pathname);
|
|
@@ -3999,7 +3994,7 @@ function copyTemplateDirectory(srcDir, destDir) {
|
|
|
3999
3994
|
function initProject(options = {}) {
|
|
4000
3995
|
const templateName = options.template || "blank";
|
|
4001
3996
|
if (!AVAILABLE_TEMPLATES.includes(templateName)) {
|
|
4002
|
-
throw new Error(`[
|
|
3997
|
+
throw new Error(`[Buntic] Unknown template "${options.template}". Available templates: ${AVAILABLE_TEMPLATES.join(", ")}.`);
|
|
4003
3998
|
}
|
|
4004
3999
|
const targetDir = resolve8(process.cwd(), options.targetDir || ".");
|
|
4005
4000
|
const includeSkills = options.includeSkills ?? true;
|
|
@@ -4007,22 +4002,22 @@ function initProject(options = {}) {
|
|
|
4007
4002
|
const pkgRoot = getPackageRoot();
|
|
4008
4003
|
const templateDir = join20(pkgRoot, "templates", templateName);
|
|
4009
4004
|
if (!existsSync21(templateDir)) {
|
|
4010
|
-
throw new Error(`[
|
|
4005
|
+
throw new Error(`[Buntic] Template directory not found: "${templateDir}"`);
|
|
4011
4006
|
}
|
|
4012
4007
|
if (existsSync21(targetDir) && !force) {
|
|
4013
4008
|
const existingEntries = readdirSync6(targetDir).filter((name) => name !== ".git" && name !== ".DS_Store");
|
|
4014
4009
|
if (existingEntries.length > 0) {
|
|
4015
|
-
throw new Error(`[
|
|
4016
|
-
` + ` Pass a new directory name (e.g. "
|
|
4010
|
+
throw new Error(`[Buntic] Target directory "${targetDir}" is not empty.
|
|
4011
|
+
` + ` Pass a new directory name (e.g. "buntic init my-site") or use --force to initialize anyway.`);
|
|
4017
4012
|
}
|
|
4018
4013
|
}
|
|
4019
4014
|
mkdirSync4(targetDir, { recursive: true });
|
|
4020
4015
|
let filesCopied = copyTemplateDirectory(templateDir, targetDir);
|
|
4021
4016
|
let skillsDir = null;
|
|
4022
4017
|
if (includeSkills) {
|
|
4023
|
-
const srcSkillsDir = join20(pkgRoot, "templates", "skills", "
|
|
4018
|
+
const srcSkillsDir = join20(pkgRoot, "templates", "skills", "buntic");
|
|
4024
4019
|
if (existsSync21(srcSkillsDir)) {
|
|
4025
|
-
skillsDir = join20(targetDir, ".agents", "skills", "
|
|
4020
|
+
skillsDir = join20(targetDir, ".agents", "skills", "buntic");
|
|
4026
4021
|
filesCopied += copyTemplateDirectory(srcSkillsDir, skillsDir);
|
|
4027
4022
|
}
|
|
4028
4023
|
}
|
|
@@ -4037,11 +4032,11 @@ function initProject(options = {}) {
|
|
|
4037
4032
|
|
|
4038
4033
|
// src/cli.ts
|
|
4039
4034
|
async function runCLI(args) {
|
|
4040
|
-
|
|
4035
|
+
registerBunticModuleResolver();
|
|
4041
4036
|
const command = args[0] || "help";
|
|
4042
4037
|
if (command === "--version" || command === "-v") {
|
|
4043
4038
|
const pkg = await Bun.file(`${getPackageRoot()}/package.json`).json();
|
|
4044
|
-
console.log(`
|
|
4039
|
+
console.log(`buntic v${pkg.version}`);
|
|
4045
4040
|
return;
|
|
4046
4041
|
}
|
|
4047
4042
|
if (command === "help" || command === "--help" || command === "-h") {
|
|
@@ -4099,25 +4094,25 @@ async function runCLI(args) {
|
|
|
4099
4094
|
});
|
|
4100
4095
|
const relTarget = relative10(process.cwd(), result.targetDir) || ".";
|
|
4101
4096
|
console.log(`
|
|
4102
|
-
\u26A1 \x1B[36m[
|
|
4097
|
+
\u26A1 \x1B[36m[Buntic]\x1B[0m Initialized new project (\x1B[33m${result.template}\x1B[0m) in: \x1B[32m${result.targetDir}\x1B[0m`);
|
|
4103
4098
|
console.log(` \u2714 Created ${result.filesCopied} file(s) (no package.json required)`);
|
|
4104
4099
|
if (result.skillsDir) {
|
|
4105
|
-
console.log(` \u2714 Installed
|
|
4100
|
+
console.log(` \u2714 Installed Buntic agent skill in .agents/skills/buntic`);
|
|
4106
4101
|
}
|
|
4107
|
-
console.log(` \u2714 Generated TypeScript definitions in .
|
|
4102
|
+
console.log(` \u2714 Generated TypeScript definitions in .buntic/types/`);
|
|
4108
4103
|
console.log(`
|
|
4109
4104
|
\x1B[1mNext steps:\x1B[0m`);
|
|
4110
4105
|
if (relTarget !== ".") {
|
|
4111
4106
|
console.log(` cd ${relTarget}`);
|
|
4112
4107
|
}
|
|
4113
|
-
console.log(`
|
|
4108
|
+
console.log(` buntic dev
|
|
4114
4109
|
`);
|
|
4115
4110
|
return;
|
|
4116
4111
|
}
|
|
4117
4112
|
if (command === "clean") {
|
|
4118
4113
|
const config = await resolveConfig(targetDir);
|
|
4119
4114
|
console.log(`
|
|
4120
|
-
\uD83E\uDDF9 \x1B[36m[
|
|
4115
|
+
\uD83E\uDDF9 \x1B[36m[Buntic]\x1B[0m Cleaning build and cache directories for: \x1B[33m${config.root}\x1B[0m`);
|
|
4121
4116
|
if (existsSync22(config.outDir)) {
|
|
4122
4117
|
rmSync4(config.outDir, { recursive: true, force: true });
|
|
4123
4118
|
console.log(` \u2714 Removed ${config.outDir}`);
|
|
@@ -4138,14 +4133,14 @@ async function runCLI(args) {
|
|
|
4138
4133
|
console.log(`\x1B[32m\u2714\x1B[0m Cache cleaned.`);
|
|
4139
4134
|
}
|
|
4140
4135
|
console.log(`
|
|
4141
|
-
\uD83D\uDE80 \x1B[36m[
|
|
4136
|
+
\uD83D\uDE80 \x1B[36m[Buntic]\x1B[0m Starting dev server for: \x1B[33m${config.root}\x1B[0m`);
|
|
4142
4137
|
const devInstance = startDevServer(config);
|
|
4143
4138
|
console.log(` \u279C Local: \x1B[32mhttp://localhost:${devInstance.port}/\x1B[0m`);
|
|
4144
4139
|
console.log(` \u279C Live reload enabled via WebSockets.
|
|
4145
4140
|
`);
|
|
4146
4141
|
process.on("SIGINT", () => {
|
|
4147
4142
|
console.log(`
|
|
4148
|
-
\x1B[33m[
|
|
4143
|
+
\x1B[33m[Buntic]\x1B[0m Shutting down server...`);
|
|
4149
4144
|
devInstance.stop();
|
|
4150
4145
|
process.exit(0);
|
|
4151
4146
|
});
|
|
@@ -4153,7 +4148,7 @@ async function runCLI(args) {
|
|
|
4153
4148
|
const config = await resolveConfig(targetDir, { outDir });
|
|
4154
4149
|
syncProjectTypes(config.root);
|
|
4155
4150
|
console.log(`
|
|
4156
|
-
\uD83D\uDCE6 \x1B[36m[
|
|
4151
|
+
\uD83D\uDCE6 \x1B[36m[Buntic]\x1B[0m Building static site for: \x1B[33m${config.root}\x1B[0m`);
|
|
4157
4152
|
const builder = new Builder(config);
|
|
4158
4153
|
const result = await builder.build({ cleanCache });
|
|
4159
4154
|
console.log(`\x1B[32m\u2714\x1B[0m Successfully built ${result.pagesCount} page(s) in ${result.durationMs}ms`);
|
|
@@ -4173,21 +4168,21 @@ async function runCLI(args) {
|
|
|
4173
4168
|
}
|
|
4174
4169
|
function printHelp() {
|
|
4175
4170
|
console.log(`
|
|
4176
|
-
\x1B[
|
|
4171
|
+
\x1B[1mBuntic\x1B[0m - Lightweight zero-dependency static site generator for Bun
|
|
4177
4172
|
|
|
4178
4173
|
\x1B[1mUSAGE:\x1B[0m
|
|
4179
|
-
|
|
4174
|
+
buntic <command> [directory] [options]
|
|
4180
4175
|
|
|
4181
4176
|
\x1B[1mCOMMANDS:\x1B[0m
|
|
4182
|
-
init [dir] Initialize a new
|
|
4177
|
+
init [dir] Initialize a new Buntic project (zero package.json)
|
|
4183
4178
|
dev [dir] Start the development server with live reload
|
|
4184
4179
|
build [dir] Build the static site for production into dist/
|
|
4185
|
-
clean [dir] Remove dist/ and .
|
|
4180
|
+
clean [dir] Remove dist/ and .buntic/cache/ directories
|
|
4186
4181
|
help Show this help message
|
|
4187
4182
|
|
|
4188
4183
|
\x1B[1mOPTIONS:\x1B[0m
|
|
4189
4184
|
-t, --template <name> Template for init: ${AVAILABLE_TEMPLATES.join(", ")} (default: blank)
|
|
4190
|
-
--no-skills Skip installing agent skills in .agents/skills/
|
|
4185
|
+
--no-skills Skip installing agent skills in .agents/skills/buntic
|
|
4191
4186
|
-f, --force Allow init in a non-empty directory
|
|
4192
4187
|
-p, --port <port> Port to run dev server on (default: 3000)
|
|
4193
4188
|
-o, --outdir <dir> Output directory for build (default: dist)
|
|
@@ -4196,15 +4191,15 @@ function printHelp() {
|
|
|
4196
4191
|
-h, --help Show help
|
|
4197
4192
|
|
|
4198
4193
|
\x1B[1mEXAMPLES:\x1B[0m
|
|
4199
|
-
$
|
|
4200
|
-
$
|
|
4201
|
-
$
|
|
4202
|
-
$
|
|
4203
|
-
$
|
|
4204
|
-
$
|
|
4205
|
-
$
|
|
4194
|
+
$ buntic init mi-sitio
|
|
4195
|
+
$ buntic init mi-sitio --template simple
|
|
4196
|
+
$ buntic dev
|
|
4197
|
+
$ buntic dev my-site --port 8080
|
|
4198
|
+
$ buntic build
|
|
4199
|
+
$ buntic build my-site --outdir ./public_html --clean-cache
|
|
4200
|
+
$ buntic clean
|
|
4206
4201
|
`);
|
|
4207
4202
|
}
|
|
4208
4203
|
|
|
4209
|
-
// bin/
|
|
4204
|
+
// bin/buntic.ts
|
|
4210
4205
|
await runCLI(process.argv.slice(2));
|