@releasekit/notes 0.1.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/README.md +223 -0
- package/dist/chunk-7Y5Y5LY6.js +1496 -0
- package/dist/chunk-DZVNOAOX.js +1447 -0
- package/dist/chunk-GN5RQW3G.js +1410 -0
- package/dist/chunk-NYHVW46L.js +1516 -0
- package/dist/chunk-R4KN5PKO.js +1509 -0
- package/dist/chunk-RKRG4VKL.js +1281 -0
- package/dist/chunk-RX6K7GTL.js +1363 -0
- package/dist/chunk-TQNHZXY7.js +1279 -0
- package/dist/chunk-WMYZTQDI.js +1496 -0
- package/dist/chunk-XRLAWPB3.js +1410 -0
- package/dist/cli.cjs +1544 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +172 -0
- package/dist/index.cjs +1473 -0
- package/dist/index.d.cts +177 -0
- package/dist/index.d.ts +177 -0
- package/dist/index.js +55 -0
- package/package.json +71 -0
- package/templates/angular/document.hbs +7 -0
- package/templates/angular/entry.hbs +2 -0
- package/templates/angular/version.hbs +8 -0
- package/templates/github-release/release.md.ejs +20 -0
- package/templates/keep-a-changelog/document.liquid +10 -0
- package/templates/keep-a-changelog/entry.liquid +2 -0
- package/templates/keep-a-changelog/version.liquid +54 -0
package/dist/cli.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
EXIT_CODES,
|
|
4
|
+
NotesError,
|
|
5
|
+
createTemplateContext,
|
|
6
|
+
detectMonorepo,
|
|
7
|
+
getDefaultConfig,
|
|
8
|
+
getExitCode,
|
|
9
|
+
loadConfig,
|
|
10
|
+
parsePackageVersioner,
|
|
11
|
+
runPipeline,
|
|
12
|
+
saveAuth,
|
|
13
|
+
writeMonorepoChangelogs
|
|
14
|
+
} from "./chunk-GN5RQW3G.js";
|
|
15
|
+
|
|
16
|
+
// src/cli.ts
|
|
17
|
+
import * as fs from "fs";
|
|
18
|
+
import * as readline from "readline";
|
|
19
|
+
import { error, info, setLogLevel, setQuietMode, success } from "@releasekit/core";
|
|
20
|
+
import { Command } from "commander";
|
|
21
|
+
var program = new Command();
|
|
22
|
+
program.name("releasekit-notes").description("Generate changelogs with LLM-powered enhancement and flexible templating").version("0.1.0");
|
|
23
|
+
program.command("generate", { isDefault: true }).description("Generate changelog from input data").option("-i, --input <file>", "Input file (default: stdin)").option("-o, --output <spec>", "Output spec (format:file)", collectOutputs, []).option("-t, --template <path>", "Template file or directory").option("-e, --engine <engine>", "Template engine (handlebars|liquid|ejs)").option("--monorepo <mode>", "Monorepo mode (root|packages|both)").option("--llm-provider <provider>", "LLM provider").option("--llm-model <model>", "LLM model").option("--llm-tasks <tasks>", "Comma-separated LLM tasks").option("--no-llm", "Disable LLM processing").option("--config <path>", "Config file path").option("--dry-run", "Preview without writing").option("--regenerate", "Regenerate entire changelog").option("-v, --verbose", "Increase verbosity", increaseVerbosity, 0).option("-q, --quiet", "Suppress non-error output").action(async (options) => {
|
|
24
|
+
setVerbosity(options.verbose);
|
|
25
|
+
if (options.quiet) setQuietMode(true);
|
|
26
|
+
try {
|
|
27
|
+
const config = loadConfig(process.cwd(), options.config);
|
|
28
|
+
if (options.output.length > 0) {
|
|
29
|
+
config.output = options.output;
|
|
30
|
+
}
|
|
31
|
+
if (config.output.length === 0) {
|
|
32
|
+
config.output = getDefaultConfig().output;
|
|
33
|
+
}
|
|
34
|
+
if (options.regenerate) {
|
|
35
|
+
config.updateStrategy = "regenerate";
|
|
36
|
+
}
|
|
37
|
+
if (options.template) {
|
|
38
|
+
config.templates = { ...config.templates, path: options.template };
|
|
39
|
+
}
|
|
40
|
+
if (options.engine) {
|
|
41
|
+
config.templates = { ...config.templates, engine: options.engine };
|
|
42
|
+
}
|
|
43
|
+
if (options.llm === false) {
|
|
44
|
+
delete config.llm;
|
|
45
|
+
} else if (options.llmProvider || options.llmModel || options.llmTasks) {
|
|
46
|
+
config.llm = config.llm ?? { provider: "openai-compatible", model: "" };
|
|
47
|
+
if (options.llmProvider) config.llm.provider = options.llmProvider;
|
|
48
|
+
if (options.llmModel) config.llm.model = options.llmModel;
|
|
49
|
+
if (options.llmTasks) {
|
|
50
|
+
const taskNames = options.llmTasks.split(",").map((t) => t.trim());
|
|
51
|
+
config.llm.tasks = {
|
|
52
|
+
enhance: taskNames.includes("enhance"),
|
|
53
|
+
summarize: taskNames.includes("summarize"),
|
|
54
|
+
categorize: taskNames.includes("categorize"),
|
|
55
|
+
releaseNotes: taskNames.includes("release-notes") || taskNames.includes("releaseNotes")
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
let inputJson;
|
|
60
|
+
if (options.input) {
|
|
61
|
+
inputJson = fs.readFileSync(options.input, "utf-8");
|
|
62
|
+
} else {
|
|
63
|
+
inputJson = await readStdin();
|
|
64
|
+
}
|
|
65
|
+
const input = parsePackageVersioner(inputJson);
|
|
66
|
+
if (options.monorepo || config.monorepo) {
|
|
67
|
+
const monorepoMode = options.monorepo ?? config.monorepo?.mode ?? "both";
|
|
68
|
+
const detected = detectMonorepo(process.cwd());
|
|
69
|
+
if (!detected.isMonorepo) {
|
|
70
|
+
info("No monorepo detected, using single package mode");
|
|
71
|
+
await runPipeline(input, config, options.dryRun ?? false);
|
|
72
|
+
} else {
|
|
73
|
+
info(`Monorepo detected with packages at ${detected.packagesPath}`);
|
|
74
|
+
const contexts = input.packages.map(createTemplateContext);
|
|
75
|
+
writeMonorepoChangelogs(
|
|
76
|
+
contexts,
|
|
77
|
+
{
|
|
78
|
+
rootPath: config.monorepo?.rootPath ?? process.cwd(),
|
|
79
|
+
packagesPath: config.monorepo?.packagesPath ?? detected.packagesPath,
|
|
80
|
+
mode: monorepoMode
|
|
81
|
+
},
|
|
82
|
+
config,
|
|
83
|
+
options.dryRun ?? false
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
} else {
|
|
87
|
+
await runPipeline(input, config, options.dryRun ?? false);
|
|
88
|
+
}
|
|
89
|
+
success("Changelog generation complete");
|
|
90
|
+
} catch (err) {
|
|
91
|
+
handleError(err);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
program.command("init").description("Create default configuration file").option("-f, --force", "Overwrite existing config").action((options) => {
|
|
95
|
+
const configPath = "releasekit.config.json";
|
|
96
|
+
if (fs.existsSync(configPath) && !options.force) {
|
|
97
|
+
error(`Config file already exists at ${configPath}. Use --force to overwrite.`);
|
|
98
|
+
process.exit(EXIT_CODES.GENERAL_ERROR);
|
|
99
|
+
}
|
|
100
|
+
const defaultConfig = {
|
|
101
|
+
$schema: "https://releasekit.dev/schema.json",
|
|
102
|
+
notes: {
|
|
103
|
+
output: [{ format: "markdown", file: "CHANGELOG.md" }],
|
|
104
|
+
updateStrategy: "prepend"
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
fs.writeFileSync(configPath, JSON.stringify(defaultConfig, null, 2), "utf-8");
|
|
108
|
+
success(`Created config file at ${configPath}`);
|
|
109
|
+
});
|
|
110
|
+
program.command("auth <provider>").description("Configure API key for an LLM provider").option("--key <key>", "API key (omit to be prompted)").action(async (provider, options) => {
|
|
111
|
+
let apiKey;
|
|
112
|
+
if (options.key) {
|
|
113
|
+
apiKey = options.key;
|
|
114
|
+
} else {
|
|
115
|
+
apiKey = await promptSecret(`Enter API key for ${provider}: `);
|
|
116
|
+
}
|
|
117
|
+
if (!apiKey.trim()) {
|
|
118
|
+
error("API key cannot be empty");
|
|
119
|
+
process.exit(EXIT_CODES.GENERAL_ERROR);
|
|
120
|
+
}
|
|
121
|
+
saveAuth(provider, apiKey.trim());
|
|
122
|
+
success(`API key saved for ${provider}`);
|
|
123
|
+
});
|
|
124
|
+
program.command("providers").description("List available LLM providers").action(() => {
|
|
125
|
+
info("Available LLM providers:");
|
|
126
|
+
console.log(" openai - OpenAI (GPT models)");
|
|
127
|
+
console.log(" anthropic - Anthropic (Claude models)");
|
|
128
|
+
console.log(" ollama - Ollama (local models)");
|
|
129
|
+
console.log(" openai-compatible - Any OpenAI-compatible endpoint");
|
|
130
|
+
});
|
|
131
|
+
function collectOutputs(value, previous) {
|
|
132
|
+
const parts = value.split(":");
|
|
133
|
+
const format = parts[0] ?? "markdown";
|
|
134
|
+
const file = parts[1];
|
|
135
|
+
const spec = { format };
|
|
136
|
+
if (file) {
|
|
137
|
+
spec.file = file;
|
|
138
|
+
}
|
|
139
|
+
return [...previous, spec];
|
|
140
|
+
}
|
|
141
|
+
function increaseVerbosity(_, previous) {
|
|
142
|
+
return previous + 1;
|
|
143
|
+
}
|
|
144
|
+
function setVerbosity(level) {
|
|
145
|
+
const levels = ["error", "warn", "info", "debug", "trace"];
|
|
146
|
+
setLogLevel(levels[Math.min(level, levels.length - 1)] ?? "error");
|
|
147
|
+
}
|
|
148
|
+
async function readStdin() {
|
|
149
|
+
const chunks = [];
|
|
150
|
+
for await (const chunk of process.stdin) {
|
|
151
|
+
chunks.push(chunk);
|
|
152
|
+
}
|
|
153
|
+
return chunks.join("");
|
|
154
|
+
}
|
|
155
|
+
function promptSecret(prompt) {
|
|
156
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
157
|
+
return new Promise((resolve) => {
|
|
158
|
+
rl.question(prompt, (answer) => {
|
|
159
|
+
rl.close();
|
|
160
|
+
resolve(answer);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function handleError(err) {
|
|
165
|
+
if (err instanceof NotesError) {
|
|
166
|
+
err.logError();
|
|
167
|
+
process.exit(getExitCode(err));
|
|
168
|
+
}
|
|
169
|
+
error(err instanceof Error ? err.message : String(err));
|
|
170
|
+
process.exit(EXIT_CODES.GENERAL_ERROR);
|
|
171
|
+
}
|
|
172
|
+
program.parse();
|