@mobilebytelabs/rconfig-cli 0.1.0 → 0.1.1
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 +24 -7
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/main.ts
|
|
4
4
|
import { chmodSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
5
|
-
import { homedir } from "node:os";
|
|
5
|
+
import { homedir as homedir2 } from "node:os";
|
|
6
6
|
import { join as join3 } from "node:path";
|
|
7
7
|
|
|
8
8
|
// ../mcp/src/firebase-import.ts
|
|
@@ -201,9 +201,11 @@ import { parseArgs } from "node:util";
|
|
|
201
201
|
// ../mcp/src/integrate-io.ts
|
|
202
202
|
import { mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
203
203
|
import { dirname, join as join2, relative } from "node:path";
|
|
204
|
+
import { execFileSync } from "node:child_process";
|
|
205
|
+
import { homedir } from "node:os";
|
|
204
206
|
|
|
205
207
|
// ../mcp/src/integrate.ts
|
|
206
|
-
var SDK_VERSION = "5.0.
|
|
208
|
+
var SDK_VERSION = "5.0.4";
|
|
207
209
|
var MAVEN = "io.github.mobilebytelabs";
|
|
208
210
|
var KTOR = "3.2.1";
|
|
209
211
|
var SAMPLE_KEY = "welcome_message";
|
|
@@ -680,12 +682,27 @@ var PLATFORMS = {
|
|
|
680
682
|
web: ["web"]
|
|
681
683
|
};
|
|
682
684
|
var fail = (r) => r && typeof r === "object" && "error" in r ? String(r.error) : null;
|
|
683
|
-
|
|
685
|
+
function debugFingerprint(keystore = join2(homedir(), ".android", "debug.keystore")) {
|
|
686
|
+
try {
|
|
687
|
+
const out = execFileSync(
|
|
688
|
+
"keytool",
|
|
689
|
+
["-list", "-v", "-keystore", keystore, "-storepass", "android", "-alias", "androiddebugkey"],
|
|
690
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }
|
|
691
|
+
);
|
|
692
|
+
return out.match(/SHA-?256:\s*([0-9A-F:]{95})/i)?.[1].toUpperCase() ?? null;
|
|
693
|
+
} catch {
|
|
694
|
+
return null;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
async function provisionWithToken(db, token, d, packageName, name, certDigests) {
|
|
684
698
|
const display = name ?? packageName.split(".").pop() ?? packageName;
|
|
685
699
|
const slug = display.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
686
700
|
let appId;
|
|
687
701
|
let key;
|
|
688
|
-
const
|
|
702
|
+
const platforms = PLATFORMS[d.type];
|
|
703
|
+
const debug = platforms.includes("android") && !certDigests?.length ? debugFingerprint() : null;
|
|
704
|
+
const cert_digests = certDigests?.length ? certDigests : debug ? [debug] : void 0;
|
|
705
|
+
const made = await onboardApp(db, token, { display_name: display, bundle_id: packageName, platforms, cert_digests });
|
|
689
706
|
const err = fail(made);
|
|
690
707
|
if (!err) {
|
|
691
708
|
const m = made;
|
|
@@ -725,7 +742,7 @@ async function integrateProject(o) {
|
|
|
725
742
|
if (!key) {
|
|
726
743
|
if (!o.token || !o.db) throw new Error("give a publishable key (rck_\u2026) or an access token (rcp_\u2026)");
|
|
727
744
|
if (o.dryRun) key = "rck_live_(issued on the real run)";
|
|
728
|
-
else ({ appId, key } = await provisionWithToken(o.db, o.token, d, packageName, o.name));
|
|
745
|
+
else ({ appId, key } = await provisionWithToken(o.db, o.token, d, packageName, o.name, o.certDigests));
|
|
729
746
|
}
|
|
730
747
|
if (!/^rck_/.test(key)) throw new Error("the key must be a publishable key (rck_\u2026)");
|
|
731
748
|
const plan = planIntegration(files, d, { key, packageName, appVersion: o.appVersion });
|
|
@@ -1062,7 +1079,7 @@ ${USAGE}`);
|
|
|
1062
1079
|
|
|
1063
1080
|
// src/main.ts
|
|
1064
1081
|
var URL_ = process.env.RCONFIG_URL ?? "https://gohifhjcvsawcdhcpbkw.supabase.co/functions/v1";
|
|
1065
|
-
var CREDENTIALS = join3(
|
|
1082
|
+
var CREDENTIALS = join3(homedir2(), ".config", "rconfig", "credentials");
|
|
1066
1083
|
function storedToken() {
|
|
1067
1084
|
try {
|
|
1068
1085
|
return readFileSync2(CREDENTIALS, "utf8").trim() || void 0;
|
|
@@ -1104,7 +1121,7 @@ async function login() {
|
|
|
1104
1121
|
process.stderr.write(/^rck_/.test(token) ? "that is a publishable key (rck_\u2026), which is PUBLIC and belongs in your app's source. Use an rcp_ access token.\n" : "that is not an rcp_ access token.\n");
|
|
1105
1122
|
return 2;
|
|
1106
1123
|
}
|
|
1107
|
-
mkdirSync2(join3(
|
|
1124
|
+
mkdirSync2(join3(homedir2(), ".config", "rconfig"), { recursive: true, mode: 448 });
|
|
1108
1125
|
writeFileSync2(CREDENTIALS, token + "\n", { mode: 384 });
|
|
1109
1126
|
chmodSync(CREDENTIALS, 384);
|
|
1110
1127
|
process.stderr.write(`saved to ${CREDENTIALS} (0600)
|
package/package.json
CHANGED