@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.
- package/README.md +55 -65
- package/bin/cli.js +39 -31
- 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
|
|
567
|
+
The preset supports two configuration modes:
|
|
568
568
|
|
|
569
|
-
### Mode 1:
|
|
569
|
+
### Mode 1: Direct Preset Usage (No Config File)
|
|
570
570
|
|
|
571
|
-
**When to use:** Simple projects
|
|
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
|
|
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:
|
|
589
|
+
### Mode 2: Preset + User Overrides (Recommended)
|
|
589
590
|
|
|
590
|
-
**When to use:** Customize specific options while
|
|
591
|
+
**When to use:** Customize specific options while keeping preset defaults
|
|
591
592
|
|
|
592
|
-
Create `.release-it.json` **
|
|
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
|
|
608
|
+
pnpm release-it-preset default
|
|
610
609
|
```
|
|
611
610
|
|
|
612
611
|
**How it works:**
|
|
613
|
-
-
|
|
614
|
-
- release-it merges your overrides on top
|
|
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
|
|
619
|
-
- ✅
|
|
620
|
-
- ✅
|
|
621
|
-
- ✅
|
|
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
|
|
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
|
|
635
|
+
pnpm release-it-preset hotfix
|
|
635
636
|
```
|
|
636
637
|
|
|
637
638
|
---
|
|
638
639
|
|
|
639
|
-
###
|
|
640
|
+
### Configuration Validation
|
|
640
641
|
|
|
641
|
-
|
|
642
|
+
The CLI validates your `.release-it.json` to prevent misconfigurations:
|
|
642
643
|
|
|
643
|
-
|
|
644
|
+
#### Error 1: Missing `extends` field
|
|
644
645
|
|
|
645
|
-
```
|
|
646
|
+
```bash
|
|
647
|
+
# .release-it.json without extends:
|
|
646
648
|
{
|
|
647
|
-
"
|
|
648
|
-
"git": {
|
|
649
|
-
"commitMessage": "custom: ${version}"
|
|
650
|
-
}
|
|
649
|
+
"git": { "requireBranch": "master" }
|
|
651
650
|
}
|
|
652
|
-
```
|
|
653
651
|
|
|
654
|
-
|
|
652
|
+
# Running:
|
|
653
|
+
pnpm release-it-preset default
|
|
655
654
|
|
|
656
|
-
|
|
657
|
-
|
|
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
|
-
**
|
|
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
|
-
|
|
670
|
+
#### Error 2: Preset mismatch
|
|
678
671
|
|
|
679
672
|
```bash
|
|
680
|
-
#
|
|
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
|
-
#
|
|
688
|
-
#
|
|
689
|
-
#
|
|
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
|
-
|
|
|
707
|
-
| Customize branch/commit
|
|
708
|
-
|
|
|
709
|
-
| Monorepo with
|
|
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
|
-
**
|
|
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
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
console.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
console.
|
|
149
|
-
console.
|
|
150
|
-
console.
|
|
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
|
|
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
|
|
174
|
+
console.log(` Tip: Create .release-it.json with "extends" to customize\n`);
|
|
167
175
|
fullArgs = ['--config', configPath, ...args];
|
|
168
176
|
}
|
|
169
177
|
|