kodingo-cli 1.0.4 → 1.0.5

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 CHANGED
@@ -14,10 +14,18 @@ const deny_1 = require("./commands/deny");
14
14
  const scan_git_1 = require("./commands/scan-git");
15
15
  const init_1 = require("./commands/init");
16
16
  const install_hook_1 = require("./commands/install-hook");
17
+ const update_1 = require("./commands/update");
17
18
  const program = new commander_1.Command();
18
- program.name("kodingo").description("Kodingo CLI").version("1.0.1");
19
+ program.name("kodingo").description("Kodingo CLI").version("1.0.4");
19
20
  // ── init ──────────────────────────────────────────────────────────────────────
20
21
  (0, init_1.registerInitCommand)(program);
22
+ // ── update ────────────────────────────────────────────────────────────────────
23
+ program
24
+ .command("update")
25
+ .description("Update kodingo-cli to the latest version")
26
+ .action(async () => {
27
+ await (0, update_1.updateCommand)();
28
+ });
21
29
  // ── capture ───────────────────────────────────────────────────────────────────
22
30
  program
23
31
  .command("capture")
@@ -85,6 +85,11 @@ function findRepoRoot(startPath) {
85
85
  function testKodingoSaveWatcher() {
86
86
  return false;
87
87
  }
88
- function testKodingoSaveWatchers() {
89
- return false;
88
+ async function validateTokenExpiry(token, maxAgeMs) {
89
+ const parts = token.split('.');
90
+ if (parts.length !== 3)
91
+ return false;
92
+ const payload = JSON.parse(Buffer.from(parts[1], 'base64').toString());
93
+ const issuedAt = payload.iat * 1000;
94
+ return Date.now() - issuedAt < maxAgeMs;
90
95
  }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateCommand = updateCommand;
4
+ const child_process_1 = require("child_process");
5
+ async function updateCommand() {
6
+ console.log("Checking for updates...");
7
+ let currentVersion;
8
+ let latestVersion;
9
+ try {
10
+ currentVersion = (0, child_process_1.execSync)("kodingo --version", { encoding: "utf-8" }).trim();
11
+ }
12
+ catch {
13
+ currentVersion = "unknown";
14
+ }
15
+ try {
16
+ latestVersion = (0, child_process_1.execSync)("npm view kodingo-cli version", { encoding: "utf-8" }).trim();
17
+ }
18
+ catch {
19
+ console.error("Could not fetch latest version. Check your internet connection.");
20
+ process.exit(1);
21
+ }
22
+ if (currentVersion === latestVersion) {
23
+ console.log(`Already on the latest version (${currentVersion}).`);
24
+ return;
25
+ }
26
+ console.log(`Updating from ${currentVersion} to ${latestVersion}...`);
27
+ try {
28
+ (0, child_process_1.execSync)("npm install -g kodingo-cli@latest", { stdio: "inherit" });
29
+ console.log(`Updated to ${latestVersion} successfully.`);
30
+ }
31
+ catch {
32
+ console.error("Update failed. Try running: npm install -g kodingo-cli@latest");
33
+ process.exit(1);
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kodingo-cli",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Kodingo CLI",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -33,4 +33,4 @@
33
33
  "@types/uuid": "^10.0.0",
34
34
  "typescript": "^5.6.0"
35
35
  }
36
- }
36
+ }