cli-changescribe 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -16,6 +16,16 @@ Create a `.env.local` file in the repo where you run the CLI:
16
16
  GROQ_API_KEY="your-key-here"
17
17
  ```
18
18
 
19
+ ### Setup process (recommended)
20
+
21
+ 1. Install `cli-changescribe` (global or per repo).
22
+ 2. Add `.env.local` with `GROQ_API_KEY`.
23
+ 3. Run `npx changescribe init` to add npm scripts.
24
+ 4. If you plan to use `--create-pr`, install and auth GitHub CLI: `gh auth login`.
25
+ 5. Run a dry run to validate:
26
+ - `changescribe commit --dry-run`
27
+ - `changescribe pr --dry-run`
28
+
19
29
  Optional environment variables for PR summaries:
20
30
 
21
31
  - `PR_SUMMARY_BASE` (default: `main`)
@@ -46,6 +56,7 @@ changescribe commit
46
56
  changescribe pr --base main --mode release
47
57
  changescribe pr --base main --create-pr --mode release
48
58
  changescribe pr --dry-run
59
+ changescribe pr --create-pr --skip-format
49
60
  ```
50
61
 
51
62
  ### Npm script parity aliases
@@ -62,4 +73,32 @@ changescribe staging:pr
62
73
 
63
74
  - `changescribe commit` stages changes if nothing is staged and commits/pushes by default.
64
75
  - `changescribe pr` can create or update a GitHub PR when `--create-pr` is passed (requires `gh`).
76
+ - `feature:pr` and `staging:pr` aliases accept overrides (e.g., `--base main`).
77
+ - `--skip-format` (or `--no-format`) skips the format step during `--create-pr`.
65
78
  - The CLI must be run inside a git repo.
79
+
80
+ ## Branching and CI/CD recommendation
81
+
82
+ We recommend a simple main/staging/feature flow:
83
+
84
+ - `feature/*` branches merge into `staging` via PRs (`changescribe feature:pr`).
85
+ - `staging` merges into `main` for releases (`changescribe staging:pr`).
86
+ - Use `--base main` or `--base staging` to override if your repo differs.
87
+
88
+ Recommended CI checks on PRs:
89
+ - `feature/*` → `staging`: lint/test/build (or your standard checks).
90
+ - `staging` → `main`: lint/test/build + any release verification.
91
+
92
+ ## Formatting recommendation
93
+
94
+ We use Biome via Ultracite. If your project matches our setup, add a `format` script like:
95
+
96
+ ```bash
97
+ ultracite format
98
+ ```
99
+
100
+ You can also pair it with a lint check:
101
+
102
+ ```bash
103
+ ultracite lint || (ultracite format && ultracite lint)
104
+ ```
@@ -30,6 +30,10 @@ async function main() {
30
30
  printHelp();
31
31
  return;
32
32
  }
33
+ if (rest.includes('-h') || rest.includes('--help')) {
34
+ printHelp();
35
+ return;
36
+ }
33
37
 
34
38
  if (command === 'commit') {
35
39
  await runCommit(rest);
@@ -47,12 +51,26 @@ async function main() {
47
51
  }
48
52
 
49
53
  if (command === 'feature:pr') {
50
- await runPrSummary(['--base', 'staging', '--create-pr', '--mode', 'feature']);
54
+ await runPrSummary([
55
+ '--base',
56
+ 'staging',
57
+ '--create-pr',
58
+ '--mode',
59
+ 'feature',
60
+ ...rest,
61
+ ]);
51
62
  return;
52
63
  }
53
64
 
54
65
  if (command === 'staging:pr') {
55
- await runPrSummary(['--base', 'main', '--create-pr', '--mode', 'release']);
66
+ await runPrSummary([
67
+ '--base',
68
+ 'main',
69
+ '--create-pr',
70
+ '--mode',
71
+ 'release',
72
+ ...rest,
73
+ ]);
56
74
  return;
57
75
  }
58
76
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "cli-changescribe",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "CLI for generating commit messages and PR summaries",
5
5
  "bin": {
6
- "changescribe": "./bin/changescribe.js"
6
+ "changescribe": "bin/changescribe.js"
7
7
  },
8
8
  "type": "commonjs",
9
9
  "files": [
package/src/pr-summary.js CHANGED
@@ -495,6 +495,17 @@ function checkExistingPr(base, head) {
495
495
  }
496
496
  }
497
497
 
498
+ function hasNpmScript(scriptName, cwd = process.cwd()) {
499
+ try {
500
+ const packagePath = path.join(cwd, 'package.json');
501
+ const raw = fs.readFileSync(packagePath, 'utf8');
502
+ const pkg = JSON.parse(raw);
503
+ return Boolean(pkg?.scripts?.[scriptName]);
504
+ } catch {
505
+ return false;
506
+ }
507
+ }
508
+
498
509
  function extractPrTitle(summary, mode) {
499
510
  const targetSection = mode === 'release' ? 'release summary' : 'what change';
500
511
  // Try to extract a title from the summary
@@ -673,6 +684,7 @@ function parseArgs(argv) {
673
684
  issue: DEFAULT_ISSUE,
674
685
  createPr: false,
675
686
  mode: '',
687
+ skipFormat: false,
676
688
  };
677
689
 
678
690
  for (let i = 0; i < argv.length; i += 1) {
@@ -693,6 +705,8 @@ function parseArgs(argv) {
693
705
  args.dryRun = true;
694
706
  } else if (current === '--create-pr') {
695
707
  args.createPr = true;
708
+ } else if (current === '--skip-format' || current === '--no-format') {
709
+ args.skipFormat = true;
696
710
  } else if (current === '--mode' && argv[i + 1]) {
697
711
  args.mode = argv[i + 1];
698
712
  i += 1;
@@ -752,12 +766,18 @@ async function main(argv) {
752
766
  // Safety checks before creating PR
753
767
  if (args.createPr) {
754
768
  // Run format as a last-minute verification step
755
- step('Running npm run format before PR creation...');
756
- try {
757
- execSync('npm run format', { encoding: 'utf8', stdio: 'inherit' });
758
- } catch (_error) {
759
- fail('npm run format failed; fix formatting errors first.');
760
- process.exit(1);
769
+ if (args.skipFormat) {
770
+ warn('Skipping format step (flagged)');
771
+ } else if (!hasNpmScript('format')) {
772
+ warn('Skipping format step (no npm script named "format")');
773
+ } else {
774
+ step('Running npm run format before PR creation...');
775
+ try {
776
+ execSync('npm run format', { encoding: 'utf8', stdio: 'inherit' });
777
+ } catch (_error) {
778
+ fail('npm run format failed; fix formatting errors first.');
779
+ process.exit(1);
780
+ }
761
781
  }
762
782
 
763
783
  // Run tests as an extra verification step