@arbidocs/cli 0.3.0 → 0.3.2
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.cjs +115 -2
- package/dist/index.cjs.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
var commander = require('commander');
|
|
5
5
|
var core = require('@arbidocs/core');
|
|
6
6
|
var prompts = require('@inquirer/prompts');
|
|
7
|
-
var sdk = require('@arbidocs/sdk');
|
|
8
7
|
var fs = require('fs');
|
|
9
8
|
var path = require('path');
|
|
9
|
+
var os = require('os');
|
|
10
10
|
var child_process = require('child_process');
|
|
11
|
+
var sdk = require('@arbidocs/sdk');
|
|
11
12
|
var module$1 = require('module');
|
|
12
13
|
|
|
13
14
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
@@ -15,6 +16,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
15
16
|
|
|
16
17
|
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
17
18
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
19
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
18
20
|
|
|
19
21
|
var store = new core.FileConfigStore();
|
|
20
22
|
function getConfig() {
|
|
@@ -65,6 +67,19 @@ function registerConfigCommand(program2) {
|
|
|
65
67
|
process.exit(1);
|
|
66
68
|
}
|
|
67
69
|
});
|
|
70
|
+
config.command("show").description("Show current configuration").action(() => {
|
|
71
|
+
const cfg = getConfig();
|
|
72
|
+
if (!cfg) {
|
|
73
|
+
console.log("Not configured. Run: arbi config set-url <url>");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
console.log(`Server URL: ${cfg.baseUrl}`);
|
|
77
|
+
console.log(`Domain: ${cfg.deploymentDomain}`);
|
|
78
|
+
console.log(`Auto-update: ${cfg.autoUpdate ? "on" : "off"}`);
|
|
79
|
+
if (cfg.selectedWorkspaceId) {
|
|
80
|
+
console.log(`Workspace: ${cfg.selectedWorkspaceId}`);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
68
83
|
}
|
|
69
84
|
|
|
70
85
|
// ../../node_modules/fake-indexeddb/build/esm/lib/errors.js
|
|
@@ -3378,6 +3393,72 @@ async function promptPassword(message) {
|
|
|
3378
3393
|
async function promptConfirm(message, defaultValue = true) {
|
|
3379
3394
|
return prompts.confirm({ message, default: defaultValue });
|
|
3380
3395
|
}
|
|
3396
|
+
var CACHE_FILE = path__default.default.join(os__default.default.homedir(), ".arbi", "version-cache.json");
|
|
3397
|
+
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
3398
|
+
function readCache() {
|
|
3399
|
+
try {
|
|
3400
|
+
const data = JSON.parse(fs__default.default.readFileSync(CACHE_FILE, "utf8"));
|
|
3401
|
+
if (data.latest && data.checkedAt && Date.now() - data.checkedAt < CACHE_TTL_MS) {
|
|
3402
|
+
return data;
|
|
3403
|
+
}
|
|
3404
|
+
} catch {
|
|
3405
|
+
}
|
|
3406
|
+
return null;
|
|
3407
|
+
}
|
|
3408
|
+
function writeCache(latest) {
|
|
3409
|
+
try {
|
|
3410
|
+
const dir = path__default.default.dirname(CACHE_FILE);
|
|
3411
|
+
if (!fs__default.default.existsSync(dir)) fs__default.default.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
3412
|
+
fs__default.default.writeFileSync(CACHE_FILE, JSON.stringify({ latest, checkedAt: Date.now() }) + "\n");
|
|
3413
|
+
} catch {
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
function getLatestVersion() {
|
|
3417
|
+
const cached = readCache();
|
|
3418
|
+
if (cached) return cached.latest;
|
|
3419
|
+
try {
|
|
3420
|
+
const latest = child_process.execSync("npm view @arbidocs/cli version 2>/dev/null", {
|
|
3421
|
+
encoding: "utf8",
|
|
3422
|
+
timeout: 5e3
|
|
3423
|
+
}).trim();
|
|
3424
|
+
writeCache(latest);
|
|
3425
|
+
return latest;
|
|
3426
|
+
} catch {
|
|
3427
|
+
return null;
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
function checkForUpdates(autoUpdate) {
|
|
3431
|
+
try {
|
|
3432
|
+
const latest = getLatestVersion();
|
|
3433
|
+
if (!latest || latest === "0.3.2") return;
|
|
3434
|
+
if (autoUpdate) {
|
|
3435
|
+
console.log(
|
|
3436
|
+
`
|
|
3437
|
+
Your arbi version is out of date (${"0.3.2"} \u2192 ${latest}). Updating...`
|
|
3438
|
+
);
|
|
3439
|
+
child_process.execSync("npm install -g @arbidocs/cli@latest", { stdio: "inherit" });
|
|
3440
|
+
console.log(`Updated to ${latest}.`);
|
|
3441
|
+
} else {
|
|
3442
|
+
console.error(
|
|
3443
|
+
`
|
|
3444
|
+
Your arbi version is out of date (${"0.3.2"} \u2192 ${latest}).
|
|
3445
|
+
Run "arbi update" to upgrade, or "arbi update auto" to always stay up to date.`
|
|
3446
|
+
);
|
|
3447
|
+
}
|
|
3448
|
+
} catch {
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
function hintUpdateOnError() {
|
|
3452
|
+
try {
|
|
3453
|
+
const cached = readCache();
|
|
3454
|
+
if (cached && cached.latest !== "0.3.2") {
|
|
3455
|
+
console.error(
|
|
3456
|
+
`Your arbi version is out of date (${"0.3.2"} \u2192 ${cached.latest}). Run "arbi update".`
|
|
3457
|
+
);
|
|
3458
|
+
}
|
|
3459
|
+
} catch {
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3381
3462
|
|
|
3382
3463
|
// src/commands/login.ts
|
|
3383
3464
|
function registerLoginCommand(program2) {
|
|
@@ -3417,6 +3498,8 @@ function registerLoginCommand(program2) {
|
|
|
3417
3498
|
} catch (err) {
|
|
3418
3499
|
console.error(`Login failed: ${core.getErrorMessage(err)}`);
|
|
3419
3500
|
process.exit(1);
|
|
3501
|
+
} finally {
|
|
3502
|
+
checkForUpdates(getConfig()?.autoUpdate);
|
|
3420
3503
|
}
|
|
3421
3504
|
});
|
|
3422
3505
|
}
|
|
@@ -3602,6 +3685,7 @@ function runAction(fn) {
|
|
|
3602
3685
|
await fn();
|
|
3603
3686
|
} catch (err) {
|
|
3604
3687
|
console.error(`Error: ${core.getErrorMessage(err)}`);
|
|
3688
|
+
hintUpdateOnError();
|
|
3605
3689
|
process.exit(1);
|
|
3606
3690
|
}
|
|
3607
3691
|
};
|
|
@@ -4962,6 +5046,34 @@ function registerTuiCommand(program2) {
|
|
|
4962
5046
|
child.on("exit", (code) => process.exit(code ?? 0));
|
|
4963
5047
|
});
|
|
4964
5048
|
}
|
|
5049
|
+
function registerUpdateCommand(program2) {
|
|
5050
|
+
const update = program2.command("update").description("Update ARBI CLI to the latest version").action(() => {
|
|
5051
|
+
console.log(`Current version: ${"0.3.2"}`);
|
|
5052
|
+
console.log("Checking for updates...\n");
|
|
5053
|
+
try {
|
|
5054
|
+
const latest = child_process.execSync("npm view @arbidocs/cli version", { encoding: "utf8" }).trim();
|
|
5055
|
+
if (latest === "0.3.2") {
|
|
5056
|
+
console.log("Already up to date.");
|
|
5057
|
+
return;
|
|
5058
|
+
}
|
|
5059
|
+
console.log(`New version available: ${latest}`);
|
|
5060
|
+
console.log("Updating...\n");
|
|
5061
|
+
child_process.execSync("npm install -g @arbidocs/cli@latest", { stdio: "inherit" });
|
|
5062
|
+
console.log(`
|
|
5063
|
+
Updated to ${latest}.`);
|
|
5064
|
+
} catch (err) {
|
|
5065
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
5066
|
+
console.error(`Update failed: ${msg}`);
|
|
5067
|
+
console.error("\nYou can update manually with:");
|
|
5068
|
+
console.error(" npm install -g @arbidocs/cli@latest");
|
|
5069
|
+
process.exit(1);
|
|
5070
|
+
}
|
|
5071
|
+
});
|
|
5072
|
+
update.command("auto").description("Enable automatic updates on login").action(() => {
|
|
5073
|
+
updateConfig({ autoUpdate: true });
|
|
5074
|
+
console.log("Auto-update enabled. ARBI CLI will update automatically on login.");
|
|
5075
|
+
});
|
|
5076
|
+
}
|
|
4965
5077
|
|
|
4966
5078
|
// src/index.ts
|
|
4967
5079
|
console.debug = () => {
|
|
@@ -4972,7 +5084,7 @@ console.info = (...args) => {
|
|
|
4972
5084
|
_origInfo(...args);
|
|
4973
5085
|
};
|
|
4974
5086
|
var program = new commander.Command();
|
|
4975
|
-
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.
|
|
5087
|
+
program.name("arbi").description("ARBI CLI \u2014 interact with ARBI from the terminal").version("0.3.2");
|
|
4976
5088
|
registerConfigCommand(program);
|
|
4977
5089
|
registerLoginCommand(program);
|
|
4978
5090
|
registerRegisterCommand(program);
|
|
@@ -4993,6 +5105,7 @@ registerSettingsCommand(program);
|
|
|
4993
5105
|
registerAgentconfigCommand(program);
|
|
4994
5106
|
registerHealthCommand(program);
|
|
4995
5107
|
registerTuiCommand(program);
|
|
5108
|
+
registerUpdateCommand(program);
|
|
4996
5109
|
program.parse();
|
|
4997
5110
|
//# sourceMappingURL=index.cjs.map
|
|
4998
5111
|
//# sourceMappingURL=index.cjs.map
|