@oorabona/release-it-preset 0.8.0 → 0.8.1

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 (3) hide show
  1. package/README.md +55 -65
  2. package/bin/cli.js +39 -31
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -564,16 +564,16 @@ pnpm release
564
564
 
565
565
  ## Configuration Modes
566
566
 
567
- The preset supports three configuration modes to suit different workflows:
567
+ The preset supports two configuration modes:
568
568
 
569
- ### Mode 1: CLI Only (No Config File)
569
+ ### Mode 1: Direct Preset Usage (No Config File)
570
570
 
571
- **When to use:** Simple projects with minimal customization needs
571
+ **When to use:** Simple projects, trust preset defaults, or customize only via environment variables
572
572
 
573
573
  Don't create `.release-it.json`. Just run the CLI:
574
574
 
575
575
  ```bash
576
- pnpm release-it-preset hotfix
576
+ pnpm release-it-preset default
577
577
  ```
578
578
 
579
579
  All configuration comes from the preset and environment variables.
@@ -582,23 +582,22 @@ All configuration comes from the preset and environment variables.
582
582
  - ✅ Zero config files
583
583
  - ✅ Consistent behavior across projects
584
584
  - ✅ Easy to understand
585
+ - ✅ Perfect for getting started
585
586
 
586
587
  ---
587
588
 
588
- ### Mode 2: CLI + User Overrides (Recommended)
589
+ ### Mode 2: Preset + User Overrides (Recommended)
589
590
 
590
- **When to use:** Customize specific options while using CLI presets
591
+ **When to use:** Customize specific options while keeping preset defaults
591
592
 
592
- Create `.release-it.json` **WITHOUT the `extends` field**:
593
+ Create `.release-it.json` **WITH the `extends` field**:
593
594
 
594
595
  ```json
595
596
  {
597
+ "extends": "@oorabona/release-it-preset/config/default",
596
598
  "git": {
597
599
  "requireBranch": "master",
598
600
  "commitMessage": "chore: release v${version}"
599
- },
600
- "npm": {
601
- "publish": true
602
601
  }
603
602
  }
604
603
  ```
@@ -606,24 +605,26 @@ Create `.release-it.json` **WITHOUT the `extends` field**:
606
605
  Run with CLI preset:
607
606
 
608
607
  ```bash
609
- pnpm release-it-preset hotfix
608
+ pnpm release-it-preset default
610
609
  ```
611
610
 
612
611
  **How it works:**
613
- - CLI selects the preset (`hotfix` in this example)
614
- - release-it merges your overrides on top of the preset
612
+ - The `extends` field loads the preset
613
+ - release-it merges your overrides on top via c12
615
614
  - **Your values take precedence** over preset defaults
615
+ - CLI validates that `extends` matches the command
616
616
 
617
617
  **Pros:**
618
- - ✅ **Recommended approach** for most use cases
619
- - ✅ CLI controls preset selection
620
- - ✅ Declarative overrides in config file
621
- - ✅ No `extends` maintenance needed
618
+ - ✅ **Recommended for customization**
619
+ - ✅ Declarative config with explicit preset
620
+ - ✅ Industry standard pattern (like ESLint, TypeScript)
621
+ - ✅ Guaranteed config merging via release-it's c12
622
622
 
623
- **Example use case:** You want to use the `hotfix` preset but require releases from `master` instead of `main`:
623
+ **Example:** Using `hotfix` preset but release from `master` instead of `main`:
624
624
 
625
625
  ```json
626
626
  {
627
+ "extends": "@oorabona/release-it-preset/config/hotfix",
627
628
  "git": {
628
629
  "requireBranch": "master"
629
630
  }
@@ -631,84 +632,73 @@ pnpm release-it-preset hotfix
631
632
  ```
632
633
 
633
634
  ```bash
634
- pnpm release-it-preset hotfix # Uses hotfix preset + your branch override
635
+ pnpm release-it-preset hotfix
635
636
  ```
636
637
 
637
638
  ---
638
639
 
639
- ### Mode 3: File with Extends (Advanced)
640
+ ### Configuration Validation
640
641
 
641
- **When to use:** Lock a specific preset regardless of CLI command
642
+ The CLI validates your `.release-it.json` to prevent misconfigurations:
642
643
 
643
- Create `.release-it.json` **WITH the `extends` field**:
644
+ #### Error 1: Missing `extends` field
644
645
 
