clawfire 0.6.5 → 0.6.6
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-LCKIGM6U.js → dev-server-PQP33VSE.js} +96 -38
- package/dist/dev.cjs +96 -38
- package/dist/dev.cjs.map +1 -1
- package/dist/dev.js +96 -38
- package/dist/dev.js.map +1 -1
- package/package.json +1 -1
package/dist/dev.js
CHANGED
|
@@ -2230,8 +2230,9 @@ function generateDashboardHtml(options) {
|
|
|
2230
2230
|
}
|
|
2231
2231
|
|
|
2232
2232
|
btn.disabled = true;
|
|
2233
|
-
btn.textContent = 'Setting...';
|
|
2234
|
-
status.
|
|
2233
|
+
btn.textContent = 'Setting up...';
|
|
2234
|
+
status.textContent = 'Selecting project, detecting web app, auto-filling config...';
|
|
2235
|
+
status.style.cssText = 'display:block;margin-top:8px;font-size:13px;padding:8px 12px;border-radius:6px;background:#0a0a1c;border:1px solid #3b82f6;color:#93c5fd;';
|
|
2235
2236
|
|
|
2236
2237
|
fetch(API + '/__dev/setup/select-project', {
|
|
2237
2238
|
method: 'POST',
|
|
@@ -2241,8 +2242,11 @@ function generateDashboardHtml(options) {
|
|
|
2241
2242
|
.then(function(r) { return r.json(); })
|
|
2242
2243
|
.then(function(data) {
|
|
2243
2244
|
if (data.success) {
|
|
2244
|
-
|
|
2245
|
-
status.
|
|
2245
|
+
var msg = data.steps ? data.steps.join('\\n') : data.message;
|
|
2246
|
+
status.textContent = msg;
|
|
2247
|
+
status.style.whiteSpace = 'pre-line';
|
|
2248
|
+
status.style.cssText = 'display:block;margin-top:8px;font-size:13px;padding:8px 12px;border-radius:6px;background:#0a1a0a;border:1px solid #22c55e;color:#22c55e;white-space:pre-line;';
|
|
2249
|
+
btn.textContent = 'Done';
|
|
2246
2250
|
setTimeout(refreshSetupStatus, 1000);
|
|
2247
2251
|
} else {
|
|
2248
2252
|
status.textContent = data.message;
|
|
@@ -3493,41 +3497,48 @@ https://console.developers.google.com/apis/api/firestore.googleapis.com/overview
|
|
|
3493
3497
|
* Handles "ALREADY_EXISTS" gracefully — returns success.
|
|
3494
3498
|
*/
|
|
3495
3499
|
async createFirestoreDatabase(location = "nam5") {
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
)
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
if (msg.includes("ALREADY_EXISTS") || msg.includes("already exists")) {
|
|
3506
|
-
return { success: true, message: "Firestore database already exists." };
|
|
3507
|
-
}
|
|
3508
|
-
if (msg.includes("403") || msg.includes("has not been used") || msg.includes("is disabled")) {
|
|
3509
|
-
const enableResult = await this.enableFirestoreApi();
|
|
3510
|
-
if (!enableResult.success) {
|
|
3511
|
-
return enableResult;
|
|
3500
|
+
const dbArgs = ["firestore:databases:create", "(default)", "--location", location, "--json"];
|
|
3501
|
+
const tryCreate = async () => {
|
|
3502
|
+
try {
|
|
3503
|
+
await this.execTimeout("firebase", dbArgs, 6e4);
|
|
3504
|
+
return { ok: true, alreadyExists: false, needsApi: false, msg: "" };
|
|
3505
|
+
} catch (err) {
|
|
3506
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
3507
|
+
if (msg.includes("ALREADY_EXISTS") || msg.includes("already exists")) {
|
|
3508
|
+
return { ok: true, alreadyExists: true, needsApi: false, msg };
|
|
3512
3509
|
}
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
await this.execTimeout(
|
|
3516
|
-
"firebase",
|
|
3517
|
-
["firestore:databases:create", "(default)", "--location", location, "--json"],
|
|
3518
|
-
6e4
|
|
3519
|
-
);
|
|
3520
|
-
return { success: true, message: `Firestore API enabled and database created (location: ${location}).` };
|
|
3521
|
-
} catch (retryErr) {
|
|
3522
|
-
const retryMsg = retryErr instanceof Error ? retryErr.message : "Unknown error";
|
|
3523
|
-
if (retryMsg.includes("ALREADY_EXISTS") || retryMsg.includes("already exists")) {
|
|
3524
|
-
return { success: true, message: "Firestore database already exists." };
|
|
3525
|
-
}
|
|
3526
|
-
return { success: false, message: `Failed to create Firestore database after enabling API: ${retryMsg}` };
|
|
3510
|
+
if (msg.includes("403") || msg.includes("has not been used") || msg.includes("is disabled")) {
|
|
3511
|
+
return { ok: false, alreadyExists: false, needsApi: true, msg };
|
|
3527
3512
|
}
|
|
3513
|
+
return { ok: false, alreadyExists: false, needsApi: false, msg };
|
|
3514
|
+
}
|
|
3515
|
+
};
|
|
3516
|
+
const first = await tryCreate();
|
|
3517
|
+
if (first.ok) {
|
|
3518
|
+
return { success: true, message: first.alreadyExists ? "Firestore database already exists." : `Firestore database created (location: ${location}).` };
|
|
3519
|
+
}
|
|
3520
|
+
if (!first.needsApi) {
|
|
3521
|
+
return { success: false, message: `Failed to create Firestore database: ${first.msg}` };
|
|
3522
|
+
}
|
|
3523
|
+
const enableResult = await this.enableFirestoreApi();
|
|
3524
|
+
if (!enableResult.success) {
|
|
3525
|
+
return enableResult;
|
|
3526
|
+
}
|
|
3527
|
+
const waits = [5e3, 5e3, 1e4, 1e4, 15e3];
|
|
3528
|
+
for (let i = 0; i < waits.length; i++) {
|
|
3529
|
+
await new Promise((r) => setTimeout(r, waits[i]));
|
|
3530
|
+
const retry = await tryCreate();
|
|
3531
|
+
if (retry.ok) {
|
|
3532
|
+
return { success: true, message: `Firestore API enabled and database created (location: ${location}).` };
|
|
3533
|
+
}
|
|
3534
|
+
if (!retry.needsApi) {
|
|
3535
|
+
return { success: false, message: `Failed to create Firestore database: ${retry.msg}` };
|
|
3528
3536
|
}
|
|
3529
|
-
return { success: false, message: `Failed to create Firestore database: ${msg}` };
|
|
3530
3537
|
}
|
|
3538
|
+
return {
|
|
3539
|
+
success: false,
|
|
3540
|
+
message: "Firestore API was enabled but database creation timed out waiting for propagation. Please wait a minute and try again."
|
|
3541
|
+
};
|
|
3531
3542
|
}
|
|
3532
3543
|
/**
|
|
3533
3544
|
* Deploy open Firestore security rules for dev testing.
|
|
@@ -4547,10 +4558,57 @@ ${liveReloadScript}
|
|
|
4547
4558
|
sendJson({ success: false, message: "projectId is required" }, 400);
|
|
4548
4559
|
return;
|
|
4549
4560
|
}
|
|
4550
|
-
|
|
4561
|
+
(async () => {
|
|
4562
|
+
const selectResult = await this.firebaseSetup.selectProject(data.projectId);
|
|
4563
|
+
if (!selectResult.success) {
|
|
4564
|
+
sendJson(selectResult);
|
|
4565
|
+
return;
|
|
4566
|
+
}
|
|
4567
|
+
const steps = [selectResult.message];
|
|
4568
|
+
try {
|
|
4569
|
+
const { apps } = await this.firebaseSetup.listWebApps();
|
|
4570
|
+
let webAppId = "";
|
|
4571
|
+
if (apps.length > 0) {
|
|
4572
|
+
webAppId = apps[0].appId;
|
|
4573
|
+
this.firebaseSetup.selectWebApp(apps[0].appId, apps[0].displayName);
|
|
4574
|
+
steps.push(`Web app "${apps[0].displayName}" selected.`);
|
|
4575
|
+
} else {
|
|
4576
|
+
const createResult = await this.firebaseSetup.createWebApp(data.projectId);
|
|
4577
|
+
if (createResult.success && createResult.appId) {
|
|
4578
|
+
webAppId = createResult.appId;
|
|
4579
|
+
steps.push(`Web app "${data.projectId}" created.`);
|
|
4580
|
+
} else {
|
|
4581
|
+
steps.push(`Web app creation skipped: ${createResult.message}`);
|
|
4582
|
+
}
|
|
4583
|
+
}
|
|
4584
|
+
if (webAppId) {
|
|
4585
|
+
try {
|
|
4586
|
+
const sdkConfig = await fetchFirebaseSdkConfig(this.options.projectDir, webAppId);
|
|
4587
|
+
const fields = {};
|
|
4588
|
+
for (const [key, value] of Object.entries(sdkConfig)) {
|
|
4589
|
+
if (value && typeof value === "string") {
|
|
4590
|
+
fields[key] = value;
|
|
4591
|
+
}
|
|
4592
|
+
}
|
|
4593
|
+
if (Object.keys(fields).length > 0) {
|
|
4594
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
4595
|
+
try {
|
|
4596
|
+
this.updateProjectConfig(key, value);
|
|
4597
|
+
} catch {
|
|
4598
|
+
}
|
|
4599
|
+
}
|
|
4600
|
+
steps.push("Config auto-filled in clawfire.config.ts.");
|
|
4601
|
+
}
|
|
4602
|
+
} catch (configErr) {
|
|
4603
|
+
steps.push(`Config auto-fill skipped: ${configErr instanceof Error ? configErr.message : "unknown error"}`);
|
|
4604
|
+
}
|
|
4605
|
+
}
|
|
4606
|
+
} catch (autoFillErr) {
|
|
4607
|
+
steps.push(`Auto-setup partial: ${autoFillErr instanceof Error ? autoFillErr.message : "unknown error"}`);
|
|
4608
|
+
}
|
|
4551
4609
|
clearFirebaseStatusCache();
|
|
4552
|
-
sendJson(
|
|
4553
|
-
}).catch((err) => sendJson({ success: false, message: err instanceof Error ? err.message : "Failed" }, 500));
|
|
4610
|
+
sendJson({ success: true, message: steps.join(" "), steps });
|
|
4611
|
+
})().catch((err) => sendJson({ success: false, message: err instanceof Error ? err.message : "Failed" }, 500));
|
|
4554
4612
|
} catch {
|
|
4555
4613
|
sendJson({ success: false, message: "Invalid JSON body" }, 400);
|
|
4556
4614
|
}
|