@pcoliveira90/pdd 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli/index.js +18 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pcoliveira90/pdd",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Patch-Driven Development CLI — safe, resilient and guided code changes",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { readFileSync } from 'fs';
2
+ import { dirname, join } from 'path';
3
+ import { fileURLToPath } from 'url';
1
4
  import { runValidation } from '../core/validator.js';
2
5
  import { openPullRequest } from '../core/pr-manager.js';
3
6
  import { generatePatchArtifacts } from '../core/patch-generator.js';
@@ -6,6 +9,14 @@ import { runDoctor } from './doctor-command.js';
6
9
  import { runStatus } from './status-command.js';
7
10
  import { runResilientFixWorkflow } from '../core/fix-runner.js';
8
11
 
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+
14
+ function readCliVersion() {
15
+ const pkgPath = join(__dirname, '../../package.json');
16
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
17
+ return pkg.version;
18
+ }
19
+
9
20
  function parseFixArgs(argv) {
10
21
  const issue = argv
11
22
  .filter(arg => !arg.startsWith('--') && arg !== 'fix')
@@ -24,6 +35,11 @@ export async function runCli(argv = process.argv.slice(2)) {
24
35
  const command = argv[0];
25
36
  const cwd = process.cwd();
26
37
 
38
+ if (command === '--version' || command === '-v' || command === '-V' || command === 'version') {
39
+ console.log(readCliVersion());
40
+ return;
41
+ }
42
+
27
43
  if (command === 'init') {
28
44
  await runInit(argv);
29
45
  return;
@@ -90,7 +106,7 @@ export async function runCli(argv = process.argv.slice(2)) {
90
106
  }
91
107
 
92
108
  if (command === 'help' || !command) {
93
- console.log('PDD CLI');
109
+ console.log(`PDD CLI ${readCliVersion()}`);
94
110
  console.log('');
95
111
  console.log('Commands:');
96
112
  console.log(' pdd init <project-name>');
@@ -98,6 +114,7 @@ export async function runCli(argv = process.argv.slice(2)) {
98
114
  console.log(' pdd doctor [--fix]');
99
115
  console.log(' pdd status');
100
116
  console.log(' pdd fix "description" [--open-pr] [--dry-run] [--no-validate]');
117
+ console.log(' pdd version (or: pdd --version, pdd -v)');
101
118
  console.log('');
102
119
  console.log('Examples:');
103
120
  console.log(' pdd doctor --fix');