@haystackeditor/cli 0.14.2 → 0.14.3
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/index.js +16 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
* npx @haystackeditor/cli pr-status 123 # Show PR status in Haystack pipeline
|
|
20
20
|
* npx @haystackeditor/cli config # Manage preferences
|
|
21
21
|
*/
|
|
22
|
+
import { readFileSync } from 'node:fs';
|
|
23
|
+
import { fileURLToPath } from 'node:url';
|
|
24
|
+
import { dirname, join } from 'node:path';
|
|
22
25
|
import { Command } from 'commander';
|
|
23
26
|
import { statusCommand } from './commands/status.js';
|
|
24
27
|
import { initCommand } from './commands/init.js';
|
|
@@ -34,11 +37,23 @@ import { dismissCommand, markReviewedCommand, undismissCommand } from './command
|
|
|
34
37
|
import { requestReviewCommand } from './commands/request-review.js';
|
|
35
38
|
import { prStatusCommand } from './commands/pr-status.js';
|
|
36
39
|
import { setupCommand } from './commands/setup.js';
|
|
40
|
+
/** Read the published version from package.json (dist/index.js → ../package.json)
|
|
41
|
+
* so `haystack --version` can't drift from the package version. Falls back
|
|
42
|
+
* gracefully so the flag never throws if the file can't be read. */
|
|
43
|
+
function getVersion() {
|
|
44
|
+
try {
|
|
45
|
+
const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
|
|
46
|
+
return JSON.parse(readFileSync(pkgPath, 'utf8')).version ?? '0.0.0';
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return '0.0.0';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
37
52
|
const program = new Command();
|
|
38
53
|
program
|
|
39
54
|
.name('haystack')
|
|
40
55
|
.description('Haystack CLI — automated PR review, triage, and merge queue')
|
|
41
|
-
.version(
|
|
56
|
+
.version(getVersion());
|
|
42
57
|
program
|
|
43
58
|
.command('init')
|
|
44
59
|
.description('Create .haystack.json configuration')
|