@withone/cli 1.12.6 → 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 +82 -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,65 @@ 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 checkLatestVersion() {
|
|
4412
|
+
try {
|
|
4413
|
+
const res = await fetch("https://registry.npmjs.org/@withone/cli/latest");
|
|
4414
|
+
if (!res.ok) return null;
|
|
4415
|
+
const data = await res.json();
|
|
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) {
|
|
4429
|
+
s.stop("");
|
|
4430
|
+
error("Failed to check for updates \u2014 could not reach npm registry");
|
|
4431
|
+
}
|
|
4432
|
+
if (currentVersion === latestVersion) {
|
|
4433
|
+
s.stop("Already up to date");
|
|
4434
|
+
if (isAgentMode()) {
|
|
4435
|
+
json({ current: currentVersion, latest: latestVersion, updated: false, message: "Already up to date" });
|
|
4436
|
+
} else {
|
|
4437
|
+
console.log(`Already up to date (v${currentVersion})`);
|
|
4438
|
+
}
|
|
4439
|
+
return;
|
|
4440
|
+
}
|
|
4441
|
+
s.stop(`Update available: v${currentVersion} \u2192 v${latestVersion}`);
|
|
4442
|
+
console.log(`Updating @withone/cli: v${currentVersion} \u2192 v${latestVersion}...`);
|
|
4443
|
+
const code = await new Promise((resolve) => {
|
|
4444
|
+
const child = spawn2("npm", ["install", "-g", "@withone/cli@latest"], {
|
|
4445
|
+
stdio: isAgentMode() ? "pipe" : "inherit",
|
|
4446
|
+
shell: true
|
|
4447
|
+
});
|
|
4448
|
+
child.on("close", resolve);
|
|
4449
|
+
child.on("error", () => resolve(1));
|
|
4450
|
+
});
|
|
4451
|
+
if (code === 0) {
|
|
4452
|
+
if (isAgentMode()) {
|
|
4453
|
+
json({ current: currentVersion, latest: latestVersion, updated: true, message: "Updated successfully" });
|
|
4454
|
+
} else {
|
|
4455
|
+
console.log(`Successfully updated to v${latestVersion}`);
|
|
4456
|
+
}
|
|
4457
|
+
} else {
|
|
4458
|
+
error("Update failed \u2014 try running: npm install -g @withone/cli@latest");
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
|
|
4462
|
+
// src/index.ts
|
|
4463
|
+
var require3 = createRequire2(import.meta.url);
|
|
4464
|
+
var { version } = require3("../package.json");
|
|
4409
4465
|
var program = new Command();
|
|
4410
4466
|
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
4467
|
|
|
@@ -4444,11 +4500,31 @@ program.name("one").option("--agent", "Machine-readable JSON output (no colors,
|
|
|
4444
4500
|
|
|
4445
4501
|
Platform names are always kebab-case (e.g. hub-spot, ship-station, google-calendar).
|
|
4446
4502
|
Run 'one platforms' to browse all 200+ available platforms.`).version(version);
|
|
4503
|
+
var updateCheckPromise;
|
|
4447
4504
|
program.hook("preAction", (thisCommand) => {
|
|
4448
4505
|
const opts = program.opts();
|
|
4449
4506
|
if (opts.agent) {
|
|
4450
4507
|
setAgentMode(true);
|
|
4451
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
|
+
}
|
|
4452
4528
|
});
|
|
4453
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) => {
|
|
4454
4530
|
await initCommand(options);
|
|
@@ -4509,6 +4585,9 @@ program.command("guide [topic]").description("Full CLI usage guide for agents (t
|
|
|
4509
4585
|
program.command("onboard").description("Agent onboarding \u2014 teaches your agent what the One CLI can do").action(async () => {
|
|
4510
4586
|
await onboardCommand();
|
|
4511
4587
|
});
|
|
4588
|
+
program.command("update").description("Update the One CLI to the latest version").action(async () => {
|
|
4589
|
+
await updateCommand();
|
|
4590
|
+
});
|
|
4512
4591
|
program.command("add [platform]").description("Shortcut for: connection add").action(async (platform) => {
|
|
4513
4592
|
await connectionAddCommand(platform);
|
|
4514
4593
|
});
|