@alleyinteractive/changelog-extractor 0.3.0 ā 0.4.0
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 +16 -4
- package/package.json +1 -1
- package/src/cli.js +35 -9
package/README.md
CHANGED
|
@@ -21,8 +21,6 @@ as both a **GitHub Action** and a **CLI tool**.
|
|
|
21
21
|
|
|
22
22
|
#### Extract All Versions
|
|
23
23
|
|
|
24
|
-
### Extract All Versions
|
|
25
|
-
|
|
26
24
|
By default, the action returns all versions in the changelog:
|
|
27
25
|
|
|
28
26
|
```yaml
|
|
@@ -36,7 +34,7 @@ By default, the action returns all versions in the changelog:
|
|
|
36
34
|
echo '${{ fromJson(steps.changelog.outputs.result)[0].contents }}'
|
|
37
35
|
```
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
#### Extract Specific Version
|
|
40
38
|
|
|
41
39
|
```yaml
|
|
42
40
|
- name: Extract v1.14.0 Changelog
|
|
@@ -47,7 +45,7 @@ By default, the action returns all versions in the changelog:
|
|
|
47
45
|
version: '1.14.0' # or 'v1.14.0'
|
|
48
46
|
```
|
|
49
47
|
|
|
50
|
-
|
|
48
|
+
#### Create Release from Latest Version
|
|
51
49
|
|
|
52
50
|
```yaml
|
|
53
51
|
name: Release
|
|
@@ -141,6 +139,20 @@ npm install -g @alleyinteractive/changelog-extractor
|
|
|
141
139
|
changelog-extractor
|
|
142
140
|
```
|
|
143
141
|
|
|
142
|
+
By default, the CLI outputs JSON to stdout. You can also specify other output
|
|
143
|
+
formats using the `--format` option:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
# JSON output (default)
|
|
147
|
+
npx @alleyinteractive/changelog-extractor --format json
|
|
148
|
+
|
|
149
|
+
# Pretty-printed dump
|
|
150
|
+
npx @alleyinteractive/changelog-extractor --format dump
|
|
151
|
+
|
|
152
|
+
# Plain text output
|
|
153
|
+
npx @alleyinteractive/changelog-extractor --format text
|
|
154
|
+
```
|
|
155
|
+
|
|
144
156
|
## Supported Changelog Format
|
|
145
157
|
|
|
146
158
|
This action parses changelogs following the
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -20,6 +20,7 @@ function printUsage() {
|
|
|
20
20
|
Usage: npx @alleyinteractive/changelog-extractor [options]
|
|
21
21
|
|
|
22
22
|
Options:
|
|
23
|
+
--format <type> Output format (default: "json"). Options: dump, text, json.
|
|
23
24
|
-f, --file <path> Path to changelog file (default: CHANGELOG.md)
|
|
24
25
|
-v, --version <ver> Specific version to extract (e.g., "1.14.0" or "v1.14.0")
|
|
25
26
|
Leave empty to return all versions
|
|
@@ -64,6 +65,20 @@ if (versionIndex !== -1 && args[versionIndex + 1]) {
|
|
|
64
65
|
|
|
65
66
|
const version = versionArg
|
|
66
67
|
|
|
68
|
+
// Parse format option.
|
|
69
|
+
let format = 'json'
|
|
70
|
+
const formatIndex = args.findIndex((arg) => arg === '--format')
|
|
71
|
+
if (formatIndex !== -1 && args[formatIndex + 1]) {
|
|
72
|
+
format = args[formatIndex + 1].toLowerCase()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!['json', 'dump', 'text'].includes(format)) {
|
|
76
|
+
console.error(
|
|
77
|
+
`ā Error: Invalid format "${format}". Valid options are: json, dump, text.`
|
|
78
|
+
)
|
|
79
|
+
process.exit(1)
|
|
80
|
+
}
|
|
81
|
+
|
|
67
82
|
// Read changelog file
|
|
68
83
|
const changelogPath = path.resolve(process.cwd(), changelogFile)
|
|
69
84
|
|
|
@@ -86,18 +101,28 @@ try {
|
|
|
86
101
|
process.exit(0)
|
|
87
102
|
}
|
|
88
103
|
|
|
104
|
+
// Default JSON output.
|
|
105
|
+
if (format === 'json') {
|
|
106
|
+
process.stdout.write(JSON.stringify(results, null, 2) + '\n')
|
|
107
|
+
process.exit(0)
|
|
108
|
+
}
|
|
109
|
+
|
|
89
110
|
// Parse changelog
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
111
|
+
if (format === 'dump') {
|
|
112
|
+
console.log(`š Parsing: ${changelogPath}`)
|
|
113
|
+
console.log(`šÆ Version: ${versionArg || 'all versions'}`)
|
|
114
|
+
console.log('')
|
|
115
|
+
}
|
|
93
116
|
|
|
94
117
|
if (results.length === 0) {
|
|
95
118
|
console.log('ā ļø No changelog entries found')
|
|
96
119
|
process.exit(1)
|
|
97
120
|
}
|
|
98
121
|
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
if (format === 'dump') {
|
|
123
|
+
console.log(`ā
Found ${results.length} version(s)\n`)
|
|
124
|
+
console.log('ā'.repeat(80))
|
|
125
|
+
}
|
|
101
126
|
|
|
102
127
|
// Pretty print results
|
|
103
128
|
results.forEach((entry, index) => {
|
|
@@ -126,10 +151,11 @@ try {
|
|
|
126
151
|
}
|
|
127
152
|
})
|
|
128
153
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
154
|
+
if (format === 'dump') {
|
|
155
|
+
console.log('\n' + 'ā'.repeat(80))
|
|
156
|
+
console.log('\nš JSON Output:\n')
|
|
157
|
+
process.stdout.write(JSON.stringify(results, null, 2) + '\n')
|
|
158
|
+
}
|
|
133
159
|
} catch (error) {
|
|
134
160
|
console.error('ā Error parsing changelog:', error.message)
|
|
135
161
|
process.exit(1)
|