@fudrouter/fsrouter 0.6.95 → 0.6.96
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/bin/cli.cjs
CHANGED
|
@@ -43,7 +43,23 @@ function createSpinner(text) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
// Resolve the package version from the nearest package.json carrying the
|
|
47
|
+
// published package name (handles both dev layout and the installed package).
|
|
48
|
+
function resolvePkg() {
|
|
49
|
+
let dir = __dirname;
|
|
50
|
+
for (let i = 0; i < 6; i++) {
|
|
51
|
+
const cand = require("path").join(dir, "package.json");
|
|
52
|
+
try {
|
|
53
|
+
const p = require(cand);
|
|
54
|
+
if (p && (p.name === "@fudrouter/fsrouter" || p.name === "amrouter")) return p;
|
|
55
|
+
} catch { /* keep walking up */ }
|
|
56
|
+
const parent = require("path").dirname(dir);
|
|
57
|
+
if (parent === dir) break;
|
|
58
|
+
dir = parent;
|
|
59
|
+
}
|
|
60
|
+
try { return require("../package.json"); } catch { return { version: "0.0.0" }; }
|
|
61
|
+
}
|
|
62
|
+
const pkg = resolvePkg();
|
|
47
63
|
const { ensureSqliteRuntime, buildEnvWithRuntime } = require("./hooks/sqliteRuntime.cjs");
|
|
48
64
|
const { ensureTrayRuntime } = require("./hooks/trayRuntime.cjs");
|
|
49
65
|
const args = process.argv.slice(2);
|
|
@@ -458,7 +474,7 @@ async function showInterfaceMenu(latestVersion) {
|
|
|
458
474
|
|
|
459
475
|
const displayHost = host === DEFAULT_HOST ? "localhost" : host;
|
|
460
476
|
|
|
461
|
-
//
|
|
477
|
+
// Tunnel/local mode for server URL display
|
|
462
478
|
let serverUrl;
|
|
463
479
|
try {
|
|
464
480
|
const { endpoint, tunnelEnabled } = await getEndpoint(port);
|
|
@@ -467,7 +483,11 @@ async function showInterfaceMenu(latestVersion) {
|
|
|
467
483
|
serverUrl = `http://${displayHost}:${port}`;
|
|
468
484
|
}
|
|
469
485
|
|
|
470
|
-
|
|
486
|
+
// Build subtitle: server URL + update notice when a newer version exists
|
|
487
|
+
let subtitle = `🚀 Server: \x1b[32m${serverUrl}\x1b[0m`;
|
|
488
|
+
if (latestVersion && latestVersion !== pkg.version) {
|
|
489
|
+
subtitle += `\n \x1b[33mâš Update tersedia: v${latestVersion} (installed: v${pkg.version})\x1b[0m`;
|
|
490
|
+
}
|
|
471
491
|
|
|
472
492
|
const menuItems = [];
|
|
473
493
|
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Migration 004 — ensure ammail* -> fsmail* rename is fully applied.
|
|
2
|
+
// Some installs (e.g. upgraded from 9Router / older builds) may still have
|
|
3
|
+
// the legacy `ammailAlias` column or `ammailOtps` table if migration 003 did
|
|
4
|
+
// not run. This makes the rename idempotent and safe to re-run.
|
|
5
|
+
export default {
|
|
6
|
+
version: 4,
|
|
7
|
+
name: "ensure-ammail-to-fsmail",
|
|
8
|
+
up(db) {
|
|
9
|
+
// 1. Rename table ammailOtps -> fsmailOtps if still present
|
|
10
|
+
try {
|
|
11
|
+
const tableExists = db.get(
|
|
12
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='ammailOtps'"
|
|
13
|
+
);
|
|
14
|
+
if (tableExists) {
|
|
15
|
+
db.exec("ALTER TABLE ammailOtps RENAME TO fsmailOtps");
|
|
16
|
+
console.log("[Migration 004] Renamed ammailOtps table to fsmailOtps");
|
|
17
|
+
}
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.warn("[Migration 004] Failed to rename table ammailOtps:", e.message);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 2. Rename column ammailAlias -> fsmailAlias in codebuddyAccounts if present
|
|
23
|
+
try {
|
|
24
|
+
const hasColumn = db.get(
|
|
25
|
+
"SELECT 1 FROM pragma_table_info('codebuddyAccounts') WHERE name='ammailAlias'"
|
|
26
|
+
);
|
|
27
|
+
if (hasColumn) {
|
|
28
|
+
db.exec("ALTER TABLE codebuddyAccounts RENAME COLUMN ammailAlias TO fsmailAlias");
|
|
29
|
+
console.log("[Migration 004] Renamed ammailAlias column to fsmailAlias in codebuddyAccounts");
|
|
30
|
+
}
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.warn("[Migration 004] Failed to rename column ammailAlias:", e.message);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 3. Normalize settings JSON keys ammail_* -> fsmail_*
|
|
36
|
+
try {
|
|
37
|
+
const row = db.get("SELECT data FROM settings WHERE id = 1");
|
|
38
|
+
if (row && row.data) {
|
|
39
|
+
const settings = JSON.parse(row.data);
|
|
40
|
+
let changed = false;
|
|
41
|
+
const newSettings = {};
|
|
42
|
+
for (const [key, value] of Object.entries(settings)) {
|
|
43
|
+
if (key.startsWith("ammail_")) {
|
|
44
|
+
const newKey = key.replace("ammail_", "fsmail_");
|
|
45
|
+
newSettings[newKey] = value;
|
|
46
|
+
changed = true;
|
|
47
|
+
} else {
|
|
48
|
+
newSettings[key] = value;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (changed) {
|
|
52
|
+
db.run("UPDATE settings SET data = ? WHERE id = 1", [JSON.stringify(newSettings)]);
|
|
53
|
+
console.log("[Migration 004] Normalized ammail_* settings keys to fsmail_*");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.warn("[Migration 004] Failed to normalize settings keys:", e.message);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
import m001 from "./001-initial.js";
|
|
5
5
|
import m002 from "./002-composite-unique.js";
|
|
6
6
|
import m003 from "./003-rename-ammail-to-fsmail.js";
|
|
7
|
+
import m004 from "./004-ensure-ammail-to-fsmail.js";
|
|
7
8
|
|
|
8
|
-
export const MIGRATIONS = [m001, m002, m003].sort((a, b) => a.version - b.version);
|
|
9
|
+
export const MIGRATIONS = [m001, m002, m003, m004].sort((a, b) => a.version - b.version);
|
|
9
10
|
|
|
10
11
|
export function latestVersion() {
|
|
11
12
|
return MIGRATIONS.length ? MIGRATIONS[MIGRATIONS.length - 1].version : 0;
|