645
- ```json
646
+ ```bash
647
+ # .release-it.json without extends:
646
648
  {
647
- "extends": "@oorabona/release-it-preset/config/hotfix",
648
- "git": {
649
- "commitMessage": "custom: ${version}"
650
- }
649
+ "git": { "requireBranch": "master" }
651
650
  }
652
- ```
653
651
 
654
- Run matching CLI command:
652
+ # Running:
653
+ pnpm release-it-preset default
655
654
 
656
- ```bash
657
- pnpm release-it-preset hotfix # Must match the extends!
655
+ # ❌ Configuration error!
656
+ # .release-it.json is missing the required "extends" field.
657
+ #
658
+ # Without "extends", your config won't merge with the preset.
659
+ # This means you'll get release-it defaults instead of preset defaults.
660
+ #
661
+ # Fix by adding this to .release-it.json:
662
+ # {
663
+ # "extends": "@oorabona/release-it-preset/config/default",
664
+ # ...your overrides
665
+ # }
658
666
  ```
659
667
 
660
- **How it works:**
661
- - The `extends` field locks the preset
662
- - CLI command **must match** the preset in `extends`
663
- - Mismatch triggers an error
664
-
665
- **Pros:**
666
- - ✅ Prevents accidental use of wrong presets
667
- - ✅ Explicit preset declaration in config
668
-
669
- **Cons:**
670
- - ⚠️ Less flexible (preset locked in file)
671
- - ⚠️ Requires updating `extends` to switch presets
672
-
673
- ---
674
-
675
- ### Configuration Error Handling
668
+ **Why `extends` is required:** Without it, release-it only loads your config file and uses release-it's own defaults. The preset is never loaded, so you lose important defaults like `npm.publish: false`.
676
669
 
677
- If your `.release-it.json` has an `extends` field that doesn't match the CLI command, you'll get a clear error:
670
+ #### Error 2: Preset mismatch
678
671
 
679
672
  ```bash
680
- # Your config extends "default", but you run:
673
+ # .release-it.json extends "default":
674
+ {
675
+ "extends": "@oorabona/release-it-preset/config/default"
676
+ }
677
+
678
+ # But you run:
681
679
  pnpm release-it-preset hotfix
682
680
 
683
681
  # ❌ Configuration mismatch error!
684
682
  # CLI preset: hotfix
685
683
  # .release-it.json extends: default
686
684
  #
