thinkwork-cli 0.5.0 → 0.5.1
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/cli.js +87 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -738,8 +738,8 @@ function registerBootstrapCommand(program2) {
|
|
|
738
738
|
bucket = await getTerraformOutput(cwd, "bucket_name");
|
|
739
739
|
dbEndpoint = await getTerraformOutput(cwd, "db_cluster_endpoint");
|
|
740
740
|
const secretArn = await getTerraformOutput(cwd, "db_secret_arn");
|
|
741
|
-
const { execSync:
|
|
742
|
-
const secretJson =
|
|
741
|
+
const { execSync: execSync9 } = await import("child_process");
|
|
742
|
+
const secretJson = execSync9(
|
|
743
743
|
`aws secretsmanager get-secret-value --secret-id "${secretArn}" --query SecretString --output text`,
|
|
744
744
|
{ encoding: "utf-8" }
|
|
745
745
|
).trim();
|
|
@@ -1671,6 +1671,90 @@ function registerMcpCommand(program2) {
|
|
|
1671
1671
|
});
|
|
1672
1672
|
}
|
|
1673
1673
|
|
|
1674
|
+
// src/commands/upgrade.ts
|
|
1675
|
+
import { execSync as execSync8 } from "child_process";
|
|
1676
|
+
import chalk8 from "chalk";
|
|
1677
|
+
function getLatestVersion() {
|
|
1678
|
+
try {
|
|
1679
|
+
return execSync8("npm view thinkwork-cli version", {
|
|
1680
|
+
encoding: "utf-8",
|
|
1681
|
+
timeout: 1e4,
|
|
1682
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
1683
|
+
}).trim();
|
|
1684
|
+
} catch {
|
|
1685
|
+
return null;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
function detectInstallMethod() {
|
|
1689
|
+
try {
|
|
1690
|
+
const which = execSync8("which thinkwork", {
|
|
1691
|
+
encoding: "utf-8",
|
|
1692
|
+
timeout: 5e3,
|
|
1693
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
1694
|
+
}).trim();
|
|
1695
|
+
if (which.includes("Cellar") || which.includes("homebrew")) return "homebrew";
|
|
1696
|
+
if (which.includes("node_modules") || which.includes("npm") || which.includes("nvm") || which.includes("fnm")) return "npm";
|
|
1697
|
+
return "npm";
|
|
1698
|
+
} catch {
|
|
1699
|
+
return "npm";
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
function compareVersions(a, b) {
|
|
1703
|
+
const pa = a.split(".").map(Number);
|
|
1704
|
+
const pb = b.split(".").map(Number);
|
|
1705
|
+
for (let i = 0; i < 3; i++) {
|
|
1706
|
+
if ((pa[i] ?? 0) < (pb[i] ?? 0)) return -1;
|
|
1707
|
+
if ((pa[i] ?? 0) > (pb[i] ?? 0)) return 1;
|
|
1708
|
+
}
|
|
1709
|
+
return 0;
|
|
1710
|
+
}
|
|
1711
|
+
function registerUpgradeCommand(program2) {
|
|
1712
|
+
program2.command("upgrade").description("Check for and install CLI updates").option("--check", "Only check for updates, don't install").action(async (opts) => {
|
|
1713
|
+
printHeader("upgrade", "", null);
|
|
1714
|
+
console.log(` Current version: ${chalk8.bold(VERSION)}`);
|
|
1715
|
+
const latest = getLatestVersion();
|
|
1716
|
+
if (!latest) {
|
|
1717
|
+
console.log(chalk8.yellow(" Could not check npm registry for updates."));
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
console.log(` Latest version: ${chalk8.bold(latest)}`);
|
|
1721
|
+
console.log("");
|
|
1722
|
+
const cmp = compareVersions(VERSION, latest);
|
|
1723
|
+
if (cmp >= 0) {
|
|
1724
|
+
console.log(chalk8.green(" \u2713 You're on the latest version."));
|
|
1725
|
+
console.log("");
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
console.log(chalk8.cyan(` Update available: ${VERSION} \u2192 ${latest}`));
|
|
1729
|
+
console.log("");
|
|
1730
|
+
if (opts.check) {
|
|
1731
|
+
const method2 = detectInstallMethod();
|
|
1732
|
+
if (method2 === "homebrew") {
|
|
1733
|
+
console.log(` Run: ${chalk8.cyan("brew upgrade thinkwork-ai/tap/thinkwork")}`);
|
|
1734
|
+
} else {
|
|
1735
|
+
console.log(` Run: ${chalk8.cyan(`npm install -g thinkwork-cli@${latest}`)}`);
|
|
1736
|
+
}
|
|
1737
|
+
console.log("");
|
|
1738
|
+
return;
|
|
1739
|
+
}
|
|
1740
|
+
const method = detectInstallMethod();
|
|
1741
|
+
const cmd = method === "homebrew" ? "brew upgrade thinkwork-ai/tap/thinkwork" : `npm install -g thinkwork-cli@${latest}`;
|
|
1742
|
+
console.log(` Installing via ${method}...`);
|
|
1743
|
+
console.log(chalk8.dim(` $ ${cmd}`));
|
|
1744
|
+
console.log("");
|
|
1745
|
+
try {
|
|
1746
|
+
execSync8(cmd, { stdio: "inherit", timeout: 12e4 });
|
|
1747
|
+
console.log("");
|
|
1748
|
+
console.log(chalk8.green(` \u2713 Upgraded to thinkwork-cli@${latest}`));
|
|
1749
|
+
} catch {
|
|
1750
|
+
console.log("");
|
|
1751
|
+
console.log(chalk8.red(` Failed to upgrade. Try manually:`));
|
|
1752
|
+
console.log(` ${chalk8.cyan(cmd)}`);
|
|
1753
|
+
}
|
|
1754
|
+
console.log("");
|
|
1755
|
+
});
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1674
1758
|
// src/cli.ts
|
|
1675
1759
|
var program = new Command();
|
|
1676
1760
|
program.name("thinkwork").description(
|
|
@@ -1696,4 +1780,5 @@ registerStatusCommand(program);
|
|
|
1696
1780
|
registerOutputsCommand(program);
|
|
1697
1781
|
registerConfigCommand(program);
|
|
1698
1782
|
registerMcpCommand(program);
|
|
1783
|
+
registerUpgradeCommand(program);
|
|
1699
1784
|
program.parse();
|