@senso-ai/cli 0.3.0 → 0.4.0
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 +18 -42
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -113,7 +113,7 @@ function getConfigPath() {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// src/utils/updater.ts
|
|
116
|
-
var
|
|
116
|
+
var NPM_PACKAGE = "@senso-ai/cli";
|
|
117
117
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
118
118
|
async function checkForUpdate(quiet) {
|
|
119
119
|
if (process.env.SENSO_NO_UPDATE_CHECK === "1" || quiet) {
|
|
@@ -128,16 +128,8 @@ async function checkForUpdate(quiet) {
|
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
try {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
{
|
|
134
|
-
headers: { Accept: "application/vnd.github.v3+json" },
|
|
135
|
-
signal: AbortSignal.timeout(5e3)
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
if (!res.ok) return;
|
|
139
|
-
const release = await res.json();
|
|
140
|
-
const latest = release.tag_name.replace(/^v/, "");
|
|
131
|
+
const latest = await getLatestVersion();
|
|
132
|
+
if (!latest) return;
|
|
141
133
|
updateConfig({
|
|
142
134
|
lastUpdateCheck: (/* @__PURE__ */ new Date()).toISOString(),
|
|
143
135
|
latestVersion: latest
|
|
@@ -148,17 +140,18 @@ async function checkForUpdate(quiet) {
|
|
|
148
140
|
} catch {
|
|
149
141
|
}
|
|
150
142
|
}
|
|
151
|
-
async function
|
|
143
|
+
async function getLatestVersion() {
|
|
152
144
|
try {
|
|
153
145
|
const res = await fetch(
|
|
154
|
-
`https://
|
|
146
|
+
`https://registry.npmjs.org/${NPM_PACKAGE}`,
|
|
155
147
|
{
|
|
156
|
-
headers: { Accept: "application/
|
|
148
|
+
headers: { Accept: "application/json" },
|
|
157
149
|
signal: AbortSignal.timeout(1e4)
|
|
158
150
|
}
|
|
159
151
|
);
|
|
160
152
|
if (!res.ok) return null;
|
|
161
|
-
|
|
153
|
+
const data = await res.json();
|
|
154
|
+
return data["dist-tags"]?.latest ?? null;
|
|
162
155
|
} catch {
|
|
163
156
|
return null;
|
|
164
157
|
}
|
|
@@ -1376,16 +1369,16 @@ function registerNotificationCommands(program2) {
|
|
|
1376
1369
|
import semver2 from "semver";
|
|
1377
1370
|
import pc7 from "picocolors";
|
|
1378
1371
|
import { execSync } from "child_process";
|
|
1372
|
+
var NPM_PACKAGE2 = "@senso-ai/cli";
|
|
1379
1373
|
function registerUpdateCommand(program2) {
|
|
1380
1374
|
program2.command("update").description("Update CLI to the latest version").action(async () => {
|
|
1381
1375
|
info(`Current version: ${pc7.bold(version)}`);
|
|
1382
|
-
info("Checking for updates...");
|
|
1383
|
-
const
|
|
1384
|
-
if (!
|
|
1376
|
+
info("Checking npm for updates...");
|
|
1377
|
+
const latest = await getLatestVersion();
|
|
1378
|
+
if (!latest) {
|
|
1385
1379
|
error("Could not check for updates. Try again later.");
|
|
1386
1380
|
process.exit(1);
|
|
1387
1381
|
}
|
|
1388
|
-
const latest = release.tag_name.replace(/^v/, "");
|
|
1389
1382
|
if (!semver2.gt(latest, version)) {
|
|
1390
1383
|
success(`Already on the latest version (${version}).`);
|
|
1391
1384
|
return;
|
|
@@ -1393,33 +1386,16 @@ function registerUpdateCommand(program2) {
|
|
|
1393
1386
|
info(`New version available: ${pc7.bold(latest)}`);
|
|
1394
1387
|
info("Updating...");
|
|
1395
1388
|
try {
|
|
1396
|
-
execSync(
|
|
1389
|
+
execSync(`npm install -g ${NPM_PACKAGE2}@latest`, {
|
|
1397
1390
|
stdio: "inherit"
|
|
1398
1391
|
});
|
|
1399
1392
|
success(`Updated to v${latest}.`);
|
|
1400
|
-
if (release.body) {
|
|
1401
|
-
console.log();
|
|
1402
|
-
console.log(pc7.dim("Release notes:"));
|
|
1403
|
-
console.log(pc7.dim(release.body.slice(0, 500)));
|
|
1404
|
-
}
|
|
1405
1393
|
} catch {
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
);
|
|
1412
|
-
success("Updated via npx cache refresh.");
|
|
1413
|
-
} catch {
|
|
1414
|
-
error("Update failed. Please reinstall manually:");
|
|
1415
|
-
console.log(
|
|
1416
|
-
` ${pc7.cyan("npm install -g senso-user-cli")}`
|
|
1417
|
-
);
|
|
1418
|
-
console.log(
|
|
1419
|
-
` ${pc7.dim("or")} ${pc7.cyan("npx github:AI-Template-SDK/senso-user-cli")}`
|
|
1420
|
-
);
|
|
1421
|
-
process.exit(1);
|
|
1422
|
-
}
|
|
1394
|
+
error("Update failed. Please reinstall manually:");
|
|
1395
|
+
console.log(
|
|
1396
|
+
` ${pc7.cyan(`npm install -g ${NPM_PACKAGE2}`)}`
|
|
1397
|
+
);
|
|
1398
|
+
process.exit(1);
|
|
1423
1399
|
}
|
|
1424
1400
|
});
|
|
1425
1401
|
}
|