@releasekit/notes 0.3.0-next.4 → 0.3.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 +2 -0
- package/dist/{aggregator-JZ3VUZKP.js → aggregator-XJ2EILO3.js} +2 -2
- package/dist/{chunk-TSLTZ26C.js → chunk-DCQ32FVH.js} +5 -3
- package/dist/chunk-E4454SIS.js +243 -0
- package/dist/{chunk-QUBVC5LF.js → chunk-ENAWZXFG.js} +559 -146
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +134 -111
- package/dist/index.d.ts +8 -219
- package/dist/index.js +9 -12
- package/package.json +14 -12
- package/dist/chunk-QCF6V2IY.js +0 -135
- package/dist/cli.cjs +0 -1939
- package/dist/cli.d.cts +0 -1
- package/dist/index.cjs +0 -1866
- package/dist/index.d.cts +0 -219
package/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
debug,
|
|
2
3
|
formatVersion,
|
|
4
|
+
info,
|
|
3
5
|
prependVersion,
|
|
4
|
-
renderMarkdown
|
|
5
|
-
|
|
6
|
+
renderMarkdown,
|
|
7
|
+
success
|
|
8
|
+
} from "./chunk-E4454SIS.js";
|
|
6
9
|
|
|
7
10
|
// src/monorepo/aggregator.ts
|
|
8
11
|
import * as fs from "fs";
|
|
9
12
|
import * as path from "path";
|
|
10
|
-
import { debug, info, success } from "@releasekit/core";
|
|
11
13
|
|
|
12
14
|
// src/monorepo/splitter.ts
|
|
13
15
|
function splitByPackage(contexts) {
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
// ../core/dist/index.js
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
function readPackageVersion(importMetaUrl) {
|
|
7
|
+
try {
|
|
8
|
+
const dir = path.dirname(fileURLToPath(importMetaUrl));
|
|
9
|
+
const packageJsonPath = path.resolve(dir, "../package.json");
|
|
10
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
11
|
+
return packageJson.version ?? "0.0.0";
|
|
12
|
+
} catch {
|
|
13
|
+
return "0.0.0";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
var LOG_LEVELS = {
|
|
17
|
+
error: 0,
|
|
18
|
+
warn: 1,
|
|
19
|
+
info: 2,
|
|
20
|
+
debug: 3,
|
|
21
|
+
trace: 4
|
|
22
|
+
};
|
|
23
|
+
var PREFIXES = {
|
|
24
|
+
error: "[ERROR]",
|
|
25
|
+
warn: "[WARN]",
|
|
26
|
+
info: "[INFO]",
|
|
27
|
+
debug: "[DEBUG]",
|
|
28
|
+
trace: "[TRACE]"
|
|
29
|
+
};
|
|
30
|
+
var COLORS = {
|
|
31
|
+
error: chalk.red,
|
|
32
|
+
warn: chalk.yellow,
|
|
33
|
+
info: chalk.blue,
|
|
34
|
+
debug: chalk.gray,
|
|
35
|
+
trace: chalk.dim
|
|
36
|
+
};
|
|
37
|
+
var currentLevel = "info";
|
|
38
|
+
var quietMode = false;
|
|
39
|
+
function setLogLevel(level) {
|
|
40
|
+
currentLevel = level;
|
|
41
|
+
}
|
|
42
|
+
function setQuietMode(quiet) {
|
|
43
|
+
quietMode = quiet;
|
|
44
|
+
}
|
|
45
|
+
function shouldLog(level) {
|
|
46
|
+
if (quietMode && level !== "error") return false;
|
|
47
|
+
return LOG_LEVELS[level] <= LOG_LEVELS[currentLevel];
|
|
48
|
+
}
|
|
49
|
+
function log(message, level = "info") {
|
|
50
|
+
if (!shouldLog(level)) return;
|
|
51
|
+
const formatted = COLORS[level](`${PREFIXES[level]} ${message}`);
|
|
52
|
+
console.error(formatted);
|
|
53
|
+
}
|
|
54
|
+
function error(message) {
|
|
55
|
+
log(message, "error");
|
|
56
|
+
}
|
|
57
|
+
function warn(message) {
|
|
58
|
+
log(message, "warn");
|
|
59
|
+
}
|
|
60
|
+
function info(message) {
|
|
61
|
+
log(message, "info");
|
|
62
|
+
}
|
|
63
|
+
function success(message) {
|
|
64
|
+
if (!shouldLog("info")) return;
|
|
65
|
+
console.error(chalk.green(`[SUCCESS] ${message}`));
|
|
66
|
+
}
|
|
67
|
+
function debug(message) {
|
|
68
|
+
log(message, "debug");
|
|
69
|
+
}
|
|
70
|
+
var ReleaseKitError = class _ReleaseKitError extends Error {
|
|
71
|
+
constructor(message) {
|
|
72
|
+
super(message);
|
|
73
|
+
this.name = this.constructor.name;
|
|
74
|
+
}
|
|
75
|
+
logError() {
|
|
76
|
+
log(this.message, "error");
|
|
77
|
+
if (this.suggestions.length > 0) {
|
|
78
|
+
log("\nSuggested solutions:", "info");
|
|
79
|
+
for (const [i, suggestion] of this.suggestions.entries()) {
|
|
80
|
+
log(`${i + 1}. ${suggestion}`, "info");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
static isReleaseKitError(error2) {
|
|
85
|
+
return error2 instanceof _ReleaseKitError;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var EXIT_CODES = {
|
|
89
|
+
SUCCESS: 0,
|
|
90
|
+
GENERAL_ERROR: 1,
|
|
91
|
+
CONFIG_ERROR: 2,
|
|
92
|
+
INPUT_ERROR: 3,
|
|
93
|
+
TEMPLATE_ERROR: 4,
|
|
94
|
+
LLM_ERROR: 5,
|
|
95
|
+
GITHUB_ERROR: 6,
|
|
96
|
+
GIT_ERROR: 7,
|
|
97
|
+
VERSION_ERROR: 8,
|
|
98
|
+
PUBLISH_ERROR: 9
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/output/markdown.ts
|
|
102
|
+
import * as fs2 from "fs";
|
|
103
|
+
import * as path2 from "path";
|
|
104
|
+
var TYPE_ORDER = ["added", "changed", "deprecated", "removed", "fixed", "security"];
|
|
105
|
+
var TYPE_LABELS = {
|
|
106
|
+
added: "Added",
|
|
107
|
+
changed: "Changed",
|
|
108
|
+
deprecated: "Deprecated",
|
|
109
|
+
removed: "Removed",
|
|
110
|
+
fixed: "Fixed",
|
|
111
|
+
security: "Security"
|
|
112
|
+
};
|
|
113
|
+
function groupEntriesByType(entries) {
|
|
114
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
115
|
+
for (const type of TYPE_ORDER) {
|
|
116
|
+
grouped.set(type, []);
|
|
117
|
+
}
|
|
118
|
+
for (const entry of entries) {
|
|
119
|
+
const existing = grouped.get(entry.type) ?? [];
|
|
120
|
+
existing.push(entry);
|
|
121
|
+
grouped.set(entry.type, existing);
|
|
122
|
+
}
|
|
123
|
+
return grouped;
|
|
124
|
+
}
|
|
125
|
+
function formatEntry(entry) {
|
|
126
|
+
let line;
|
|
127
|
+
if (entry.breaking && entry.scope) {
|
|
128
|
+
line = `- **BREAKING** **${entry.scope}**: ${entry.description}`;
|
|
129
|
+
} else if (entry.breaking) {
|
|
130
|
+
line = `- **BREAKING** ${entry.description}`;
|
|
131
|
+
} else if (entry.scope) {
|
|
132
|
+
line = `- **${entry.scope}**: ${entry.description}`;
|
|
133
|
+
} else {
|
|
134
|
+
line = `- ${entry.description}`;
|
|
135
|
+
}
|
|
136
|
+
if (entry.issueIds && entry.issueIds.length > 0) {
|
|
137
|
+
line += ` (${entry.issueIds.join(", ")})`;
|
|
138
|
+
}
|
|
139
|
+
return line;
|
|
140
|
+
}
|
|
141
|
+
function formatVersion(context, options) {
|
|
142
|
+
const lines = [];
|
|
143
|
+
const versionLabel = options?.includePackageName && context.packageName ? `${context.packageName}@${context.version}` : context.version;
|
|
144
|
+
const versionHeader = context.previousVersion ? `## [${versionLabel}]` : `## ${versionLabel}`;
|
|
145
|
+
lines.push(`${versionHeader} - ${context.date}`);
|
|
146
|
+
lines.push("");
|
|
147
|
+
if (context.compareUrl) {
|
|
148
|
+
lines.push(`[Full Changelog](${context.compareUrl})`);
|
|
149
|
+
lines.push("");
|
|
150
|
+
}
|
|
151
|
+
if (context.enhanced?.summary) {
|
|
152
|
+
lines.push(context.enhanced.summary);
|
|
153
|
+
lines.push("");
|
|
154
|
+
}
|
|
155
|
+
const grouped = groupEntriesByType(context.entries);
|
|
156
|
+
for (const [type, entries] of grouped) {
|
|
157
|
+
if (entries.length === 0) continue;
|
|
158
|
+
lines.push(`### ${TYPE_LABELS[type]}`);
|
|
159
|
+
for (const entry of entries) {
|
|
160
|
+
lines.push(formatEntry(entry));
|
|
161
|
+
}
|
|
162
|
+
lines.push("");
|
|
163
|
+
}
|
|
164
|
+
return lines.join("\n");
|
|
165
|
+
}
|
|
166
|
+
function formatHeader() {
|
|
167
|
+
return `# Changelog
|
|
168
|
+
|
|
169
|
+
All notable changes to this project will be documented in this file.
|
|
170
|
+
|
|
171
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
172
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
173
|
+
|
|
174
|
+
`;
|
|
175
|
+
}
|
|
176
|
+
function renderMarkdown(contexts, options) {
|
|
177
|
+
const sections = [formatHeader()];
|
|
178
|
+
for (const context of contexts) {
|
|
179
|
+
sections.push(formatVersion(context, options));
|
|
180
|
+
}
|
|
181
|
+
return sections.join("\n");
|
|
182
|
+
}
|
|
183
|
+
function prependVersion(existingPath, context, options) {
|
|
184
|
+
let existing = "";
|
|
185
|
+
if (fs2.existsSync(existingPath)) {
|
|
186
|
+
existing = fs2.readFileSync(existingPath, "utf-8");
|
|
187
|
+
const headerEnd = existing.indexOf("\n## ");
|
|
188
|
+
if (headerEnd >= 0) {
|
|
189
|
+
const header = existing.slice(0, headerEnd);
|
|
190
|
+
const body = existing.slice(headerEnd + 1);
|
|
191
|
+
const newVersion = formatVersion(context, options);
|
|
192
|
+
return `${header}
|
|
193
|
+
|
|
194
|
+
${newVersion}
|
|
195
|
+
${body}`;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return renderMarkdown([context]);
|
|
199
|
+
}
|
|
200
|
+
function writeMarkdown(outputPath, contexts, config, dryRun, options) {
|
|
201
|
+
const content = renderMarkdown(contexts, options);
|
|
202
|
+
const label = /changelog/i.test(outputPath) ? "Changelog" : "Release notes";
|
|
203
|
+
if (dryRun) {
|
|
204
|
+
info(`[DRY RUN] ${label} preview (would write to ${outputPath}):`);
|
|
205
|
+
info(content);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const dir = path2.dirname(outputPath);
|
|
209
|
+
if (!fs2.existsSync(dir)) {
|
|
210
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
211
|
+
}
|
|
212
|
+
if (outputPath === "-") {
|
|
213
|
+
process.stdout.write(content);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (config.updateStrategy === "prepend" && fs2.existsSync(outputPath) && contexts.length === 1) {
|
|
217
|
+
const firstContext = contexts[0];
|
|
218
|
+
if (firstContext) {
|
|
219
|
+
const updated = prependVersion(outputPath, firstContext, options);
|
|
220
|
+
fs2.writeFileSync(outputPath, updated, "utf-8");
|
|
221
|
+
}
|
|
222
|
+
} else {
|
|
223
|
+
fs2.writeFileSync(outputPath, content, "utf-8");
|
|
224
|
+
}
|
|
225
|
+
success(`${label} written to ${outputPath}`);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export {
|
|
229
|
+
readPackageVersion,
|
|
230
|
+
setLogLevel,
|
|
231
|
+
setQuietMode,
|
|
232
|
+
error,
|
|
233
|
+
warn,
|
|
234
|
+
info,
|
|
235
|
+
success,
|
|
236
|
+
debug,
|
|
237
|
+
ReleaseKitError,
|
|
238
|
+
EXIT_CODES,
|
|
239
|
+
formatVersion,
|
|
240
|
+
renderMarkdown,
|
|
241
|
+
prependVersion,
|
|
242
|
+
writeMarkdown
|
|
243
|
+
};
|