@withone/cli 1.12.6 → 1.12.7
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 +57 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { createRequire } from "module";
|
|
4
|
+
import { createRequire as createRequire2 } from "module";
|
|
5
5
|
import { Command } from "commander";
|
|
6
6
|
|
|
7
7
|
// src/commands/init.ts
|
|
@@ -4403,9 +4403,60 @@ validation rules, and platform-specific details.
|
|
|
4403
4403
|
---`;
|
|
4404
4404
|
}
|
|
4405
4405
|
|
|
4406
|
-
// src/
|
|
4406
|
+
// src/commands/update.ts
|
|
4407
|
+
import { createRequire } from "module";
|
|
4408
|
+
import { spawn as spawn2 } from "child_process";
|
|
4407
4409
|
var require2 = createRequire(import.meta.url);
|
|
4408
|
-
var { version } = require2("../package.json");
|
|
4410
|
+
var { version: currentVersion } = require2("../package.json");
|
|
4411
|
+
async function updateCommand() {
|
|
4412
|
+
const s = createSpinner();
|
|
4413
|
+
s.start("Checking for updates...");
|
|
4414
|
+
let latestVersion;
|
|
4415
|
+
try {
|
|
4416
|
+
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
|
+
}
|
|
4421
|
+
const data = await res.json();
|
|
4422
|
+
latestVersion = data.version;
|
|
4423
|
+
} catch (err) {
|
|
4424
|
+
s.stop("");
|
|
4425
|
+
error("Failed to check for updates \u2014 could not reach npm registry");
|
|
4426
|
+
}
|
|
4427
|
+
if (currentVersion === latestVersion) {
|
|
4428
|
+
s.stop("Already up to date");
|
|
4429
|
+
if (isAgentMode()) {
|
|
4430
|
+
json({ current: currentVersion, latest: latestVersion, updated: false, message: "Already up to date" });
|
|
4431
|
+
} else {
|
|
4432
|
+
console.log(`Already up to date (v${currentVersion})`);
|
|
4433
|
+
}
|
|
4434
|
+
return;
|
|
4435
|
+
}
|
|
4436
|
+
s.stop(`Update available: v${currentVersion} \u2192 v${latestVersion}`);
|
|
4437
|
+
console.log(`Updating @withone/cli: v${currentVersion} \u2192 v${latestVersion}...`);
|
|
4438
|
+
const code = await new Promise((resolve) => {
|
|
4439
|
+
const child = spawn2("npm", ["install", "-g", "@withone/cli@latest"], {
|
|
4440
|
+
stdio: isAgentMode() ? "pipe" : "inherit",
|
|
4441
|
+
shell: true
|
|
4442
|
+
});
|
|
4443
|
+
child.on("close", resolve);
|
|
4444
|
+
child.on("error", () => resolve(1));
|
|
4445
|
+
});
|
|
4446
|
+
if (code === 0) {
|
|
4447
|
+
if (isAgentMode()) {
|
|
4448
|
+
json({ current: currentVersion, latest: latestVersion, updated: true, message: "Updated successfully" });
|
|
4449
|
+
} else {
|
|
4450
|
+
console.log(`Successfully updated to v${latestVersion}`);
|
|
4451
|
+
}
|
|
4452
|
+
} else {
|
|
4453
|
+
error("Update failed \u2014 try running: npm install -g @withone/cli@latest");
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
|
|
4457
|
+
// src/index.ts
|
|
4458
|
+
var require3 = createRequire2(import.meta.url);
|
|
4459
|
+
var { version } = require3("../package.json");
|
|
4409
4460
|
var program = new Command();
|
|
4410
4461
|
program.name("one").option("--agent", "Machine-readable JSON output (no colors, spinners, or prompts)").description(`One CLI \u2014 Connect AI agents to 200+ platforms through one interface.
|
|
4411
4462
|
|
|
@@ -4509,6 +4560,9 @@ program.command("guide [topic]").description("Full CLI usage guide for agents (t
|
|
|
4509
4560
|
program.command("onboard").description("Agent onboarding \u2014 teaches your agent what the One CLI can do").action(async () => {
|
|
4510
4561
|
await onboardCommand();
|
|
4511
4562
|
});
|
|
4563
|
+
program.command("update").description("Update the One CLI to the latest version").action(async () => {
|
|
4564
|
+
await updateCommand();
|
|
4565
|
+
});
|
|
4512
4566
|
program.command("add [platform]").description("Shortcut for: connection add").action(async (platform) => {
|
|
4513
4567
|
await connectionAddCommand(platform);
|
|
4514
4568
|
});
|