forge-remote 0.1.6 → 0.1.8
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/package.json +1 -1
- package/src/init.js +42 -3
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { execSync, execFileSync } from "child_process";
|
|
6
6
|
import { createInterface } from "readline";
|
|
7
7
|
import { hostname, platform, homedir } from "os";
|
|
8
|
-
import { existsSync, mkdirSync, writeFileSync, readFileSync } from "fs";
|
|
8
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync, rmSync } from "fs";
|
|
9
9
|
import { join, dirname } from "path";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import { initializeApp, cert } from "firebase-admin/app";
|
|
@@ -440,6 +440,27 @@ export async function runInit({ projectId: overrideProjectId } = {}) {
|
|
|
440
440
|
sdkConfig = await getWebAppConfig(projectId, appId);
|
|
441
441
|
break; // Success — exit retry loop.
|
|
442
442
|
} catch (e) {
|
|
443
|
+
const errMsg = e.message || "";
|
|
444
|
+
|
|
445
|
+
// Detect deleted projects — no point retrying, bail immediately.
|
|
446
|
+
if (errMsg.includes("has been deleted") || errMsg.includes("DELETED")) {
|
|
447
|
+
// Clear stale cached config so next run starts fresh.
|
|
448
|
+
try {
|
|
449
|
+
rmSync(forgeDir, { recursive: true, force: true });
|
|
450
|
+
} catch {
|
|
451
|
+
// Best-effort cleanup.
|
|
452
|
+
}
|
|
453
|
+
throw new Error(
|
|
454
|
+
`Project "${projectId}" has been deleted and is pending permanent removal (30 days).\n\n` +
|
|
455
|
+
chalk.bold(
|
|
456
|
+
" The cached config has been cleared. Re-run with a new project ID:\n\n",
|
|
457
|
+
) +
|
|
458
|
+
chalk.cyan(
|
|
459
|
+
` forge-remote init --project-id forge-remote-${sanitizedHostname()}-2\n`,
|
|
460
|
+
),
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
443
464
|
if (attempt < maxSdkRetries) {
|
|
444
465
|
console.log(
|
|
445
466
|
chalk.yellow(
|
|
@@ -451,7 +472,7 @@ export async function runInit({ projectId: overrideProjectId } = {}) {
|
|
|
451
472
|
} else {
|
|
452
473
|
throw new Error(
|
|
453
474
|
`Could not retrieve SDK config after ${maxSdkRetries} attempts.\n` +
|
|
454
|
-
` Last error: ${
|
|
475
|
+
` Last error: ${errMsg}\n\n` +
|
|
455
476
|
chalk.bold(" Try these steps:\n\n") +
|
|
456
477
|
chalk.cyan(
|
|
457
478
|
` 1. Wait 30 seconds, then re-run: forge-remote init\n`,
|
|
@@ -527,7 +548,25 @@ export async function runInit({ projectId: overrideProjectId } = {}) {
|
|
|
527
548
|
|
|
528
549
|
console.log(chalk.bold("\n📋 Step 5/11 — Enabling Firestore...\n"));
|
|
529
550
|
|
|
530
|
-
//
|
|
551
|
+
// Enable the Firestore API first (required for new projects).
|
|
552
|
+
try {
|
|
553
|
+
console.log(
|
|
554
|
+
chalk.dim(" Enabling Firestore API (if not already enabled)..."),
|
|
555
|
+
);
|
|
556
|
+
await enableApi(projectId, "firestore.googleapis.com");
|
|
557
|
+
console.log(chalk.green(" ✓ Firestore API enabled"));
|
|
558
|
+
} catch (e) {
|
|
559
|
+
console.log(
|
|
560
|
+
chalk.yellow(` ⚠ Could not enable Firestore API: ${e.message}`),
|
|
561
|
+
);
|
|
562
|
+
console.log(
|
|
563
|
+
chalk.dim(
|
|
564
|
+
" Continuing — Firestore creation may still work if already enabled.",
|
|
565
|
+
),
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// Check if Firestore already exists by listing databases.
|
|
531
570
|
const existingDbs = run(
|
|
532
571
|
["firebase", "firestore:databases:list", "--project", projectId],
|
|
533
572
|
{ silent: true },
|