clawfire 0.6.16 → 0.6.18
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-FYHT3WN5.js → dev-server-54RXFRNZ.js} +80 -2
- package/dist/dev.cjs +79 -1
- package/dist/dev.cjs.map +1 -1
- package/dist/dev.js +80 -2
- package/dist/dev.js.map +1 -1
- package/package.json +1 -1
- package/templates/starter/functions/package.json +0 -1
- package/templates/starter/functions/tsconfig.json +2 -2
package/dist/dev.js
CHANGED
|
@@ -3056,7 +3056,7 @@ function generateDashboardHtml(options) {
|
|
|
3056
3056
|
|
|
3057
3057
|
// src/dev/firebase-setup.ts
|
|
3058
3058
|
import { execFile as execFile2, spawn } from "child_process";
|
|
3059
|
-
import { existsSync as existsSync6, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
3059
|
+
import { existsSync as existsSync6, readFileSync as readFileSync4, writeFileSync as writeFileSync3, rmSync } from "fs";
|
|
3060
3060
|
import { resolve as resolve5, join as join4 } from "path";
|
|
3061
3061
|
import { tmpdir, platform, homedir } from "os";
|
|
3062
3062
|
var FirebaseSetup = class {
|
|
@@ -3532,6 +3532,15 @@ var FirebaseSetup = class {
|
|
|
3532
3532
|
if (!existsSync6(pkgPath)) {
|
|
3533
3533
|
return { success: false, message: "functions/package.json not found." };
|
|
3534
3534
|
}
|
|
3535
|
+
this.ensureFunctionsCJS(functionsDir);
|
|
3536
|
+
const distDir = resolve5(functionsDir, "dist");
|
|
3537
|
+
if (existsSync6(distDir)) {
|
|
3538
|
+
try {
|
|
3539
|
+
rmSync(distDir, { recursive: true, force: true });
|
|
3540
|
+
console.log(" \x1B[32m\u2713\x1B[0m Cleaned functions/dist/");
|
|
3541
|
+
} catch {
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3535
3544
|
try {
|
|
3536
3545
|
await this.execTimeout("npm", ["install"], 12e4, functionsDir);
|
|
3537
3546
|
} catch (err) {
|
|
@@ -3548,11 +3557,80 @@ var FirebaseSetup = class {
|
|
|
3548
3557
|
await this.execTimeout("npx", ["tsc"], 6e4, functionsDir);
|
|
3549
3558
|
}
|
|
3550
3559
|
}
|
|
3551
|
-
return { success: true, message: "Functions built successfully." };
|
|
3552
3560
|
} catch (err) {
|
|
3553
3561
|
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
3554
3562
|
return { success: false, message: `Functions build failed: ${msg}` };
|
|
3555
3563
|
}
|
|
3564
|
+
const mainEntry = resolve5(functionsDir, "dist/index.js");
|
|
3565
|
+
if (!existsSync6(mainEntry)) {
|
|
3566
|
+
return { success: false, message: "Build produced no output (dist/index.js not found)." };
|
|
3567
|
+
}
|
|
3568
|
+
try {
|
|
3569
|
+
const firstLine = readFileSync4(mainEntry, "utf-8").split("\n")[0];
|
|
3570
|
+
const isESM = firstLine.startsWith("import ") || firstLine.startsWith("export ");
|
|
3571
|
+
if (isESM) {
|
|
3572
|
+
console.log(" \x1B[33m\u26A0\x1B[0m Warning: dist/index.js appears to be ESM, not CJS");
|
|
3573
|
+
} else {
|
|
3574
|
+
console.log(" \x1B[32m\u2713\x1B[0m Build output verified (CJS)");
|
|
3575
|
+
}
|
|
3576
|
+
} catch {
|
|
3577
|
+
}
|
|
3578
|
+
try {
|
|
3579
|
+
const verifyScript = [
|
|
3580
|
+
'process.env.FIREBASE_CONFIG=JSON.stringify({projectId:"verify"});',
|
|
3581
|
+
'process.env.GCLOUD_PROJECT="verify";',
|
|
3582
|
+
'try{require("./dist/index.js");console.log("OK")}',
|
|
3583
|
+
'catch(e){console.error("LOAD_ERROR:"+e.message);process.exit(1)}'
|
|
3584
|
+
].join("");
|
|
3585
|
+
await this.execTimeout("node", ["-e", verifyScript], 15e3, functionsDir);
|
|
3586
|
+
console.log(" \x1B[32m\u2713\x1B[0m Module load verification passed");
|
|
3587
|
+
} catch (verifyErr) {
|
|
3588
|
+
const msg = verifyErr instanceof Error ? verifyErr.message : "Unknown";
|
|
3589
|
+
const match = msg.match(/LOAD_ERROR:(.+?)(\n|$)/);
|
|
3590
|
+
const detail = match ? match[1].trim() : msg.substring(0, 300);
|
|
3591
|
+
console.log(` \x1B[31m\u2717\x1B[0m Module load failed: ${detail}`);
|
|
3592
|
+
return { success: false, message: `Functions built but failed to load: ${detail}` };
|
|
3593
|
+
}
|
|
3594
|
+
return { success: true, message: "Functions built successfully." };
|
|
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 = resolve5(functionsDir, "package.json");
|
|
3602
|
+
try {
|
|
3603
|
+
const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
|
|
3604
|
+
if (pkg.type === "module") {
|
|
3605
|
+
delete pkg.type;
|
|
3606
|
+
writeFileSync3(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 = resolve5(functionsDir, "tsconfig.json");
|
|
3612
|
+
try {
|
|
3613
|
+
if (existsSync6(tsconfigPath)) {
|
|
3614
|
+
let content = readFileSync4(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
|
+
writeFileSync3(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
|
+
}
|
|
3556
3634
|
}
|
|
3557
3635
|
// ─── Service Enable ────────────────────────────────────────────────
|
|
3558
3636
|
enableService(service) {
|