clawfire 0.4.3 → 0.4.4
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-PAI4XU2S.js → dev-server-XLMLGSQP.js} +83 -27
- package/dist/dev.cjs +83 -27
- package/dist/dev.cjs.map +1 -1
- package/dist/dev.js +83 -27
- package/dist/dev.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -209,7 +209,7 @@ async function runDevServer() {
|
|
|
209
209
|
const port = portArg ? parseInt(portArg.split("=")[1], 10) : 3e3;
|
|
210
210
|
const apiPort = apiPortArg ? parseInt(apiPortArg.split("=")[1], 10) : 3456;
|
|
211
211
|
const noHotReload = args.includes("--no-hot-reload");
|
|
212
|
-
const { startDevServer } = await import("./dev-server-
|
|
212
|
+
const { startDevServer } = await import("./dev-server-XLMLGSQP.js");
|
|
213
213
|
await startDevServer({
|
|
214
214
|
projectDir,
|
|
215
215
|
port,
|
|
@@ -1083,38 +1083,89 @@ async function checkCli(projectDir) {
|
|
|
1083
1083
|
return result;
|
|
1084
1084
|
}
|
|
1085
1085
|
async function fetchFirebaseSdkConfig(projectDir) {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
return
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1086
|
+
try {
|
|
1087
|
+
const output = await execWithTimeout(
|
|
1088
|
+
"firebase",
|
|
1089
|
+
["apps:sdkconfig", "web", "--json"],
|
|
1090
|
+
projectDir,
|
|
1091
|
+
15e3
|
|
1092
|
+
);
|
|
1093
|
+
const config = parseSdkConfigOutput(output);
|
|
1094
|
+
if (config) return config;
|
|
1095
|
+
} catch {
|
|
1096
|
+
}
|
|
1097
|
+
let webApps = [];
|
|
1098
|
+
try {
|
|
1099
|
+
const appsOutput = await execWithTimeout(
|
|
1100
|
+
"firebase",
|
|
1101
|
+
["apps:list", "--json"],
|
|
1102
|
+
projectDir,
|
|
1103
|
+
15e3
|
|
1104
|
+
);
|
|
1105
|
+
const appsData = JSON.parse(appsOutput);
|
|
1106
|
+
const allApps = appsData?.result || [];
|
|
1107
|
+
webApps = allApps.filter((a) => a.platform === "WEB").map((a) => ({
|
|
1108
|
+
appId: String(a.appId || ""),
|
|
1109
|
+
displayName: String(a.displayName || "")
|
|
1110
|
+
})).filter((a) => a.appId);
|
|
1111
|
+
} catch {
|
|
1112
|
+
throw new Error(
|
|
1113
|
+
"Failed to fetch Firebase SDK config. Make sure you are logged in and have an active project selected."
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
if (webApps.length === 0) {
|
|
1117
|
+
throw new Error(
|
|
1118
|
+
"No web app registered in this Firebase project. Go to Firebase Console > Project Settings > General > Your apps > Add app (Web) to create one, then click Auto-fill again."
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
const appId = webApps[0].appId;
|
|
1122
|
+
try {
|
|
1123
|
+
const output = await execWithTimeout(
|
|
1124
|
+
"firebase",
|
|
1125
|
+
["apps:sdkconfig", "web", appId, "--json"],
|
|
1126
|
+
projectDir,
|
|
1127
|
+
15e3
|
|
1128
|
+
);
|
|
1129
|
+
const config = parseSdkConfigOutput(output);
|
|
1130
|
+
if (config) return config;
|
|
1131
|
+
} catch (err) {
|
|
1132
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
1133
|
+
throw new Error(`Failed to fetch config for web app ${appId}: ${msg}`);
|
|
1110
1134
|
}
|
|
1111
1135
|
throw new Error("Could not parse Firebase SDK config from CLI output");
|
|
1112
1136
|
}
|
|
1137
|
+
function parseSdkConfigOutput(output) {
|
|
1138
|
+
try {
|
|
1139
|
+
const data = JSON.parse(output);
|
|
1140
|
+
if (data?.result?.sdkConfig) {
|
|
1141
|
+
return data.result.sdkConfig;
|
|
1142
|
+
}
|
|
1143
|
+
if (data?.result?.fileContents) {
|
|
1144
|
+
const contents = data.result.fileContents;
|
|
1145
|
+
const config = {};
|
|
1146
|
+
const extract = (key) => {
|
|
1147
|
+
const match = contents.match(new RegExp(`"${key}"\\s*:\\s*"([^"]+)"`));
|
|
1148
|
+
return match ? match[1] : void 0;
|
|
1149
|
+
};
|
|
1150
|
+
config.apiKey = extract("apiKey");
|
|
1151
|
+
config.authDomain = extract("authDomain");
|
|
1152
|
+
config.projectId = extract("projectId");
|
|
1153
|
+
config.storageBucket = extract("storageBucket");
|
|
1154
|
+
config.messagingSenderId = extract("messagingSenderId");
|
|
1155
|
+
config.appId = extract("appId");
|
|
1156
|
+
if (config.apiKey || config.projectId) return config;
|
|
1157
|
+
}
|
|
1158
|
+
} catch {
|
|
1159
|
+
}
|
|
1160
|
+
return null;
|
|
1161
|
+
}
|
|
1113
1162
|
function execWithTimeout(command, args, cwd, timeoutMs) {
|
|
1114
1163
|
return new Promise((resolve6, reject) => {
|
|
1115
|
-
const proc = execFile(command, args, { cwd, timeout: timeoutMs }, (err, stdout) => {
|
|
1164
|
+
const proc = execFile(command, args, { cwd, timeout: timeoutMs }, (err, stdout, stderr) => {
|
|
1116
1165
|
if (err) {
|
|
1117
|
-
|
|
1166
|
+
const detail = stderr?.trim() || stdout?.trim() || "";
|
|
1167
|
+
const enriched = new Error(`${err.message}${detail ? "\n" + detail : ""}`);
|
|
1168
|
+
reject(enriched);
|
|
1118
1169
|
} else {
|
|
1119
1170
|
resolve6(stdout);
|
|
1120
1171
|
}
|
|
@@ -1863,7 +1914,12 @@ function generateDashboardHtml(options) {
|
|
|
1863
1914
|
if (wizStatus) wizStatus.style.display = 'none';
|
|
1864
1915
|
|
|
1865
1916
|
fetch(API + '/__dev/firebase-sdk-config')
|
|
1866
|
-
.then(function(r) {
|
|
1917
|
+
.then(function(r) {
|
|
1918
|
+
if (!r.ok) {
|
|
1919
|
+
return r.json().catch(function() { return { error: 'Server error (' + r.status + ')' }; });
|
|
1920
|
+
}
|
|
1921
|
+
return r.json();
|
|
1922
|
+
})
|
|
1867
1923
|
.then(function(data) {
|
|
1868
1924
|
if (data.error) {
|
|
1869
1925
|
showAutoFillResult(false, data.error);
|
package/dist/dev.cjs
CHANGED
|
@@ -1495,38 +1495,89 @@ async function checkCli(projectDir) {
|
|
|
1495
1495
|
return result;
|
|
1496
1496
|
}
|
|
1497
1497
|
async function fetchFirebaseSdkConfig(projectDir) {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
return
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1498
|
+
try {
|
|
1499
|
+
const output = await execWithTimeout(
|
|
1500
|
+
"firebase",
|
|
1501
|
+
["apps:sdkconfig", "web", "--json"],
|
|
1502
|
+
projectDir,
|
|
1503
|
+
15e3
|
|
1504
|
+
);
|
|
1505
|
+
const config = parseSdkConfigOutput(output);
|
|
1506
|
+
if (config) return config;
|
|
1507
|
+
} catch {
|
|
1508
|
+
}
|
|
1509
|
+
let webApps = [];
|
|
1510
|
+
try {
|
|
1511
|
+
const appsOutput = await execWithTimeout(
|
|
1512
|
+
"firebase",
|
|
1513
|
+
["apps:list", "--json"],
|
|
1514
|
+
projectDir,
|
|
1515
|
+
15e3
|
|
1516
|
+
);
|
|
1517
|
+
const appsData = JSON.parse(appsOutput);
|
|
1518
|
+
const allApps = appsData?.result || [];
|
|
1519
|
+
webApps = allApps.filter((a) => a.platform === "WEB").map((a) => ({
|
|
1520
|
+
appId: String(a.appId || ""),
|
|
1521
|
+
displayName: String(a.displayName || "")
|
|
1522
|
+
})).filter((a) => a.appId);
|
|
1523
|
+
} catch {
|
|
1524
|
+
throw new Error(
|
|
1525
|
+
"Failed to fetch Firebase SDK config. Make sure you are logged in and have an active project selected."
|
|
1526
|
+
);
|
|
1527
|
+
}
|
|
1528
|
+
if (webApps.length === 0) {
|
|
1529
|
+
throw new Error(
|
|
1530
|
+
"No web app registered in this Firebase project. Go to Firebase Console > Project Settings > General > Your apps > Add app (Web) to create one, then click Auto-fill again."
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
const appId = webApps[0].appId;
|
|
1534
|
+
try {
|
|
1535
|
+
const output = await execWithTimeout(
|
|
1536
|
+
"firebase",
|
|
1537
|
+
["apps:sdkconfig", "web", appId, "--json"],
|
|
1538
|
+
projectDir,
|
|
1539
|
+
15e3
|
|
1540
|
+
);
|
|
1541
|
+
const config = parseSdkConfigOutput(output);
|
|
1542
|
+
if (config) return config;
|
|
1543
|
+
} catch (err) {
|
|
1544
|
+
const msg = err instanceof Error ? err.message : "Unknown error";
|
|
1545
|
+
throw new Error(`Failed to fetch config for web app ${appId}: ${msg}`);
|
|
1522
1546
|
}
|
|
1523
1547
|
throw new Error("Could not parse Firebase SDK config from CLI output");
|
|
1524
1548
|
}
|
|
1549
|
+
function parseSdkConfigOutput(output) {
|
|
1550
|
+
try {
|
|
1551
|
+
const data = JSON.parse(output);
|
|
1552
|
+
if (data?.result?.sdkConfig) {
|
|
1553
|
+
return data.result.sdkConfig;
|
|
1554
|
+
}
|
|
1555
|
+
if (data?.result?.fileContents) {
|
|
1556
|
+
const contents = data.result.fileContents;
|
|
1557
|
+
const config = {};
|
|
1558
|
+
const extract = (key) => {
|
|
1559
|
+
const match = contents.match(new RegExp(`"${key}"\\s*:\\s*"([^"]+)"`));
|
|
1560
|
+
return match ? match[1] : void 0;
|
|
1561
|
+
};
|
|
1562
|
+
config.apiKey = extract("apiKey");
|
|
1563
|
+
config.authDomain = extract("authDomain");
|
|
1564
|
+
config.projectId = extract("projectId");
|
|
1565
|
+
config.storageBucket = extract("storageBucket");
|
|
1566
|
+
config.messagingSenderId = extract("messagingSenderId");
|
|
1567
|
+
config.appId = extract("appId");
|
|
1568
|
+
if (config.apiKey || config.projectId) return config;
|
|
1569
|
+
}
|
|
1570
|
+
} catch {
|
|
1571
|
+
}
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1525
1574
|
function execWithTimeout(command, args, cwd, timeoutMs) {
|
|
1526
1575
|
return new Promise((resolve7, reject) => {
|
|
1527
|
-
const proc = (0, import_node_child_process.execFile)(command, args, { cwd, timeout: timeoutMs }, (err, stdout) => {
|
|
1576
|
+
const proc = (0, import_node_child_process.execFile)(command, args, { cwd, timeout: timeoutMs }, (err, stdout, stderr) => {
|
|
1528
1577
|
if (err) {
|
|
1529
|
-
|
|
1578
|
+
const detail = stderr?.trim() || stdout?.trim() || "";
|
|
1579
|
+
const enriched = new Error(`${err.message}${detail ? "\n" + detail : ""}`);
|
|
1580
|
+
reject(enriched);
|
|
1530
1581
|
} else {
|
|
1531
1582
|
resolve7(stdout);
|
|
1532
1583
|
}
|
|
@@ -2275,7 +2326,12 @@ function generateDashboardHtml(options) {
|
|
|
2275
2326
|
if (wizStatus) wizStatus.style.display = 'none';
|
|
2276
2327
|
|
|
2277
2328
|
fetch(API + '/__dev/firebase-sdk-config')
|
|
2278
|
-
.then(function(r) {
|
|
2329
|
+
.then(function(r) {
|
|
2330
|
+
if (!r.ok) {
|
|
2331
|
+
return r.json().catch(function() { return { error: 'Server error (' + r.status + ')' }; });
|
|
2332
|
+
}
|
|
2333
|
+
return r.json();
|
|
2334
|
+
})
|
|
2279
2335
|
.then(function(data) {
|
|
2280
2336
|
if (data.error) {
|
|
2281
2337
|
showAutoFillResult(false, data.error);
|