chekk 0.2.4 → 0.2.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/bin/chekk.js +57 -15
- package/package.json +1 -1
- package/src/display.js +1 -1
package/bin/chekk.js
CHANGED
|
@@ -1,20 +1,62 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { execSync, spawn } from 'child_process';
|
|
3
4
|
import { Command } from 'commander';
|
|
4
5
|
import { run } from '../src/index.js';
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
const LOCAL_VERSION = '0.2.5';
|
|
8
|
+
|
|
9
|
+
// ── Auto-update check ──
|
|
10
|
+
// If running from a cached npx install, check if there's a newer version
|
|
11
|
+
// and re-exec with @latest to ensure users always get the freshest build.
|
|
12
|
+
async function checkForUpdate() {
|
|
13
|
+
try {
|
|
14
|
+
const latest = execSync('npm view chekk version 2>/dev/null', {
|
|
15
|
+
encoding: 'utf-8',
|
|
16
|
+
timeout: 3000,
|
|
17
|
+
}).trim();
|
|
18
|
+
|
|
19
|
+
if (latest && latest !== LOCAL_VERSION && isNewer(latest, LOCAL_VERSION)) {
|
|
20
|
+
// Re-run with the latest version
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
const child = spawn('npx', ['--yes', `chekk@${latest}`, ...args], {
|
|
23
|
+
stdio: 'inherit',
|
|
24
|
+
shell: true,
|
|
25
|
+
});
|
|
26
|
+
child.on('exit', (code) => process.exit(code || 0));
|
|
27
|
+
return true; // signal that we're handing off
|
|
28
|
+
}
|
|
29
|
+
} catch {
|
|
30
|
+
// Network down or timeout — just run the local version
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isNewer(remote, local) {
|
|
36
|
+
const r = remote.split('.').map(Number);
|
|
37
|
+
const l = local.split('.').map(Number);
|
|
38
|
+
for (let i = 0; i < 3; i++) {
|
|
39
|
+
if ((r[i] || 0) > (l[i] || 0)) return true;
|
|
40
|
+
if ((r[i] || 0) < (l[i] || 0)) return false;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handedOff = await checkForUpdate();
|
|
46
|
+
if (!handedOff) {
|
|
47
|
+
const program = new Command();
|
|
48
|
+
|
|
49
|
+
program
|
|
50
|
+
.name('chekk')
|
|
51
|
+
.description('The engineering capability score. See how you prompt.')
|
|
52
|
+
.version(LOCAL_VERSION)
|
|
53
|
+
.option('--offline', 'Skip AI prose generation, show data-driven output')
|
|
54
|
+
.option('--verbose', 'Show detailed per-project and per-metric breakdowns')
|
|
55
|
+
.option('--json', 'Output raw metrics as JSON')
|
|
56
|
+
.option('--no-upload', 'Skip the claim prompt')
|
|
57
|
+
.action(async (options) => {
|
|
58
|
+
await run(options);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
program.parse();
|
|
62
|
+
}
|
package/package.json
CHANGED
package/src/display.js
CHANGED