@repo-toolkit/changelog 0.7.2 → 0.8.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/cli.js +14 -21
- package/index.js +6 -15
- package/package.json +2 -2
package/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import {
|
|
4
|
+
import { parseFlags, INTERACTIVE_FLAG, resolveCliOptions } from "@repo-toolkit/publish-package";
|
|
5
5
|
|
|
6
6
|
// src/index.ts
|
|
7
7
|
import { createWriteStream } from "fs";
|
|
@@ -133,9 +133,10 @@ async function createPreset(options = {}) {
|
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
async function createGenerator(options = {}) {
|
|
136
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
136
137
|
const presetOptions = splitPresetOptions(options);
|
|
137
138
|
const preset = await createPreset(presetOptions);
|
|
138
|
-
const generator = new ConventionalChangelog();
|
|
139
|
+
const generator = new ConventionalChangelog(cwd);
|
|
139
140
|
const generatorOptions = {
|
|
140
141
|
append: options.append ?? false,
|
|
141
142
|
releaseCount: options.releaseCount ?? 0,
|
|
@@ -144,7 +145,7 @@ async function createGenerator(options = {}) {
|
|
|
144
145
|
tagPrefix: options.tagPrefix ?? "v",
|
|
145
146
|
firstRelease: options.firstRelease ?? false
|
|
146
147
|
};
|
|
147
|
-
generator.readPackage().loadPreset(preset).options(generatorOptions).config({
|
|
148
|
+
generator.readPackage(resolve(cwd, "package.json")).loadPreset(preset).options(generatorOptions).config({
|
|
148
149
|
tags: preset.tags,
|
|
149
150
|
commits: preset.commits,
|
|
150
151
|
parser: preset.parser,
|
|
@@ -153,21 +154,11 @@ async function createGenerator(options = {}) {
|
|
|
153
154
|
return generator;
|
|
154
155
|
}
|
|
155
156
|
async function generateChangelog(options = {}) {
|
|
156
|
-
const
|
|
157
|
-
const cwd = resolve(options.cwd ?? initialCwd);
|
|
157
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
158
158
|
const outputPath = resolveOutputPath(cwd, options.outputFile ?? "CHANGELOG.md");
|
|
159
159
|
await mkdir(dirname(outputPath), { recursive: true });
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
try {
|
|
164
|
-
const generator = await createGenerator(options);
|
|
165
|
-
return await pipeGeneratorToFile(generator, outputPath);
|
|
166
|
-
} finally {
|
|
167
|
-
if (cwd !== initialCwd) {
|
|
168
|
-
process.chdir(initialCwd);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
160
|
+
const generator = await createGenerator({ ...options, cwd });
|
|
161
|
+
return await pipeGeneratorToFile(generator, outputPath);
|
|
171
162
|
}
|
|
172
163
|
|
|
173
164
|
// src/cli.ts
|
|
@@ -180,7 +171,8 @@ var SPECS = [
|
|
|
180
171
|
{ name: "append", boolean: true, negatable: true },
|
|
181
172
|
{ name: "first-release", boolean: true, negatable: true },
|
|
182
173
|
{ name: "skip-unstable", boolean: true, negatable: true },
|
|
183
|
-
{ name: "output-unreleased", boolean: true, negatable: true }
|
|
174
|
+
{ name: "output-unreleased", boolean: true, negatable: true },
|
|
175
|
+
INTERACTIVE_FLAG
|
|
184
176
|
];
|
|
185
177
|
function printHelp() {
|
|
186
178
|
console.log(`repo-toolkit-changelog
|
|
@@ -198,6 +190,7 @@ Options:
|
|
|
198
190
|
--first-release Include all commits when no prior release tag exists
|
|
199
191
|
--no-skip-unstable Include unstable releases
|
|
200
192
|
--no-output-unreleased Omit the unreleased section
|
|
193
|
+
-i, --interactive Prompt for missing required values interactively
|
|
201
194
|
-h, --help Show this help message
|
|
202
195
|
`);
|
|
203
196
|
}
|
|
@@ -227,10 +220,10 @@ async function main() {
|
|
|
227
220
|
printHelp();
|
|
228
221
|
return;
|
|
229
222
|
}
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
223
|
+
const merged = await resolveCliOptions({
|
|
224
|
+
result,
|
|
225
|
+
buildOptions: (flags) => buildOptions(flags.values)
|
|
226
|
+
});
|
|
234
227
|
const outputPath = await generateChangelog(merged);
|
|
235
228
|
console.log(`Changelog generated at ${outputPath}.`);
|
|
236
229
|
}
|
package/index.js
CHANGED
|
@@ -128,9 +128,10 @@ async function createPreset(options = {}) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
async function createGenerator(options = {}) {
|
|
131
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
131
132
|
const presetOptions = splitPresetOptions(options);
|
|
132
133
|
const preset = await createPreset(presetOptions);
|
|
133
|
-
const generator = new ConventionalChangelog();
|
|
134
|
+
const generator = new ConventionalChangelog(cwd);
|
|
134
135
|
const generatorOptions = {
|
|
135
136
|
append: options.append ?? false,
|
|
136
137
|
releaseCount: options.releaseCount ?? 0,
|
|
@@ -139,7 +140,7 @@ async function createGenerator(options = {}) {
|
|
|
139
140
|
tagPrefix: options.tagPrefix ?? "v",
|
|
140
141
|
firstRelease: options.firstRelease ?? false
|
|
141
142
|
};
|
|
142
|
-
generator.readPackage().loadPreset(preset).options(generatorOptions).config({
|
|
143
|
+
generator.readPackage(resolve(cwd, "package.json")).loadPreset(preset).options(generatorOptions).config({
|
|
143
144
|
tags: preset.tags,
|
|
144
145
|
commits: preset.commits,
|
|
145
146
|
parser: preset.parser,
|
|
@@ -148,21 +149,11 @@ async function createGenerator(options = {}) {
|
|
|
148
149
|
return generator;
|
|
149
150
|
}
|
|
150
151
|
async function generateChangelog(options = {}) {
|
|
151
|
-
const
|
|
152
|
-
const cwd = resolve(options.cwd ?? initialCwd);
|
|
152
|
+
const cwd = resolve(options.cwd ?? process.cwd());
|
|
153
153
|
const outputPath = resolveOutputPath(cwd, options.outputFile ?? "CHANGELOG.md");
|
|
154
154
|
await mkdir(dirname(outputPath), { recursive: true });
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
const generator = await createGenerator(options);
|
|
160
|
-
return await pipeGeneratorToFile(generator, outputPath);
|
|
161
|
-
} finally {
|
|
162
|
-
if (cwd !== initialCwd) {
|
|
163
|
-
process.chdir(initialCwd);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
155
|
+
const generator = await createGenerator({ ...options, cwd });
|
|
156
|
+
return await pipeGeneratorToFile(generator, outputPath);
|
|
166
157
|
}
|
|
167
158
|
export {
|
|
168
159
|
DEFAULT_TYPES,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repo-toolkit/changelog",
|
|
3
3
|
"description": "Shared conventional changelog preset, generator, and CLI for repository releases",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"node": ">=20"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@repo-toolkit/publish-package": "0.
|
|
30
|
+
"@repo-toolkit/publish-package": "0.8.0",
|
|
31
31
|
"conventional-changelog": "^7.2.1",
|
|
32
32
|
"conventional-changelog-conventionalcommits": "^9.3.1"
|
|
33
33
|
},
|