@releasekit/notes 0.27.0 → 0.28.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/dist/{chunk-RASPVTWN.js → chunk-5TPZELKB.js} +132 -81
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/docs/templates.md +12 -0
- package/package.json +1 -1
|
@@ -357,6 +357,9 @@ var LLMConfigSchema = z.object({
|
|
|
357
357
|
}).default({ pullRequests: true }).describe("Additional context sources for the LLM."),
|
|
358
358
|
categoryOrder: z.array(z.string()).optional().describe(
|
|
359
359
|
"Explicit ordering of categories in the output. Categories not listed retain their configured order after the listed ones."
|
|
360
|
+
),
|
|
361
|
+
cache: z.boolean().default(false).describe(
|
|
362
|
+
"Cache LLM responses on disk (under the OS temp dir), keyed by a hash of the provider, model, prompt, and request options. A re-run or backfill with the same inputs reuses the cached generation instead of re-calling the provider. Off by default."
|
|
360
363
|
)
|
|
361
364
|
});
|
|
362
365
|
var ReleaseNotesConfigSchema = z.object({
|
|
@@ -731,8 +734,55 @@ function getDefaultConfig() {
|
|
|
731
734
|
}
|
|
732
735
|
|
|
733
736
|
// src/core/pipeline.ts
|
|
734
|
-
import * as
|
|
735
|
-
import * as
|
|
737
|
+
import * as fs13 from "fs";
|
|
738
|
+
import * as path12 from "path";
|
|
739
|
+
|
|
740
|
+
// src/llm/cache.ts
|
|
741
|
+
import { createHash } from "crypto";
|
|
742
|
+
import * as fs6 from "fs/promises";
|
|
743
|
+
import * as os2 from "os";
|
|
744
|
+
import * as path6 from "path";
|
|
745
|
+
function defaultCacheDir() {
|
|
746
|
+
return path6.join(os2.tmpdir(), "releasekit", "llm-cache");
|
|
747
|
+
}
|
|
748
|
+
function stableStringify(value) {
|
|
749
|
+
return JSON.stringify(
|
|
750
|
+
value,
|
|
751
|
+
(_key, val) => val && typeof val === "object" && !Array.isArray(val) ? Object.fromEntries(Object.entries(val).sort(([a], [b]) => a < b ? -1 : 1)) : val
|
|
752
|
+
);
|
|
753
|
+
}
|
|
754
|
+
function withContentHashCache(provider, identity, dir = defaultCacheDir()) {
|
|
755
|
+
return {
|
|
756
|
+
name: provider.name,
|
|
757
|
+
capabilities: provider.capabilities,
|
|
758
|
+
async complete(messages, options) {
|
|
759
|
+
const key = createHash("sha256").update(
|
|
760
|
+
stableStringify({
|
|
761
|
+
provider: provider.name,
|
|
762
|
+
model: identity.model,
|
|
763
|
+
baseURL: identity.baseURL,
|
|
764
|
+
messages,
|
|
765
|
+
temperature: options?.temperature,
|
|
766
|
+
maxTokens: options?.maxTokens,
|
|
767
|
+
schema: options?.schema,
|
|
768
|
+
toolName: options?.toolName
|
|
769
|
+
})
|
|
770
|
+
).digest("hex");
|
|
771
|
+
const file = path6.join(dir, `${key}.json`);
|
|
772
|
+
try {
|
|
773
|
+
return JSON.parse(await fs6.readFile(file, "utf-8"));
|
|
774
|
+
} catch {
|
|
775
|
+
}
|
|
776
|
+
const result = await provider.complete(messages, options);
|
|
777
|
+
try {
|
|
778
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
779
|
+
await fs6.writeFile(file, JSON.stringify(result));
|
|
780
|
+
} catch {
|
|
781
|
+
}
|
|
782
|
+
return result;
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
}
|
|
736
786
|
|
|
737
787
|
// src/llm/context/prFetcher.ts
|
|
738
788
|
import { RequestError } from "@octokit/request-error";
|
|
@@ -845,10 +895,10 @@ var LLM_DEFAULTS = {
|
|
|
845
895
|
};
|
|
846
896
|
|
|
847
897
|
// src/llm/examples/fetcher.ts
|
|
848
|
-
import { createHash } from "crypto";
|
|
849
|
-
import * as
|
|
850
|
-
import * as
|
|
851
|
-
import * as
|
|
898
|
+
import { createHash as createHash2 } from "crypto";
|
|
899
|
+
import * as fs7 from "fs";
|
|
900
|
+
import * as os3 from "os";
|
|
901
|
+
import * as path7 from "path";
|
|
852
902
|
import { RequestError as RequestError2 } from "@octokit/request-error";
|
|
853
903
|
import { Octokit as Octokit2 } from "@octokit/rest";
|
|
854
904
|
|
|
@@ -904,16 +954,16 @@ ${blocks.join("\n")}
|
|
|
904
954
|
|
|
905
955
|
// src/llm/examples/fetcher.ts
|
|
906
956
|
function cacheDir() {
|
|
907
|
-
return
|
|
957
|
+
return path7.join(os3.tmpdir(), "releasekit", "examples");
|
|
908
958
|
}
|
|
909
959
|
function cacheKey(owner, repo, packageName) {
|
|
910
960
|
const safe = packageName.replace(/[^a-zA-Z0-9-]/g, "_");
|
|
911
|
-
const hash =
|
|
912
|
-
return
|
|
961
|
+
const hash = createHash2("sha256").update(packageName).digest("hex").slice(0, 8);
|
|
962
|
+
return path7.join(cacheDir(), owner, repo, `${safe}_${hash}.json`);
|
|
913
963
|
}
|
|
914
964
|
function readCache(key, latestTag, count) {
|
|
915
965
|
try {
|
|
916
|
-
const raw =
|
|
966
|
+
const raw = fs7.readFileSync(key, "utf-8");
|
|
917
967
|
const entry = JSON.parse(raw);
|
|
918
968
|
if (entry.latestTag !== latestTag || entry.count < count) return null;
|
|
919
969
|
return entry.examples;
|
|
@@ -923,8 +973,8 @@ function readCache(key, latestTag, count) {
|
|
|
923
973
|
}
|
|
924
974
|
function writeCache(key, latestTag, count, examples) {
|
|
925
975
|
try {
|
|
926
|
-
|
|
927
|
-
|
|
976
|
+
fs7.mkdirSync(path7.dirname(key), { recursive: true });
|
|
977
|
+
fs7.writeFileSync(key, JSON.stringify({ latestTag, count, examples }), "utf-8");
|
|
928
978
|
} catch {
|
|
929
979
|
}
|
|
930
980
|
}
|
|
@@ -1079,6 +1129,16 @@ var AnthropicProvider = class extends BaseLLMProvider {
|
|
|
1079
1129
|
}
|
|
1080
1130
|
};
|
|
1081
1131
|
|
|
1132
|
+
// src/utils/json.ts
|
|
1133
|
+
function extractJsonFromResponse(response) {
|
|
1134
|
+
const stripped = response.replace(/^```(?:json)?\n?/, "").replace(/\n?```$/, "").trim();
|
|
1135
|
+
const objectMatch = stripped.match(/\{[\s\S]*\}/);
|
|
1136
|
+
if (objectMatch) return objectMatch[0];
|
|
1137
|
+
const arrayMatch = stripped.match(/\[[\s\S]*\]/);
|
|
1138
|
+
if (arrayMatch) return arrayMatch[0];
|
|
1139
|
+
return stripped;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1082
1142
|
// src/llm/ollama.ts
|
|
1083
1143
|
var OllamaProvider = class extends BaseLLMProvider {
|
|
1084
1144
|
name = "ollama";
|
|
@@ -1141,7 +1201,7 @@ var OllamaProvider = class extends BaseLLMProvider {
|
|
|
1141
1201
|
const content = data.message.content;
|
|
1142
1202
|
if (options?.schema) {
|
|
1143
1203
|
try {
|
|
1144
|
-
const structured = JSON.parse(content);
|
|
1204
|
+
const structured = JSON.parse(extractJsonFromResponse(content));
|
|
1145
1205
|
return { content, structured };
|
|
1146
1206
|
} catch (e) {
|
|
1147
1207
|
debug(`Ollama: failed to parse structured response: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -1208,7 +1268,7 @@ var OpenAIProvider = class extends BaseLLMProvider {
|
|
|
1208
1268
|
}
|
|
1209
1269
|
if (options?.schema) {
|
|
1210
1270
|
try {
|
|
1211
|
-
const structured = JSON.parse(content);
|
|
1271
|
+
const structured = JSON.parse(extractJsonFromResponse(content));
|
|
1212
1272
|
return { content, structured };
|
|
1213
1273
|
} catch (e) {
|
|
1214
1274
|
debug(`OpenAI: failed to parse structured response: ${e instanceof Error ? e.message : String(e)}`);
|
|
@@ -1267,16 +1327,6 @@ var OpenAICompatibleProvider = class extends BaseLLMProvider {
|
|
|
1267
1327
|
}
|
|
1268
1328
|
};
|
|
1269
1329
|
|
|
1270
|
-
// src/utils/json.ts
|
|
1271
|
-
function extractJsonFromResponse(response) {
|
|
1272
|
-
const stripped = response.replace(/^```(?:json)?\n?/, "").replace(/\n?```$/, "").trim();
|
|
1273
|
-
const objectMatch = stripped.match(/\{[\s\S]*\}/);
|
|
1274
|
-
if (objectMatch) return objectMatch[0];
|
|
1275
|
-
const arrayMatch = stripped.match(/\[[\s\S]*\]/);
|
|
1276
|
-
if (arrayMatch) return arrayMatch[0];
|
|
1277
|
-
return stripped;
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
1330
|
// src/llm/correctiveRetry.ts
|
|
1281
1331
|
async function withCorrectiveRetry(call, validate, buildCorrectionMessages3, initialMessages, maxCorrectiveAttempts = 2) {
|
|
1282
1332
|
let messages = initialMessages;
|
|
@@ -1914,20 +1964,20 @@ function createProvider(config) {
|
|
|
1914
1964
|
}
|
|
1915
1965
|
|
|
1916
1966
|
// src/output/versioned.ts
|
|
1917
|
-
import * as
|
|
1918
|
-
import * as
|
|
1967
|
+
import * as fs8 from "fs";
|
|
1968
|
+
import * as path8 from "path";
|
|
1919
1969
|
function writeVersionedNotes(contexts, directory, dryRun, nested, renderContent) {
|
|
1920
1970
|
const written = [];
|
|
1921
1971
|
for (const ctx of contexts) {
|
|
1922
|
-
const outputPath = nested ?
|
|
1972
|
+
const outputPath = nested ? path8.join(directory, ctx.packageName, `${ctx.version}.md`) : path8.join(directory, `${ctx.version}.md`);
|
|
1923
1973
|
const content = renderContent(ctx);
|
|
1924
1974
|
if (dryRun) {
|
|
1925
1975
|
info(`[DRY RUN] Release notes (would write to ${outputPath}):`);
|
|
1926
1976
|
info(content);
|
|
1927
1977
|
continue;
|
|
1928
1978
|
}
|
|
1929
|
-
|
|
1930
|
-
|
|
1979
|
+
fs8.mkdirSync(path8.dirname(outputPath), { recursive: true });
|
|
1980
|
+
fs8.writeFileSync(outputPath, content, "utf-8");
|
|
1931
1981
|
success(`Release notes written to ${outputPath}`);
|
|
1932
1982
|
written.push(outputPath);
|
|
1933
1983
|
}
|
|
@@ -1935,7 +1985,7 @@ function writeVersionedNotes(contexts, directory, dryRun, nested, renderContent)
|
|
|
1935
1985
|
}
|
|
1936
1986
|
|
|
1937
1987
|
// src/templates/ejs.ts
|
|
1938
|
-
import * as
|
|
1988
|
+
import * as fs9 from "fs";
|
|
1939
1989
|
import ejs from "ejs";
|
|
1940
1990
|
function renderEjs(template, context) {
|
|
1941
1991
|
try {
|
|
@@ -1945,16 +1995,16 @@ function renderEjs(template, context) {
|
|
|
1945
1995
|
}
|
|
1946
1996
|
}
|
|
1947
1997
|
function renderEjsFile(filePath, context) {
|
|
1948
|
-
if (!
|
|
1998
|
+
if (!fs9.existsSync(filePath)) {
|
|
1949
1999
|
throw new TemplateError(`Template file not found: ${filePath}`);
|
|
1950
2000
|
}
|
|
1951
|
-
const template =
|
|
2001
|
+
const template = fs9.readFileSync(filePath, "utf-8");
|
|
1952
2002
|
return renderEjs(template, context);
|
|
1953
2003
|
}
|
|
1954
2004
|
|
|
1955
2005
|
// src/templates/handlebars.ts
|
|
1956
|
-
import * as
|
|
1957
|
-
import * as
|
|
2006
|
+
import * as fs10 from "fs";
|
|
2007
|
+
import * as path9 from "path";
|
|
1958
2008
|
import Handlebars from "handlebars";
|
|
1959
2009
|
function registerHandlebarsHelpers() {
|
|
1960
2010
|
Handlebars.registerHelper("capitalize", (str) => {
|
|
@@ -1980,28 +2030,28 @@ function renderHandlebars(template, context) {
|
|
|
1980
2030
|
}
|
|
1981
2031
|
}
|
|
1982
2032
|
function renderHandlebarsFile(filePath, context) {
|
|
1983
|
-
if (!
|
|
2033
|
+
if (!fs10.existsSync(filePath)) {
|
|
1984
2034
|
throw new TemplateError(`Template file not found: ${filePath}`);
|
|
1985
2035
|
}
|
|
1986
|
-
const template =
|
|
2036
|
+
const template = fs10.readFileSync(filePath, "utf-8");
|
|
1987
2037
|
return renderHandlebars(template, context);
|
|
1988
2038
|
}
|
|
1989
2039
|
function renderHandlebarsComposable(templateDir, context) {
|
|
1990
2040
|
registerHandlebarsHelpers();
|
|
1991
|
-
const versionPath =
|
|
1992
|
-
const entryPath =
|
|
1993
|
-
const documentPath =
|
|
1994
|
-
if (!
|
|
2041
|
+
const versionPath = path9.join(templateDir, "version.hbs");
|
|
2042
|
+
const entryPath = path9.join(templateDir, "entry.hbs");
|
|
2043
|
+
const documentPath = path9.join(templateDir, "document.hbs");
|
|
2044
|
+
if (!fs10.existsSync(documentPath)) {
|
|
1995
2045
|
throw new TemplateError(`Document template not found: ${documentPath}`);
|
|
1996
2046
|
}
|
|
1997
|
-
if (
|
|
1998
|
-
Handlebars.registerPartial("version",
|
|
2047
|
+
if (fs10.existsSync(versionPath)) {
|
|
2048
|
+
Handlebars.registerPartial("version", fs10.readFileSync(versionPath, "utf-8"));
|
|
1999
2049
|
}
|
|
2000
|
-
if (
|
|
2001
|
-
Handlebars.registerPartial("entry",
|
|
2050
|
+
if (fs10.existsSync(entryPath)) {
|
|
2051
|
+
Handlebars.registerPartial("entry", fs10.readFileSync(entryPath, "utf-8"));
|
|
2002
2052
|
}
|
|
2003
2053
|
try {
|
|
2004
|
-
const compiled = Handlebars.compile(
|
|
2054
|
+
const compiled = Handlebars.compile(fs10.readFileSync(documentPath, "utf-8"));
|
|
2005
2055
|
return compiled(context);
|
|
2006
2056
|
} catch (error2) {
|
|
2007
2057
|
throw new TemplateError(`Handlebars render error: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
@@ -2009,8 +2059,8 @@ function renderHandlebarsComposable(templateDir, context) {
|
|
|
2009
2059
|
}
|
|
2010
2060
|
|
|
2011
2061
|
// src/templates/liquid.ts
|
|
2012
|
-
import * as
|
|
2013
|
-
import * as
|
|
2062
|
+
import * as fs11 from "fs";
|
|
2063
|
+
import * as path10 from "path";
|
|
2014
2064
|
import { Liquid } from "liquidjs";
|
|
2015
2065
|
function createLiquidEngine(root) {
|
|
2016
2066
|
return new Liquid({
|
|
@@ -2028,15 +2078,15 @@ function renderLiquid(template, context) {
|
|
|
2028
2078
|
}
|
|
2029
2079
|
}
|
|
2030
2080
|
function renderLiquidFile(filePath, context) {
|
|
2031
|
-
if (!
|
|
2081
|
+
if (!fs11.existsSync(filePath)) {
|
|
2032
2082
|
throw new TemplateError(`Template file not found: ${filePath}`);
|
|
2033
2083
|
}
|
|
2034
|
-
const template =
|
|
2084
|
+
const template = fs11.readFileSync(filePath, "utf-8");
|
|
2035
2085
|
return renderLiquid(template, context);
|
|
2036
2086
|
}
|
|
2037
2087
|
function renderLiquidComposable(templateDir, context) {
|
|
2038
|
-
const documentPath =
|
|
2039
|
-
if (!
|
|
2088
|
+
const documentPath = path10.join(templateDir, "document.liquid");
|
|
2089
|
+
if (!fs11.existsSync(documentPath)) {
|
|
2040
2090
|
throw new TemplateError(`Document template not found: ${documentPath}`);
|
|
2041
2091
|
}
|
|
2042
2092
|
const engine = createLiquidEngine(templateDir);
|
|
@@ -2048,10 +2098,10 @@ function renderLiquidComposable(templateDir, context) {
|
|
|
2048
2098
|
}
|
|
2049
2099
|
|
|
2050
2100
|
// src/templates/loader.ts
|
|
2051
|
-
import * as
|
|
2052
|
-
import * as
|
|
2101
|
+
import * as fs12 from "fs";
|
|
2102
|
+
import * as path11 from "path";
|
|
2053
2103
|
function getEngineFromFile(filePath) {
|
|
2054
|
-
const ext =
|
|
2104
|
+
const ext = path11.extname(filePath).toLowerCase();
|
|
2055
2105
|
switch (ext) {
|
|
2056
2106
|
case ".liquid":
|
|
2057
2107
|
return "liquid";
|
|
@@ -2085,10 +2135,10 @@ function getRenderFileFn(engine) {
|
|
|
2085
2135
|
}
|
|
2086
2136
|
}
|
|
2087
2137
|
function detectTemplateMode(templatePath) {
|
|
2088
|
-
if (!
|
|
2138
|
+
if (!fs12.existsSync(templatePath)) {
|
|
2089
2139
|
throw new TemplateError(`Template path not found: ${templatePath}`);
|
|
2090
2140
|
}
|
|
2091
|
-
const stat =
|
|
2141
|
+
const stat = fs12.statSync(templatePath);
|
|
2092
2142
|
if (stat.isFile()) {
|
|
2093
2143
|
return "single";
|
|
2094
2144
|
}
|
|
@@ -2106,7 +2156,7 @@ function renderSingleFile(templatePath, context, engine) {
|
|
|
2106
2156
|
};
|
|
2107
2157
|
}
|
|
2108
2158
|
function renderComposable(templateDir, context, engine) {
|
|
2109
|
-
const files =
|
|
2159
|
+
const files = fs12.readdirSync(templateDir);
|
|
2110
2160
|
const engineMap = {
|
|
2111
2161
|
liquid: { document: "document.liquid", version: "version.liquid", entry: "entry.liquid" },
|
|
2112
2162
|
handlebars: { document: "document.hbs", version: "version.hbs", entry: "entry.hbs" },
|
|
@@ -2129,15 +2179,15 @@ function renderComposable(templateDir, context, engine) {
|
|
|
2129
2179
|
return { content: renderHandlebarsComposable(templateDir, context), engine: resolvedEngine };
|
|
2130
2180
|
}
|
|
2131
2181
|
const expectedFiles = engineMap[resolvedEngine];
|
|
2132
|
-
const documentPath =
|
|
2133
|
-
if (!
|
|
2182
|
+
const documentPath = path11.join(templateDir, expectedFiles.document);
|
|
2183
|
+
if (!fs12.existsSync(documentPath)) {
|
|
2134
2184
|
throw new TemplateError(`Document template not found: ${expectedFiles.document}`);
|
|
2135
2185
|
}
|
|
2136
|
-
const versionPath =
|
|
2137
|
-
const entryPath =
|
|
2186
|
+
const versionPath = path11.join(templateDir, expectedFiles.version);
|
|
2187
|
+
const entryPath = path11.join(templateDir, expectedFiles.entry);
|
|
2138
2188
|
const render = getRenderFn(resolvedEngine);
|
|
2139
|
-
const entryTemplate =
|
|
2140
|
-
const versionTemplate =
|
|
2189
|
+
const entryTemplate = fs12.existsSync(entryPath) ? fs12.readFileSync(entryPath, "utf-8") : null;
|
|
2190
|
+
const versionTemplate = fs12.existsSync(versionPath) ? fs12.readFileSync(versionPath, "utf-8") : null;
|
|
2141
2191
|
if (entryTemplate && versionTemplate) {
|
|
2142
2192
|
const versionsWithEntries = context.versions.map((versionCtx) => {
|
|
2143
2193
|
const entries = versionCtx.entries.map((entry) => {
|
|
@@ -2148,7 +2198,7 @@ function renderComposable(templateDir, context, engine) {
|
|
|
2148
2198
|
});
|
|
2149
2199
|
const docContext = { ...context, renderedVersions: versionsWithEntries };
|
|
2150
2200
|
return {
|
|
2151
|
-
content: render(
|
|
2201
|
+
content: render(fs12.readFileSync(documentPath, "utf-8"), docContext),
|
|
2152
2202
|
engine: resolvedEngine
|
|
2153
2203
|
};
|
|
2154
2204
|
}
|
|
@@ -2333,12 +2383,13 @@ async function processWithLLM(context, llmConfig, examples) {
|
|
|
2333
2383
|
info(`LLM base URL: ${llmConfig.baseURL}`);
|
|
2334
2384
|
}
|
|
2335
2385
|
const rawProvider = createProvider(llmConfig);
|
|
2386
|
+
const baseProvider = llmConfig.cache ? withContentHashCache(rawProvider, { model: llmConfig.model, baseURL: llmConfig.baseURL }) : rawProvider;
|
|
2336
2387
|
const retryOpts = llmConfig.retry ?? LLM_DEFAULTS.retry;
|
|
2337
2388
|
const configOptions = llmConfig.options;
|
|
2338
2389
|
const provider = {
|
|
2339
|
-
name:
|
|
2340
|
-
capabilities:
|
|
2341
|
-
complete: (messages, opts) => withRetry(() =>
|
|
2390
|
+
name: baseProvider.name,
|
|
2391
|
+
capabilities: baseProvider.capabilities,
|
|
2392
|
+
complete: (messages, opts) => withRetry(() => baseProvider.complete(messages, { ...configOptions, ...opts }), retryOpts)
|
|
2342
2393
|
};
|
|
2343
2394
|
const activeTasks = Object.entries(tasks).filter(([, enabled]) => enabled).map(([name]) => name);
|
|
2344
2395
|
info(`Running LLM tasks: ${activeTasks.join(", ")}`);
|
|
@@ -2394,17 +2445,17 @@ function getBuiltinTemplatePath(style) {
|
|
|
2394
2445
|
let packageRoot;
|
|
2395
2446
|
try {
|
|
2396
2447
|
const currentUrl = import.meta.url;
|
|
2397
|
-
packageRoot =
|
|
2398
|
-
packageRoot =
|
|
2448
|
+
packageRoot = path12.dirname(new URL(currentUrl).pathname);
|
|
2449
|
+
packageRoot = path12.join(packageRoot, "..", "..");
|
|
2399
2450
|
} catch {
|
|
2400
2451
|
packageRoot = __dirname;
|
|
2401
2452
|
}
|
|
2402
|
-
return
|
|
2453
|
+
return path12.join(packageRoot, "templates", style);
|
|
2403
2454
|
}
|
|
2404
2455
|
async function generateWithTemplate(contexts, templatesConfig, outputPath, repoUrl, dryRun) {
|
|
2405
2456
|
let templatePath;
|
|
2406
2457
|
if (templatesConfig?.path) {
|
|
2407
|
-
templatePath =
|
|
2458
|
+
templatePath = path12.resolve(templatesConfig.path);
|
|
2408
2459
|
} else {
|
|
2409
2460
|
templatePath = getBuiltinTemplatePath("keep-a-changelog");
|
|
2410
2461
|
}
|
|
@@ -2419,11 +2470,11 @@ async function generateWithTemplate(contexts, templatesConfig, outputPath, repoU
|
|
|
2419
2470
|
process.stdout.write(result.content);
|
|
2420
2471
|
return;
|
|
2421
2472
|
}
|
|
2422
|
-
const dir =
|
|
2423
|
-
if (!
|
|
2424
|
-
|
|
2473
|
+
const dir = path12.dirname(outputPath);
|
|
2474
|
+
if (!fs13.existsSync(dir)) {
|
|
2475
|
+
fs13.mkdirSync(dir, { recursive: true });
|
|
2425
2476
|
}
|
|
2426
|
-
|
|
2477
|
+
fs13.writeFileSync(outputPath, result.content, "utf-8");
|
|
2427
2478
|
const label = /changelog/i.test(outputPath) ? "Changelog" : "Release notes";
|
|
2428
2479
|
success(`${label} written to ${outputPath} (using ${result.engine} template)`);
|
|
2429
2480
|
}
|
|
@@ -2527,8 +2578,8 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
|
|
|
2527
2578
|
const nested = detectMonorepo(process.cwd()).isMonorepo || contexts.length > 1;
|
|
2528
2579
|
const renderContent = (ctx) => {
|
|
2529
2580
|
if (releaseNotesConfig.templates?.path) {
|
|
2530
|
-
const templatePath =
|
|
2531
|
-
const docCtx = { ...createDocumentContext([ctx], void 0), perPackage: true };
|
|
2581
|
+
const templatePath = path12.resolve(releaseNotesConfig.templates.path);
|
|
2582
|
+
const docCtx = { ...createDocumentContext([ctx], void 0), perPackage: true, output: "file" };
|
|
2532
2583
|
return renderTemplate(templatePath, docCtx, releaseNotesConfig.templates.engine).content;
|
|
2533
2584
|
}
|
|
2534
2585
|
if (ctx.enhanced?.releaseNotes) return ctx.enhanced.releaseNotes;
|
|
@@ -2552,8 +2603,8 @@ async function runPipeline(input, config, dryRun, pipelineOptions) {
|
|
|
2552
2603
|
} else if (releaseNotesConfig) {
|
|
2553
2604
|
if (releaseNotesConfig.templates?.path) {
|
|
2554
2605
|
try {
|
|
2555
|
-
const templatePath =
|
|
2556
|
-
const docCtx = { ...createDocumentContext([ctx], void 0), perPackage: true };
|
|
2606
|
+
const templatePath = path12.resolve(releaseNotesConfig.templates.path);
|
|
2607
|
+
const docCtx = { ...createDocumentContext([ctx], void 0), perPackage: true, output: "release" };
|
|
2557
2608
|
const rendered = renderTemplate(
|
|
2558
2609
|
templatePath,
|
|
2559
2610
|
docCtx,
|
|
@@ -2604,7 +2655,7 @@ async function writeMonorepoFiles(contexts, config, dryRun, fileName) {
|
|
|
2604
2655
|
}
|
|
2605
2656
|
|
|
2606
2657
|
// src/command.ts
|
|
2607
|
-
import * as
|
|
2658
|
+
import * as fs14 from "fs";
|
|
2608
2659
|
import * as readline from "readline";
|
|
2609
2660
|
import { Command } from "commander";
|
|
2610
2661
|
function createNotesCommand() {
|
|
@@ -2705,7 +2756,7 @@ function createNotesCommand() {
|
|
|
2705
2756
|
}
|
|
2706
2757
|
let inputJson;
|
|
2707
2758
|
if (options.input) {
|
|
2708
|
-
inputJson =
|
|
2759
|
+
inputJson = fs14.readFileSync(options.input, "utf-8");
|
|
2709
2760
|
} else {
|
|
2710
2761
|
inputJson = await readStdin();
|
|
2711
2762
|
}
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
package/docs/templates.md
CHANGED
|
@@ -71,6 +71,18 @@ The outermost template (`document`) receives:
|
|
|
71
71
|
| `unreleased` | `TemplateContext \| undefined` | Unreleased changes, if any |
|
|
72
72
|
| `compareUrls` | `Record<string, string> \| undefined` | Map of version → compare URL for all versions |
|
|
73
73
|
| `perPackage` | `boolean \| undefined` | `true` when rendered inline for a single package (e.g. GitHub release body). Use this to suppress document-level headings that are redundant when the content is embedded in a release that already shows the package name and version. |
|
|
74
|
+
| `output` | `'file' \| 'release' \| undefined` | Which release-notes destination this render targets: `'file'` (an in-repo per-version file) or `'release'` (the GitHub release body). Branch on it to emit content that only suits one — most importantly, docs-site **YAML frontmatter**, which would render as literal text in a GitHub release. |
|
|
75
|
+
|
|
76
|
+
A release-notes template that adds frontmatter for the in-repo file but not the GitHub release body:
|
|
77
|
+
|
|
78
|
+
```liquid
|
|
79
|
+
{% if output == "file" %}---
|
|
80
|
+
title: {{ versions[0].version }}
|
|
81
|
+
date: {{ versions[0].date }}
|
|
82
|
+
---
|
|
83
|
+
{% endif %}{% for v in versions %}{% for entry in v.entries %}- {{ entry.description }}
|
|
84
|
+
{% endfor %}{% endfor %}
|
|
85
|
+
```
|
|
74
86
|
|
|
75
87
|
### Version context
|
|
76
88
|
|
package/package.json
CHANGED