@renbostudios/edge-ota 0.2.9 → 0.3.0
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/index.js +28 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -146,7 +146,7 @@ const spin = (() => {
|
|
|
146
146
|
};
|
|
147
147
|
})();
|
|
148
148
|
// ─── Package version ─────────────────────────────────────────────────────────
|
|
149
|
-
let packageVersion = "0.
|
|
149
|
+
let packageVersion = "0.3.0";
|
|
150
150
|
try {
|
|
151
151
|
const pkgPath = path.join(__dirname, "..", "package.json");
|
|
152
152
|
if (fs.existsSync(pkgPath)) {
|
|
@@ -163,6 +163,8 @@ function printBanner() {
|
|
|
163
163
|
console.log(` ${c.dim}renbostudios.com${c.reset}`);
|
|
164
164
|
console.log(`${sep}\n`);
|
|
165
165
|
}
|
|
166
|
+
// ─── app.json helpers ────────────────────────────────────────────────────────
|
|
167
|
+
const DEFAULT_SERVER = "https://api.ota.renbo.site";
|
|
166
168
|
function readAppJson(cwd) {
|
|
167
169
|
const appJsonPath = path.resolve(cwd, "app.json");
|
|
168
170
|
if (!fs.existsSync(appJsonPath)) {
|
|
@@ -193,7 +195,7 @@ function readAppJson(cwd) {
|
|
|
193
195
|
console.error(` Run ${c.cyan}edge-ota init${c.reset} to set this up.\n`);
|
|
194
196
|
process.exit(1);
|
|
195
197
|
}
|
|
196
|
-
// Parse serverUrl and projectId from the updates URL
|
|
198
|
+
// Parse serverUrl and projectId from the updates URL.
|
|
197
199
|
// Expected format: https://<host>/api/projects/<uuid>/updates
|
|
198
200
|
// or: https://<host>/api/updates
|
|
199
201
|
let serverUrl;
|
|
@@ -213,7 +215,14 @@ function readAppJson(cwd) {
|
|
|
213
215
|
console.error(` ${c.red}✗${c.reset} Could not parse ${c.dim}expo.updates.url${c.reset} in app.json`);
|
|
214
216
|
process.exit(1);
|
|
215
217
|
}
|
|
216
|
-
|
|
218
|
+
// ── Project-level server override ──
|
|
219
|
+
// expo.extra.edgeOtaServer lets users point a specific project at a
|
|
220
|
+
// different (self-hosted) EdgeOTA instance without re-logging in.
|
|
221
|
+
const projectServer = expo?.extra?.edgeOtaServer;
|
|
222
|
+
if (projectServer) {
|
|
223
|
+
serverUrl = projectServer.replace(/\/$/, "");
|
|
224
|
+
}
|
|
225
|
+
return { serverUrl, projectId, runtimeVersion, publicKey: expo?.extra?.edgeOtaPublicKey };
|
|
217
226
|
}
|
|
218
227
|
function updateAppJson(cwd, serverUrl, projectId, publicKey) {
|
|
219
228
|
const appJsonPath = path.resolve(cwd, "app.json");
|
|
@@ -225,6 +234,8 @@ function updateAppJson(cwd, serverUrl, projectId, publicKey) {
|
|
|
225
234
|
data.expo = {};
|
|
226
235
|
if (!data.expo.updates)
|
|
227
236
|
data.expo.updates = {};
|
|
237
|
+
if (!data.expo.extra)
|
|
238
|
+
data.expo.extra = {};
|
|
228
239
|
const cleanUrl = serverUrl.replace(/\/$/, "");
|
|
229
240
|
data.expo.updates.url = projectId
|
|
230
241
|
? `${cleanUrl}/api/projects/${projectId}/updates`
|
|
@@ -232,13 +243,15 @@ function updateAppJson(cwd, serverUrl, projectId, publicKey) {
|
|
|
232
243
|
data.expo.updates.checkAutomatically = data.expo.updates.checkAutomatically ?? "ON_LOAD";
|
|
233
244
|
data.expo.updates.fallbackToCacheTimeout = data.expo.updates.fallbackToCacheTimeout ?? 30000;
|
|
234
245
|
data.expo.updates.requestHeaders = data.expo.updates.requestHeaders ?? { "expo-channel-name": "production" };
|
|
246
|
+
// Store the server URL in expo.extra.edgeOtaServer so users can easily
|
|
247
|
+
// override which EdgeOTA instance this project points to without re-running
|
|
248
|
+
// `edge-ota login`. They can edit this value directly in app.json.
|
|
249
|
+
data.expo.extra.edgeOtaServer = cleanUrl;
|
|
235
250
|
if (publicKey) {
|
|
236
|
-
data.expo.updates.codeSigningCertificate = undefined; // clear legacy
|
|
237
|
-
data.expo.extra = data.expo.extra ?? {};
|
|
238
251
|
data.expo.extra.edgeOtaPublicKey = publicKey;
|
|
239
252
|
}
|
|
240
253
|
fs.writeFileSync(appJsonPath, JSON.stringify(data, null, 2) + "\n", "utf-8");
|
|
241
|
-
console.log(` ${c.dim}app.json${c.reset} updated ${c.dim}expo.updates.url${c.reset}`);
|
|
254
|
+
console.log(` ${c.dim}app.json${c.reset} updated ${c.dim}expo.updates.url${c.reset} + ${c.dim}expo.extra.edgeOtaServer${c.reset}`);
|
|
242
255
|
}
|
|
243
256
|
catch (e) {
|
|
244
257
|
console.error(` ${c.yellow}⚠${c.reset} Could not update app.json: ${e.message}`);
|
|
@@ -462,11 +475,16 @@ program.action(() => {
|
|
|
462
475
|
program
|
|
463
476
|
.command("login")
|
|
464
477
|
.description("Authenticate with your EdgeOTA account")
|
|
465
|
-
.option("-s, --server <url>",
|
|
478
|
+
.option("-s, --server <url>", `EdgeOTA server URL (default: ${DEFAULT_SERVER})`)
|
|
466
479
|
.action(async (options) => {
|
|
467
480
|
printBanner();
|
|
468
|
-
|
|
469
|
-
|
|
481
|
+
const usingCustomServer = options.server && options.server !== DEFAULT_SERVER;
|
|
482
|
+
console.log(` ${c.bold}Sign in to EdgeOTA${c.reset}`);
|
|
483
|
+
if (usingCustomServer) {
|
|
484
|
+
console.log(` ${c.dim}server: ${options.server}${c.reset}`);
|
|
485
|
+
}
|
|
486
|
+
console.log();
|
|
487
|
+
const serverUrl = (options.server || DEFAULT_SERVER).replace(/\/$/, "");
|
|
470
488
|
const email = await ask(` ${c.dim}email:${c.reset} `);
|
|
471
489
|
const password = await askSecret(` ${c.dim}password:${c.reset} `);
|
|
472
490
|
spin.start("authenticating");
|
|
@@ -527,7 +545,7 @@ program
|
|
|
527
545
|
process.exit(1);
|
|
528
546
|
}
|
|
529
547
|
const globalCfg = loadGlobalConfig();
|
|
530
|
-
const serverUrl = (options.server || globalCfg?.serverUrl ||
|
|
548
|
+
const serverUrl = (options.server || globalCfg?.serverUrl || DEFAULT_SERVER).replace(/\/$/, "");
|
|
531
549
|
const cwd = process.cwd();
|
|
532
550
|
// Fetch existing projects
|
|
533
551
|
spin.start("fetching existing projects from server");
|
package/package.json
CHANGED