@releasekit/version 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 +5 -3
- package/dist/baseError-FARJUY5U.js +6 -0
- package/dist/chunk-2MN2VLZF.js +85 -0
- package/dist/{chunk-ZEXPJ53Z.js → chunk-V6S7BEBD.js} +523 -133
- package/dist/cli.d.ts +5 -2
- package/dist/cli.js +22 -23
- package/dist/index.d.ts +9 -208
- package/dist/index.js +4 -2
- package/docs/CI_CD_INTEGRATION.md +13 -13
- package/docs/versioning.md +14 -14
- package/package.json +14 -12
- package/version.schema.json +1 -1
- package/dist/baseError-ZCZHF6A2.js +0 -7
- package/dist/chunk-GQLJ7JQY.js +0 -18
- package/dist/cli.cjs +0 -2230
- package/dist/cli.d.cts +0 -4
- package/dist/index.cjs +0 -2150
- package/dist/index.d.cts +0 -208
|
@@ -1,13 +1,400 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BaseVersionError
|
|
3
|
-
|
|
2
|
+
BaseVersionError,
|
|
3
|
+
ReleaseKitError
|
|
4
|
+
} from "./chunk-2MN2VLZF.js";
|
|
4
5
|
import {
|
|
5
6
|
execAsync,
|
|
6
7
|
execSync
|
|
7
8
|
} from "./chunk-LMPZV35Z.js";
|
|
8
9
|
|
|
9
|
-
//
|
|
10
|
-
import
|
|
10
|
+
// ../config/dist/index.js
|
|
11
|
+
import * as fs from "fs";
|
|
12
|
+
import * as path from "path";
|
|
13
|
+
import * as TOML from "smol-toml";
|
|
14
|
+
import * as fs3 from "fs";
|
|
15
|
+
import * as path3 from "path";
|
|
16
|
+
import { z as z2 } from "zod";
|
|
17
|
+
import { z } from "zod";
|
|
18
|
+
import * as fs2 from "fs";
|
|
19
|
+
import * as os from "os";
|
|
20
|
+
import * as path2 from "path";
|
|
21
|
+
function parseCargoToml(cargoPath) {
|
|
22
|
+
const content = fs.readFileSync(cargoPath, "utf-8");
|
|
23
|
+
return TOML.parse(content);
|
|
24
|
+
}
|
|
25
|
+
function isCargoToml(filePath) {
|
|
26
|
+
return path.basename(filePath) === "Cargo.toml";
|
|
27
|
+
}
|
|
28
|
+
var ConfigError = class extends ReleaseKitError {
|
|
29
|
+
code = "CONFIG_ERROR";
|
|
30
|
+
suggestions;
|
|
31
|
+
constructor(message, suggestions) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.suggestions = suggestions ?? [
|
|
34
|
+
"Check that releasekit.config.json exists and is valid JSON",
|
|
35
|
+
"Run with --verbose for more details"
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var MAX_JSONC_LENGTH = 1e5;
|
|
40
|
+
function parseJsonc(content) {
|
|
41
|
+
if (content.length > MAX_JSONC_LENGTH) {
|
|
42
|
+
throw new Error(`JSONC content too long: ${content.length} characters (max ${MAX_JSONC_LENGTH})`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return JSON.parse(content);
|
|
46
|
+
} catch {
|
|
47
|
+
const cleaned = content.replace(/\/\/[^\r\n]{0,10000}$/gm, "").replace(/\/\*[\s\S]{0,50000}?\*\//g, "").trim();
|
|
48
|
+
return JSON.parse(cleaned);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
var GitConfigSchema = z.object({
|
|
52
|
+
remote: z.string().default("origin"),
|
|
53
|
+
branch: z.string().default("main"),
|
|
54
|
+
pushMethod: z.enum(["auto", "ssh", "https"]).default("auto"),
|
|
55
|
+
/**
|
|
56
|
+
* Optional env var name containing a GitHub token for HTTPS pushes.
|
|
57
|
+
* When set, publish steps can use this token without mutating git remotes.
|
|
58
|
+
*/
|
|
59
|
+
httpsTokenEnv: z.string().optional(),
|
|
60
|
+
push: z.boolean().optional(),
|
|
61
|
+
skipHooks: z.boolean().optional()
|
|
62
|
+
});
|
|
63
|
+
var MonorepoConfigSchema = z.object({
|
|
64
|
+
mode: z.enum(["root", "packages", "both"]).optional(),
|
|
65
|
+
rootPath: z.string().optional(),
|
|
66
|
+
packagesPath: z.string().optional(),
|
|
67
|
+
mainPackage: z.string().optional()
|
|
68
|
+
});
|
|
69
|
+
var BranchPatternSchema = z.object({
|
|
70
|
+
pattern: z.string(),
|
|
71
|
+
releaseType: z.enum(["major", "minor", "patch", "prerelease"])
|
|
72
|
+
});
|
|
73
|
+
var VersionCargoConfigSchema = z.object({
|
|
74
|
+
enabled: z.boolean().default(true),
|
|
75
|
+
paths: z.array(z.string()).optional()
|
|
76
|
+
});
|
|
77
|
+
var VersionConfigSchema = z.object({
|
|
78
|
+
tagTemplate: z.string().default("v{version}"),
|
|
79
|
+
packageSpecificTags: z.boolean().default(false),
|
|
80
|
+
preset: z.string().default("conventional"),
|
|
81
|
+
sync: z.boolean().default(true),
|
|
82
|
+
packages: z.array(z.string()).default([]),
|
|
83
|
+
mainPackage: z.string().optional(),
|
|
84
|
+
updateInternalDependencies: z.enum(["major", "minor", "patch", "no-internal-update"]).default("minor"),
|
|
85
|
+
skip: z.array(z.string()).optional(),
|
|
86
|
+
commitMessage: z.string().optional(),
|
|
87
|
+
versionStrategy: z.enum(["branchPattern", "commitMessage"]).default("commitMessage"),
|
|
88
|
+
branchPatterns: z.array(BranchPatternSchema).optional(),
|
|
89
|
+
defaultReleaseType: z.enum(["major", "minor", "patch", "prerelease"]).optional(),
|
|
90
|
+
mismatchStrategy: z.enum(["error", "warn", "ignore", "prefer-package", "prefer-git"]).default("warn"),
|
|
91
|
+
versionPrefix: z.string().default(""),
|
|
92
|
+
prereleaseIdentifier: z.string().optional(),
|
|
93
|
+
strictReachable: z.boolean().default(false),
|
|
94
|
+
cargo: VersionCargoConfigSchema.optional()
|
|
95
|
+
});
|
|
96
|
+
var NpmConfigSchema = z.object({
|
|
97
|
+
enabled: z.boolean().default(true),
|
|
98
|
+
auth: z.enum(["auto", "oidc", "token"]).default("auto"),
|
|
99
|
+
provenance: z.boolean().default(true),
|
|
100
|
+
access: z.enum(["public", "restricted"]).default("public"),
|
|
101
|
+
registry: z.string().default("https://registry.npmjs.org"),
|
|
102
|
+
copyFiles: z.array(z.string()).default(["LICENSE"]),
|
|
103
|
+
tag: z.string().default("latest")
|
|
104
|
+
});
|
|
105
|
+
var CargoPublishConfigSchema = z.object({
|
|
106
|
+
enabled: z.boolean().default(false),
|
|
107
|
+
noVerify: z.boolean().default(false),
|
|
108
|
+
publishOrder: z.array(z.string()).default([]),
|
|
109
|
+
clean: z.boolean().default(false)
|
|
110
|
+
});
|
|
111
|
+
var PublishGitConfigSchema = z.object({
|
|
112
|
+
push: z.boolean().default(true),
|
|
113
|
+
pushMethod: z.enum(["auto", "ssh", "https"]).optional(),
|
|
114
|
+
remote: z.string().optional(),
|
|
115
|
+
branch: z.string().optional(),
|
|
116
|
+
httpsTokenEnv: z.string().optional(),
|
|
117
|
+
skipHooks: z.boolean().optional()
|
|
118
|
+
});
|
|
119
|
+
var GitHubReleaseConfigSchema = z.object({
|
|
120
|
+
enabled: z.boolean().default(true),
|
|
121
|
+
draft: z.boolean().default(true),
|
|
122
|
+
perPackage: z.boolean().default(true),
|
|
123
|
+
prerelease: z.union([z.literal("auto"), z.boolean()]).default("auto"),
|
|
124
|
+
/**
|
|
125
|
+
* Controls how release notes are sourced for GitHub releases.
|
|
126
|
+
* - 'auto': Use RELEASE_NOTES.md if it exists, then per-package changelog
|
|
127
|
+
* data from the version output, then GitHub's auto-generated notes.
|
|
128
|
+
* - 'github': Always use GitHub's auto-generated notes.
|
|
129
|
+
* - 'none': No notes body.
|
|
130
|
+
* - Any other string: Treated as a file path to read notes from.
|
|
131
|
+
*/
|
|
132
|
+
releaseNotes: z.union([z.literal("auto"), z.literal("github"), z.literal("none"), z.string()]).default("auto")
|
|
133
|
+
});
|
|
134
|
+
var VerifyRegistryConfigSchema = z.object({
|
|
135
|
+
enabled: z.boolean().default(true),
|
|
136
|
+
maxAttempts: z.number().int().positive().default(5),
|
|
137
|
+
initialDelay: z.number().int().positive().default(15e3),
|
|
138
|
+
backoffMultiplier: z.number().positive().default(2)
|
|
139
|
+
});
|
|
140
|
+
var VerifyConfigSchema = z.object({
|
|
141
|
+
npm: VerifyRegistryConfigSchema.default({
|
|
142
|
+
enabled: true,
|
|
143
|
+
maxAttempts: 5,
|
|
144
|
+
initialDelay: 15e3,
|
|
145
|
+
backoffMultiplier: 2
|
|
146
|
+
}),
|
|
147
|
+
cargo: VerifyRegistryConfigSchema.default({
|
|
148
|
+
enabled: true,
|
|
149
|
+
maxAttempts: 10,
|
|
150
|
+
initialDelay: 3e4,
|
|
151
|
+
backoffMultiplier: 2
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
var PublishConfigSchema = z.object({
|
|
155
|
+
git: PublishGitConfigSchema.optional(),
|
|
156
|
+
npm: NpmConfigSchema.default({
|
|
157
|
+
enabled: true,
|
|
158
|
+
auth: "auto",
|
|
159
|
+
provenance: true,
|
|
160
|
+
access: "public",
|
|
161
|
+
registry: "https://registry.npmjs.org",
|
|
162
|
+
copyFiles: ["LICENSE"],
|
|
163
|
+
tag: "latest"
|
|
164
|
+
}),
|
|
165
|
+
cargo: CargoPublishConfigSchema.default({
|
|
166
|
+
enabled: false,
|
|
167
|
+
noVerify: false,
|
|
168
|
+
publishOrder: [],
|
|
169
|
+
clean: false
|
|
170
|
+
}),
|
|
171
|
+
githubRelease: GitHubReleaseConfigSchema.default({
|
|
172
|
+
enabled: true,
|
|
173
|
+
draft: true,
|
|
174
|
+
perPackage: true,
|
|
175
|
+
prerelease: "auto",
|
|
176
|
+
releaseNotes: "auto"
|
|
177
|
+
}),
|
|
178
|
+
verify: VerifyConfigSchema.default({
|
|
179
|
+
npm: {
|
|
180
|
+
enabled: true,
|
|
181
|
+
maxAttempts: 5,
|
|
182
|
+
initialDelay: 15e3,
|
|
183
|
+
backoffMultiplier: 2
|
|
184
|
+
},
|
|
185
|
+
cargo: {
|
|
186
|
+
enabled: true,
|
|
187
|
+
maxAttempts: 10,
|
|
188
|
+
initialDelay: 3e4,
|
|
189
|
+
backoffMultiplier: 2
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
var TemplateConfigSchema = z.object({
|
|
194
|
+
path: z.string().optional(),
|
|
195
|
+
engine: z.enum(["handlebars", "liquid", "ejs"]).optional()
|
|
196
|
+
});
|
|
197
|
+
var OutputConfigSchema = z.object({
|
|
198
|
+
format: z.enum(["markdown", "github-release", "json"]),
|
|
199
|
+
file: z.string().optional(),
|
|
200
|
+
options: z.record(z.string(), z.unknown()).optional(),
|
|
201
|
+
templates: TemplateConfigSchema.optional()
|
|
202
|
+
});
|
|
203
|
+
var LLMOptionsSchema = z.object({
|
|
204
|
+
timeout: z.number().optional(),
|
|
205
|
+
maxTokens: z.number().optional(),
|
|
206
|
+
temperature: z.number().optional()
|
|
207
|
+
});
|
|
208
|
+
var LLMRetryConfigSchema = z.object({
|
|
209
|
+
maxAttempts: z.number().int().positive().optional(),
|
|
210
|
+
initialDelay: z.number().nonnegative().optional(),
|
|
211
|
+
maxDelay: z.number().positive().optional(),
|
|
212
|
+
backoffFactor: z.number().positive().optional()
|
|
213
|
+
});
|
|
214
|
+
var LLMTasksConfigSchema = z.object({
|
|
215
|
+
summarize: z.boolean().optional(),
|
|
216
|
+
enhance: z.boolean().optional(),
|
|
217
|
+
categorize: z.boolean().optional(),
|
|
218
|
+
releaseNotes: z.boolean().optional()
|
|
219
|
+
});
|
|
220
|
+
var LLMCategorySchema = z.object({
|
|
221
|
+
name: z.string(),
|
|
222
|
+
description: z.string(),
|
|
223
|
+
scopes: z.array(z.string()).optional()
|
|
224
|
+
});
|
|
225
|
+
var ScopeRulesSchema = z.object({
|
|
226
|
+
allowed: z.array(z.string()).optional(),
|
|
227
|
+
caseSensitive: z.boolean().default(false),
|
|
228
|
+
invalidScopeAction: z.enum(["remove", "keep", "fallback"]).default("remove"),
|
|
229
|
+
fallbackScope: z.string().optional()
|
|
230
|
+
});
|
|
231
|
+
var ScopeConfigSchema = z.object({
|
|
232
|
+
mode: z.enum(["restricted", "packages", "none", "unrestricted"]).default("unrestricted"),
|
|
233
|
+
rules: ScopeRulesSchema.optional()
|
|
234
|
+
});
|
|
235
|
+
var LLMPromptOverridesSchema = z.object({
|
|
236
|
+
enhance: z.string().optional(),
|
|
237
|
+
categorize: z.string().optional(),
|
|
238
|
+
enhanceAndCategorize: z.string().optional(),
|
|
239
|
+
summarize: z.string().optional(),
|
|
240
|
+
releaseNotes: z.string().optional()
|
|
241
|
+
});
|
|
242
|
+
var LLMPromptsConfigSchema = z.object({
|
|
243
|
+
instructions: LLMPromptOverridesSchema.optional(),
|
|
244
|
+
templates: LLMPromptOverridesSchema.optional()
|
|
245
|
+
});
|
|
246
|
+
var LLMConfigSchema = z.object({
|
|
247
|
+
provider: z.string(),
|
|
248
|
+
model: z.string(),
|
|
249
|
+
baseURL: z.string().optional(),
|
|
250
|
+
apiKey: z.string().optional(),
|
|
251
|
+
options: LLMOptionsSchema.optional(),
|
|
252
|
+
concurrency: z.number().int().positive().optional(),
|
|
253
|
+
retry: LLMRetryConfigSchema.optional(),
|
|
254
|
+
tasks: LLMTasksConfigSchema.optional(),
|
|
255
|
+
categories: z.array(LLMCategorySchema).optional(),
|
|
256
|
+
style: z.string().optional(),
|
|
257
|
+
scopes: ScopeConfigSchema.optional(),
|
|
258
|
+
prompts: LLMPromptsConfigSchema.optional()
|
|
259
|
+
});
|
|
260
|
+
var NotesInputConfigSchema = z.object({
|
|
261
|
+
source: z.string().optional(),
|
|
262
|
+
file: z.string().optional()
|
|
263
|
+
});
|
|
264
|
+
var NotesConfigSchema = z.object({
|
|
265
|
+
input: NotesInputConfigSchema.optional(),
|
|
266
|
+
output: z.array(OutputConfigSchema).default([{ format: "markdown", file: "CHANGELOG.md" }]),
|
|
267
|
+
monorepo: MonorepoConfigSchema.optional(),
|
|
268
|
+
templates: TemplateConfigSchema.optional(),
|
|
269
|
+
llm: LLMConfigSchema.optional(),
|
|
270
|
+
updateStrategy: z.enum(["prepend", "regenerate"]).default("prepend")
|
|
271
|
+
});
|
|
272
|
+
var CILabelsConfigSchema = z.object({
|
|
273
|
+
stable: z.string().default("release:stable"),
|
|
274
|
+
prerelease: z.string().default("release:prerelease"),
|
|
275
|
+
skip: z.string().default("release:skip"),
|
|
276
|
+
major: z.string().default("release:major"),
|
|
277
|
+
minor: z.string().default("release:minor"),
|
|
278
|
+
patch: z.string().default("release:patch")
|
|
279
|
+
});
|
|
280
|
+
var CIConfigSchema = z.object({
|
|
281
|
+
releaseStrategy: z.enum(["manual", "direct", "standing-pr", "scheduled"]).default("direct"),
|
|
282
|
+
releaseTrigger: z.enum(["commit", "label"]).default("label"),
|
|
283
|
+
prPreview: z.boolean().default(true),
|
|
284
|
+
autoRelease: z.boolean().default(false),
|
|
285
|
+
/**
|
|
286
|
+
* Commit message prefixes that should not trigger a release.
|
|
287
|
+
* Defaults to `['chore: release ']` to match the release commit template
|
|
288
|
+
* (`chore: release ${packageName} v${version}`) and provide a
|
|
289
|
+
* secondary loop-prevention guard alongside `[skip ci]`.
|
|
290
|
+
*/
|
|
291
|
+
skipPatterns: z.array(z.string()).default(["chore: release "]),
|
|
292
|
+
minChanges: z.number().int().positive().default(1),
|
|
293
|
+
labels: CILabelsConfigSchema.default({
|
|
294
|
+
stable: "release:stable",
|
|
295
|
+
prerelease: "release:prerelease",
|
|
296
|
+
skip: "release:skip",
|
|
297
|
+
major: "release:major",
|
|
298
|
+
minor: "release:minor",
|
|
299
|
+
patch: "release:patch"
|
|
300
|
+
})
|
|
301
|
+
});
|
|
302
|
+
var ReleaseCIConfigSchema = z.object({
|
|
303
|
+
skipPatterns: z.array(z.string().min(1)).optional(),
|
|
304
|
+
minChanges: z.number().int().positive().optional(),
|
|
305
|
+
/** Set to `false` to disable GitHub release creation in CI. */
|
|
306
|
+
githubRelease: z.literal(false).optional(),
|
|
307
|
+
/** Set to `false` to disable changelog generation in CI. */
|
|
308
|
+
notes: z.literal(false).optional()
|
|
309
|
+
});
|
|
310
|
+
var ReleaseConfigSchema = z.object({
|
|
311
|
+
/**
|
|
312
|
+
* Optional steps to enable. The version step always runs; only 'notes' and
|
|
313
|
+
* 'publish' can be opted out. Omitting a step is equivalent to --skip-<step>.
|
|
314
|
+
*/
|
|
315
|
+
steps: z.array(z.enum(["notes", "publish"])).min(1).optional(),
|
|
316
|
+
ci: ReleaseCIConfigSchema.optional()
|
|
317
|
+
});
|
|
318
|
+
var ReleaseKitConfigSchema = z.object({
|
|
319
|
+
git: GitConfigSchema.optional(),
|
|
320
|
+
monorepo: MonorepoConfigSchema.optional(),
|
|
321
|
+
version: VersionConfigSchema.optional(),
|
|
322
|
+
publish: PublishConfigSchema.optional(),
|
|
323
|
+
notes: NotesConfigSchema.optional(),
|
|
324
|
+
ci: CIConfigSchema.optional(),
|
|
325
|
+
release: ReleaseConfigSchema.optional()
|
|
326
|
+
});
|
|
327
|
+
var MAX_INPUT_LENGTH = 1e4;
|
|
328
|
+
function substituteVariables(value) {
|
|
329
|
+
if (value.length > MAX_INPUT_LENGTH) {
|
|
330
|
+
throw new Error(`Input too long: ${value.length} characters (max ${MAX_INPUT_LENGTH})`);
|
|
331
|
+
}
|
|
332
|
+
const envPattern = /\{env:([^}]{1,1000})\}/g;
|
|
333
|
+
const filePattern = /\{file:([^}]{1,1000})\}/g;
|
|
334
|
+
let result = value;
|
|
335
|
+
result = result.replace(envPattern, (_, varName) => {
|
|
336
|
+
return process.env[varName] ?? "";
|
|
337
|
+
});
|
|
338
|
+
result = result.replace(filePattern, (_, filePath) => {
|
|
339
|
+
const expandedPath = filePath.startsWith("~") ? path2.join(os.homedir(), filePath.slice(1)) : filePath;
|
|
340
|
+
try {
|
|
341
|
+
return fs2.readFileSync(expandedPath, "utf-8").trim();
|
|
342
|
+
} catch {
|
|
343
|
+
return "";
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
var SOLE_REFERENCE_PATTERN = /^\{(?:env|file):[^}]+\}$/;
|
|
349
|
+
function substituteInObject(obj) {
|
|
350
|
+
if (typeof obj === "string") {
|
|
351
|
+
const result = substituteVariables(obj);
|
|
352
|
+
if (result === "" && SOLE_REFERENCE_PATTERN.test(obj)) {
|
|
353
|
+
return void 0;
|
|
354
|
+
}
|
|
355
|
+
return result;
|
|
356
|
+
}
|
|
357
|
+
if (Array.isArray(obj)) {
|
|
358
|
+
return obj.map((item) => substituteInObject(item));
|
|
359
|
+
}
|
|
360
|
+
if (obj && typeof obj === "object") {
|
|
361
|
+
const result = {};
|
|
362
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
363
|
+
result[key] = substituteInObject(value);
|
|
364
|
+
}
|
|
365
|
+
return result;
|
|
366
|
+
}
|
|
367
|
+
return obj;
|
|
368
|
+
}
|
|
369
|
+
var AUTH_DIR = path2.join(os.homedir(), ".config", "releasekit");
|
|
370
|
+
var AUTH_FILE = path2.join(AUTH_DIR, "auth.json");
|
|
371
|
+
var CONFIG_FILE = "releasekit.config.json";
|
|
372
|
+
function loadConfigFile(configPath) {
|
|
373
|
+
if (!fs3.existsSync(configPath)) {
|
|
374
|
+
return {};
|
|
375
|
+
}
|
|
376
|
+
try {
|
|
377
|
+
const content = fs3.readFileSync(configPath, "utf-8");
|
|
378
|
+
const parsed = parseJsonc(content);
|
|
379
|
+
const substituted = substituteInObject(parsed);
|
|
380
|
+
return ReleaseKitConfigSchema.parse(substituted);
|
|
381
|
+
} catch (error) {
|
|
382
|
+
if (error instanceof z2.ZodError) {
|
|
383
|
+
const issues = error.issues.map((i) => ` ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
384
|
+
throw new ConfigError(`Config validation errors:
|
|
385
|
+
${issues}`);
|
|
386
|
+
}
|
|
387
|
+
if (error instanceof SyntaxError) {
|
|
388
|
+
throw new ConfigError(`Invalid JSON in config file: ${error.message}`);
|
|
389
|
+
}
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function loadConfig(options) {
|
|
394
|
+
const cwd3 = options?.cwd ?? process.cwd();
|
|
395
|
+
const configPath = options?.configPath ?? path3.join(cwd3, CONFIG_FILE);
|
|
396
|
+
return loadConfigFile(configPath);
|
|
397
|
+
}
|
|
11
398
|
|
|
12
399
|
// src/types.ts
|
|
13
400
|
function toVersionConfig(config, gitConfig) {
|
|
@@ -48,8 +435,8 @@ function toVersionConfig(config, gitConfig) {
|
|
|
48
435
|
}
|
|
49
436
|
|
|
50
437
|
// src/config.ts
|
|
51
|
-
function
|
|
52
|
-
const fullConfig =
|
|
438
|
+
function loadConfig2(options) {
|
|
439
|
+
const fullConfig = loadConfig(options);
|
|
53
440
|
return toVersionConfig(fullConfig.version, fullConfig.git);
|
|
54
441
|
}
|
|
55
442
|
|
|
@@ -111,11 +498,14 @@ function createVersionError(code, details) {
|
|
|
111
498
|
}
|
|
112
499
|
|
|
113
500
|
// src/utils/jsonOutput.ts
|
|
501
|
+
import fs4 from "fs";
|
|
114
502
|
var _jsonOutputMode = false;
|
|
503
|
+
var _pendingWrites = [];
|
|
115
504
|
var _jsonData = {
|
|
116
505
|
dryRun: false,
|
|
117
506
|
updates: [],
|
|
118
507
|
changelogs: [],
|
|
508
|
+
sharedEntries: void 0,
|
|
119
509
|
tags: []
|
|
120
510
|
};
|
|
121
511
|
function enableJsonOutput(dryRun = false) {
|
|
@@ -123,8 +513,23 @@ function enableJsonOutput(dryRun = false) {
|
|
|
123
513
|
_jsonData.dryRun = dryRun;
|
|
124
514
|
_jsonData.updates = [];
|
|
125
515
|
_jsonData.changelogs = [];
|
|
516
|
+
_jsonData.sharedEntries = void 0;
|
|
126
517
|
_jsonData.tags = [];
|
|
127
518
|
_jsonData.commitMessage = void 0;
|
|
519
|
+
_pendingWrites.length = 0;
|
|
520
|
+
}
|
|
521
|
+
function recordPendingWrite(path10, content) {
|
|
522
|
+
if (!_jsonOutputMode) return;
|
|
523
|
+
_pendingWrites.push({ path: path10, content });
|
|
524
|
+
}
|
|
525
|
+
function flushPendingWrites() {
|
|
526
|
+
try {
|
|
527
|
+
for (const { path: path10, content } of _pendingWrites) {
|
|
528
|
+
fs4.writeFileSync(path10, content);
|
|
529
|
+
}
|
|
530
|
+
} finally {
|
|
531
|
+
_pendingWrites.length = 0;
|
|
532
|
+
}
|
|
128
533
|
}
|
|
129
534
|
function isJsonOutputMode() {
|
|
130
535
|
return _jsonOutputMode;
|
|
@@ -141,6 +546,10 @@ function addChangelogData(data) {
|
|
|
141
546
|
if (!_jsonOutputMode) return;
|
|
142
547
|
_jsonData.changelogs.push(data);
|
|
143
548
|
}
|
|
549
|
+
function setSharedEntries(entries) {
|
|
550
|
+
if (!_jsonOutputMode) return;
|
|
551
|
+
_jsonData.sharedEntries = entries.length > 0 ? entries : void 0;
|
|
552
|
+
}
|
|
144
553
|
function addTag(tag) {
|
|
145
554
|
if (!_jsonOutputMode) return;
|
|
146
555
|
_jsonData.tags.push(tag);
|
|
@@ -201,8 +610,8 @@ import { Bumper } from "conventional-recommended-bump";
|
|
|
201
610
|
import semver3 from "semver";
|
|
202
611
|
|
|
203
612
|
// src/git/repository.ts
|
|
204
|
-
import { existsSync, statSync } from "fs";
|
|
205
|
-
import { join } from "path";
|
|
613
|
+
import { existsSync as existsSync3, statSync } from "fs";
|
|
614
|
+
import { join as join3 } from "path";
|
|
206
615
|
function getCurrentBranch() {
|
|
207
616
|
const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
208
617
|
return result.toString().trim();
|
|
@@ -344,7 +753,7 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
|
|
|
344
753
|
let allTags = [];
|
|
345
754
|
try {
|
|
346
755
|
const { execSync: execSync2 } = await import("./commandExecutor-E44ID5U4.js");
|
|
347
|
-
const tagsOutput = execSync2("git", ["tag", "
|
|
756
|
+
const tagsOutput = execSync2("git", ["tag", "--sort=-creatordate"], { cwd: process.cwd() });
|
|
348
757
|
allTags = tagsOutput.toString().trim().split("\n").filter((tag) => tag.length > 0);
|
|
349
758
|
} catch (err) {
|
|
350
759
|
log(`Error getting tags: ${err instanceof Error ? err.message : String(err)}`, "error");
|
|
@@ -357,67 +766,26 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
|
|
|
357
766
|
let packageTags = allTags.filter((tag) => packageTagRegex.test(tag));
|
|
358
767
|
log(`Found ${packageTags.length} matching tags for ${packageName}`, "debug");
|
|
359
768
|
if (packageTags.length > 0) {
|
|
360
|
-
const chronologicalFirst = packageTags[0];
|
|
361
|
-
void chronologicalFirst;
|
|
362
|
-
const sortedPackageTags2 = [...packageTags].sort((a, b) => {
|
|
363
|
-
let versionA = "";
|
|
364
|
-
let versionB = "";
|
|
365
|
-
if (a.includes("@")) {
|
|
366
|
-
const parts = a.split("@");
|
|
367
|
-
const afterAt = parts[parts.length - 1] || "";
|
|
368
|
-
versionA = afterAt.replace(new RegExp(`^${escapeRegExp(versionPrefix || "")}`), "");
|
|
369
|
-
} else {
|
|
370
|
-
versionA = a.replace(new RegExp(`^${escapeRegExp(packageName)}`), "").replace(new RegExp(`^${escapeRegExp(versionPrefix || "")}`), "");
|
|
371
|
-
}
|
|
372
|
-
if (b.includes("@")) {
|
|
373
|
-
const parts = b.split("@");
|
|
374
|
-
const afterAtB = parts[parts.length - 1] || "";
|
|
375
|
-
versionB = afterAtB.replace(new RegExp(`^${escapeRegExp(versionPrefix || "")}`), "");
|
|
376
|
-
} else {
|
|
377
|
-
versionB = b.replace(new RegExp(`^${escapeRegExp(packageName)}`), "").replace(new RegExp(`^${escapeRegExp(versionPrefix || "")}`), "");
|
|
378
|
-
}
|
|
379
|
-
const cleanVersionA = semver.clean(versionA) || "0.0.0";
|
|
380
|
-
const cleanVersionB = semver.clean(versionB) || "0.0.0";
|
|
381
|
-
return semver.rcompare(cleanVersionA, cleanVersionB);
|
|
382
|
-
});
|
|
383
769
|
log(`Found ${packageTags.length} package tags using configured pattern`, "debug");
|
|
384
|
-
log(`Using
|
|
385
|
-
return
|
|
770
|
+
log(`Using most recently created tag: ${packageTags[0]}`, "debug");
|
|
771
|
+
return packageTags[0];
|
|
386
772
|
}
|
|
387
773
|
if (versionPrefix) {
|
|
388
774
|
const pattern1 = new RegExp(`^${escapedPackageName}@${escapeRegExp(versionPrefix)}`);
|
|
389
775
|
packageTags = allTags.filter((tag) => pattern1.test(tag));
|
|
390
776
|
if (packageTags.length > 0) {
|
|
391
|
-
const sortedPackageTags2 = [...packageTags].sort((a, b) => {
|
|
392
|
-
const aParts = a.split("@");
|
|
393
|
-
const afterAt = aParts[aParts.length - 1] || "";
|
|
394
|
-
const versionA = afterAt.replace(new RegExp(`^${escapeRegExp(versionPrefix || "")}`), "");
|
|
395
|
-
const bParts = b.split("@");
|
|
396
|
-
const afterAtB = bParts[bParts.length - 1] || "";
|
|
397
|
-
const versionB = afterAtB.replace(new RegExp(`^${escapeRegExp(versionPrefix || "")}`), "");
|
|
398
|
-
const cleanVersionA = semver.clean(versionA) || "0.0.0";
|
|
399
|
-
const cleanVersionB = semver.clean(versionB) || "0.0.0";
|
|
400
|
-
return semver.rcompare(cleanVersionA, cleanVersionB);
|
|
401
|
-
});
|
|
402
777
|
log(`Found ${packageTags.length} package tags using pattern: packageName@${versionPrefix}...`, "debug");
|
|
403
|
-
log(`Using
|
|
404
|
-
return
|
|
778
|
+
log(`Using most recently created tag: ${packageTags[0]}`, "debug");
|
|
779
|
+
return packageTags[0];
|
|
405
780
|
}
|
|
406
781
|
}
|
|
407
782
|
if (versionPrefix) {
|
|
408
783
|
const pattern2 = new RegExp(`^${escapeRegExp(versionPrefix)}${escapedPackageName}@`);
|
|
409
784
|
packageTags = allTags.filter((tag) => pattern2.test(tag));
|
|
410
785
|
if (packageTags.length > 0) {
|
|
411
|
-
const sortedPackageTags2 = [...packageTags].sort((a, b) => {
|
|
412
|
-
const aParts = a.split("@");
|
|
413
|
-
const versionA = semver.clean(aParts[aParts.length - 1] || "") || "0.0.0";
|
|
414
|
-
const bParts = b.split("@");
|
|
415
|
-
const versionB = semver.clean(bParts[bParts.length - 1] || "") || "0.0.0";
|
|
416
|
-
return semver.rcompare(versionA, versionB);
|
|
417
|
-
});
|
|
418
786
|
log(`Found ${packageTags.length} package tags using pattern: ${versionPrefix}packageName@...`, "debug");
|
|
419
|
-
log(`Using
|
|
420
|
-
return
|
|
787
|
+
log(`Using most recently created tag: ${packageTags[0]}`, "debug");
|
|
788
|
+
return packageTags[0];
|
|
421
789
|
}
|
|
422
790
|
}
|
|
423
791
|
const pattern3 = new RegExp(`^${escapedPackageName}@`);
|
|
@@ -431,16 +799,9 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
|
|
|
431
799
|
}
|
|
432
800
|
return "";
|
|
433
801
|
}
|
|
434
|
-
const sortedPackageTags = [...packageTags].sort((a, b) => {
|
|
435
|
-
const aParts = a.split("@");
|
|
436
|
-
const versionA = semver.clean(aParts[aParts.length - 1] || "") || "0.0.0";
|
|
437
|
-
const bParts = b.split("@");
|
|
438
|
-
const versionB = semver.clean(bParts[bParts.length - 1] || "") || "0.0.0";
|
|
439
|
-
return semver.rcompare(versionA, versionB);
|
|
440
|
-
});
|
|
441
802
|
log(`Found ${packageTags.length} package tags for ${packageName}`, "debug");
|
|
442
|
-
log(`Using
|
|
443
|
-
return
|
|
803
|
+
log(`Using most recently created tag: ${packageTags[0]}`, "debug");
|
|
804
|
+
return packageTags[0];
|
|
444
805
|
}
|
|
445
806
|
log(`Package-specific tags disabled for ${packageName}, falling back to global tags`, "debug");
|
|
446
807
|
return "";
|
|
@@ -455,16 +816,15 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
|
|
|
455
816
|
}
|
|
456
817
|
|
|
457
818
|
// src/utils/manifestHelpers.ts
|
|
458
|
-
import
|
|
459
|
-
import
|
|
819
|
+
import fs6 from "fs";
|
|
820
|
+
import path5 from "path";
|
|
460
821
|
|
|
461
822
|
// src/cargo/cargoHandler.ts
|
|
462
|
-
import
|
|
463
|
-
import
|
|
464
|
-
import
|
|
465
|
-
import * as TOML from "smol-toml";
|
|
823
|
+
import fs5 from "fs";
|
|
824
|
+
import path4 from "path";
|
|
825
|
+
import * as TOML2 from "smol-toml";
|
|
466
826
|
function getCargoInfo(cargoPath) {
|
|
467
|
-
if (!
|
|
827
|
+
if (!fs5.existsSync(cargoPath)) {
|
|
468
828
|
log(`Cargo.toml file not found at: ${cargoPath}`, "error");
|
|
469
829
|
throw new Error(`Cargo.toml file not found at: ${cargoPath}`);
|
|
470
830
|
}
|
|
@@ -478,7 +838,7 @@ function getCargoInfo(cargoPath) {
|
|
|
478
838
|
name: cargo.package.name,
|
|
479
839
|
version: cargo.package.version || "0.0.0",
|
|
480
840
|
path: cargoPath,
|
|
481
|
-
dir:
|
|
841
|
+
dir: path4.dirname(cargoPath),
|
|
482
842
|
content: cargo
|
|
483
843
|
};
|
|
484
844
|
} catch (error) {
|
|
@@ -497,14 +857,16 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
|
|
|
497
857
|
if (!packageName) {
|
|
498
858
|
throw new Error(`No package name found in ${cargoPath}`);
|
|
499
859
|
}
|
|
500
|
-
if (!
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
860
|
+
if (!cargo.package) {
|
|
861
|
+
cargo.package = { name: packageName, version };
|
|
862
|
+
} else {
|
|
863
|
+
cargo.package.version = version;
|
|
864
|
+
}
|
|
865
|
+
const updatedContent = TOML2.stringify(cargo);
|
|
866
|
+
if (dryRun) {
|
|
867
|
+
recordPendingWrite(cargoPath, updatedContent);
|
|
868
|
+
} else {
|
|
869
|
+
fs5.writeFileSync(cargoPath, updatedContent);
|
|
508
870
|
}
|
|
509
871
|
addPackageUpdate(packageName, version, cargoPath);
|
|
510
872
|
log(`${dryRun ? "[DRY RUN] Would update" : "Updated"} Cargo.toml at ${cargoPath} to version ${version}`, "success");
|
|
@@ -519,11 +881,11 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
|
|
|
519
881
|
|
|
520
882
|
// src/utils/manifestHelpers.ts
|
|
521
883
|
function getVersionFromManifests(packageDir) {
|
|
522
|
-
const packageJsonPath =
|
|
523
|
-
const cargoTomlPath =
|
|
524
|
-
if (
|
|
884
|
+
const packageJsonPath = path5.join(packageDir, "package.json");
|
|
885
|
+
const cargoTomlPath = path5.join(packageDir, "Cargo.toml");
|
|
886
|
+
if (fs6.existsSync(packageJsonPath)) {
|
|
525
887
|
try {
|
|
526
|
-
const packageJson = JSON.parse(
|
|
888
|
+
const packageJson = JSON.parse(fs6.readFileSync(packageJsonPath, "utf-8"));
|
|
527
889
|
if (packageJson.version) {
|
|
528
890
|
log(`Found version ${packageJson.version} in package.json`, "debug");
|
|
529
891
|
return {
|
|
@@ -539,7 +901,7 @@ function getVersionFromManifests(packageDir) {
|
|
|
539
901
|
log(`Error reading package.json: ${errMsg}`, "warning");
|
|
540
902
|
}
|
|
541
903
|
}
|
|
542
|
-
if (
|
|
904
|
+
if (fs6.existsSync(cargoTomlPath)) {
|
|
543
905
|
try {
|
|
544
906
|
const cargoInfo = getCargoInfo(cargoTomlPath);
|
|
545
907
|
if (cargoInfo.version) {
|
|
@@ -566,8 +928,7 @@ function getVersionFromManifests(packageDir) {
|
|
|
566
928
|
}
|
|
567
929
|
|
|
568
930
|
// src/utils/versionUtils.ts
|
|
569
|
-
import
|
|
570
|
-
import { parseCargoToml as parseCargoToml2 } from "@releasekit/config";
|
|
931
|
+
import fs7 from "fs";
|
|
571
932
|
import semver2 from "semver";
|
|
572
933
|
|
|
573
934
|
// src/git/tagVerification.ts
|
|
@@ -943,8 +1304,8 @@ async function calculateVersion(config, options) {
|
|
|
943
1304
|
}
|
|
944
1305
|
|
|
945
1306
|
// src/package/packageProcessor.ts
|
|
946
|
-
import * as
|
|
947
|
-
import
|
|
1307
|
+
import * as fs9 from "fs";
|
|
1308
|
+
import path7 from "path";
|
|
948
1309
|
|
|
949
1310
|
// src/changelog/commitParser.ts
|
|
950
1311
|
var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
|
|
@@ -1152,21 +1513,23 @@ function shouldProcessPackage(packageName, skip = []) {
|
|
|
1152
1513
|
}
|
|
1153
1514
|
|
|
1154
1515
|
// src/package/packageManagement.ts
|
|
1155
|
-
import
|
|
1156
|
-
import
|
|
1516
|
+
import fs8 from "fs";
|
|
1517
|
+
import path6 from "path";
|
|
1157
1518
|
function updatePackageVersion(packagePath, version, dryRun = false) {
|
|
1158
1519
|
if (isCargoToml(packagePath)) {
|
|
1159
1520
|
updateCargoVersion(packagePath, version, dryRun);
|
|
1160
1521
|
return;
|
|
1161
1522
|
}
|
|
1162
1523
|
try {
|
|
1163
|
-
const packageContent =
|
|
1524
|
+
const packageContent = fs8.readFileSync(packagePath, "utf8");
|
|
1164
1525
|
const packageJson = JSON.parse(packageContent);
|
|
1165
1526
|
const packageName = packageJson.name;
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1527
|
+
const updatedContent = `${JSON.stringify({ ...packageJson, version }, null, 2)}
|
|
1528
|
+
`;
|
|
1529
|
+
if (dryRun) {
|
|
1530
|
+
recordPendingWrite(packagePath, updatedContent);
|
|
1531
|
+
} else {
|
|
1532
|
+
fs8.writeFileSync(packagePath, updatedContent);
|
|
1170
1533
|
}
|
|
1171
1534
|
addPackageUpdate(packageName, version, packagePath);
|
|
1172
1535
|
log(
|
|
@@ -1226,6 +1589,7 @@ var PackageProcessor = class {
|
|
|
1226
1589
|
log("No packages found to process.", "info");
|
|
1227
1590
|
return { updatedPackages: [], tags: [] };
|
|
1228
1591
|
}
|
|
1592
|
+
const sharedEntriesMap = /* @__PURE__ */ new Map();
|
|
1229
1593
|
for (const pkg of pkgsToConsider) {
|
|
1230
1594
|
const name = pkg.packageJson.name;
|
|
1231
1595
|
const pkgPath = pkg.dir;
|
|
@@ -1311,8 +1675,10 @@ var PackageProcessor = class {
|
|
|
1311
1675
|
sharedPackageDirs
|
|
1312
1676
|
);
|
|
1313
1677
|
if (repoLevelEntries.length > 0) {
|
|
1314
|
-
log(`
|
|
1315
|
-
|
|
1678
|
+
log(`Found ${repoLevelEntries.length} repo-level commit(s) for ${name}`, "debug");
|
|
1679
|
+
for (const entry of repoLevelEntries) {
|
|
1680
|
+
sharedEntriesMap.set(`${entry.type}:${entry.description}`, entry);
|
|
1681
|
+
}
|
|
1316
1682
|
}
|
|
1317
1683
|
if (changelogEntries.length === 0) {
|
|
1318
1684
|
changelogEntries = [
|
|
@@ -1333,9 +1699,9 @@ var PackageProcessor = class {
|
|
|
1333
1699
|
}
|
|
1334
1700
|
let repoUrl;
|
|
1335
1701
|
try {
|
|
1336
|
-
const packageJsonPath2 =
|
|
1337
|
-
if (
|
|
1338
|
-
const packageJson = JSON.parse(
|
|
1702
|
+
const packageJsonPath2 = path7.join(pkgPath, "package.json");
|
|
1703
|
+
if (fs9.existsSync(packageJsonPath2)) {
|
|
1704
|
+
const packageJson = JSON.parse(fs9.readFileSync(packageJsonPath2, "utf8"));
|
|
1339
1705
|
if (packageJson.repository) {
|
|
1340
1706
|
if (typeof packageJson.repository === "string") {
|
|
1341
1707
|
repoUrl = packageJson.repository;
|
|
@@ -1361,8 +1727,8 @@ var PackageProcessor = class {
|
|
|
1361
1727
|
repoUrl: repoUrl || null,
|
|
1362
1728
|
entries: changelogEntries
|
|
1363
1729
|
});
|
|
1364
|
-
const packageJsonPath =
|
|
1365
|
-
if (
|
|
1730
|
+
const packageJsonPath = path7.join(pkgPath, "package.json");
|
|
1731
|
+
if (fs9.existsSync(packageJsonPath)) {
|
|
1366
1732
|
updatePackageVersion(packageJsonPath, nextVersion, this.dryRun);
|
|
1367
1733
|
}
|
|
1368
1734
|
const cargoEnabled = this.fullConfig.cargo?.enabled !== false;
|
|
@@ -1372,9 +1738,9 @@ var PackageProcessor = class {
|
|
|
1372
1738
|
log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
|
|
1373
1739
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
1374
1740
|
for (const cargoPath of cargoPaths) {
|
|
1375
|
-
const resolvedCargoPath =
|
|
1741
|
+
const resolvedCargoPath = path7.resolve(pkgPath, cargoPath, "Cargo.toml");
|
|
1376
1742
|
log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
|
|
1377
|
-
if (
|
|
1743
|
+
if (fs9.existsSync(resolvedCargoPath)) {
|
|
1378
1744
|
log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
|
|
1379
1745
|
updatePackageVersion(resolvedCargoPath, nextVersion, this.dryRun);
|
|
1380
1746
|
} else {
|
|
@@ -1382,9 +1748,9 @@ var PackageProcessor = class {
|
|
|
1382
1748
|
}
|
|
1383
1749
|
}
|
|
1384
1750
|
} else {
|
|
1385
|
-
const cargoTomlPath =
|
|
1751
|
+
const cargoTomlPath = path7.join(pkgPath, "Cargo.toml");
|
|
1386
1752
|
log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
|
|
1387
|
-
if (
|
|
1753
|
+
if (fs9.existsSync(cargoTomlPath)) {
|
|
1388
1754
|
log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
|
|
1389
1755
|
updatePackageVersion(cargoTomlPath, nextVersion, this.dryRun);
|
|
1390
1756
|
} else {
|
|
@@ -1410,24 +1776,32 @@ var PackageProcessor = class {
|
|
|
1410
1776
|
}
|
|
1411
1777
|
updatedPackagesInfo.push({ name, version: nextVersion, path: pkgPath });
|
|
1412
1778
|
}
|
|
1779
|
+
setSharedEntries([...sharedEntriesMap.values()]);
|
|
1413
1780
|
if (updatedPackagesInfo.length === 0) {
|
|
1414
1781
|
log("No packages required a version update.", "info");
|
|
1415
1782
|
return { updatedPackages: [], tags };
|
|
1416
1783
|
}
|
|
1417
1784
|
const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
|
|
1418
1785
|
const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
|
|
1419
|
-
|
|
1786
|
+
const versionsMatch = updatedPackagesInfo.length <= 1 || updatedPackagesInfo.every((p) => p.version === representativeVersion);
|
|
1787
|
+
let commitMessage = this.commitMessageTemplate || "chore: release";
|
|
1420
1788
|
const MAX_COMMIT_MSG_LENGTH = 1e4;
|
|
1421
1789
|
if (commitMessage.length > MAX_COMMIT_MSG_LENGTH) {
|
|
1422
1790
|
log("Commit message template too long, truncating", "warning");
|
|
1423
1791
|
commitMessage = commitMessage.slice(0, MAX_COMMIT_MSG_LENGTH);
|
|
1424
1792
|
}
|
|
1425
1793
|
const placeholderRegex = /\$\{[^{}$]{1,1000}\}/;
|
|
1426
|
-
if (
|
|
1427
|
-
const packageName = updatedPackagesInfo[0].name;
|
|
1794
|
+
if (placeholderRegex.test(commitMessage)) {
|
|
1795
|
+
const packageName = updatedPackagesInfo.length === 1 ? updatedPackagesInfo[0].name : packageNames;
|
|
1428
1796
|
commitMessage = formatCommitMessage(commitMessage, representativeVersion, packageName);
|
|
1429
1797
|
} else {
|
|
1430
|
-
|
|
1798
|
+
if (versionsMatch) {
|
|
1799
|
+
const formattedVersion = `${formatVersionPrefix(this.versionPrefix)}${representativeVersion}`;
|
|
1800
|
+
commitMessage = `${commitMessage} ${packageNames} ${formattedVersion}`;
|
|
1801
|
+
} else {
|
|
1802
|
+
const packageVersionList = updatedPackagesInfo.map((p) => `${p.name}@${p.version}`).join(", ");
|
|
1803
|
+
commitMessage = `${commitMessage} ${packageVersionList}`;
|
|
1804
|
+
}
|
|
1431
1805
|
}
|
|
1432
1806
|
setCommitMessage(commitMessage);
|
|
1433
1807
|
if (this.dryRun) {
|
|
@@ -1442,8 +1816,8 @@ var PackageProcessor = class {
|
|
|
1442
1816
|
};
|
|
1443
1817
|
|
|
1444
1818
|
// src/core/versionStrategies.ts
|
|
1445
|
-
import
|
|
1446
|
-
import * as
|
|
1819
|
+
import fs10 from "fs";
|
|
1820
|
+
import * as path8 from "path";
|
|
1447
1821
|
function shouldProcessPackage2(pkg, config) {
|
|
1448
1822
|
const pkgName = pkg.packageJson.name;
|
|
1449
1823
|
return shouldProcessPackage(pkgName, config.skip);
|
|
@@ -1457,15 +1831,15 @@ function updateCargoFiles(packageDir, version, cargoConfig, dryRun = false) {
|
|
|
1457
1831
|
const cargoPaths = cargoConfig?.paths;
|
|
1458
1832
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
1459
1833
|
for (const cargoPath of cargoPaths) {
|
|
1460
|
-
const resolvedCargoPath =
|
|
1461
|
-
if (
|
|
1834
|
+
const resolvedCargoPath = path8.resolve(packageDir, cargoPath, "Cargo.toml");
|
|
1835
|
+
if (fs10.existsSync(resolvedCargoPath)) {
|
|
1462
1836
|
updatePackageVersion(resolvedCargoPath, version, dryRun);
|
|
1463
1837
|
updatedFiles.push(resolvedCargoPath);
|
|
1464
1838
|
}
|
|
1465
1839
|
}
|
|
1466
1840
|
} else {
|
|
1467
|
-
const cargoTomlPath =
|
|
1468
|
-
if (
|
|
1841
|
+
const cargoTomlPath = path8.join(packageDir, "Cargo.toml");
|
|
1842
|
+
if (fs10.existsSync(cargoTomlPath)) {
|
|
1469
1843
|
updatePackageVersion(cargoTomlPath, version, dryRun);
|
|
1470
1844
|
updatedFiles.push(cargoTomlPath);
|
|
1471
1845
|
}
|
|
@@ -1480,7 +1854,7 @@ function createSyncStrategy(config) {
|
|
|
1480
1854
|
tagTemplate,
|
|
1481
1855
|
baseBranch,
|
|
1482
1856
|
branchPattern,
|
|
1483
|
-
commitMessage = `chore
|
|
1857
|
+
commitMessage = `chore: release \${packageName} v\${version}`,
|
|
1484
1858
|
prereleaseIdentifier,
|
|
1485
1859
|
dryRun,
|
|
1486
1860
|
mainPackage
|
|
@@ -1535,8 +1909,8 @@ function createSyncStrategy(config) {
|
|
|
1535
1909
|
const processedPaths = /* @__PURE__ */ new Set();
|
|
1536
1910
|
try {
|
|
1537
1911
|
if (packages.root) {
|
|
1538
|
-
const rootPkgPath =
|
|
1539
|
-
if (
|
|
1912
|
+
const rootPkgPath = path8.join(packages.root, "package.json");
|
|
1913
|
+
if (fs10.existsSync(rootPkgPath)) {
|
|
1540
1914
|
updatePackageVersion(rootPkgPath, nextVersion, dryRun);
|
|
1541
1915
|
files.push(rootPkgPath);
|
|
1542
1916
|
updatedPackages.push("root");
|
|
@@ -1555,7 +1929,7 @@ function createSyncStrategy(config) {
|
|
|
1555
1929
|
if (!shouldProcessPackage2(pkg, config)) {
|
|
1556
1930
|
continue;
|
|
1557
1931
|
}
|
|
1558
|
-
const packageJsonPath =
|
|
1932
|
+
const packageJsonPath = path8.join(pkg.dir, "package.json");
|
|
1559
1933
|
if (processedPaths.has(packageJsonPath)) {
|
|
1560
1934
|
continue;
|
|
1561
1935
|
}
|
|
@@ -1619,11 +1993,11 @@ function createSyncStrategy(config) {
|
|
|
1619
1993
|
entries: changelogEntries
|
|
1620
1994
|
});
|
|
1621
1995
|
let tagPackageName = null;
|
|
1622
|
-
let commitPackageName;
|
|
1623
1996
|
if (config.packageSpecificTags && packages.packages.length === 1) {
|
|
1624
1997
|
tagPackageName = packages.packages[0].packageJson.name;
|
|
1625
|
-
commitPackageName = packages.packages[0].packageJson.name;
|
|
1626
1998
|
}
|
|
1999
|
+
const workspaceNames = updatedPackages.filter((n) => n !== "root");
|
|
2000
|
+
const commitPackageName = workspaceNames.length > 0 ? workspaceNames.join(", ") : void 0;
|
|
1627
2001
|
const nextTag = formatTag(
|
|
1628
2002
|
nextVersion,
|
|
1629
2003
|
formattedPrefix,
|
|
@@ -1631,7 +2005,16 @@ function createSyncStrategy(config) {
|
|
|
1631
2005
|
tagTemplate,
|
|
1632
2006
|
config.packageSpecificTags || false
|
|
1633
2007
|
);
|
|
1634
|
-
|
|
2008
|
+
let formattedCommitMessage;
|
|
2009
|
+
const hasPackageNamePlaceholder = commitMessage.includes("${packageName}");
|
|
2010
|
+
if (commitPackageName === void 0 && !hasPackageNamePlaceholder) {
|
|
2011
|
+
formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, void 0, void 0);
|
|
2012
|
+
} else if (commitPackageName === void 0) {
|
|
2013
|
+
formattedCommitMessage = commitMessage.replace(/\$\{version\}/g, nextVersion).replace(/\$\{packageName\}/g, "").replace(/\$\{scope\}/g, "");
|
|
2014
|
+
} else {
|
|
2015
|
+
formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, commitPackageName, void 0);
|
|
2016
|
+
}
|
|
2017
|
+
formattedCommitMessage = formattedCommitMessage.replace(/\s{2,}/g, " ").trim();
|
|
1635
2018
|
addTag(nextTag);
|
|
1636
2019
|
setCommitMessage(formattedCommitMessage);
|
|
1637
2020
|
if (!dryRun) {
|
|
@@ -1653,7 +2036,13 @@ function createSyncStrategy(config) {
|
|
|
1653
2036
|
function createSingleStrategy(config) {
|
|
1654
2037
|
return async (packages) => {
|
|
1655
2038
|
try {
|
|
1656
|
-
const {
|
|
2039
|
+
const {
|
|
2040
|
+
mainPackage,
|
|
2041
|
+
versionPrefix,
|
|
2042
|
+
tagTemplate,
|
|
2043
|
+
commitMessage = `chore: release \${packageName} v\${version}`,
|
|
2044
|
+
dryRun
|
|
2045
|
+
} = config;
|
|
1657
2046
|
let packageName;
|
|
1658
2047
|
if (mainPackage) {
|
|
1659
2048
|
packageName = mainPackage;
|
|
@@ -1737,9 +2126,9 @@ function createSingleStrategy(config) {
|
|
|
1737
2126
|
}
|
|
1738
2127
|
let repoUrl;
|
|
1739
2128
|
try {
|
|
1740
|
-
const packageJsonPath2 =
|
|
1741
|
-
if (
|
|
1742
|
-
const packageJson = JSON.parse(
|
|
2129
|
+
const packageJsonPath2 = path8.join(pkgPath, "package.json");
|
|
2130
|
+
if (fs10.existsSync(packageJsonPath2)) {
|
|
2131
|
+
const packageJson = JSON.parse(fs10.readFileSync(packageJsonPath2, "utf8"));
|
|
1743
2132
|
if (packageJson.repository) {
|
|
1744
2133
|
if (typeof packageJson.repository === "string") {
|
|
1745
2134
|
repoUrl = packageJson.repository;
|
|
@@ -1765,7 +2154,7 @@ function createSingleStrategy(config) {
|
|
|
1765
2154
|
repoUrl: repoUrl || null,
|
|
1766
2155
|
entries: changelogEntries
|
|
1767
2156
|
});
|
|
1768
|
-
const packageJsonPath =
|
|
2157
|
+
const packageJsonPath = path8.join(pkgPath, "package.json");
|
|
1769
2158
|
updatePackageVersion(packageJsonPath, nextVersion, dryRun);
|
|
1770
2159
|
const filesToCommit = [packageJsonPath];
|
|
1771
2160
|
const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo, dryRun);
|
|
@@ -1871,7 +2260,7 @@ var GitError = class extends BaseVersionError {
|
|
|
1871
2260
|
};
|
|
1872
2261
|
|
|
1873
2262
|
// src/utils/packageFiltering.ts
|
|
1874
|
-
import
|
|
2263
|
+
import path9 from "path";
|
|
1875
2264
|
import micromatch2 from "micromatch";
|
|
1876
2265
|
function filterPackagesByConfig(packages, configTargets, workspaceRoot) {
|
|
1877
2266
|
if (configTargets.length === 0) {
|
|
@@ -1897,7 +2286,7 @@ function filterByDirectoryPattern(packages, pattern, workspaceRoot) {
|
|
|
1897
2286
|
}
|
|
1898
2287
|
const normalizedPattern = pattern.replace(/\\/g, "/");
|
|
1899
2288
|
return packages.filter((pkg) => {
|
|
1900
|
-
const relativePath =
|
|
2289
|
+
const relativePath = path9.relative(workspaceRoot, pkg.dir);
|
|
1901
2290
|
const normalizedRelativePath = relativePath.replace(/\\/g, "/");
|
|
1902
2291
|
if (normalizedPattern === normalizedRelativePath) {
|
|
1903
2292
|
return true;
|
|
@@ -2045,10 +2434,11 @@ var VersionEngine = class {
|
|
|
2045
2434
|
};
|
|
2046
2435
|
|
|
2047
2436
|
export {
|
|
2048
|
-
loadConfig,
|
|
2437
|
+
loadConfig2 as loadConfig,
|
|
2049
2438
|
VersionErrorCode,
|
|
2050
2439
|
createVersionError,
|
|
2051
2440
|
enableJsonOutput,
|
|
2441
|
+
flushPendingWrites,
|
|
2052
2442
|
getJsonData,
|
|
2053
2443
|
printJsonOutput,
|
|
2054
2444
|
log,
|