@releasekit/notes 0.2.0-next.9 → 0.2.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/LICENSE +21 -0
- package/README.md +3 -1
- package/dist/aggregator-YA7LC3KJ.js +13 -0
- package/dist/chunk-ATNNRK62.js +165 -0
- package/dist/{chunk-BLWJTLRD.js → chunk-IKER5VME.js} +687 -429
- package/dist/chunk-SAUES3BF.js +231 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +13 -29
- package/dist/index.d.ts +8 -182
- package/dist/index.js +13 -7
- package/package.json +43 -36
- package/dist/cli.cjs +0 -1750
- package/dist/cli.d.cts +0 -1
- package/dist/index.cjs +0 -1656
- package/dist/index.d.cts +0 -182
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sam Maister
|
|
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @releasekit/notes
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Release notes and changelog generation from conventional commits with LLM-powered enhancement and flexible templating
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -19,6 +19,8 @@ npm install -g @releasekit/notes
|
|
|
19
19
|
pnpm add -g @releasekit/notes
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
> **Note:** This package is ESM only and requires Node.js 20+.
|
|
23
|
+
|
|
22
24
|
## Quick Start
|
|
23
25
|
|
|
24
26
|
```bash
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
debug,
|
|
3
|
+
formatVersion,
|
|
4
|
+
info,
|
|
5
|
+
prependVersion,
|
|
6
|
+
renderMarkdown,
|
|
7
|
+
success
|
|
8
|
+
} from "./chunk-SAUES3BF.js";
|
|
9
|
+
|
|
10
|
+
// src/monorepo/aggregator.ts
|
|
11
|
+
import * as fs from "fs";
|
|
12
|
+
import * as path from "path";
|
|
13
|
+
|
|
14
|
+
// src/monorepo/splitter.ts
|
|
15
|
+
function splitByPackage(contexts) {
|
|
16
|
+
const byPackage = /* @__PURE__ */ new Map();
|
|
17
|
+
for (const ctx of contexts) {
|
|
18
|
+
byPackage.set(ctx.packageName, ctx);
|
|
19
|
+
}
|
|
20
|
+
return byPackage;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/monorepo/aggregator.ts
|
|
24
|
+
function writeFile(outputPath, content, dryRun) {
|
|
25
|
+
if (dryRun) {
|
|
26
|
+
info(`Would write to ${outputPath}`);
|
|
27
|
+
debug(content);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const dir = path.dirname(outputPath);
|
|
31
|
+
if (!fs.existsSync(dir)) {
|
|
32
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
fs.writeFileSync(outputPath, content, "utf-8");
|
|
35
|
+
success(`Changelog written to ${outputPath}`);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
function aggregateToRoot(contexts) {
|
|
39
|
+
const aggregated = {
|
|
40
|
+
packageName: "monorepo",
|
|
41
|
+
version: contexts[0]?.version ?? "0.0.0",
|
|
42
|
+
previousVersion: contexts[0]?.previousVersion ?? null,
|
|
43
|
+
date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0] ?? "",
|
|
44
|
+
repoUrl: contexts[0]?.repoUrl ?? null,
|
|
45
|
+
entries: []
|
|
46
|
+
};
|
|
47
|
+
for (const ctx of contexts) {
|
|
48
|
+
for (const entry of ctx.entries) {
|
|
49
|
+
aggregated.entries.push({
|
|
50
|
+
...entry,
|
|
51
|
+
scope: entry.scope ? `${ctx.packageName}/${entry.scope}` : ctx.packageName
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return aggregated;
|
|
56
|
+
}
|
|
57
|
+
function writeMonorepoChangelogs(contexts, options, config, dryRun) {
|
|
58
|
+
const files = [];
|
|
59
|
+
if (options.mode === "root" || options.mode === "both") {
|
|
60
|
+
const rootPath = path.join(options.rootPath, "CHANGELOG.md");
|
|
61
|
+
const fmtOpts = { includePackageName: true };
|
|
62
|
+
info(`Writing root changelog to ${rootPath}`);
|
|
63
|
+
let rootContent;
|
|
64
|
+
if (config.updateStrategy === "prepend" && fs.existsSync(rootPath)) {
|
|
65
|
+
const newSections = contexts.map((ctx) => formatVersion(ctx, fmtOpts)).join("\n");
|
|
66
|
+
const existing = fs.readFileSync(rootPath, "utf-8");
|
|
67
|
+
const headerEnd = existing.indexOf("\n## ");
|
|
68
|
+
if (headerEnd >= 0) {
|
|
69
|
+
rootContent = `${existing.slice(0, headerEnd)}
|
|
70
|
+
|
|
71
|
+
${newSections}
|
|
72
|
+
${existing.slice(headerEnd + 1)}`;
|
|
73
|
+
} else {
|
|
74
|
+
rootContent = renderMarkdown(contexts, fmtOpts);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
rootContent = renderMarkdown(contexts, fmtOpts);
|
|
78
|
+
}
|
|
79
|
+
if (writeFile(rootPath, rootContent, dryRun)) {
|
|
80
|
+
files.push(rootPath);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (options.mode === "packages" || options.mode === "both") {
|
|
84
|
+
const byPackage = splitByPackage(contexts);
|
|
85
|
+
const packageDirMap = buildPackageDirMap(options.rootPath, options.packagesPath);
|
|
86
|
+
for (const [packageName, ctx] of byPackage) {
|
|
87
|
+
const simpleName = packageName.split("/").pop();
|
|
88
|
+
const packageDir = packageDirMap.get(packageName) ?? (simpleName ? packageDirMap.get(simpleName) : void 0) ?? null;
|
|
89
|
+
if (packageDir) {
|
|
90
|
+
const changelogPath = path.join(packageDir, "CHANGELOG.md");
|
|
91
|
+
info(`Writing changelog for ${packageName} to ${changelogPath}`);
|
|
92
|
+
const pkgContent = config.updateStrategy === "prepend" && fs.existsSync(changelogPath) ? prependVersion(changelogPath, ctx) : renderMarkdown([ctx]);
|
|
93
|
+
if (writeFile(changelogPath, pkgContent, dryRun)) {
|
|
94
|
+
files.push(changelogPath);
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
info(`Could not find directory for package ${packageName}, skipping`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return files;
|
|
102
|
+
}
|
|
103
|
+
function buildPackageDirMap(rootPath, packagesPath) {
|
|
104
|
+
const map = /* @__PURE__ */ new Map();
|
|
105
|
+
const packagesDir = path.join(rootPath, packagesPath);
|
|
106
|
+
if (!fs.existsSync(packagesDir)) {
|
|
107
|
+
return map;
|
|
108
|
+
}
|
|
109
|
+
for (const entry of fs.readdirSync(packagesDir, { withFileTypes: true })) {
|
|
110
|
+
if (!entry.isDirectory()) continue;
|
|
111
|
+
const dirPath = path.join(packagesDir, entry.name);
|
|
112
|
+
map.set(entry.name, dirPath);
|
|
113
|
+
const packageJsonPath = path.join(dirPath, "package.json");
|
|
114
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
115
|
+
try {
|
|
116
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
117
|
+
if (pkg.name) {
|
|
118
|
+
map.set(pkg.name, dirPath);
|
|
119
|
+
}
|
|
120
|
+
} catch {
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return map;
|
|
125
|
+
}
|
|
126
|
+
function detectMonorepo(cwd) {
|
|
127
|
+
const pnpmWorkspacesPath = path.join(cwd, "pnpm-workspace.yaml");
|
|
128
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
129
|
+
if (fs.existsSync(pnpmWorkspacesPath)) {
|
|
130
|
+
const content = fs.readFileSync(pnpmWorkspacesPath, "utf-8");
|
|
131
|
+
const packagesMatch = content.match(/packages:\s*\n\s*-\s*['"]([^'"]+)['"]/);
|
|
132
|
+
if (packagesMatch?.[1]) {
|
|
133
|
+
const packagesGlob = packagesMatch[1];
|
|
134
|
+
const packagesPath = packagesGlob.replace(/\/?\*$/, "").replace(/\/\*\*$/, "");
|
|
135
|
+
return { isMonorepo: true, packagesPath: packagesPath || "packages" };
|
|
136
|
+
}
|
|
137
|
+
return { isMonorepo: true, packagesPath: "packages" };
|
|
138
|
+
}
|
|
139
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
140
|
+
try {
|
|
141
|
+
const content = fs.readFileSync(packageJsonPath, "utf-8");
|
|
142
|
+
const pkg = JSON.parse(content);
|
|
143
|
+
if (pkg.workspaces) {
|
|
144
|
+
const workspaces = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces.packages;
|
|
145
|
+
if (workspaces?.length) {
|
|
146
|
+
const firstWorkspace = workspaces[0];
|
|
147
|
+
if (firstWorkspace) {
|
|
148
|
+
const packagesPath = firstWorkspace.replace(/\/?\*$/, "").replace(/\/\*\*$/, "");
|
|
149
|
+
return { isMonorepo: true, packagesPath: packagesPath || "packages" };
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
} catch {
|
|
154
|
+
return { isMonorepo: false, packagesPath: "" };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return { isMonorepo: false, packagesPath: "" };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
splitByPackage,
|
|
162
|
+
aggregateToRoot,
|
|
163
|
+
writeMonorepoChangelogs,
|
|
164
|
+
detectMonorepo
|
|
165
|
+
};
|