@suronai/cli 0.1.41 → 0.1.42
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/commands.js +21 -11
package/package.json
CHANGED
package/src/commands.js
CHANGED
|
@@ -30,15 +30,14 @@ function openBrowser(url) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function
|
|
34
|
-
process.stdout.write(prompt);
|
|
33
|
+
function prompt(question) {
|
|
35
34
|
return new Promise(resolve => {
|
|
35
|
+
process.stdout.write(question);
|
|
36
36
|
const handler = (buf) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
37
|
+
const line = buf.toString().split("\n")[0].trim();
|
|
38
|
+
process.stdin.removeListener("data", handler);
|
|
39
|
+
process.stdin.pause();
|
|
40
|
+
resolve(line);
|
|
42
41
|
};
|
|
43
42
|
process.stdin.resume();
|
|
44
43
|
process.stdin.setEncoding("utf-8");
|
|
@@ -178,8 +177,7 @@ async function patchEntryPoint(cwd, isEsm) {
|
|
|
178
177
|
console.log(ui.blank());
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
await
|
|
182
|
-
const answer = "";
|
|
180
|
+
const answer = await prompt(ui.promptLine("apply patch? [Y/n]"));
|
|
183
181
|
const confirmed = answer === "" || /^y(es)?$/i.test(answer);
|
|
184
182
|
console.log(ui.blank());
|
|
185
183
|
console.log(ui.hr());
|
|
@@ -263,7 +261,7 @@ export const loginCommand = new Command("login")
|
|
|
263
261
|
console.log(ui.kv("URL", loginUrl, 6));
|
|
264
262
|
console.log(ui.blank());
|
|
265
263
|
|
|
266
|
-
await
|
|
264
|
+
await prompt(ui.promptLine("open browser"));
|
|
267
265
|
openBrowser(loginUrl);
|
|
268
266
|
console.log(ui.blank());
|
|
269
267
|
|
|
@@ -494,6 +492,7 @@ export const whoamiCommand = new Command("whoami")
|
|
|
494
492
|
});
|
|
495
493
|
|
|
496
494
|
export const upCommand = new Command("up")
|
|
495
|
+
.description("Push a new version of .env")
|
|
497
496
|
.action(async () => {
|
|
498
497
|
requireToken();
|
|
499
498
|
const cwd = process.cwd();
|
|
@@ -502,9 +501,20 @@ export const upCommand = new Command("up")
|
|
|
502
501
|
if (!existsSync(join(cwd, ".env"))) cancel(".env not found");
|
|
503
502
|
|
|
504
503
|
const suronJson = JSON.parse(readFileSync(join(cwd, ".suron.json"), "utf-8"));
|
|
505
|
-
const { app_id }
|
|
504
|
+
const { app_id, version: currentVersion } = suronJson;
|
|
506
505
|
const env_plaintext = readFileSync(join(cwd, ".env"), "utf-8");
|
|
507
506
|
|
|
507
|
+
// ── Check if anything changed ─────────────────────────────────────────────
|
|
508
|
+
try {
|
|
509
|
+
const latest = await api(`/apps/${app_id}/versions/${currentVersion}`);
|
|
510
|
+
if (latest.env_plaintext?.trim() === env_plaintext.trim()) {
|
|
511
|
+
console.log(ui.blank());
|
|
512
|
+
console.log(ui.okBlock("nothing to push · .env unchanged since " + currentVersion));
|
|
513
|
+
console.log(ui.blank());
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
} catch { /* if fetch fails just proceed */ }
|
|
517
|
+
|
|
508
518
|
const s = spinner();
|
|
509
519
|
s.start("Pushing new version");
|
|
510
520
|
|