clawfire 0.6.15 → 0.6.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/{dev-server-3SUUU4D2.js → dev-server-6PFNZWAZ.js} +63 -3
- package/dist/dev.cjs +63 -3
- package/dist/dev.cjs.map +1 -1
- package/dist/dev.js +63 -3
- package/dist/dev.js.map +1 -1
- package/package.json +1 -1
- package/templates/starter/app/components/nav.html +1 -1
- package/templates/starter/app/pages/index.html +5 -4
- package/templates/starter/app/pages/todos/index.html +20 -2
- package/templates/starter/functions/package.json +0 -1
- package/templates/starter/functions/tsconfig.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -269,7 +269,7 @@ async function runDevServer() {
|
|
|
269
269
|
const port = portArg ? parseInt(portArg.split("=")[1], 10) : 3e3;
|
|
270
270
|
const apiPort = apiPortArg ? parseInt(apiPortArg.split("=")[1], 10) : 3456;
|
|
271
271
|
const noHotReload = args.includes("--no-hot-reload");
|
|
272
|
-
const { startDevServer } = await import("./dev-server-
|
|
272
|
+
const { startDevServer } = await import("./dev-server-6PFNZWAZ.js");
|
|
273
273
|
await startDevServer({
|
|
274
274
|
projectDir,
|
|
275
275
|
port,
|
|
@@ -769,6 +769,7 @@ var PageCompiler = class {
|
|
|
769
769
|
try {
|
|
770
770
|
const compiled = this.compile(fullPath);
|
|
771
771
|
let html = compiled.html;
|
|
772
|
+
html = this.sanitizeForProduction(html);
|
|
772
773
|
if (scriptToInject) {
|
|
773
774
|
if (html.includes("</body>")) {
|
|
774
775
|
html = html.replace("</body>", scriptToInject + "\n</body>");
|
|
@@ -797,6 +798,18 @@ var PageCompiler = class {
|
|
|
797
798
|
walk(this.pagesDir);
|
|
798
799
|
return { pages, errors };
|
|
799
800
|
}
|
|
801
|
+
// ─── Production Sanitization ─────────────────────────────────────
|
|
802
|
+
/**
|
|
803
|
+
* Remove dev-only content from production builds:
|
|
804
|
+
* - Sections wrapped in <!-- dev-only:start --> / <!-- dev-only:end -->
|
|
805
|
+
* - Links to http://localhost (API Playground, dev dashboard, etc.)
|
|
806
|
+
*/
|
|
807
|
+
sanitizeForProduction(html) {
|
|
808
|
+
html = html.replace(/<!--\s*dev-only:start\s*-->[\s\S]*?<!--\s*dev-only:end\s*-->/g, "");
|
|
809
|
+
html = html.replace(/<a\s[^>]*href="http:\/\/localhost[^"]*"[^>]*>[\s\S]*?<\/a>/g, "");
|
|
810
|
+
html = html.replace(/\n{3,}/g, "\n\n");
|
|
811
|
+
return html;
|
|
812
|
+
}
|
|
800
813
|
// ─── Internal Methods ────────────────────────────────────────────
|
|
801
814
|
/**
|
|
802
815
|
* Extract <!-- @key: value --> metadata from HTML.
|
|
@@ -3145,6 +3158,7 @@ var FirebaseSetup = class {
|
|
|
3145
3158
|
if (!existsSync5(pkgPath)) {
|
|
3146
3159
|
return { success: false, message: "functions/package.json not found." };
|
|
3147
3160
|
}
|
|
3161
|
+
this.ensureFunctionsCJS(functionsDir);
|
|
3148
3162
|
try {
|
|
3149
3163
|
await this.execTimeout("npm", ["install"], 12e4, functionsDir);
|
|
3150
3164
|
} catch (err) {
|
|
@@ -3167,6 +3181,45 @@ var FirebaseSetup = class {
|
|
|
3167
3181
|
return { success: false, message: `Functions build failed: ${msg}` };
|
|
3168
3182
|
}
|
|
3169
3183
|
}
|
|
3184
|
+
/**
|
|
3185
|
+
* Ensure functions/ uses CommonJS for Firebase Functions compatibility.
|
|
3186
|
+
* ESM + Firebase CLI analysis often fails. Auto-fix if needed.
|
|
3187
|
+
*/
|
|
3188
|
+
ensureFunctionsCJS(functionsDir) {
|
|
3189
|
+
const pkgPath = resolve4(functionsDir, "package.json");
|
|
3190
|
+
try {
|
|
3191
|
+
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
3192
|
+
if (pkg.type === "module") {
|
|
3193
|
+
delete pkg.type;
|
|
3194
|
+
writeFileSync3(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
3195
|
+
console.log(' \x1B[32m\u2713\x1B[0m Auto-fixed: removed "type": "module" from functions/package.json');
|
|
3196
|
+
}
|
|
3197
|
+
} catch {
|
|
3198
|
+
}
|
|
3199
|
+
const tsconfigPath = resolve4(functionsDir, "tsconfig.json");
|
|
3200
|
+
try {
|
|
3201
|
+
if (existsSync5(tsconfigPath)) {
|
|
3202
|
+
let content = readFileSync4(tsconfigPath, "utf-8");
|
|
3203
|
+
const tsconfig = JSON.parse(content);
|
|
3204
|
+
let changed = false;
|
|
3205
|
+
const mod = (tsconfig.compilerOptions?.module || "").toLowerCase();
|
|
3206
|
+
if (mod === "esnext" || mod === "es2022" || mod === "es2020" || mod === "nodenext" || mod === "node16") {
|
|
3207
|
+
tsconfig.compilerOptions.module = "CommonJS";
|
|
3208
|
+
changed = true;
|
|
3209
|
+
}
|
|
3210
|
+
const res = (tsconfig.compilerOptions?.moduleResolution || "").toLowerCase();
|
|
3211
|
+
if (res === "bundler" || res === "nodenext" || res === "node16") {
|
|
3212
|
+
tsconfig.compilerOptions.moduleResolution = "node";
|
|
3213
|
+
changed = true;
|
|
3214
|
+
}
|
|
3215
|
+
if (changed) {
|
|
3216
|
+
writeFileSync3(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
|
|
3217
|
+
console.log(" \x1B[32m\u2713\x1B[0m Auto-fixed: functions/tsconfig.json \u2192 CommonJS + node resolution");
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
} catch {
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3170
3223
|
// ─── Service Enable ────────────────────────────────────────────────
|
|
3171
3224
|
enableService(service) {
|
|
3172
3225
|
const firebaseJsonPath = resolve4(this.projectDir, "firebase.json");
|
|
@@ -4656,9 +4709,16 @@ ${liveReloadScript}
|
|
|
4656
4709
|
console.log(" \x1B[32m\u2713\x1B[0m Functions deployed");
|
|
4657
4710
|
steps.push("Functions deployed");
|
|
4658
4711
|
} else {
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4712
|
+
const errMsg = (funcResult.message || "").toLowerCase();
|
|
4713
|
+
const isBillingError = ["billing", "blaze", "pay-as-you-go", "upgrade your project", "budget"].some((kw) => errMsg.includes(kw));
|
|
4714
|
+
if (isBillingError) {
|
|
4715
|
+
blazeRequired = true;
|
|
4716
|
+
console.log(" \x1B[33m\u26A0\x1B[0m Functions deploy failed (Blaze plan required)");
|
|
4717
|
+
steps.push("Functions skipped (Blaze plan required)");
|
|
4718
|
+
} else {
|
|
4719
|
+
console.log(` \x1B[31m\u2717\x1B[0m Functions deploy failed: ${funcResult.message}`);
|
|
4720
|
+
steps.push(`Functions deploy failed: ${funcResult.message}`);
|
|
4721
|
+
}
|
|
4662
4722
|
}
|
|
4663
4723
|
}
|
|
4664
4724
|
clearFirebaseStatusCache();
|
package/dist/dev.cjs
CHANGED
|
@@ -1181,6 +1181,7 @@ var PageCompiler = class {
|
|
|
1181
1181
|
try {
|
|
1182
1182
|
const compiled = this.compile(fullPath);
|
|
1183
1183
|
let html = compiled.html;
|
|
1184
|
+
html = this.sanitizeForProduction(html);
|
|
1184
1185
|
if (scriptToInject) {
|
|
1185
1186
|
if (html.includes("</body>")) {
|
|
1186
1187
|
html = html.replace("</body>", scriptToInject + "\n</body>");
|
|
@@ -1209,6 +1210,18 @@ var PageCompiler = class {
|
|
|
1209
1210
|
walk(this.pagesDir);
|
|
1210
1211
|
return { pages, errors };
|
|
1211
1212
|
}
|
|
1213
|
+
// ─── Production Sanitization ─────────────────────────────────────
|
|
1214
|
+
/**
|
|
1215
|
+
* Remove dev-only content from production builds:
|
|
1216
|
+
* - Sections wrapped in <!-- dev-only:start --> / <!-- dev-only:end -->
|
|
1217
|
+
* - Links to http://localhost (API Playground, dev dashboard, etc.)
|
|
1218
|
+
*/
|
|
1219
|
+
sanitizeForProduction(html) {
|
|
1220
|
+
html = html.replace(/<!--\s*dev-only:start\s*-->[\s\S]*?<!--\s*dev-only:end\s*-->/g, "");
|
|
1221
|
+
html = html.replace(/<a\s[^>]*href="http:\/\/localhost[^"]*"[^>]*>[\s\S]*?<\/a>/g, "");
|
|
1222
|
+
html = html.replace(/\n{3,}/g, "\n\n");
|
|
1223
|
+
return html;
|
|
1224
|
+
}
|
|
1212
1225
|
// ─── Internal Methods ────────────────────────────────────────────
|
|
1213
1226
|
/**
|
|
1214
1227
|
* Extract <!-- @key: value --> metadata from HTML.
|
|
@@ -3557,6 +3570,7 @@ var FirebaseSetup = class {
|
|
|
3557
3570
|
if (!(0, import_node_fs4.existsSync)(pkgPath)) {
|
|
3558
3571
|
return { success: false, message: "functions/package.json not found." };
|
|
3559
3572
|
}
|
|
3573
|
+
this.ensureFunctionsCJS(functionsDir);
|
|
3560
3574
|
try {
|
|
3561
3575
|
await this.execTimeout("npm", ["install"], 12e4, functionsDir);
|
|
3562
3576
|
} catch (err) {
|
|
@@ -3579,6 +3593,45 @@ var FirebaseSetup = class {
|
|
|
3579
3593
|
return { success: false, message: `Functions build failed: ${msg}` };
|
|
3580
3594
|
}
|
|
3581
3595
|
}
|
|
3596
|
+
/**
|
|
3597
|
+
* Ensure functions/ uses CommonJS for Firebase Functions compatibility.
|
|
3598
|
+
* ESM + Firebase CLI analysis often fails. Auto-fix if needed.
|
|
3599
|
+
*/
|
|
3600
|
+
ensureFunctionsCJS(functionsDir) {
|
|
3601
|
+
const pkgPath = (0, import_node_path4.resolve)(functionsDir, "package.json");
|
|
3602
|
+
try {
|
|
3603
|
+
const pkg = JSON.parse((0, import_node_fs4.readFileSync)(pkgPath, "utf-8"));
|
|
3604
|
+
if (pkg.type === "module") {
|
|
3605
|
+
delete pkg.type;
|
|
3606
|
+
(0, import_node_fs4.writeFileSync)(pkgPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
|
|
3607
|
+
console.log(' \x1B[32m\u2713\x1B[0m Auto-fixed: removed "type": "module" from functions/package.json');
|
|
3608
|
+
}
|
|
3609
|
+
} catch {
|
|
3610
|
+
}
|
|
3611
|
+
const tsconfigPath = (0, import_node_path4.resolve)(functionsDir, "tsconfig.json");
|
|
3612
|
+
try {
|
|
3613
|
+
if ((0, import_node_fs4.existsSync)(tsconfigPath)) {
|
|
3614
|
+
let content = (0, import_node_fs4.readFileSync)(tsconfigPath, "utf-8");
|
|
3615
|
+
const tsconfig = JSON.parse(content);
|
|
3616
|
+
let changed = false;
|
|
3617
|
+
const mod = (tsconfig.compilerOptions?.module || "").toLowerCase();
|
|
3618
|
+
if (mod === "esnext" || mod === "es2022" || mod === "es2020" || mod === "nodenext" || mod === "node16") {
|
|
3619
|
+
tsconfig.compilerOptions.module = "CommonJS";
|
|
3620
|
+
changed = true;
|
|
3621
|
+
}
|
|
3622
|
+
const res = (tsconfig.compilerOptions?.moduleResolution || "").toLowerCase();
|
|
3623
|
+
if (res === "bundler" || res === "nodenext" || res === "node16") {
|
|
3624
|
+
tsconfig.compilerOptions.moduleResolution = "node";
|
|
3625
|
+
changed = true;
|
|
3626
|
+
}
|
|
3627
|
+
if (changed) {
|
|
3628
|
+
(0, import_node_fs4.writeFileSync)(tsconfigPath, JSON.stringify(tsconfig, null, 2) + "\n", "utf-8");
|
|
3629
|
+
console.log(" \x1B[32m\u2713\x1B[0m Auto-fixed: functions/tsconfig.json \u2192 CommonJS + node resolution");
|
|
3630
|
+
}
|
|
3631
|
+
}
|
|
3632
|
+
} catch {
|
|
3633
|
+
}
|
|
3634
|
+
}
|
|
3582
3635
|
// ─── Service Enable ────────────────────────────────────────────────
|
|
3583
3636
|
enableService(service) {
|
|
3584
3637
|
const firebaseJsonPath = (0, import_node_path4.resolve)(this.projectDir, "firebase.json");
|
|
@@ -5068,9 +5121,16 @@ ${liveReloadScript}
|
|
|
5068
5121
|
console.log(" \x1B[32m\u2713\x1B[0m Functions deployed");
|
|
5069
5122
|
steps.push("Functions deployed");
|
|
5070
5123
|
} else {
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5124
|
+
const errMsg = (funcResult.message || "").toLowerCase();
|
|
5125
|
+
const isBillingError = ["billing", "blaze", "pay-as-you-go", "upgrade your project", "budget"].some((kw) => errMsg.includes(kw));
|
|
5126
|
+
if (isBillingError) {
|
|
5127
|
+
blazeRequired = true;
|
|
5128
|
+
console.log(" \x1B[33m\u26A0\x1B[0m Functions deploy failed (Blaze plan required)");
|
|
5129
|
+
steps.push("Functions skipped (Blaze plan required)");
|
|
5130
|
+
} else {
|
|
5131
|
+
console.log(` \x1B[31m\u2717\x1B[0m Functions deploy failed: ${funcResult.message}`);
|
|
5132
|
+
steps.push(`Functions deploy failed: ${funcResult.message}`);
|
|
5133
|
+
}
|
|
5074
5134
|
}
|
|
5075
5135
|
}
|
|
5076
5136
|
clearFirebaseStatusCache();
|