687
- # Either:
688
- # 1. Remove the "extends" field from .release-it.json (recommended)
689
- # Your overrides will merge with the CLI preset automatically
690
- #
691
- # 2. Run: release-it-preset default
692
- # → Use the preset specified in your config file
693
- #
694
- # 3. Update .release-it.json extends to: "@oorabona/release-it-preset/config/hotfix"
695
- # → Match your config file to the CLI command
685
+ # Either:
686
+ # 1. Run: release-it-preset default
687
+ # 2. Update .release-it.json extends to: "@oorabona/release-it-preset/config/hotfix"
696
688
  ```
697
689
 
698
- This prevents silent misconfigurations where the wrong preset runs unexpectedly.
699
-
700
690
  ---
701
691
 
702
692
  ### Which Mode Should I Use?
703
693
 
704
694
  | Scenario | Recommended Mode |
705
695
  |----------|------------------|
706
- | Minimal config, trust defaults | **Mode 1** (CLI only) |
707
- | Customize branch/commit messages | **Mode 2** (CLI + overrides) |
708
- | Lock preset for safety | **Mode 3** (File with extends) |
709
- | Monorepo with different presets per package | **Mode 2** (CLI + overrides) |
696
+ | Quick start, minimal config | **Mode 1** (No config file) |
697
+ | Customize branch/commit/hooks | **Mode 2** (Config with extends) |
698
+ | Environment-only customization | **Mode 1** (Use env vars) |
699
+ | Monorepo with per-package config | **Mode 2** (Each package has own config) |
710
700
 
711
- **Most users should use Mode 2** for the best balance of flexibility and clarity.
701
+ **Use Mode 1 to get started, switch to Mode 2 when you need customization.**
712
702
 
713
703
  ## Borrowing Scripts & Workflows
714
704
 
package/bin/cli.js CHANGED
@@ -119,36 +119,44 @@ function handleReleaseCommand(configName, args) {
119
119
 
120
120
  const expectedExtends = `@oorabona/release-it-preset/config/${configName}`;
121
121
 
122
- if (userConfig.extends) {
123
- // If extends exists, it MUST match the CLI preset
124
- const extendsMatch = userConfig.extends.match(/@oorabona\/release-it-preset\/config\/(\w+)/);
125
- const extendsPreset = extendsMatch?.[1];
126
-
127
- if (extendsPreset && extendsPreset !== configName) {
128
- console.error(`\n❌ Configuration mismatch error!`);
129
- console.error(` CLI preset: ${configName}`);
130
- console.error(` .release-it.json extends: ${extendsPreset}`);
131
- console.error(``);
132
- console.error(`Either:`);
133
- console.error(` 1. Remove the "extends" field from .release-it.json (recommended)`);
134
- console.error(` → Your overrides will merge with the CLI preset automatically`);
135
- console.error(``);
136
- console.error(` 2. Run: release-it-preset ${extendsPreset}`);
137
- console.error(` → Use the preset specified in your config file`);
138
- console.error(``);
139
- console.error(` 3. Update .release-it.json extends to: "${expectedExtends}"`);
140
- console.error(` → Match your config file to the CLI command\n`);
141
- process.exit(1);
142
- }
143
-
144
- console.log(`✅ Config file extends matches CLI preset: ${configName}`);
145
- console.log(`📝 Using: ${userConfigPath}\n`);
146
- } else {
147
- // No extends = natural merge (Mode 3 - Hybrid)
148
- console.log(`📝 Merging CLI preset "${configName}" with user config overrides`);
149
- console.log(` Config file: ${userConfigPath}`);
150
- console.log(` User overrides will take precedence\n`);
122
+ if (!userConfig.extends) {
123
+ // ERROR: extends is required for config merging
124
+ console.error(`\n❌ Configuration error!`);
125
+ console.error(` .release-it.json is missing the required "extends" field.`);
126
+ console.error(``);
127
+ console.error(`Without "extends", your config won't merge with the preset.`);
128
+ console.error(`This means you'll get release-it defaults instead of preset defaults.`);
129
+ console.error(``);
130
+ console.error(`Fix by adding this to .release-it.json:`);
131
+ console.error(` {`);
132
+ console.error(` "extends": "${expectedExtends}",`);
133
+ console.error(` ...your overrides`);
134
+ console.error(` }`);
135
+ console.error(``);
136
+ console.error(`Or remove .release-it.json to use the preset directly.\n`);
137
+ process.exit(1);
138
+ }
139
+
140
+ // Validate extends matches CLI preset
141
+ const extendsMatch = userConfig.extends.match(/@oorabona\/release-it-preset\/config\/(\w+)/);
142
+ const extendsPreset = extendsMatch?.[1];
143
+
144
+ if (extendsPreset && extendsPreset !== configName) {
145
+ console.error(`\n❌ Configuration mismatch error!`);
146
+ console.error(` CLI preset: ${configName}`);
147
+ console.error(` .release-it.json extends: ${extendsPreset}`);
148
+ console.error(``);
149
+ console.error(`Either:`);
150
+ console.error(` 1. Run: release-it-preset ${extendsPreset}`);
151
+ console.error(` → Use the preset specified in your config file`);
152
+ console.error(``);
153
+ console.error(` 2. Update .release-it.json extends to: "${expectedExtends}"`);
154
+ console.error(` → Match your config file to the CLI command\n`);
155
+ process.exit(1);
151
156
  }
157
+
158
+ console.log(`✅ Config validated: preset "${configName}"`);
159
+ console.log(`📝 Using: ${userConfigPath}\n`);
152
160
  } catch (error) {
153
161
  if (error instanceof SyntaxError) {
154
162
  console.error(`❌ Failed to parse .release-it.json: ${error.message}`);
@@ -158,12 +166,12 @@ function handleReleaseCommand(configName, args) {
158
166
  process.exit(1);
159
167
  }
160
168
 
161
- // Let release-it handle the merge naturally
169
+ // Let release-it discover .release-it.json and merge via extends
162
170
  fullArgs = [...args];
163
171
  } else {
164
172
  // No user config - use preset directly
165
173
  console.log(`📝 Using preset config directly: ${configPath}`);
166
- console.log(` Tip: Create .release-it.json (without "extends") to add overrides\n`);
174
+ console.log(` Tip: Create .release-it.json with "extends" to customize\n`);
167
175
  fullArgs = ['--config', configPath, ...args];
168
176
  }
169
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oorabona/release-it-preset",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Shared release-it configuration and scripts for the organisation",
5
5
  "type": "module",
6
6
  "keywords": [