@withone/cli 1.12.7 → 1.12.8
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 +35 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4408,19 +4408,24 @@ import { createRequire } from "module";
|
|
|
4408
4408
|
import { spawn as spawn2 } from "child_process";
|
|
4409
4409
|
var require2 = createRequire(import.meta.url);
|
|
4410
4410
|
var { version: currentVersion } = require2("../package.json");
|
|
4411
|
-
async function
|
|
4412
|
-
const s = createSpinner();
|
|
4413
|
-
s.start("Checking for updates...");
|
|
4414
|
-
let latestVersion;
|
|
4411
|
+
async function checkLatestVersion() {
|
|
4415
4412
|
try {
|
|
4416
4413
|
const res = await fetch("https://registry.npmjs.org/@withone/cli/latest");
|
|
4417
|
-
if (!res.ok)
|
|
4418
|
-
s.stop("");
|
|
4419
|
-
error(`Failed to check for updates (HTTP ${res.status})`);
|
|
4420
|
-
}
|
|
4414
|
+
if (!res.ok) return null;
|
|
4421
4415
|
const data = await res.json();
|
|
4422
|
-
|
|
4423
|
-
} catch
|
|
4416
|
+
return data.version;
|
|
4417
|
+
} catch {
|
|
4418
|
+
return null;
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
function getCurrentVersion() {
|
|
4422
|
+
return currentVersion;
|
|
4423
|
+
}
|
|
4424
|
+
async function updateCommand() {
|
|
4425
|
+
const s = createSpinner();
|
|
4426
|
+
s.start("Checking for updates...");
|
|
4427
|
+
const latestVersion = await checkLatestVersion();
|
|
4428
|
+
if (!latestVersion) {
|
|
4424
4429
|
s.stop("");
|
|
4425
4430
|
error("Failed to check for updates \u2014 could not reach npm registry");
|
|
4426
4431
|
}
|
|
@@ -4495,11 +4500,31 @@ program.name("one").option("--agent", "Machine-readable JSON output (no colors,
|
|
|
4495
4500
|
|
|
4496
4501
|
Platform names are always kebab-case (e.g. hub-spot, ship-station, google-calendar).
|
|
4497
4502
|
Run 'one platforms' to browse all 200+ available platforms.`).version(version);
|
|
4503
|
+
var updateCheckPromise;
|
|
4498
4504
|
program.hook("preAction", (thisCommand) => {
|
|
4499
4505
|
const opts = program.opts();
|
|
4500
4506
|
if (opts.agent) {
|
|
4501
4507
|
setAgentMode(true);
|
|
4502
4508
|
}
|
|
4509
|
+
const commandName = thisCommand.args?.[0];
|
|
4510
|
+
if (commandName !== "update") {
|
|
4511
|
+
updateCheckPromise = checkLatestVersion();
|
|
4512
|
+
}
|
|
4513
|
+
});
|
|
4514
|
+
program.hook("postAction", async () => {
|
|
4515
|
+
if (!updateCheckPromise) return;
|
|
4516
|
+
const latestVersion = await updateCheckPromise;
|
|
4517
|
+
if (!latestVersion) return;
|
|
4518
|
+
const current = getCurrentVersion();
|
|
4519
|
+
if (current === latestVersion) return;
|
|
4520
|
+
if (isAgentMode()) {
|
|
4521
|
+
process.stderr.write(`
|
|
4522
|
+
Update available: v${current} \u2192 v${latestVersion}. Run "one update" to upgrade.
|
|
4523
|
+
`);
|
|
4524
|
+
} else {
|
|
4525
|
+
console.log(`
|
|
4526
|
+
\x1B[33mUpdate available: v${current} \u2192 v${latestVersion}. Run \x1B[1mone update\x1B[22m to upgrade.\x1B[0m`);
|
|
4527
|
+
}
|
|
4503
4528
|
});
|
|
4504
4529
|
program.command("init").description("Set up One and install MCP to your AI agents").option("-y, --yes", "Skip confirmations").option("-g, --global", "Install MCP globally (available in all projects)").option("-p, --project", "Install MCP for this project only (creates .mcp.json)").action(async (options) => {
|
|
4505
4530
|
await initCommand(options);
|