clawfire 0.6.17 → 0.6.19
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-6PFNZWAZ.js → dev-server-MLT3ZO5A.js} +69 -30
- package/dist/dev.cjs +68 -29
- package/dist/dev.cjs.map +1 -1
- package/dist/dev.js +69 -30
- package/dist/dev.js.map +1 -1
- package/package.json +1 -1
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 {
|
|
@@ -3389,40 +3389,41 @@ var FirebaseSetup = class {
|
|
|
3389
3389
|
return { success: false, message: "Invalid firebase.json." };
|
|
3390
3390
|
}
|
|
3391
3391
|
const timeoutMs = targets.includes("functions") ? 3e5 : 12e4;
|
|
3392
|
+
const args = ["deploy", "--only", targets, "--json"];
|
|
3393
|
+
if (targets.includes("functions")) args.push("--force");
|
|
3392
3394
|
try {
|
|
3393
|
-
const output = await this.execTimeout(
|
|
3394
|
-
|
|
3395
|
-
["deploy", "--only", targets, "--json"],
|
|
3396
|
-
timeoutMs
|
|
3397
|
-
);
|
|
3398
|
-
let url = "";
|
|
3399
|
-
try {
|
|
3400
|
-
const data = JSON.parse(output);
|
|
3401
|
-
if (data?.result) {
|
|
3402
|
-
for (const key of Object.keys(data.result)) {
|
|
3403
|
-
if (key.startsWith("hosting") && typeof data.result[key] === "object") {
|
|
3404
|
-
url = data.result[key]?.url || data.result[key]?.site?.url || "";
|
|
3405
|
-
if (url) break;
|
|
3406
|
-
}
|
|
3407
|
-
}
|
|
3408
|
-
}
|
|
3409
|
-
} catch {
|
|
3410
|
-
const urlMatch = output.match(/https:\/\/[a-z0-9-]+\.web\.app/i);
|
|
3411
|
-
if (urlMatch) url = urlMatch[0];
|
|
3412
|
-
}
|
|
3413
|
-
if (!url) {
|
|
3414
|
-
const state = this.loadState();
|
|
3415
|
-
if (state.projectId) {
|
|
3416
|
-
url = `https://${state.projectId}.web.app`;
|
|
3417
|
-
}
|
|
3418
|
-
}
|
|
3419
|
-
const label = targets.includes("functions") ? "Hosting + Functions" : "Hosting";
|
|
3420
|
-
return { success: true, url: url || void 0, message: `${label} deployed successfully!` };
|
|
3395
|
+
const output = await this.execTimeout("firebase", args, timeoutMs);
|
|
3396
|
+
return { success: true, url: this.extractDeployUrl(output), message: `${targets.includes("functions") ? "Functions" : "Hosting"} deployed successfully!` };
|
|
3421
3397
|
} catch (err) {
|
|
3422
3398
|
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
3399
|
+
if (msg.includes("successfully deployed") || msg.includes("Successful create operation") || msg.includes("Successful update operation")) {
|
|
3400
|
+
return { success: true, url: this.extractDeployUrl(msg), message: `${targets.includes("functions") ? "Functions" : "Hosting"} deployed successfully!` };
|
|
3401
|
+
}
|
|
3423
3402
|
return { success: false, message: `Deploy failed: ${msg}` };
|
|
3424
3403
|
}
|
|
3425
3404
|
}
|
|
3405
|
+
/** Extract hosting URL from deploy output */
|
|
3406
|
+
extractDeployUrl(output) {
|
|
3407
|
+
try {
|
|
3408
|
+
const data = JSON.parse(output);
|
|
3409
|
+
if (data?.result) {
|
|
3410
|
+
for (const key of Object.keys(data.result)) {
|
|
3411
|
+
if (key.startsWith("hosting") && typeof data.result[key] === "object") {
|
|
3412
|
+
const url = data.result[key]?.url || data.result[key]?.site?.url || "";
|
|
3413
|
+
if (url) return url;
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
} catch {
|
|
3418
|
+
const urlMatch = output.match(/https:\/\/[a-z0-9-]+\.web\.app/i);
|
|
3419
|
+
if (urlMatch) return urlMatch[0];
|
|
3420
|
+
}
|
|
3421
|
+
const state = this.loadState();
|
|
3422
|
+
if (state.projectId) {
|
|
3423
|
+
return `https://${state.projectId}.web.app`;
|
|
3424
|
+
}
|
|
3425
|
+
return void 0;
|
|
3426
|
+
}
|
|
3426
3427
|
// ─── Full Deploy Pipeline ────────────────────────────────────────────
|
|
3427
3428
|
/**
|
|
3428
3429
|
* Sync environment variables to functions/.env for production.
|
|
@@ -3533,6 +3534,14 @@ var FirebaseSetup = class {
|
|
|
3533
3534
|
return { success: false, message: "functions/package.json not found." };
|
|
3534
3535
|
}
|
|
3535
3536
|
this.ensureFunctionsCJS(functionsDir);
|
|
3537
|
+
const distDir = resolve5(functionsDir, "dist");
|
|
3538
|
+
if (existsSync6(distDir)) {
|
|
3539
|
+
try {
|
|
3540
|
+
rmSync(distDir, { recursive: true, force: true });
|
|
3541
|
+
console.log(" \x1B[32m\u2713\x1B[0m Cleaned functions/dist/");
|
|
3542
|
+
} catch {
|
|
3543
|
+
}
|
|
3544
|
+
}
|
|
3536
3545
|
try {
|
|
3537
3546
|
await this.execTimeout("npm", ["install"], 12e4, functionsDir);
|
|
3538
3547
|
} catch (err) {
|
|
@@ -3549,11 +3558,41 @@ var FirebaseSetup = class {
|
|
|
3549
3558
|
await this.execTimeout("npx", ["tsc"], 6e4, functionsDir);
|
|
3550
3559
|
}
|
|
3551
3560
|
}
|
|
3552
|
-
return { success: true, message: "Functions built successfully." };
|
|
3553
3561
|
} catch (err) {
|
|
3554
3562
|
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
3555
3563
|
return { success: false, message: `Functions build failed: ${msg}` };
|
|
3556
3564
|
}
|
|
3565
|
+
const mainEntry = resolve5(functionsDir, "dist/index.js");
|
|
3566
|
+
if (!existsSync6(mainEntry)) {
|
|
3567
|
+
return { success: false, message: "Build produced no output (dist/index.js not found)." };
|
|
3568
|
+
}
|
|
3569
|
+
try {
|
|
3570
|
+
const firstLine = readFileSync4(mainEntry, "utf-8").split("\n")[0];
|
|
3571
|
+
const isESM = firstLine.startsWith("import ") || firstLine.startsWith("export ");
|
|
3572
|
+
if (isESM) {
|
|
3573
|
+
console.log(" \x1B[33m\u26A0\x1B[0m Warning: dist/index.js appears to be ESM, not CJS");
|
|
3574
|
+
} else {
|
|
3575
|
+
console.log(" \x1B[32m\u2713\x1B[0m Build output verified (CJS)");
|
|
3576
|
+
}
|
|
3577
|
+
} catch {
|
|
3578
|
+
}
|
|
3579
|
+
try {
|
|
3580
|
+
const verifyScript = [
|
|
3581
|
+
'process.env.FIREBASE_CONFIG=JSON.stringify({projectId:"verify"});',
|
|
3582
|
+
'process.env.GCLOUD_PROJECT="verify";',
|
|
3583
|
+
'try{require("./dist/index.js");console.log("OK")}',
|
|
3584
|
+
'catch(e){console.error("LOAD_ERROR:"+e.message);process.exit(1)}'
|
|
3585
|
+
].join("");
|
|
3586
|
+
await this.execTimeout("node", ["-e", verifyScript], 15e3, functionsDir);
|
|
3587
|
+
console.log(" \x1B[32m\u2713\x1B[0m Module load verification passed");
|
|
3588
|
+
} catch (verifyErr) {
|
|
3589
|
+
const msg = verifyErr instanceof Error ? verifyErr.message : "Unknown";
|
|
3590
|
+
const match = msg.match(/LOAD_ERROR:(.+?)(\n|$)/);
|
|
3591
|
+
const detail = match ? match[1].trim() : msg.substring(0, 300);
|
|
3592
|
+
console.log(` \x1B[31m\u2717\x1B[0m Module load failed: ${detail}`);
|
|
3593
|
+
return { success: false, message: `Functions built but failed to load: ${detail}` };
|
|
3594
|
+
}
|
|
3595
|
+
return { success: true, message: "Functions built successfully." };
|
|
3557
3596
|
}
|
|
3558
3597
|
/**
|
|
3559
3598
|
* Ensure functions/ uses CommonJS for Firebase Functions compatibility.
|