Skip to content

Commit ea57f89

Browse files
committed
fix(cli): read version from package.json instead of hardcoded '2.0.0'
The CLI hardcoded .version('2.0.0') so 'shipnode --version' kept reporting 2.0.0 even on the 3.0 line. Now reads the version field from package.json at startup — stays in sync with whatever the package actually is. Caught while linking the local 3.0.0 build into biormin.
1 parent 4a3e8ab commit ea57f89

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/cli/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env node
22

3+
import { readFileSync } from 'node:fs';
4+
import { fileURLToPath } from 'node:url';
5+
import { dirname, join } from 'node:path';
36
import { Command } from 'commander';
47
import { cmdInit } from './commands/init.js';
58
import { cmdDeploy } from './commands/deploy.js';
@@ -25,12 +28,18 @@ import { cmdUpgrade } from './commands/upgrade.js';
2528
import { cmdBackupSetup, cmdBackupRun, cmdBackupStatus, cmdBackupList } from './commands/backup.js';
2629
import { cmdCloudflareInit, cmdCloudflareAudit, cmdCloudflareStatus } from './commands/cloudflare.js';
2730

31+
// Read version from package.json so `shipnode --version` stays in sync with the published
32+
// version automatically. The dist layout puts this file at dist/cli/index.js, so the
33+
// package.json is two levels up.
34+
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json');
35+
const { version } = JSON.parse(readFileSync(pkgPath, 'utf8')) as { version: string };
36+
2837
const program = new Command();
2938

3039
program
3140
.name('shipnode')
3241
.description('Deploy Node.js apps to a single VPS')
33-
.version('2.0.0');
42+
.version(version);
3443

3544
// ── Core ──────────────────────────────────────────────────────────
3645

0 commit comments

Comments
 (0)