@scalar/release-notes 0.1.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/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/commands/generate.d.ts +5 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +105 -0
- package/dist/commands/sync-markdown.d.ts +5 -0
- package/dist/commands/sync-markdown.d.ts.map +1 -0
- package/dist/commands/sync-markdown.js +25 -0
- package/dist/config/define-config.d.ts +6 -0
- package/dist/config/define-config.d.ts.map +1 -0
- package/dist/config/define-config.js +4 -0
- package/dist/config/read-config.d.ts +18 -0
- package/dist/config/read-config.d.ts.map +1 -0
- package/dist/config/read-config.js +86 -0
- package/dist/config/types.d.ts +70 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +1 -0
- package/dist/core/detect-versioned-changelog-paths.d.ts +5 -0
- package/dist/core/detect-versioned-changelog-paths.d.ts.map +1 -0
- package/dist/core/detect-versioned-changelog-paths.js +56 -0
- package/dist/core/extract-changelog-section.d.ts +5 -0
- package/dist/core/extract-changelog-section.d.ts.map +1 -0
- package/dist/core/extract-changelog-section.js +16 -0
- package/dist/core/fetch-pull-requests.d.ts +28 -0
- package/dist/core/fetch-pull-requests.d.ts.map +1 -0
- package/dist/core/fetch-pull-requests.js +65 -0
- package/dist/core/generate-release-note.d.ts +45 -0
- package/dist/core/generate-release-note.d.ts.map +1 -0
- package/dist/core/generate-release-note.js +186 -0
- package/dist/core/paths.d.ts +7 -0
- package/dist/core/paths.d.ts.map +1 -0
- package/dist/core/paths.js +13 -0
- package/dist/core/products.d.ts +8 -0
- package/dist/core/products.d.ts.map +1 -0
- package/dist/core/products.js +12 -0
- package/dist/core/run-release-notes-generator.d.ts +26 -0
- package/dist/core/run-release-notes-generator.d.ts.map +1 -0
- package/dist/core/run-release-notes-generator.js +150 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/providers/anthropic.d.ts +9 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +53 -0
- package/dist/providers/openai.d.ts +9 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +54 -0
- package/dist/types.d.ts +129 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +167 -0
- package/dist/writers/write-release-notes-json.d.ts +15 -0
- package/dist/writers/write-release-notes-json.d.ts.map +1 -0
- package/dist/writers/write-release-notes-json.js +114 -0
- package/dist/writers/write-release-notes-markdown.d.ts +13 -0
- package/dist/writers/write-release-notes-markdown.d.ts.map +1 -0
- package/dist/writers/write-release-notes-markdown.js +23 -0
- package/dist/writers/write-release-notes-schema.d.ts +20 -0
- package/dist/writers/write-release-notes-schema.d.ts.map +1 -0
- package/dist/writers/write-release-notes-schema.js +37 -0
- package/package.json +68 -0
- package/schemas/release-notes.schema.json +232 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present Scalar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# @scalar/release-notes
|
|
2
|
+
|
|
3
|
+
Generate curated release notes from Changesets-style `CHANGELOG.md` files and write a stable `RELEASE_NOTES.json` file, with optional derived Markdown output.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -D @scalar/release-notes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## CLI
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
scalar-release-notes --all --provider anthropic --model claude-sonnet-4-5
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For a single package without a config file:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
scalar-release-notes \
|
|
21
|
+
--package @example/client \
|
|
22
|
+
--changelog packages/client/CHANGELOG.md \
|
|
23
|
+
--output packages/client/RELEASE_NOTES.json \
|
|
24
|
+
--provider openai \
|
|
25
|
+
--model gpt-4.1-mini
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Configuration
|
|
29
|
+
|
|
30
|
+
Create `release-notes.config.mjs`:
|
|
31
|
+
|
|
32
|
+
```js
|
|
33
|
+
import { createAnthropicProvider, defineReleaseNotesConfig } from '@scalar/release-notes'
|
|
34
|
+
|
|
35
|
+
export default defineReleaseNotesConfig({
|
|
36
|
+
provider: createAnthropicProvider({
|
|
37
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
38
|
+
model: 'claude-sonnet-4-5',
|
|
39
|
+
}),
|
|
40
|
+
github: {
|
|
41
|
+
repo: 'owner/repo',
|
|
42
|
+
token: process.env.GITHUB_TOKEN,
|
|
43
|
+
baseBranch: 'main',
|
|
44
|
+
},
|
|
45
|
+
products: [
|
|
46
|
+
{
|
|
47
|
+
slug: 'client',
|
|
48
|
+
packageName: '@example/client',
|
|
49
|
+
displayName: 'Example Client',
|
|
50
|
+
description: 'an API client for Example',
|
|
51
|
+
changelogPath: 'packages/client/CHANGELOG.md',
|
|
52
|
+
outputPath: 'packages/client/RELEASE_NOTES.json',
|
|
53
|
+
markdownPath: 'packages/client/RELEASE_NOTES.md',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
})
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
JavaScript, JSON, and TypeScript config files are discovered by name. TypeScript config loading depends on your runtime being able to import `.ts` files, for example through `tsx`.
|
|
60
|
+
|
|
61
|
+
The published JSON Schema for `RELEASE_NOTES.json` is available at `@scalar/release-notes/schema`.
|
|
62
|
+
|
|
63
|
+
## Providers
|
|
64
|
+
|
|
65
|
+
Use Anthropic:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { createAnthropicProvider } from '@scalar/release-notes'
|
|
69
|
+
|
|
70
|
+
createAnthropicProvider({
|
|
71
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
72
|
+
model: 'claude-sonnet-4-5',
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Use OpenAI:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
import { createOpenAIProvider } from '@scalar/release-notes'
|
|
80
|
+
|
|
81
|
+
createOpenAIProvider({
|
|
82
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
83
|
+
model: 'gpt-4.1-mini',
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use a custom provider:
|
|
88
|
+
|
|
89
|
+
```js
|
|
90
|
+
export default defineReleaseNotesConfig({
|
|
91
|
+
provider: {
|
|
92
|
+
name: 'internal-agent',
|
|
93
|
+
async generateJson({ systemPrompt, userPrompt }) {
|
|
94
|
+
return callInternalAgent({ systemPrompt, userPrompt })
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
})
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The provider can return either a JSON object or a JSON string. The package validates the result before writing `RELEASE_NOTES.json`.
|
|
101
|
+
|
|
102
|
+
## GitHub Actions
|
|
103
|
+
|
|
104
|
+
Anthropic:
|
|
105
|
+
|
|
106
|
+
```yaml
|
|
107
|
+
- name: Generate release notes
|
|
108
|
+
run: pnpm scalar-release-notes --all --provider anthropic --model claude-sonnet-4-5
|
|
109
|
+
env:
|
|
110
|
+
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
111
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
OpenAI:
|
|
115
|
+
|
|
116
|
+
```yaml
|
|
117
|
+
- name: Generate release notes
|
|
118
|
+
run: pnpm scalar-release-notes --all --provider openai --model gpt-4.1-mini
|
|
119
|
+
env:
|
|
120
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
121
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Markdown Sync
|
|
125
|
+
|
|
126
|
+
Regenerate Markdown from JSON without using AI:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
scalar-release-notes sync-release-notes-markdown \
|
|
130
|
+
--json packages/client/RELEASE_NOTES.json \
|
|
131
|
+
--markdown packages/client/RELEASE_NOTES.md
|
|
132
|
+
```
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,eAAO,MAAM,qBAAqB,QAAO,OAWxC,CAAA"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { createReleaseNotesGeneratorCommand } from './commands/generate.js';
|
|
5
|
+
import { createSyncReleaseNotesMarkdownCommand } from './commands/sync-markdown.js';
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
const { version } = require('../package.json');
|
|
8
|
+
export const createReleaseNotesCli = () => {
|
|
9
|
+
const program = new Command();
|
|
10
|
+
program
|
|
11
|
+
.name('scalar-release-notes')
|
|
12
|
+
.description('Generate curated release notes from Changesets changelogs')
|
|
13
|
+
.version(version);
|
|
14
|
+
program.addCommand(createReleaseNotesGeneratorCommand(), { isDefault: true });
|
|
15
|
+
program.addCommand(createSyncReleaseNotesMarkdownCommand());
|
|
16
|
+
return program;
|
|
17
|
+
};
|
|
18
|
+
createReleaseNotesCli().parse();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { ReleaseNotesConfig } from '../config/types.js';
|
|
3
|
+
export declare const createReleaseNotesGeneratorCommand: (baseConfig?: ReleaseNotesConfig) => Command;
|
|
4
|
+
export declare const releaseNotesGenerator: Command;
|
|
5
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,OAAO,KAAK,EAAuB,kBAAkB,EAAuB,MAAM,iBAAiB,CAAA;AA6DnG,eAAO,MAAM,kCAAkC,GAAI,aAAY,kBAAuB,KAAG,OAwFxF,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAuC,CAAA"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { createBuiltInProvider, hasBuiltInProviderApiKey, readReleaseNotesConfig, } from '../config/read-config.js';
|
|
3
|
+
import { getChangedPathsForReleaseFiltering } from '../core/detect-versioned-changelog-paths.js';
|
|
4
|
+
import { runReleaseNotesGeneratorForProduct } from '../core/run-release-notes-generator.js';
|
|
5
|
+
const createAdHocProduct = (options, fallbackDescription) => {
|
|
6
|
+
if (!options.package || !options.changelog || !options.output) {
|
|
7
|
+
throw new Error('Pass --all or provide --package, --changelog, and --output.');
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
slug: options.package,
|
|
11
|
+
packageName: options.package,
|
|
12
|
+
displayName: options.package,
|
|
13
|
+
description: fallbackDescription,
|
|
14
|
+
changelogPath: options.changelog,
|
|
15
|
+
outputPath: options.output,
|
|
16
|
+
markdownPath: options.markdown,
|
|
17
|
+
dependencyChangelogPaths: options.dependencyChangelog ?? [],
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const resolveCliOverrides = (options) => {
|
|
21
|
+
if (options.provider !== undefined && options.provider !== 'anthropic' && options.provider !== 'openai') {
|
|
22
|
+
throw new Error(`Unsupported provider "${options.provider}". Use "anthropic" or "openai".`);
|
|
23
|
+
}
|
|
24
|
+
const provider = options.provider;
|
|
25
|
+
return {
|
|
26
|
+
config: options.config,
|
|
27
|
+
provider,
|
|
28
|
+
model: options.model,
|
|
29
|
+
apiKeyEnv: options.apiKeyEnv,
|
|
30
|
+
repo: options.repo,
|
|
31
|
+
baseBranch: options.baseBranch,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export const createReleaseNotesGeneratorCommand = (baseConfig = {}) => {
|
|
35
|
+
return new Command('release-notes-generator')
|
|
36
|
+
.description('Generate AI-written release notes from a CHANGELOG and append them to a product RELEASE_NOTES.json. Use --all to generate notes for every configured product.')
|
|
37
|
+
.option('--all', 'Generate release notes for every product in the config', false)
|
|
38
|
+
.option('--product <slug>', 'Configured product slug to generate')
|
|
39
|
+
.option('-p, --package <name>', 'NPM package name for ad-hoc generation')
|
|
40
|
+
.option('-c, --changelog <path>', 'Path to the package CHANGELOG.md')
|
|
41
|
+
.option('-o, --output <path>', 'Path to the package RELEASE_NOTES.json to update')
|
|
42
|
+
.option('-m, --markdown <path>', 'Optional path to a derived RELEASE_NOTES.md')
|
|
43
|
+
.option('-v, --version <semver>', 'Version that was just released')
|
|
44
|
+
.option('-d, --dependency-changelog <path>', 'Dependency CHANGELOG.md whose just-released section should be folded into the release note. Repeat for multiple dependencies.', (value, previous = []) => [...previous, value], [])
|
|
45
|
+
.option('--date <YYYY-MM-DD>', 'Release date (defaults to today in UTC)')
|
|
46
|
+
.option('--provider <provider>', 'AI provider to use: anthropic or openai')
|
|
47
|
+
.option('--model <id>', 'AI model to use')
|
|
48
|
+
.option('--api-key-env <name>', 'Environment variable that contains the selected provider API key')
|
|
49
|
+
.option('--repo <owner/repo>', 'GitHub repository slug for PR context and changelog links')
|
|
50
|
+
.option('--base-branch <branch>', 'Base branch for changelog links and --all git filtering')
|
|
51
|
+
.option('--config <path>', 'Path to a release-notes config file')
|
|
52
|
+
.option('--dry-run', 'Print the generated note instead of writing it', false)
|
|
53
|
+
.option('--force', 'With --all, generate release notes for every configured product', false)
|
|
54
|
+
.option('--no-markdown-output', 'Skip Markdown regeneration')
|
|
55
|
+
.action(async (options) => {
|
|
56
|
+
const cliOverrides = resolveCliOverrides(options);
|
|
57
|
+
const config = await readReleaseNotesConfig(cliOverrides, baseConfig);
|
|
58
|
+
const builtInProvider = cliOverrides.provider ?? 'anthropic';
|
|
59
|
+
// When relying on a built-in provider, skip gracefully if its API key is missing.
|
|
60
|
+
// This keeps `pnpm release:version --all` from failing on forks, contributor
|
|
61
|
+
// machines, or CI that do not have the provider secret configured.
|
|
62
|
+
//
|
|
63
|
+
// The warning intentionally names only the provider, never the resolved
|
|
64
|
+
// environment variable name. The env var name is harmless to log, but keeping
|
|
65
|
+
// it out of the message avoids a false-positive clear-text-logging alert from
|
|
66
|
+
// CodeQL, whose name-based heuristic flags anything derived from `apiKeyEnv`.
|
|
67
|
+
const usesBuiltInProvider = Boolean(cliOverrides.provider) || !config.provider;
|
|
68
|
+
if (usesBuiltInProvider && !hasBuiltInProviderApiKey(builtInProvider, options.apiKeyEnv)) {
|
|
69
|
+
console.warn(`No API key set for the ${builtInProvider} provider; skipping release-notes generation.`);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const provider = config.provider ??
|
|
73
|
+
createBuiltInProvider({
|
|
74
|
+
provider: builtInProvider,
|
|
75
|
+
model: options.model,
|
|
76
|
+
apiKeyEnv: options.apiKeyEnv,
|
|
77
|
+
});
|
|
78
|
+
const products = options.all
|
|
79
|
+
? config.products
|
|
80
|
+
: options.product
|
|
81
|
+
? config.products.filter((product) => product.slug === options.product)
|
|
82
|
+
: [createAdHocProduct(options, config.prompts.productDescriptionFallback ?? 'an open-source package')];
|
|
83
|
+
if (products.length === 0) {
|
|
84
|
+
throw new Error(options.product ? `No configured product found for slug ${options.product}.` : 'No products configured.');
|
|
85
|
+
}
|
|
86
|
+
const changedPaths = options.all && !options.force
|
|
87
|
+
? await getChangedPathsForReleaseFiltering(config.github.baseBranch ?? 'main')
|
|
88
|
+
: null;
|
|
89
|
+
for (const product of products) {
|
|
90
|
+
await runReleaseNotesGeneratorForProduct({
|
|
91
|
+
product,
|
|
92
|
+
provider,
|
|
93
|
+
version: options.version,
|
|
94
|
+
date: options.date,
|
|
95
|
+
model: options.model,
|
|
96
|
+
dryRun: options.dryRun,
|
|
97
|
+
changedPaths,
|
|
98
|
+
writeMarkdown: options.markdownOutput,
|
|
99
|
+
github: config.github,
|
|
100
|
+
prompts: config.prompts,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
export const releaseNotesGenerator = createReleaseNotesGeneratorCommand();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import type { ReleaseNotesConfig } from '../config/types.js';
|
|
3
|
+
export declare const createSyncReleaseNotesMarkdownCommand: (baseConfig?: ReleaseNotesConfig) => Command;
|
|
4
|
+
export declare const syncReleaseNotesMarkdown: Command;
|
|
5
|
+
//# sourceMappingURL=sync-markdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-markdown.d.ts","sourceRoot":"","sources":["../../src/commands/sync-markdown.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAYzD,eAAO,MAAM,qCAAqC,GAAI,aAAY,kBAAuB,KAAG,OAgB3F,CAAA;AAED,eAAO,MAAM,wBAAwB,SAA0C,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { buildReleaseNotesPreamble } from '@scalar/helpers/markdown/release-notes';
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { readReleaseNotesConfig } from '../config/read-config.js';
|
|
4
|
+
import { resolveUserPath } from '../core/paths.js';
|
|
5
|
+
import { findReleaseNotesProductByJsonPath } from '../core/products.js';
|
|
6
|
+
import { readReleaseNotesJsonFile } from '../writers/write-release-notes-json.js';
|
|
7
|
+
import { writeReleaseNotesMarkdown } from '../writers/write-release-notes-markdown.js';
|
|
8
|
+
export const createSyncReleaseNotesMarkdownCommand = (baseConfig = {}) => {
|
|
9
|
+
return new Command('sync-release-notes-markdown')
|
|
10
|
+
.description('Regenerate RELEASE_NOTES.md from RELEASE_NOTES.json (no AI, no JSON writes).')
|
|
11
|
+
.requiredOption('-j, --json <path>', 'Path to RELEASE_NOTES.json')
|
|
12
|
+
.requiredOption('-m, --markdown <path>', 'Path to the derived RELEASE_NOTES.md to write')
|
|
13
|
+
.option('--config <path>', 'Path to a release-notes config file')
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
const config = await readReleaseNotesConfig({ config: options.config }, baseConfig);
|
|
16
|
+
const jsonPath = resolveUserPath(options.json);
|
|
17
|
+
const markdownPath = resolveUserPath(options.markdown);
|
|
18
|
+
const entries = await readReleaseNotesJsonFile(jsonPath);
|
|
19
|
+
const product = findReleaseNotesProductByJsonPath(jsonPath, config.products);
|
|
20
|
+
const preamble = buildReleaseNotesPreamble(product?.displayName);
|
|
21
|
+
const result = await writeReleaseNotesMarkdown({ path: markdownPath, entries, preamble });
|
|
22
|
+
console.log(`${result.created ? 'Created' : 'Updated'} ${result.path}`);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const syncReleaseNotesMarkdown = createSyncReleaseNotesMarkdownCommand();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ReleaseNotesConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Identity helper that gives JavaScript and TypeScript config files strong editor types.
|
|
4
|
+
*/
|
|
5
|
+
export declare const defineReleaseNotesConfig: (config: ReleaseNotesConfig) => ReleaseNotesConfig;
|
|
6
|
+
//# sourceMappingURL=define-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../src/config/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,kBAAkB,KAAG,kBAA4B,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BuiltInProviderName, ReleaseNotesConfig, ReleaseNotesProvider, ResolvedReleaseNotesConfig } from './types.js';
|
|
2
|
+
export type CliConfigOverrides = {
|
|
3
|
+
config?: string;
|
|
4
|
+
provider?: BuiltInProviderName;
|
|
5
|
+
model?: string;
|
|
6
|
+
apiKeyEnv?: string;
|
|
7
|
+
repo?: string;
|
|
8
|
+
baseBranch?: string;
|
|
9
|
+
};
|
|
10
|
+
/** Whether the API key for a built-in provider is available (and non-empty) in the environment. */
|
|
11
|
+
export declare const hasBuiltInProviderApiKey: (provider: BuiltInProviderName, apiKeyEnv?: string) => boolean;
|
|
12
|
+
export declare const createBuiltInProvider: (options: {
|
|
13
|
+
provider: BuiltInProviderName;
|
|
14
|
+
model?: string;
|
|
15
|
+
apiKeyEnv?: string;
|
|
16
|
+
}) => ReleaseNotesProvider;
|
|
17
|
+
export declare const readReleaseNotesConfig: (overrides?: CliConfigOverrides, baseConfig?: ReleaseNotesConfig, cwd?: string) => Promise<ResolvedReleaseNotesConfig>;
|
|
18
|
+
//# sourceMappingURL=read-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-config.d.ts","sourceRoot":"","sources":["../../src/config/read-config.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,mBAAmB,EAEnB,kBAAkB,EAClB,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAShB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAyCD,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,GAAI,UAAU,mBAAmB,EAAE,YAAY,MAAM,KAAG,OACpD,CAAA;AAEzC,eAAO,MAAM,qBAAqB,GAAI,SAAS;IAC7C,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,KAAG,oBAMH,CAAA;AAUD,eAAO,MAAM,sBAAsB,GACjC,YAAW,kBAAuB,EAClC,aAAY,kBAAuB,EACnC,YAA2C,KAC1C,OAAO,CAAC,0BAA0B,CA2BpC,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { access, readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { createAnthropicProvider } from '../providers/anthropic.js';
|
|
5
|
+
import { createOpenAIProvider } from '../providers/openai.js';
|
|
6
|
+
const CONFIG_FILES = [
|
|
7
|
+
'release-notes.config.mjs',
|
|
8
|
+
'release-notes.config.js',
|
|
9
|
+
'release-notes.config.json',
|
|
10
|
+
'release-notes.config.ts',
|
|
11
|
+
];
|
|
12
|
+
const pathExists = async (path) => {
|
|
13
|
+
try {
|
|
14
|
+
await access(path);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const findConfigPath = async (cwd) => {
|
|
22
|
+
for (const file of CONFIG_FILES) {
|
|
23
|
+
const candidate = resolve(cwd, file);
|
|
24
|
+
if (await pathExists(candidate)) {
|
|
25
|
+
return candidate;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
const loadConfigFile = async (path) => {
|
|
31
|
+
if (path.endsWith('.json')) {
|
|
32
|
+
const raw = await readFile(path, 'utf-8');
|
|
33
|
+
return JSON.parse(raw);
|
|
34
|
+
}
|
|
35
|
+
const module = (await import(pathToFileURL(path).href));
|
|
36
|
+
if (!module.default || typeof module.default !== 'object') {
|
|
37
|
+
throw new Error(`Expected ${path} to export a release notes config object as default.`);
|
|
38
|
+
}
|
|
39
|
+
return module.default;
|
|
40
|
+
};
|
|
41
|
+
/** Default environment variable that holds the API key for a built-in provider. */
|
|
42
|
+
const getBuiltInProviderApiKeyEnv = (provider, apiKeyEnv) => apiKeyEnv ?? (provider === 'anthropic' ? 'ANTHROPIC_API_KEY' : 'OPENAI_API_KEY');
|
|
43
|
+
const getApiKey = (provider, apiKeyEnv) => process.env[getBuiltInProviderApiKeyEnv(provider, apiKeyEnv)];
|
|
44
|
+
/** Whether the API key for a built-in provider is available (and non-empty) in the environment. */
|
|
45
|
+
export const hasBuiltInProviderApiKey = (provider, apiKeyEnv) => Boolean(getApiKey(provider, apiKeyEnv));
|
|
46
|
+
export const createBuiltInProvider = (options) => {
|
|
47
|
+
const apiKey = getApiKey(options.provider, options.apiKeyEnv);
|
|
48
|
+
if (options.provider === 'openai') {
|
|
49
|
+
return createOpenAIProvider({ apiKey, model: options.model });
|
|
50
|
+
}
|
|
51
|
+
return createAnthropicProvider({ apiKey, model: options.model });
|
|
52
|
+
};
|
|
53
|
+
const resolveGithub = (configGithub, overrides) => {
|
|
54
|
+
return {
|
|
55
|
+
repo: overrides.repo ?? configGithub?.repo,
|
|
56
|
+
baseBranch: overrides.baseBranch ?? configGithub?.baseBranch ?? 'main',
|
|
57
|
+
token: configGithub?.token ?? process.env.GITHUB_TOKEN,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export const readReleaseNotesConfig = async (overrides = {}, baseConfig = {}, cwd = process.env.INIT_CWD ?? process.cwd()) => {
|
|
61
|
+
const configPath = overrides.config ? resolve(cwd, overrides.config) : await findConfigPath(cwd);
|
|
62
|
+
const fileConfig = configPath ? await loadConfigFile(configPath) : {};
|
|
63
|
+
const config = {
|
|
64
|
+
...baseConfig,
|
|
65
|
+
...fileConfig,
|
|
66
|
+
github: {
|
|
67
|
+
...baseConfig.github,
|
|
68
|
+
...fileConfig.github,
|
|
69
|
+
},
|
|
70
|
+
prompts: {
|
|
71
|
+
...baseConfig.prompts,
|
|
72
|
+
...fileConfig.prompts,
|
|
73
|
+
},
|
|
74
|
+
products: fileConfig.products ?? baseConfig.products,
|
|
75
|
+
provider: fileConfig.provider ?? baseConfig.provider,
|
|
76
|
+
};
|
|
77
|
+
const provider = overrides.provider
|
|
78
|
+
? createBuiltInProvider({ provider: overrides.provider, model: overrides.model, apiKeyEnv: overrides.apiKeyEnv })
|
|
79
|
+
: config.provider;
|
|
80
|
+
return {
|
|
81
|
+
provider,
|
|
82
|
+
products: config.products ?? [],
|
|
83
|
+
github: resolveGithub(config.github, overrides),
|
|
84
|
+
prompts: config.prompts ?? {},
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A release notes target wired to a changelog input and JSON/Markdown outputs.
|
|
3
|
+
*/
|
|
4
|
+
export type ReleaseNotesProduct = {
|
|
5
|
+
/** Short slug used by the CLI for `--product` filtering. */
|
|
6
|
+
slug: string;
|
|
7
|
+
/** NPM package name shown in prompts and logs. */
|
|
8
|
+
packageName: string;
|
|
9
|
+
/** User-facing product name used in AI prompts and markdown preambles. */
|
|
10
|
+
displayName: string;
|
|
11
|
+
/** One-line product description for the AI system prompt. */
|
|
12
|
+
description: string;
|
|
13
|
+
/** Path to the product's Changesets-style `CHANGELOG.md`. */
|
|
14
|
+
changelogPath: string;
|
|
15
|
+
/** Path to the curated `RELEASE_NOTES.json` source of truth. */
|
|
16
|
+
outputPath: string;
|
|
17
|
+
/** Optional derived `RELEASE_NOTES.md` path. Defaults to a sibling of the JSON file. */
|
|
18
|
+
markdownPath?: string;
|
|
19
|
+
/** Dependency CHANGELOGs folded into the parent release note. */
|
|
20
|
+
dependencyChangelogPaths?: readonly string[];
|
|
21
|
+
};
|
|
22
|
+
export type ProductPromptContext = {
|
|
23
|
+
/** User-facing product name. */
|
|
24
|
+
displayName: string;
|
|
25
|
+
/** One-line description of what the product is. */
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
export type PromptContext = {
|
|
29
|
+
product: ProductPromptContext;
|
|
30
|
+
};
|
|
31
|
+
export type PromptOptions = {
|
|
32
|
+
/** Fallback description used when the CLI creates an ad-hoc product. */
|
|
33
|
+
productDescriptionFallback?: string;
|
|
34
|
+
/** Optional full system prompt override. */
|
|
35
|
+
systemPrompt?: (context: PromptContext) => string;
|
|
36
|
+
};
|
|
37
|
+
export type GithubOptions = {
|
|
38
|
+
/** GitHub repository slug in `owner/repo` form. */
|
|
39
|
+
repo?: string;
|
|
40
|
+
/** Branch used when building changelog links and git diff filters. */
|
|
41
|
+
baseBranch?: string;
|
|
42
|
+
/** GitHub token for PR context fetching. */
|
|
43
|
+
token?: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Pluggable AI provider contract used by the generic release notes generator.
|
|
47
|
+
*/
|
|
48
|
+
export type ReleaseNotesProvider = {
|
|
49
|
+
name: string;
|
|
50
|
+
defaultModel?: string;
|
|
51
|
+
generateJson(options: {
|
|
52
|
+
model?: string;
|
|
53
|
+
systemPrompt: string;
|
|
54
|
+
userPrompt: string;
|
|
55
|
+
schema: unknown;
|
|
56
|
+
maxOutputTokens: number;
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}): Promise<unknown>;
|
|
59
|
+
};
|
|
60
|
+
export type BuiltInProviderName = 'anthropic' | 'openai';
|
|
61
|
+
export type ReleaseNotesConfig = {
|
|
62
|
+
provider?: ReleaseNotesProvider;
|
|
63
|
+
products?: readonly ReleaseNotesProduct[];
|
|
64
|
+
github?: GithubOptions;
|
|
65
|
+
prompts?: PromptOptions;
|
|
66
|
+
};
|
|
67
|
+
export type ResolvedReleaseNotesConfig = Required<Pick<ReleaseNotesConfig, 'github' | 'prompts'>> & Omit<ReleaseNotesConfig, 'github' | 'prompts'> & {
|
|
68
|
+
products: readonly ReleaseNotesProduct[];
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAA;IACZ,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAA;IACnB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAA;IACnB,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAA;IACrB,gEAAgE;IAChE,UAAU,EAAE,MAAM,CAAA;IAClB,wFAAwF;IACxF,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iEAAiE;IACjE,wBAAwB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC7C,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAA;IACnB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,oBAAoB,CAAA;CAC9B,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,wEAAwE;IACxE,0BAA0B,CAAC,EAAE,MAAM,CAAA;IACnC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,MAAM,CAAA;CAClD,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,mDAAmD;IACnD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,YAAY,CAAC,OAAO,EAAE;QACpB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,YAAY,EAAE,MAAM,CAAA;QACpB,UAAU,EAAE,MAAM,CAAA;QAClB,MAAM,EAAE,OAAO,CAAA;QACf,eAAe,EAAE,MAAM,CAAA;QACvB,MAAM,CAAC,EAAE,WAAW,CAAA;KACrB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,QAAQ,CAAA;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,CAAC,EAAE,oBAAoB,CAAA;IAC/B,QAAQ,CAAC,EAAE,SAAS,mBAAmB,EAAE,CAAA;IACzC,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,CAAA;AAED,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC,GAC/F,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,SAAS,CAAC,GAAG;IAC/C,QAAQ,EAAE,SAAS,mBAAmB,EAAE,CAAA;CACzC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ReleaseNotesProduct } from '../config/types.js';
|
|
2
|
+
export declare const wasChangelogVersioned: (changelogPath: string, changedPaths: ReadonlySet<string>) => boolean;
|
|
3
|
+
export declare const shouldGenerateReleaseNotesForProduct: (product: ReleaseNotesProduct, changedPaths: ReadonlySet<string> | null) => boolean;
|
|
4
|
+
export declare const getChangedPathsForReleaseFiltering: (baseBranch?: string) => Promise<Set<string> | null>;
|
|
5
|
+
//# sourceMappingURL=detect-versioned-changelog-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-versioned-changelog-paths.d.ts","sourceRoot":"","sources":["../../src/core/detect-versioned-changelog-paths.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAkB1D,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,EAAE,cAAc,WAAW,CAAC,MAAM,CAAC,KAAG,OAEhG,CAAA;AAED,eAAO,MAAM,oCAAoC,GAC/C,SAAS,mBAAmB,EAC5B,cAAc,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,KACvC,OAgBF,CAAA;AAqBD,eAAO,MAAM,kCAAkC,GAAU,mBAAmB,KAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAMxG,CAAA"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { dirname, join, relative, resolve } from 'node:path';
|
|
3
|
+
import { promisify } from 'node:util';
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
const getWorkspaceRoot = () => process.env.INIT_CWD ?? process.cwd();
|
|
6
|
+
const normalizeRepoRelativePath = (inputPath) => {
|
|
7
|
+
const repoRoot = getWorkspaceRoot();
|
|
8
|
+
const absolute = resolve(repoRoot, inputPath);
|
|
9
|
+
return relative(repoRoot, absolute).replace(/\\/g, '/');
|
|
10
|
+
};
|
|
11
|
+
const getVersionedPathsForChangelog = (changelogPath) => {
|
|
12
|
+
const normalizedChangelog = normalizeRepoRelativePath(changelogPath);
|
|
13
|
+
const packageJsonPath = join(dirname(normalizedChangelog), 'package.json').replace(/\\/g, '/');
|
|
14
|
+
return [normalizedChangelog, packageJsonPath];
|
|
15
|
+
};
|
|
16
|
+
export const wasChangelogVersioned = (changelogPath, changedPaths) => {
|
|
17
|
+
return getVersionedPathsForChangelog(changelogPath).some((path) => changedPaths.has(path));
|
|
18
|
+
};
|
|
19
|
+
export const shouldGenerateReleaseNotesForProduct = (product, changedPaths) => {
|
|
20
|
+
if (changedPaths === null) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (wasChangelogVersioned(product.changelogPath, changedPaths)) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
for (const dependencyPath of product.dependencyChangelogPaths ?? []) {
|
|
27
|
+
if (wasChangelogVersioned(dependencyPath, changedPaths)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
const getPathsChangedSinceBase = async (baseBranch) => {
|
|
34
|
+
try {
|
|
35
|
+
const { stdout } = await execFileAsync('git', ['diff', '--name-only', baseBranch], {
|
|
36
|
+
cwd: getWorkspaceRoot(),
|
|
37
|
+
});
|
|
38
|
+
const paths = stdout
|
|
39
|
+
.split('\n')
|
|
40
|
+
.map((line) => line.trim())
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.map((line) => line.replace(/\\/g, '/'));
|
|
43
|
+
return new Set(paths);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.warn(`Could not read git diff for release-notes filtering: ${error.message}. Generating for all registered products.`);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export const getChangedPathsForReleaseFiltering = async (baseBranch = 'main') => {
|
|
51
|
+
const changed = await getPathsChangedSinceBase(baseBranch);
|
|
52
|
+
if (changed === null) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
return new Set([...changed].map((path) => path.replace(/\\/g, '/')));
|
|
56
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-changelog-section.d.ts","sourceRoot":"","sources":["../../src/core/extract-changelog-section.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,KAAG,MAAM,GAAG,IAepF,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pull a single version's section out of a Changesets-style `CHANGELOG.md`.
|
|
3
|
+
*/
|
|
4
|
+
export const extractChangelogSection = (markdown, version) => {
|
|
5
|
+
const lines = markdown.split('\n');
|
|
6
|
+
const headingPattern = new RegExp(`^##\\s+${version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s*$`);
|
|
7
|
+
const startIndex = lines.findIndex((line) => headingPattern.test(line));
|
|
8
|
+
if (startIndex === -1) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const contentStartIndex = startIndex + 1;
|
|
12
|
+
const nextHeadingOffset = lines.slice(contentStartIndex).findIndex((line) => /^##\s+/.test(line));
|
|
13
|
+
const endIndex = nextHeadingOffset === -1 ? lines.length : contentStartIndex + nextHeadingOffset;
|
|
14
|
+
const section = lines.slice(contentStartIndex, endIndex).join('\n').trim();
|
|
15
|
+
return section.length > 0 ? section : null;
|
|
16
|
+
};
|