@releasekit/version 0.7.45 → 0.7.46
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/{baseError-DQHIJACF.js → baseError-6PKATI6Z.js} +1 -1
- package/dist/chunk-3FG6RVHS.js +18 -0
- package/dist/{chunk-45DJUNXI.js → chunk-V44UWRAP.js} +106 -1178
- package/dist/cli.js +3 -4
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-Q3FHZORY.js +0 -89
- package/dist/dist-3B6ZXCEH.js +0 -431
- package/dist/dist-XFQOB6BJ.js +0 -102
|
@@ -1,413 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
BaseVersionError
|
|
3
|
-
|
|
4
|
-
sanitizePackageName
|
|
5
|
-
} from "./chunk-Q3FHZORY.js";
|
|
2
|
+
BaseVersionError
|
|
3
|
+
} from "./chunk-3FG6RVHS.js";
|
|
6
4
|
import {
|
|
7
5
|
execAsync,
|
|
8
6
|
execSync
|
|
9
7
|
} from "./chunk-LMPZV35Z.js";
|
|
10
8
|
|
|
11
|
-
//
|
|
12
|
-
import
|
|
13
|
-
import * as path from "path";
|
|
14
|
-
import * as TOML from "smol-toml";
|
|
15
|
-
import * as fs3 from "fs";
|
|
16
|
-
import * as path3 from "path";
|
|
17
|
-
import { z as z2 } from "zod";
|
|
18
|
-
import { z } from "zod";
|
|
19
|
-
import * as fs2 from "fs";
|
|
20
|
-
import * as os from "os";
|
|
21
|
-
import * as path2 from "path";
|
|
22
|
-
function parseCargoToml(cargoPath) {
|
|
23
|
-
const content = fs.readFileSync(cargoPath, "utf-8");
|
|
24
|
-
return TOML.parse(content);
|
|
25
|
-
}
|
|
26
|
-
function isCargoToml(filePath) {
|
|
27
|
-
return path.basename(filePath) === "Cargo.toml";
|
|
28
|
-
}
|
|
29
|
-
var ConfigError = class extends ReleaseKitError {
|
|
30
|
-
code = "CONFIG_ERROR";
|
|
31
|
-
suggestions;
|
|
32
|
-
constructor(message, suggestions) {
|
|
33
|
-
super(message);
|
|
34
|
-
this.suggestions = suggestions ?? [
|
|
35
|
-
"Check that releasekit.config.json exists and is valid JSON",
|
|
36
|
-
"Run with --verbose for more details"
|
|
37
|
-
];
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var MAX_JSONC_LENGTH = 1e5;
|
|
41
|
-
function parseJsonc(content) {
|
|
42
|
-
if (content.length > MAX_JSONC_LENGTH) {
|
|
43
|
-
throw new Error(`JSONC content too long: ${content.length} characters (max ${MAX_JSONC_LENGTH})`);
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
} catch {
|
|
48
|
-
const cleaned = content.replace(/\/\/[^\r\n]{0,10000}$/gm, "").replace(/\/\*[\s\S]{0,50000}?\*\//g, "").trim();
|
|
49
|
-
return JSON.parse(cleaned);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
var GitConfigSchema = z.object({
|
|
53
|
-
remote: z.string().default("origin"),
|
|
54
|
-
branch: z.string().default("main"),
|
|
55
|
-
pushMethod: z.enum(["auto", "ssh", "https"]).default("auto"),
|
|
56
|
-
/**
|
|
57
|
-
* Optional env var name containing a GitHub token for HTTPS pushes.
|
|
58
|
-
* When set, publish steps can use this token without mutating git remotes.
|
|
59
|
-
*/
|
|
60
|
-
httpsTokenEnv: z.string().optional(),
|
|
61
|
-
push: z.boolean().optional(),
|
|
62
|
-
skipHooks: z.boolean().optional()
|
|
63
|
-
});
|
|
64
|
-
var MonorepoConfigSchema = z.object({
|
|
65
|
-
mode: z.enum(["root", "packages", "both"]).optional(),
|
|
66
|
-
rootPath: z.string().optional(),
|
|
67
|
-
packagesPath: z.string().optional(),
|
|
68
|
-
mainPackage: z.string().optional()
|
|
69
|
-
});
|
|
70
|
-
var BranchPatternSchema = z.object({
|
|
71
|
-
pattern: z.string(),
|
|
72
|
-
releaseType: z.enum(["major", "minor", "patch", "prerelease"])
|
|
73
|
-
});
|
|
74
|
-
var VersionCargoConfigSchema = z.object({
|
|
75
|
-
enabled: z.boolean().default(true),
|
|
76
|
-
paths: z.array(z.string()).optional()
|
|
77
|
-
});
|
|
78
|
-
var VersionConfigSchema = z.object({
|
|
79
|
-
tagTemplate: z.string().default("v{version}"),
|
|
80
|
-
packageSpecificTags: z.boolean().default(false),
|
|
81
|
-
preset: z.string().default("conventional"),
|
|
82
|
-
sync: z.boolean().default(true),
|
|
83
|
-
packages: z.array(z.string()).default([]),
|
|
84
|
-
mainPackage: z.string().optional(),
|
|
85
|
-
updateInternalDependencies: z.enum(["major", "minor", "patch", "no-internal-update"]).default("minor"),
|
|
86
|
-
skip: z.array(z.string()).optional(),
|
|
87
|
-
commitMessage: z.string().optional(),
|
|
88
|
-
versionStrategy: z.enum(["branchPattern", "commitMessage"]).default("commitMessage"),
|
|
89
|
-
branchPatterns: z.array(BranchPatternSchema).optional(),
|
|
90
|
-
defaultReleaseType: z.enum(["major", "minor", "patch", "prerelease"]).optional(),
|
|
91
|
-
mismatchStrategy: z.enum(["error", "warn", "ignore", "prefer-package", "prefer-git"]).default("warn"),
|
|
92
|
-
versionPrefix: z.string().default(""),
|
|
93
|
-
prereleaseIdentifier: z.string().optional(),
|
|
94
|
-
strictReachable: z.boolean().default(false),
|
|
95
|
-
cargo: VersionCargoConfigSchema.optional()
|
|
96
|
-
});
|
|
97
|
-
var NpmConfigSchema = z.object({
|
|
98
|
-
enabled: z.boolean().default(true),
|
|
99
|
-
auth: z.enum(["auto", "oidc", "token"]).default("auto"),
|
|
100
|
-
provenance: z.boolean().default(true),
|
|
101
|
-
access: z.enum(["public", "restricted"]).default("public"),
|
|
102
|
-
registry: z.string().default("https://registry.npmjs.org"),
|
|
103
|
-
copyFiles: z.array(z.string()).default(["LICENSE"]),
|
|
104
|
-
tag: z.string().default("latest")
|
|
105
|
-
});
|
|
106
|
-
var CargoPublishConfigSchema = z.object({
|
|
107
|
-
enabled: z.boolean().default(false),
|
|
108
|
-
noVerify: z.boolean().default(false),
|
|
109
|
-
publishOrder: z.array(z.string()).default([]),
|
|
110
|
-
clean: z.boolean().default(false)
|
|
111
|
-
});
|
|
112
|
-
var PublishGitConfigSchema = z.object({
|
|
113
|
-
push: z.boolean().default(true),
|
|
114
|
-
pushMethod: z.enum(["auto", "ssh", "https"]).optional(),
|
|
115
|
-
remote: z.string().optional(),
|
|
116
|
-
branch: z.string().optional(),
|
|
117
|
-
httpsTokenEnv: z.string().optional(),
|
|
118
|
-
skipHooks: z.boolean().optional()
|
|
119
|
-
});
|
|
120
|
-
var GitHubReleaseConfigSchema = z.object({
|
|
121
|
-
enabled: z.boolean().default(true),
|
|
122
|
-
draft: z.boolean().default(true),
|
|
123
|
-
perPackage: z.boolean().default(true),
|
|
124
|
-
prerelease: z.union([z.literal("auto"), z.boolean()]).default("auto"),
|
|
125
|
-
/**
|
|
126
|
-
* Controls the source for the GitHub release body.
|
|
127
|
-
* - 'auto': Use release notes if enabled, else changelog, else GitHub auto-generated.
|
|
128
|
-
* - 'releaseNotes': Use LLM-generated release notes (requires notes.releaseNotes.enabled: true).
|
|
129
|
-
* - 'changelog': Use formatted changelog entries.
|
|
130
|
-
* - 'generated': Use GitHub's auto-generated notes.
|
|
131
|
-
* - 'none': No body.
|
|
132
|
-
*/
|
|
133
|
-
body: z.enum(["auto", "releaseNotes", "changelog", "generated", "none"]).default("auto"),
|
|
134
|
-
/**
|
|
135
|
-
* Template string for the GitHub release title when a package name is resolved.
|
|
136
|
-
* Available variables: ${packageName} (original scoped name), ${version} (e.g. "v1.0.0").
|
|
137
|
-
* Version-only tags (e.g. "v1.0.0") always use the tag as-is.
|
|
138
|
-
*/
|
|
139
|
-
/* biome-ignore lint/suspicious/noTemplateCurlyInString: default template value */
|
|
140
|
-
titleTemplate: z.string().default("${packageName}: ${version}")
|
|
141
|
-
});
|
|
142
|
-
var VerifyRegistryConfigSchema = z.object({
|
|
143
|
-
enabled: z.boolean().default(true),
|
|
144
|
-
maxAttempts: z.number().int().positive().default(5),
|
|
145
|
-
initialDelay: z.number().int().positive().default(15e3),
|
|
146
|
-
backoffMultiplier: z.number().positive().default(2)
|
|
147
|
-
});
|
|
148
|
-
var VerifyConfigSchema = z.object({
|
|
149
|
-
npm: VerifyRegistryConfigSchema.default({
|
|
150
|
-
enabled: true,
|
|
151
|
-
maxAttempts: 5,
|
|
152
|
-
initialDelay: 15e3,
|
|
153
|
-
backoffMultiplier: 2
|
|
154
|
-
}),
|
|
155
|
-
cargo: VerifyRegistryConfigSchema.default({
|
|
156
|
-
enabled: true,
|
|
157
|
-
maxAttempts: 10,
|
|
158
|
-
initialDelay: 3e4,
|
|
159
|
-
backoffMultiplier: 2
|
|
160
|
-
})
|
|
161
|
-
});
|
|
162
|
-
var PublishConfigSchema = z.object({
|
|
163
|
-
git: PublishGitConfigSchema.optional(),
|
|
164
|
-
npm: NpmConfigSchema.default({
|
|
165
|
-
enabled: true,
|
|
166
|
-
auth: "auto",
|
|
167
|
-
provenance: true,
|
|
168
|
-
access: "public",
|
|
169
|
-
registry: "https://registry.npmjs.org",
|
|
170
|
-
copyFiles: ["LICENSE"],
|
|
171
|
-
tag: "latest"
|
|
172
|
-
}),
|
|
173
|
-
cargo: CargoPublishConfigSchema.default({
|
|
174
|
-
enabled: false,
|
|
175
|
-
noVerify: false,
|
|
176
|
-
publishOrder: [],
|
|
177
|
-
clean: false
|
|
178
|
-
}),
|
|
179
|
-
githubRelease: GitHubReleaseConfigSchema.default({
|
|
180
|
-
enabled: true,
|
|
181
|
-
draft: true,
|
|
182
|
-
perPackage: true,
|
|
183
|
-
prerelease: "auto",
|
|
184
|
-
body: "auto",
|
|
185
|
-
/* biome-ignore lint/suspicious/noTemplateCurlyInString: default template value */
|
|
186
|
-
titleTemplate: "${packageName}: ${version}"
|
|
187
|
-
}),
|
|
188
|
-
verify: VerifyConfigSchema.default({
|
|
189
|
-
npm: {
|
|
190
|
-
enabled: true,
|
|
191
|
-
maxAttempts: 5,
|
|
192
|
-
initialDelay: 15e3,
|
|
193
|
-
backoffMultiplier: 2
|
|
194
|
-
},
|
|
195
|
-
cargo: {
|
|
196
|
-
enabled: true,
|
|
197
|
-
maxAttempts: 10,
|
|
198
|
-
initialDelay: 3e4,
|
|
199
|
-
backoffMultiplier: 2
|
|
200
|
-
}
|
|
201
|
-
})
|
|
202
|
-
});
|
|
203
|
-
var TemplateConfigSchema = z.object({
|
|
204
|
-
path: z.string().optional(),
|
|
205
|
-
engine: z.enum(["handlebars", "liquid", "ejs"]).optional()
|
|
206
|
-
});
|
|
207
|
-
var LocationModeSchema = z.enum(["root", "packages", "both"]);
|
|
208
|
-
var ChangelogConfigSchema = z.object({
|
|
209
|
-
mode: LocationModeSchema.optional(),
|
|
210
|
-
file: z.string().optional(),
|
|
211
|
-
templates: TemplateConfigSchema.optional()
|
|
212
|
-
});
|
|
213
|
-
var LLMOptionsSchema = z.object({
|
|
214
|
-
timeout: z.number().optional(),
|
|
215
|
-
maxTokens: z.number().optional(),
|
|
216
|
-
temperature: z.number().optional()
|
|
217
|
-
});
|
|
218
|
-
var LLMRetryConfigSchema = z.object({
|
|
219
|
-
maxAttempts: z.number().int().positive().optional(),
|
|
220
|
-
initialDelay: z.number().nonnegative().optional(),
|
|
221
|
-
maxDelay: z.number().positive().optional(),
|
|
222
|
-
backoffFactor: z.number().positive().optional()
|
|
223
|
-
});
|
|
224
|
-
var LLMTasksConfigSchema = z.object({
|
|
225
|
-
summarize: z.boolean().optional(),
|
|
226
|
-
enhance: z.boolean().optional(),
|
|
227
|
-
categorize: z.boolean().optional(),
|
|
228
|
-
releaseNotes: z.boolean().optional()
|
|
229
|
-
});
|
|
230
|
-
var LLMCategorySchema = z.object({
|
|
231
|
-
name: z.string(),
|
|
232
|
-
description: z.string(),
|
|
233
|
-
scopes: z.array(z.string()).optional()
|
|
234
|
-
});
|
|
235
|
-
var ScopeRulesSchema = z.object({
|
|
236
|
-
allowed: z.array(z.string()).optional(),
|
|
237
|
-
caseSensitive: z.boolean().default(false),
|
|
238
|
-
invalidScopeAction: z.enum(["remove", "keep", "fallback"]).default("remove"),
|
|
239
|
-
fallbackScope: z.string().optional()
|
|
240
|
-
});
|
|
241
|
-
var ScopeConfigSchema = z.object({
|
|
242
|
-
mode: z.enum(["restricted", "packages", "none", "unrestricted"]).default("unrestricted"),
|
|
243
|
-
rules: ScopeRulesSchema.optional()
|
|
244
|
-
});
|
|
245
|
-
var LLMPromptOverridesSchema = z.object({
|
|
246
|
-
enhance: z.string().optional(),
|
|
247
|
-
categorize: z.string().optional(),
|
|
248
|
-
enhanceAndCategorize: z.string().optional(),
|
|
249
|
-
summarize: z.string().optional(),
|
|
250
|
-
releaseNotes: z.string().optional()
|
|
251
|
-
});
|
|
252
|
-
var LLMPromptsConfigSchema = z.object({
|
|
253
|
-
instructions: LLMPromptOverridesSchema.optional(),
|
|
254
|
-
templates: LLMPromptOverridesSchema.optional()
|
|
255
|
-
});
|
|
256
|
-
var LLMConfigSchema = z.object({
|
|
257
|
-
provider: z.string(),
|
|
258
|
-
model: z.string(),
|
|
259
|
-
baseURL: z.string().optional(),
|
|
260
|
-
apiKey: z.string().optional(),
|
|
261
|
-
options: LLMOptionsSchema.optional(),
|
|
262
|
-
concurrency: z.number().int().positive().optional(),
|
|
263
|
-
retry: LLMRetryConfigSchema.optional(),
|
|
264
|
-
tasks: LLMTasksConfigSchema.optional(),
|
|
265
|
-
categories: z.array(LLMCategorySchema).optional(),
|
|
266
|
-
style: z.string().optional(),
|
|
267
|
-
scopes: ScopeConfigSchema.optional(),
|
|
268
|
-
prompts: LLMPromptsConfigSchema.optional()
|
|
269
|
-
});
|
|
270
|
-
var ReleaseNotesConfigSchema = z.object({
|
|
271
|
-
mode: LocationModeSchema.optional(),
|
|
272
|
-
file: z.string().optional(),
|
|
273
|
-
templates: TemplateConfigSchema.optional(),
|
|
274
|
-
llm: LLMConfigSchema.optional()
|
|
275
|
-
});
|
|
276
|
-
var NotesInputConfigSchema = z.object({
|
|
277
|
-
source: z.string().optional(),
|
|
278
|
-
file: z.string().optional()
|
|
279
|
-
});
|
|
280
|
-
var NotesConfigSchema = z.object({
|
|
281
|
-
changelog: z.union([z.literal(false), ChangelogConfigSchema]).optional(),
|
|
282
|
-
releaseNotes: z.union([z.literal(false), ReleaseNotesConfigSchema]).optional(),
|
|
283
|
-
updateStrategy: z.enum(["prepend", "regenerate"]).optional()
|
|
284
|
-
});
|
|
285
|
-
var CILabelsConfigSchema = z.object({
|
|
286
|
-
stable: z.string().default("release:stable"),
|
|
287
|
-
prerelease: z.string().default("release:prerelease"),
|
|
288
|
-
skip: z.string().default("release:skip"),
|
|
289
|
-
major: z.string().default("release:major"),
|
|
290
|
-
minor: z.string().default("release:minor"),
|
|
291
|
-
patch: z.string().default("release:patch")
|
|
292
|
-
});
|
|
293
|
-
var CIConfigSchema = z.object({
|
|
294
|
-
releaseStrategy: z.enum(["manual", "direct", "standing-pr", "scheduled"]).default("direct"),
|
|
295
|
-
releaseTrigger: z.enum(["commit", "label"]).default("label"),
|
|
296
|
-
prPreview: z.boolean().default(true),
|
|
297
|
-
autoRelease: z.boolean().default(false),
|
|
298
|
-
/**
|
|
299
|
-
* Commit message prefixes that should not trigger a release.
|
|
300
|
-
* Defaults to `['chore: release ']` to match the release commit template
|
|
301
|
-
* (`chore: release ${packageName} v${version}`) and provide a
|
|
302
|
-
* secondary loop-prevention guard alongside `[skip ci]`.
|
|
303
|
-
*/
|
|
304
|
-
skipPatterns: z.array(z.string()).default(["chore: release "]),
|
|
305
|
-
minChanges: z.number().int().positive().default(1),
|
|
306
|
-
labels: CILabelsConfigSchema.default({
|
|
307
|
-
stable: "release:stable",
|
|
308
|
-
prerelease: "release:prerelease",
|
|
309
|
-
skip: "release:skip",
|
|
310
|
-
major: "release:major",
|
|
311
|
-
minor: "release:minor",
|
|
312
|
-
patch: "release:patch"
|
|
313
|
-
})
|
|
314
|
-
});
|
|
315
|
-
var ReleaseCIConfigSchema = z.object({
|
|
316
|
-
skipPatterns: z.array(z.string().min(1)).optional(),
|
|
317
|
-
minChanges: z.number().int().positive().optional(),
|
|
318
|
-
/** Set to `false` to disable GitHub release creation in CI. */
|
|
319
|
-
githubRelease: z.literal(false).optional(),
|
|
320
|
-
/** Set to `false` to disable changelog generation in CI. */
|
|
321
|
-
notes: z.literal(false).optional()
|
|
322
|
-
});
|
|
323
|
-
var ReleaseConfigSchema = z.object({
|
|
324
|
-
/**
|
|
325
|
-
* Optional steps to enable. The version step always runs; only 'notes' and
|
|
326
|
-
* 'publish' can be opted out. Omitting a step is equivalent to --skip-<step>.
|
|
327
|
-
*/
|
|
328
|
-
steps: z.array(z.enum(["notes", "publish"])).min(1).optional(),
|
|
329
|
-
ci: ReleaseCIConfigSchema.optional()
|
|
330
|
-
});
|
|
331
|
-
var ReleaseKitConfigSchema = z.object({
|
|
332
|
-
git: GitConfigSchema.optional(),
|
|
333
|
-
monorepo: MonorepoConfigSchema.optional(),
|
|
334
|
-
version: VersionConfigSchema.optional(),
|
|
335
|
-
publish: PublishConfigSchema.optional(),
|
|
336
|
-
notes: NotesConfigSchema.optional(),
|
|
337
|
-
ci: CIConfigSchema.optional(),
|
|
338
|
-
release: ReleaseConfigSchema.optional()
|
|
339
|
-
});
|
|
340
|
-
var MAX_INPUT_LENGTH = 1e4;
|
|
341
|
-
function substituteVariables(value) {
|
|
342
|
-
if (value.length > MAX_INPUT_LENGTH) {
|
|
343
|
-
throw new Error(`Input too long: ${value.length} characters (max ${MAX_INPUT_LENGTH})`);
|
|
344
|
-
}
|
|
345
|
-
const envPattern = /\{env:([^}]{1,1000})\}/g;
|
|
346
|
-
const filePattern = /\{file:([^}]{1,1000})\}/g;
|
|
347
|
-
let result = value;
|
|
348
|
-
result = result.replace(envPattern, (_, varName) => {
|
|
349
|
-
return process.env[varName] ?? "";
|
|
350
|
-
});
|
|
351
|
-
result = result.replace(filePattern, (_, filePath) => {
|
|
352
|
-
const expandedPath = filePath.startsWith("~") ? path2.join(os.homedir(), filePath.slice(1)) : filePath;
|
|
353
|
-
try {
|
|
354
|
-
return fs2.readFileSync(expandedPath, "utf-8").trim();
|
|
355
|
-
} catch {
|
|
356
|
-
return "";
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
return result;
|
|
360
|
-
}
|
|
361
|
-
var SOLE_REFERENCE_PATTERN = /^\{(?:env|file):[^}]+\}$/;
|
|
362
|
-
function substituteInObject(obj) {
|
|
363
|
-
if (typeof obj === "string") {
|
|
364
|
-
const result = substituteVariables(obj);
|
|
365
|
-
if (result === "" && SOLE_REFERENCE_PATTERN.test(obj)) {
|
|
366
|
-
return void 0;
|
|
367
|
-
}
|
|
368
|
-
return result;
|
|
369
|
-
}
|
|
370
|
-
if (Array.isArray(obj)) {
|
|
371
|
-
return obj.map((item) => substituteInObject(item));
|
|
372
|
-
}
|
|
373
|
-
if (obj && typeof obj === "object") {
|
|
374
|
-
const result = {};
|
|
375
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
376
|
-
result[key] = substituteInObject(value);
|
|
377
|
-
}
|
|
378
|
-
return result;
|
|
379
|
-
}
|
|
380
|
-
return obj;
|
|
381
|
-
}
|
|
382
|
-
var AUTH_DIR = path2.join(os.homedir(), ".config", "releasekit");
|
|
383
|
-
var AUTH_FILE = path2.join(AUTH_DIR, "auth.json");
|
|
384
|
-
var CONFIG_FILE = "releasekit.config.json";
|
|
385
|
-
function loadConfigFile(configPath) {
|
|
386
|
-
if (!fs3.existsSync(configPath)) {
|
|
387
|
-
return {};
|
|
388
|
-
}
|
|
389
|
-
try {
|
|
390
|
-
const content = fs3.readFileSync(configPath, "utf-8");
|
|
391
|
-
const parsed = parseJsonc(content);
|
|
392
|
-
const substituted = substituteInObject(parsed);
|
|
393
|
-
return ReleaseKitConfigSchema.parse(substituted);
|
|
394
|
-
} catch (error) {
|
|
395
|
-
if (error instanceof z2.ZodError) {
|
|
396
|
-
const issues = error.issues.map((i) => ` ${i.path.join(".")}: ${i.message}`).join("\n");
|
|
397
|
-
throw new ConfigError(`Config validation errors:
|
|
398
|
-
${issues}`);
|
|
399
|
-
}
|
|
400
|
-
if (error instanceof SyntaxError) {
|
|
401
|
-
throw new ConfigError(`Invalid JSON in config file: ${error.message}`);
|
|
402
|
-
}
|
|
403
|
-
throw error;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
function loadConfig(options) {
|
|
407
|
-
const cwd3 = options?.cwd ?? process.cwd();
|
|
408
|
-
const configPath = options?.configPath ?? path3.join(cwd3, CONFIG_FILE);
|
|
409
|
-
return loadConfigFile(configPath);
|
|
410
|
-
}
|
|
9
|
+
// src/config.ts
|
|
10
|
+
import { loadConfig as loadReleaseKitConfig } from "@releasekit/config";
|
|
411
11
|
|
|
412
12
|
// src/types.ts
|
|
413
13
|
function toVersionConfig(config, gitConfig) {
|
|
@@ -448,8 +48,8 @@ function toVersionConfig(config, gitConfig) {
|
|
|
448
48
|
}
|
|
449
49
|
|
|
450
50
|
// src/config.ts
|
|
451
|
-
function
|
|
452
|
-
const fullConfig =
|
|
51
|
+
function loadConfig(options) {
|
|
52
|
+
const fullConfig = loadReleaseKitConfig(options);
|
|
453
53
|
return toVersionConfig(fullConfig.version, fullConfig.git);
|
|
454
54
|
}
|
|
455
55
|
|
|
@@ -511,7 +111,7 @@ function createVersionError(code, details) {
|
|
|
511
111
|
}
|
|
512
112
|
|
|
513
113
|
// src/utils/jsonOutput.ts
|
|
514
|
-
import
|
|
114
|
+
import fs from "fs";
|
|
515
115
|
var _jsonOutputMode = false;
|
|
516
116
|
var _pendingWrites = [];
|
|
517
117
|
var _jsonData = {
|
|
@@ -531,14 +131,14 @@ function enableJsonOutput(dryRun = false) {
|
|
|
531
131
|
_jsonData.commitMessage = void 0;
|
|
532
132
|
_pendingWrites.length = 0;
|
|
533
133
|
}
|
|
534
|
-
function recordPendingWrite(
|
|
134
|
+
function recordPendingWrite(path7, content) {
|
|
535
135
|
if (!_jsonOutputMode) return;
|
|
536
|
-
_pendingWrites.push({ path:
|
|
136
|
+
_pendingWrites.push({ path: path7, content });
|
|
537
137
|
}
|
|
538
138
|
function flushPendingWrites() {
|
|
539
139
|
try {
|
|
540
|
-
for (const { path:
|
|
541
|
-
|
|
140
|
+
for (const { path: path7, content } of _pendingWrites) {
|
|
141
|
+
fs.writeFileSync(path7, content);
|
|
542
142
|
}
|
|
543
143
|
} finally {
|
|
544
144
|
_pendingWrites.length = 0;
|
|
@@ -582,690 +182,13 @@ function printJsonOutput() {
|
|
|
582
182
|
|
|
583
183
|
// src/core/versionCalculator.ts
|
|
584
184
|
import { cwd } from "process";
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
return args.reduce((finalArgs, arg) => {
|
|
589
|
-
if (arg) {
|
|
590
|
-
finalArgs.push(String(arg));
|
|
591
|
-
}
|
|
592
|
-
return finalArgs;
|
|
593
|
-
}, []);
|
|
594
|
-
}
|
|
595
|
-
function toArray(value) {
|
|
596
|
-
return Array.isArray(value) ? value : [value];
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
// ../../node_modules/.pnpm/@conventional-changelog+git-client@2.5.1_conventional-commits-filter@5.0.0_conventional-commits-parser@6.2.1/node_modules/@conventional-changelog/git-client/dist/GitClient.js
|
|
600
|
-
import { spawn } from "child_process";
|
|
601
|
-
|
|
602
|
-
// ../../node_modules/.pnpm/@simple-libs+stream-utils@1.1.0/node_modules/@simple-libs/stream-utils/dist/index.js
|
|
603
|
-
import { Readable } from "stream";
|
|
604
|
-
async function toArray2(iterable) {
|
|
605
|
-
const result = [];
|
|
606
|
-
for await (const item of iterable) {
|
|
607
|
-
result.push(item);
|
|
608
|
-
}
|
|
609
|
-
return result;
|
|
610
|
-
}
|
|
611
|
-
async function concatBufferStream(iterable) {
|
|
612
|
-
return Buffer.concat(await toArray2(iterable));
|
|
613
|
-
}
|
|
614
|
-
async function firstFromStream(stream) {
|
|
615
|
-
for await (const tag of stream) {
|
|
616
|
-
return tag;
|
|
617
|
-
}
|
|
618
|
-
return null;
|
|
619
|
-
}
|
|
620
|
-
async function* splitStream(stream, separator) {
|
|
621
|
-
let chunk;
|
|
622
|
-
let payload;
|
|
623
|
-
let buffer = "";
|
|
624
|
-
for await (chunk of stream) {
|
|
625
|
-
buffer += chunk.toString();
|
|
626
|
-
if (buffer.includes(separator)) {
|
|
627
|
-
payload = buffer.split(separator);
|
|
628
|
-
buffer = payload.pop() || "";
|
|
629
|
-
yield* payload;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
if (buffer) {
|
|
633
|
-
yield buffer;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
// ../../node_modules/.pnpm/@simple-libs+child-process-utils@1.0.1/node_modules/@simple-libs/child-process-utils/dist/index.js
|
|
638
|
-
async function exitCode(process2) {
|
|
639
|
-
if (process2.exitCode !== null) {
|
|
640
|
-
return process2.exitCode;
|
|
641
|
-
}
|
|
642
|
-
return new Promise((resolve2) => process2.once("close", resolve2));
|
|
643
|
-
}
|
|
644
|
-
async function catchProcessError(process2) {
|
|
645
|
-
let error = new Error("Process exited with non-zero code");
|
|
646
|
-
let stderr = "";
|
|
647
|
-
process2.on("error", (err) => {
|
|
648
|
-
error = err;
|
|
649
|
-
});
|
|
650
|
-
if (process2.stderr) {
|
|
651
|
-
let chunk;
|
|
652
|
-
for await (chunk of process2.stderr) {
|
|
653
|
-
stderr += chunk.toString();
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
const code = await exitCode(process2);
|
|
657
|
-
if (stderr) {
|
|
658
|
-
error = new Error(stderr);
|
|
659
|
-
}
|
|
660
|
-
return code ? error : null;
|
|
661
|
-
}
|
|
662
|
-
async function* outputStream(process2) {
|
|
663
|
-
const { stdout } = process2;
|
|
664
|
-
const errorPromise = catchProcessError(process2);
|
|
665
|
-
if (stdout) {
|
|
666
|
-
stdout.on("error", (err) => {
|
|
667
|
-
if (err.name === "AbortError" && process2.exitCode === null) {
|
|
668
|
-
process2.kill("SIGKILL");
|
|
669
|
-
}
|
|
670
|
-
});
|
|
671
|
-
yield* stdout;
|
|
672
|
-
}
|
|
673
|
-
const error = await errorPromise;
|
|
674
|
-
if (error) {
|
|
675
|
-
throw error;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
function output(process2) {
|
|
679
|
-
return concatBufferStream(outputStream(process2));
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// ../../node_modules/.pnpm/@conventional-changelog+git-client@2.5.1_conventional-commits-filter@5.0.0_conventional-commits-parser@6.2.1/node_modules/@conventional-changelog/git-client/dist/GitClient.js
|
|
683
|
-
var SCISSOR = "------------------------ >8 ------------------------";
|
|
684
|
-
var GitClient = class {
|
|
685
|
-
cwd;
|
|
686
|
-
debug;
|
|
687
|
-
constructor(cwd3, debug) {
|
|
688
|
-
this.cwd = cwd3;
|
|
689
|
-
this.debug = debug;
|
|
690
|
-
}
|
|
691
|
-
formatArgs(...args) {
|
|
692
|
-
const finalArgs = formatArgs(...args);
|
|
693
|
-
if (this.debug) {
|
|
694
|
-
this.debug(finalArgs);
|
|
695
|
-
}
|
|
696
|
-
return finalArgs;
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* Raw exec method to run git commands.
|
|
700
|
-
* @param args
|
|
701
|
-
* @returns Stdout string output of the command.
|
|
702
|
-
*/
|
|
703
|
-
async exec(...args) {
|
|
704
|
-
return (await output(spawn("git", this.formatArgs(...args), {
|
|
705
|
-
cwd: this.cwd
|
|
706
|
-
}))).toString().trim();
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Raw exec method to run git commands with stream output.
|
|
710
|
-
* @param args
|
|
711
|
-
* @returns Stdout stream of the command.
|
|
712
|
-
*/
|
|
713
|
-
execStream(...args) {
|
|
714
|
-
return outputStream(spawn("git", this.formatArgs(...args), {
|
|
715
|
-
cwd: this.cwd
|
|
716
|
-
}));
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Initialize a new git repository.
|
|
720
|
-
* @returns Boolean result.
|
|
721
|
-
*/
|
|
722
|
-
async init() {
|
|
723
|
-
try {
|
|
724
|
-
await this.exec("init");
|
|
725
|
-
return true;
|
|
726
|
-
} catch (err) {
|
|
727
|
-
return false;
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
/**
|
|
731
|
-
* Get raw commits stream.
|
|
732
|
-
* @param params
|
|
733
|
-
* @param params.path - Read commits from specific path.
|
|
734
|
-
* @param params.from - Start commits range.
|
|
735
|
-
* @param params.to - End commits range.
|
|
736
|
-
* @param params.format - Commits format.
|
|
737
|
-
* @yields Raw commits data.
|
|
738
|
-
*/
|
|
739
|
-
async *getRawCommits(params = {}) {
|
|
740
|
-
const { path: path11, from = "", to = "HEAD", format = "%B", ignore, reverse, merges, since } = params;
|
|
741
|
-
const shouldNotIgnore = ignore ? (chunk2) => !ignore.test(chunk2) : () => true;
|
|
742
|
-
const stdout = this.execStream("log", `--format=${format}%n${SCISSOR}`, since && `--since=${since instanceof Date ? since.toISOString() : since}`, reverse && "--reverse", merges && "--merges", merges === false && "--no-merges", [from, to].filter(Boolean).join(".."), ...path11 ? ["--", ...toArray(path11)] : []);
|
|
743
|
-
const commitsStream = splitStream(stdout, `${SCISSOR}
|
|
744
|
-
`);
|
|
745
|
-
let chunk;
|
|
746
|
-
for await (chunk of commitsStream) {
|
|
747
|
-
if (shouldNotIgnore(chunk)) {
|
|
748
|
-
yield chunk;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
/**
|
|
753
|
-
* Get tags stream.
|
|
754
|
-
* @param params
|
|
755
|
-
* @yields Tags
|
|
756
|
-
*/
|
|
757
|
-
async *getTags(params = {}) {
|
|
758
|
-
const { path: path11, from = "", to = "HEAD", since } = params;
|
|
759
|
-
const tagRegex = /tag:\s*(.+?)[,)]/gi;
|
|
760
|
-
const stdout = this.execStream("log", "--decorate", "--no-color", "--date-order", since && `--since=${since instanceof Date ? since.toISOString() : since}`, [from, to].filter(Boolean).join(".."), ...path11 ? ["--", ...toArray(path11)] : []);
|
|
761
|
-
let chunk;
|
|
762
|
-
let matches;
|
|
763
|
-
let tag;
|
|
764
|
-
for await (chunk of stdout) {
|
|
765
|
-
matches = chunk.toString().trim().matchAll(tagRegex);
|
|
766
|
-
for ([, tag] of matches) {
|
|
767
|
-
yield tag;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Get last tag.
|
|
773
|
-
* @param params
|
|
774
|
-
* @returns Last tag, `null` if not found.
|
|
775
|
-
*/
|
|
776
|
-
async getLastTag(params) {
|
|
777
|
-
return firstFromStream(this.getTags(params));
|
|
778
|
-
}
|
|
779
|
-
/**
|
|
780
|
-
* Check file is ignored via .gitignore.
|
|
781
|
-
* @param file - Path to target file.
|
|
782
|
-
* @returns Boolean value.
|
|
783
|
-
*/
|
|
784
|
-
async checkIgnore(file) {
|
|
785
|
-
try {
|
|
786
|
-
await this.exec("check-ignore", "--", file);
|
|
787
|
-
return true;
|
|
788
|
-
} catch (err) {
|
|
789
|
-
return false;
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* Add files to git index.
|
|
794
|
-
* @param files - Files to stage.
|
|
795
|
-
*/
|
|
796
|
-
async add(files) {
|
|
797
|
-
await this.exec("add", "--", ...toArray(files));
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
* Commit changes.
|
|
801
|
-
* @param params
|
|
802
|
-
* @param params.verify
|
|
803
|
-
* @param params.sign
|
|
804
|
-
* @param params.files
|
|
805
|
-
* @param params.allowEmpty
|
|
806
|
-
* @param params.message
|
|
807
|
-
*/
|
|
808
|
-
async commit(params) {
|
|
809
|
-
const { verify = true, sign = false, files = [], allowEmpty = false, message } = params;
|
|
810
|
-
await this.exec("commit", !verify && "--no-verify", sign && "-S", allowEmpty && "--allow-empty", "-m", message, "--", ...files);
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* Create a tag for the current commit.
|
|
814
|
-
* @param params
|
|
815
|
-
* @param params.sign
|
|
816
|
-
* @param params.name
|
|
817
|
-
* @param params.message
|
|
818
|
-
*/
|
|
819
|
-
async tag(params) {
|
|
820
|
-
let { sign = false, name, message } = params;
|
|
821
|
-
if (sign) {
|
|
822
|
-
message = "";
|
|
823
|
-
}
|
|
824
|
-
await this.exec("tag", sign && "-s", message && "-a", ...message ? ["-m", message] : [], "--", name);
|
|
825
|
-
}
|
|
826
|
-
/**
|
|
827
|
-
* Get current branch name.
|
|
828
|
-
* @returns Current branch name.
|
|
829
|
-
*/
|
|
830
|
-
async getCurrentBranch() {
|
|
831
|
-
const branch = await this.exec("rev-parse", "--abbrev-ref", "HEAD");
|
|
832
|
-
return branch;
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Get default branch name.
|
|
836
|
-
* @returns Default branch name.
|
|
837
|
-
*/
|
|
838
|
-
async getDefaultBranch() {
|
|
839
|
-
const branch = (await this.exec("rev-parse", "--abbrev-ref", "origin/HEAD")).replace(/^origin\//, "");
|
|
840
|
-
return branch;
|
|
841
|
-
}
|
|
842
|
-
/**
|
|
843
|
-
* Push changes to remote.
|
|
844
|
-
* @param branch
|
|
845
|
-
* @param params
|
|
846
|
-
* @param params.verify
|
|
847
|
-
*/
|
|
848
|
-
async push(branch, params = {}) {
|
|
849
|
-
const { verify = true, tags = false, followTags = false, force = false } = params;
|
|
850
|
-
await this.exec("push", followTags && "--follow-tags", tags && "--tags", !verify && "--no-verify", force && "--force", "origin", "--", branch);
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* Verify rev exists.
|
|
854
|
-
* @param rev
|
|
855
|
-
* @param safe - If `true`, will not throw error if rev not found.
|
|
856
|
-
* @returns Target hash.
|
|
857
|
-
*/
|
|
858
|
-
async verify(rev, safe) {
|
|
859
|
-
let git = this.exec("rev-parse", "--verify", rev);
|
|
860
|
-
if (safe) {
|
|
861
|
-
git = git.catch(() => "");
|
|
862
|
-
}
|
|
863
|
-
return await git;
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Get config value by key.
|
|
867
|
-
* @param key - Config key.
|
|
868
|
-
* @returns Config value.
|
|
869
|
-
*/
|
|
870
|
-
async getConfig(key) {
|
|
871
|
-
return await this.exec("config", "--get", "--", key);
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Set config value by key.
|
|
875
|
-
* @param key - Config key.
|
|
876
|
-
* @param value - Config value.
|
|
877
|
-
*/
|
|
878
|
-
async setConfig(key, value) {
|
|
879
|
-
await this.exec("config", "--", key, value);
|
|
880
|
-
}
|
|
881
|
-
/**
|
|
882
|
-
* Fetch changes from remote.
|
|
883
|
-
* @param params
|
|
884
|
-
*/
|
|
885
|
-
async fetch(params = {}) {
|
|
886
|
-
const { prune = false, unshallow = false, tags = false, all = false, remote, branch } = params;
|
|
887
|
-
await this.exec("fetch", prune && "--prune", unshallow && "--unshallow", tags && "--tags", all && "--all", ...remote && branch ? [
|
|
888
|
-
"--",
|
|
889
|
-
remote,
|
|
890
|
-
branch
|
|
891
|
-
] : []);
|
|
892
|
-
}
|
|
893
|
-
/**
|
|
894
|
-
* Create a new branch.
|
|
895
|
-
* @param branch - Branch name.
|
|
896
|
-
*/
|
|
897
|
-
async createBranch(branch) {
|
|
898
|
-
await this.exec("checkout", "-b", branch);
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Delete a branch.
|
|
902
|
-
* @param branch - Branch name.
|
|
903
|
-
*/
|
|
904
|
-
async deleteBranch(branch) {
|
|
905
|
-
await this.exec("branch", "-D", "--", branch);
|
|
906
|
-
}
|
|
907
|
-
/**
|
|
908
|
-
* Checkout a branch.
|
|
909
|
-
* @param branch - Branch name.
|
|
910
|
-
*/
|
|
911
|
-
async checkout(branch) {
|
|
912
|
-
await this.exec("checkout", branch);
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
|
|
916
|
-
// ../../node_modules/.pnpm/@conventional-changelog+git-client@2.5.1_conventional-commits-filter@5.0.0_conventional-commits-parser@6.2.1/node_modules/@conventional-changelog/git-client/dist/ConventionalGitClient.js
|
|
917
|
-
import semver from "semver";
|
|
918
|
-
var ConventionalGitClient = class extends GitClient {
|
|
919
|
-
deps = null;
|
|
920
|
-
loadDeps() {
|
|
921
|
-
if (this.deps) {
|
|
922
|
-
return this.deps;
|
|
923
|
-
}
|
|
924
|
-
this.deps = Promise.all([
|
|
925
|
-
import("./dist-3B6ZXCEH.js").then(({ parseCommits }) => parseCommits),
|
|
926
|
-
import("./dist-XFQOB6BJ.js").then(({ filterRevertedCommits }) => filterRevertedCommits)
|
|
927
|
-
]);
|
|
928
|
-
return this.deps;
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* Get parsed commits stream.
|
|
932
|
-
* @param params
|
|
933
|
-
* @param params.path - Read commits from specific path.
|
|
934
|
-
* @param params.from - Start commits range.
|
|
935
|
-
* @param params.to - End commits range.
|
|
936
|
-
* @param params.format - Commits format.
|
|
937
|
-
* @param parserOptions - Commit parser options.
|
|
938
|
-
* @yields Raw commits data.
|
|
939
|
-
*/
|
|
940
|
-
async *getCommits(params = {}, parserOptions = {}) {
|
|
941
|
-
const { filterReverts, ...gitLogParams } = params;
|
|
942
|
-
const [parseCommits, filterRevertedCommits] = await this.loadDeps();
|
|
943
|
-
if (filterReverts) {
|
|
944
|
-
yield* filterRevertedCommits(this.getCommits(gitLogParams, parserOptions));
|
|
945
|
-
return;
|
|
946
|
-
}
|
|
947
|
-
const parse2 = parseCommits(parserOptions);
|
|
948
|
-
const commitsStream = this.getRawCommits(gitLogParams);
|
|
949
|
-
yield* parse2(commitsStream);
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* Get semver tags stream.
|
|
953
|
-
* @param params
|
|
954
|
-
* @param params.prefix - Get semver tags with specific prefix.
|
|
955
|
-
* @param params.skipUnstable - Skip semver tags with unstable versions.
|
|
956
|
-
* @param params.clean - Clean version from prefix and trash.
|
|
957
|
-
* @yields Semver tags.
|
|
958
|
-
*/
|
|
959
|
-
async *getSemverTags(params = {}) {
|
|
960
|
-
const { prefix, skipUnstable, clean } = params;
|
|
961
|
-
const tagsStream = this.getTags();
|
|
962
|
-
const unstableTagRegex = /\d+\.\d+\.\d+-.+/;
|
|
963
|
-
const cleanTag = clean ? (tag2, unprefixed2) => semver.clean(unprefixed2 || tag2) : (tag2) => tag2;
|
|
964
|
-
let unprefixed;
|
|
965
|
-
let tag;
|
|
966
|
-
for await (tag of tagsStream) {
|
|
967
|
-
if (skipUnstable && unstableTagRegex.test(tag)) {
|
|
968
|
-
continue;
|
|
969
|
-
}
|
|
970
|
-
if (prefix) {
|
|
971
|
-
const isPrefixed = typeof prefix === "string" ? tag.startsWith(prefix) : prefix.test(tag);
|
|
972
|
-
if (isPrefixed) {
|
|
973
|
-
unprefixed = tag.replace(prefix, "");
|
|
974
|
-
if (semver.valid(unprefixed)) {
|
|
975
|
-
tag = cleanTag(tag, unprefixed);
|
|
976
|
-
if (tag) {
|
|
977
|
-
yield tag;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
} else if (semver.valid(tag)) {
|
|
982
|
-
tag = cleanTag(tag);
|
|
983
|
-
if (tag) {
|
|
984
|
-
yield tag;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Get last semver tag.
|
|
991
|
-
* @param params - getSemverTags params.
|
|
992
|
-
* @returns Last semver tag, `null` if not found.
|
|
993
|
-
*/
|
|
994
|
-
async getLastSemverTag(params = {}) {
|
|
995
|
-
return firstFromStream(this.getSemverTags(params));
|
|
996
|
-
}
|
|
997
|
-
/**
|
|
998
|
-
* Get current sematic version from git tags.
|
|
999
|
-
* @param params - Additional git params.
|
|
1000
|
-
* @returns Current sematic version, `null` if not found.
|
|
1001
|
-
*/
|
|
1002
|
-
async getVersionFromTags(params = {}) {
|
|
1003
|
-
const semverTagsStream = this.getSemverTags({
|
|
1004
|
-
clean: true,
|
|
1005
|
-
...params
|
|
1006
|
-
});
|
|
1007
|
-
const semverTags = [];
|
|
1008
|
-
for await (const tag of semverTagsStream) {
|
|
1009
|
-
semverTags.push(tag);
|
|
1010
|
-
}
|
|
1011
|
-
if (!semverTags.length) {
|
|
1012
|
-
return null;
|
|
1013
|
-
}
|
|
1014
|
-
return semverTags.sort(semver.rcompare)[0] || null;
|
|
1015
|
-
}
|
|
1016
|
-
};
|
|
1017
|
-
|
|
1018
|
-
// ../../node_modules/.pnpm/conventional-changelog-preset-loader@5.0.0/node_modules/conventional-changelog-preset-loader/dist/presetLoader.js
|
|
1019
|
-
import path4 from "path";
|
|
1020
|
-
function resolvePresetNameVariants(preset) {
|
|
1021
|
-
if (path4.isAbsolute(preset)) {
|
|
1022
|
-
return [preset];
|
|
1023
|
-
}
|
|
1024
|
-
let scope = "";
|
|
1025
|
-
let name = preset.toLocaleLowerCase();
|
|
1026
|
-
if (preset.startsWith("@")) {
|
|
1027
|
-
const parts = preset.split("/");
|
|
1028
|
-
scope = `${parts.shift()}/`;
|
|
1029
|
-
if (scope === "@conventional-changelog/") {
|
|
1030
|
-
return [preset];
|
|
1031
|
-
}
|
|
1032
|
-
name = parts.join("/");
|
|
1033
|
-
}
|
|
1034
|
-
if (!name.startsWith("conventional-changelog-")) {
|
|
1035
|
-
name = `conventional-changelog-${name}`;
|
|
1036
|
-
}
|
|
1037
|
-
const altPreset = `${scope}${name}`;
|
|
1038
|
-
if (altPreset !== preset) {
|
|
1039
|
-
return [altPreset, preset];
|
|
1040
|
-
}
|
|
1041
|
-
return [preset];
|
|
1042
|
-
}
|
|
1043
|
-
function getModuleDefaultExport(module) {
|
|
1044
|
-
if (("__esModule" in module || Object.getPrototypeOf(module) === null) && "default" in module) {
|
|
1045
|
-
return module.default;
|
|
1046
|
-
}
|
|
1047
|
-
return module;
|
|
1048
|
-
}
|
|
1049
|
-
async function loadWithFallbacks(moduleLoader, variants) {
|
|
1050
|
-
let error = null;
|
|
1051
|
-
for (const variant of variants) {
|
|
1052
|
-
try {
|
|
1053
|
-
return getModuleDefaultExport(await moduleLoader(variant));
|
|
1054
|
-
} catch (err) {
|
|
1055
|
-
if (!error) {
|
|
1056
|
-
error = err;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
throw error;
|
|
1061
|
-
}
|
|
1062
|
-
function createPresetLoader(moduleLoader) {
|
|
1063
|
-
return async function loadPreset2(presetOrParams) {
|
|
1064
|
-
let preset = "";
|
|
1065
|
-
let params = null;
|
|
1066
|
-
if (typeof presetOrParams === "string") {
|
|
1067
|
-
preset = presetOrParams;
|
|
1068
|
-
} else if (typeof presetOrParams === "object" && typeof presetOrParams.name === "string") {
|
|
1069
|
-
preset = presetOrParams.name;
|
|
1070
|
-
params = presetOrParams;
|
|
1071
|
-
} else {
|
|
1072
|
-
throw Error("Preset must be string or object with property `name`");
|
|
1073
|
-
}
|
|
1074
|
-
const presetNameVariants = resolvePresetNameVariants(preset);
|
|
1075
|
-
let createPreset = null;
|
|
1076
|
-
try {
|
|
1077
|
-
createPreset = await loadWithFallbacks(moduleLoader, presetNameVariants);
|
|
1078
|
-
} catch (err) {
|
|
1079
|
-
throw new Error(`Unable to load the "${preset}" preset. Please make sure it's installed.`, {
|
|
1080
|
-
cause: err
|
|
1081
|
-
});
|
|
1082
|
-
}
|
|
1083
|
-
if (typeof createPreset !== "function") {
|
|
1084
|
-
throw new Error(`The "${preset}" preset does not export a function. Maybe you are using an old version of the preset. Please upgrade.`);
|
|
1085
|
-
}
|
|
1086
|
-
return params ? await createPreset(params) : await createPreset();
|
|
1087
|
-
};
|
|
1088
|
-
}
|
|
1089
|
-
var loadPreset = createPresetLoader((preset) => import(preset));
|
|
1090
|
-
|
|
1091
|
-
// ../../node_modules/.pnpm/conventional-recommended-bump@11.2.0/node_modules/conventional-recommended-bump/dist/utils.js
|
|
1092
|
-
function isIterable(value) {
|
|
1093
|
-
return value !== null && (typeof value[Symbol.iterator] === "function" || typeof value[Symbol.asyncIterator] === "function");
|
|
1094
|
-
}
|
|
1095
|
-
function bindLogNamespace(namespace, logger) {
|
|
1096
|
-
return (messages) => logger(namespace, messages);
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
// ../../node_modules/.pnpm/conventional-recommended-bump@11.2.0/node_modules/conventional-recommended-bump/dist/bumper.js
|
|
1100
|
-
var VERSIONS = [
|
|
1101
|
-
"major",
|
|
1102
|
-
"minor",
|
|
1103
|
-
"patch"
|
|
1104
|
-
];
|
|
1105
|
-
var Bumper = class {
|
|
1106
|
-
gitClient;
|
|
1107
|
-
params;
|
|
1108
|
-
whatBump;
|
|
1109
|
-
tagGetter;
|
|
1110
|
-
commitsGetter;
|
|
1111
|
-
constructor(cwdOrGitClient = process.cwd()) {
|
|
1112
|
-
this.gitClient = typeof cwdOrGitClient === "string" ? new ConventionalGitClient(cwdOrGitClient) : cwdOrGitClient;
|
|
1113
|
-
this.whatBump = null;
|
|
1114
|
-
this.params = Promise.resolve({
|
|
1115
|
-
commits: {
|
|
1116
|
-
format: "%B%n-hash-%n%H",
|
|
1117
|
-
filterReverts: true
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
this.tagGetter = () => this.getLastSemverTag();
|
|
1121
|
-
this.commitsGetter = () => this.getCommits();
|
|
1122
|
-
}
|
|
1123
|
-
composeParams(params) {
|
|
1124
|
-
this.params = Promise.all([params, this.params]).then(([params2, prevParams]) => ({
|
|
1125
|
-
options: {
|
|
1126
|
-
...prevParams.options,
|
|
1127
|
-
...params2.options
|
|
1128
|
-
},
|
|
1129
|
-
tags: {
|
|
1130
|
-
...prevParams.tags,
|
|
1131
|
-
...params2.tags
|
|
1132
|
-
},
|
|
1133
|
-
commits: {
|
|
1134
|
-
...prevParams.commits,
|
|
1135
|
-
...params2.commits
|
|
1136
|
-
},
|
|
1137
|
-
parser: {
|
|
1138
|
-
...prevParams.parser,
|
|
1139
|
-
...params2.parser
|
|
1140
|
-
}
|
|
1141
|
-
}));
|
|
1142
|
-
}
|
|
1143
|
-
async getLastSemverTag() {
|
|
1144
|
-
const { tags } = await this.params;
|
|
1145
|
-
return await this.gitClient.getLastSemverTag(tags);
|
|
1146
|
-
}
|
|
1147
|
-
async *getCommits() {
|
|
1148
|
-
const { options, commits, parser } = await this.params;
|
|
1149
|
-
const parserParams = {
|
|
1150
|
-
...parser
|
|
1151
|
-
};
|
|
1152
|
-
if (!parserParams.warn && options?.warn) {
|
|
1153
|
-
parserParams.warn = bindLogNamespace("parser", options.warn);
|
|
1154
|
-
}
|
|
1155
|
-
yield* this.gitClient.getCommits({
|
|
1156
|
-
from: await this.tagGetter() || "",
|
|
1157
|
-
...commits
|
|
1158
|
-
}, parserParams);
|
|
1159
|
-
}
|
|
1160
|
-
/**
|
|
1161
|
-
* Load configs from a preset
|
|
1162
|
-
* @param preset
|
|
1163
|
-
* @param loader - Preset module loader, if not provided, will use default loader
|
|
1164
|
-
* @returns this
|
|
1165
|
-
*/
|
|
1166
|
-
loadPreset(preset, loader) {
|
|
1167
|
-
const loadPreset2 = loader ? createPresetLoader(loader) : loadPreset;
|
|
1168
|
-
const config = loadPreset2(preset).then((config2) => {
|
|
1169
|
-
if (!config2) {
|
|
1170
|
-
throw Error("Preset is not loaded or have incorrect exports");
|
|
1171
|
-
}
|
|
1172
|
-
return config2;
|
|
1173
|
-
});
|
|
1174
|
-
this.whatBump = async (commits) => {
|
|
1175
|
-
const { whatBump } = await config;
|
|
1176
|
-
return whatBump(commits);
|
|
1177
|
-
};
|
|
1178
|
-
this.composeParams(config);
|
|
1179
|
-
return this;
|
|
1180
|
-
}
|
|
1181
|
-
/**
|
|
1182
|
-
* Set config directly
|
|
1183
|
-
* @param config - Config object
|
|
1184
|
-
* @returns this
|
|
1185
|
-
*/
|
|
1186
|
-
config(config) {
|
|
1187
|
-
this.composeParams(config);
|
|
1188
|
-
return this;
|
|
1189
|
-
}
|
|
1190
|
-
/**
|
|
1191
|
-
* Set bumper options
|
|
1192
|
-
* @param options - Bumper options
|
|
1193
|
-
* @returns this
|
|
1194
|
-
*/
|
|
1195
|
-
options(options) {
|
|
1196
|
-
this.composeParams({
|
|
1197
|
-
options
|
|
1198
|
-
});
|
|
1199
|
-
return this;
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* Set params to get the last semver tag
|
|
1203
|
-
* @param paramsOrTag - Params to get the last semver tag or a tag name
|
|
1204
|
-
* @returns this
|
|
1205
|
-
*/
|
|
1206
|
-
tag(paramsOrTag) {
|
|
1207
|
-
if (typeof paramsOrTag === "string") {
|
|
1208
|
-
this.tagGetter = () => paramsOrTag;
|
|
1209
|
-
} else {
|
|
1210
|
-
this.tagGetter = () => this.getLastSemverTag();
|
|
1211
|
-
this.composeParams({
|
|
1212
|
-
tags: paramsOrTag
|
|
1213
|
-
});
|
|
1214
|
-
}
|
|
1215
|
-
return this;
|
|
1216
|
-
}
|
|
1217
|
-
commits(paramsOrCommits, parserOptions) {
|
|
1218
|
-
if (isIterable(paramsOrCommits)) {
|
|
1219
|
-
this.commitsGetter = () => paramsOrCommits;
|
|
1220
|
-
} else {
|
|
1221
|
-
this.commitsGetter = () => this.getCommits();
|
|
1222
|
-
this.composeParams({
|
|
1223
|
-
commits: paramsOrCommits,
|
|
1224
|
-
parser: parserOptions
|
|
1225
|
-
});
|
|
1226
|
-
}
|
|
1227
|
-
return this;
|
|
1228
|
-
}
|
|
1229
|
-
/**
|
|
1230
|
-
* Recommend a bump by `whatBump` function
|
|
1231
|
-
* @param whatBump - Function to recommend a bump from commits
|
|
1232
|
-
* @returns Bump recommendation
|
|
1233
|
-
*/
|
|
1234
|
-
async bump(whatBump = this.whatBump) {
|
|
1235
|
-
if (typeof whatBump !== "function") {
|
|
1236
|
-
throw Error("`whatBump` must be a function");
|
|
1237
|
-
}
|
|
1238
|
-
const { gitClient } = this;
|
|
1239
|
-
const { options } = await this.params;
|
|
1240
|
-
if (!gitClient.debug && options?.debug) {
|
|
1241
|
-
gitClient.debug = bindLogNamespace("git-client", options.debug);
|
|
1242
|
-
}
|
|
1243
|
-
const commitsStream = this.commitsGetter();
|
|
1244
|
-
const commits = [];
|
|
1245
|
-
let commit;
|
|
1246
|
-
for await (commit of commitsStream) {
|
|
1247
|
-
commits.push(commit);
|
|
1248
|
-
}
|
|
1249
|
-
const result = await whatBump(commits);
|
|
1250
|
-
if (result && "level" in result) {
|
|
1251
|
-
return {
|
|
1252
|
-
...result,
|
|
1253
|
-
releaseType: VERSIONS[result.level],
|
|
1254
|
-
commits
|
|
1255
|
-
};
|
|
1256
|
-
}
|
|
1257
|
-
return {
|
|
1258
|
-
commits
|
|
1259
|
-
};
|
|
1260
|
-
}
|
|
1261
|
-
};
|
|
1262
|
-
|
|
1263
|
-
// src/core/versionCalculator.ts
|
|
1264
|
-
import semver4 from "semver";
|
|
185
|
+
import { sanitizePackageName as sanitizePackageName2 } from "@releasekit/core";
|
|
186
|
+
import { Bumper } from "conventional-recommended-bump";
|
|
187
|
+
import semver3 from "semver";
|
|
1265
188
|
|
|
1266
189
|
// src/git/repository.ts
|
|
1267
|
-
import { existsSync
|
|
1268
|
-
import { join
|
|
190
|
+
import { existsSync, statSync } from "fs";
|
|
191
|
+
import { join } from "path";
|
|
1269
192
|
function getCurrentBranch() {
|
|
1270
193
|
const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
1271
194
|
return result.toString().trim();
|
|
@@ -1273,7 +196,10 @@ function getCurrentBranch() {
|
|
|
1273
196
|
|
|
1274
197
|
// src/git/tagsAndBranches.ts
|
|
1275
198
|
import { getSemverTags } from "git-semver-tags";
|
|
1276
|
-
import
|
|
199
|
+
import semver from "semver";
|
|
200
|
+
|
|
201
|
+
// src/utils/formatting.ts
|
|
202
|
+
import { sanitizePackageName } from "@releasekit/core";
|
|
1277
203
|
|
|
1278
204
|
// src/utils/logging.ts
|
|
1279
205
|
import chalk from "chalk";
|
|
@@ -1391,9 +317,9 @@ async function getLatestTag(versionPrefix) {
|
|
|
1391
317
|
}
|
|
1392
318
|
const chronologicalLatest = tags[0];
|
|
1393
319
|
const sortedTags = [...tags].sort((a, b) => {
|
|
1394
|
-
const versionA =
|
|
1395
|
-
const versionB =
|
|
1396
|
-
return
|
|
320
|
+
const versionA = semver.clean(a) || "0.0.0";
|
|
321
|
+
const versionB = semver.clean(b) || "0.0.0";
|
|
322
|
+
return semver.rcompare(versionA, versionB);
|
|
1397
323
|
});
|
|
1398
324
|
const semanticLatest = sortedTags[0];
|
|
1399
325
|
if (semanticLatest !== chronologicalLatest) {
|
|
@@ -1484,15 +410,16 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
|
|
|
1484
410
|
}
|
|
1485
411
|
|
|
1486
412
|
// src/utils/manifestHelpers.ts
|
|
1487
|
-
import
|
|
1488
|
-
import
|
|
413
|
+
import fs3 from "fs";
|
|
414
|
+
import path2 from "path";
|
|
1489
415
|
|
|
1490
416
|
// src/cargo/cargoHandler.ts
|
|
1491
|
-
import
|
|
1492
|
-
import
|
|
1493
|
-
import
|
|
417
|
+
import fs2 from "fs";
|
|
418
|
+
import path from "path";
|
|
419
|
+
import { isCargoToml, parseCargoToml } from "@releasekit/config";
|
|
420
|
+
import * as TOML from "smol-toml";
|
|
1494
421
|
function getCargoInfo(cargoPath) {
|
|
1495
|
-
if (!
|
|
422
|
+
if (!fs2.existsSync(cargoPath)) {
|
|
1496
423
|
log(`Cargo.toml file not found at: ${cargoPath}`, "error");
|
|
1497
424
|
throw new Error(`Cargo.toml file not found at: ${cargoPath}`);
|
|
1498
425
|
}
|
|
@@ -1506,7 +433,7 @@ function getCargoInfo(cargoPath) {
|
|
|
1506
433
|
name: cargo.package.name,
|
|
1507
434
|
version: cargo.package.version || "0.0.0",
|
|
1508
435
|
path: cargoPath,
|
|
1509
|
-
dir:
|
|
436
|
+
dir: path.dirname(cargoPath),
|
|
1510
437
|
content: cargo
|
|
1511
438
|
};
|
|
1512
439
|
} catch (error) {
|
|
@@ -1530,11 +457,11 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
|
|
|
1530
457
|
} else {
|
|
1531
458
|
cargo.package.version = version;
|
|
1532
459
|
}
|
|
1533
|
-
const updatedContent =
|
|
460
|
+
const updatedContent = TOML.stringify(cargo);
|
|
1534
461
|
if (dryRun) {
|
|
1535
462
|
recordPendingWrite(cargoPath, updatedContent);
|
|
1536
463
|
} else {
|
|
1537
|
-
|
|
464
|
+
fs2.writeFileSync(cargoPath, updatedContent);
|
|
1538
465
|
}
|
|
1539
466
|
addPackageUpdate(packageName, version, cargoPath);
|
|
1540
467
|
log(`${dryRun ? "[DRY RUN] Would update" : "Updated"} Cargo.toml at ${cargoPath} to version ${version}`, "success");
|
|
@@ -1549,11 +476,11 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
|
|
|
1549
476
|
|
|
1550
477
|
// src/utils/manifestHelpers.ts
|
|
1551
478
|
function getVersionFromManifests(packageDir) {
|
|
1552
|
-
const packageJsonPath =
|
|
1553
|
-
const cargoTomlPath =
|
|
1554
|
-
if (
|
|
479
|
+
const packageJsonPath = path2.join(packageDir, "package.json");
|
|
480
|
+
const cargoTomlPath = path2.join(packageDir, "Cargo.toml");
|
|
481
|
+
if (fs3.existsSync(packageJsonPath)) {
|
|
1555
482
|
try {
|
|
1556
|
-
const packageJson = JSON.parse(
|
|
483
|
+
const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
|
|
1557
484
|
if (packageJson.version) {
|
|
1558
485
|
log(`Found version ${packageJson.version} in package.json`, "debug");
|
|
1559
486
|
return {
|
|
@@ -1569,7 +496,7 @@ function getVersionFromManifests(packageDir) {
|
|
|
1569
496
|
log(`Error reading package.json: ${errMsg}`, "warning");
|
|
1570
497
|
}
|
|
1571
498
|
}
|
|
1572
|
-
if (
|
|
499
|
+
if (fs3.existsSync(cargoTomlPath)) {
|
|
1573
500
|
try {
|
|
1574
501
|
const cargoInfo = getCargoInfo(cargoTomlPath);
|
|
1575
502
|
if (cargoInfo.version) {
|
|
@@ -1596,8 +523,9 @@ function getVersionFromManifests(packageDir) {
|
|
|
1596
523
|
}
|
|
1597
524
|
|
|
1598
525
|
// src/utils/versionUtils.ts
|
|
1599
|
-
import
|
|
1600
|
-
import
|
|
526
|
+
import fs4 from "fs";
|
|
527
|
+
import { parseCargoToml as parseCargoToml2 } from "@releasekit/config";
|
|
528
|
+
import semver2 from "semver";
|
|
1601
529
|
|
|
1602
530
|
// src/git/tagVerification.ts
|
|
1603
531
|
function verifyTag(tagName, cwd3) {
|
|
@@ -1639,33 +567,33 @@ function normalizePrereleaseIdentifier(prereleaseIdentifier, config) {
|
|
|
1639
567
|
return void 0;
|
|
1640
568
|
}
|
|
1641
569
|
function bumpVersion(currentVersion, bumpType, prereleaseIdentifier) {
|
|
1642
|
-
if (prereleaseIdentifier && STANDARD_BUMP_TYPES.includes(bumpType) && !
|
|
570
|
+
if (prereleaseIdentifier && STANDARD_BUMP_TYPES.includes(bumpType) && !semver2.prerelease(currentVersion)) {
|
|
1643
571
|
const preBumpType = `pre${bumpType}`;
|
|
1644
572
|
log(`Creating prerelease version with identifier '${prereleaseIdentifier}' using ${preBumpType}`, "debug");
|
|
1645
|
-
return
|
|
573
|
+
return semver2.inc(currentVersion, preBumpType, prereleaseIdentifier) || "";
|
|
1646
574
|
}
|
|
1647
|
-
if (
|
|
1648
|
-
const parsed =
|
|
575
|
+
if (semver2.prerelease(currentVersion) && STANDARD_BUMP_TYPES.includes(bumpType)) {
|
|
576
|
+
const parsed = semver2.parse(currentVersion);
|
|
1649
577
|
if (!parsed) {
|
|
1650
|
-
return
|
|
578
|
+
return semver2.inc(currentVersion, bumpType) || "";
|
|
1651
579
|
}
|
|
1652
580
|
if (bumpType === "major" && parsed.minor === 0 && parsed.patch === 0 || bumpType === "minor" && parsed.patch === 0 || bumpType === "patch") {
|
|
1653
581
|
log(`Cleaning prerelease identifier from ${currentVersion} for ${bumpType} bump`, "debug");
|
|
1654
582
|
return `${parsed.major}.${parsed.minor}.${parsed.patch}`;
|
|
1655
583
|
}
|
|
1656
584
|
log(`Standard increment for ${currentVersion} with ${bumpType} bump`, "debug");
|
|
1657
|
-
return
|
|
585
|
+
return semver2.inc(currentVersion, bumpType) || "";
|
|
1658
586
|
}
|
|
1659
587
|
if (prereleaseIdentifier) {
|
|
1660
|
-
return
|
|
588
|
+
return semver2.inc(currentVersion, bumpType, prereleaseIdentifier) || "";
|
|
1661
589
|
}
|
|
1662
|
-
return
|
|
590
|
+
return semver2.inc(currentVersion, bumpType) || "";
|
|
1663
591
|
}
|
|
1664
592
|
function detectVersionMismatch(tagVersion, packageVersion) {
|
|
1665
|
-
const tagIsPrerelease =
|
|
1666
|
-
const packageIsPrerelease =
|
|
1667
|
-
const tagParsed =
|
|
1668
|
-
const packageParsed =
|
|
593
|
+
const tagIsPrerelease = semver2.prerelease(tagVersion) !== null;
|
|
594
|
+
const packageIsPrerelease = semver2.prerelease(packageVersion) !== null;
|
|
595
|
+
const tagParsed = semver2.parse(tagVersion);
|
|
596
|
+
const packageParsed = semver2.parse(packageVersion);
|
|
1669
597
|
if (!tagParsed || !packageParsed) {
|
|
1670
598
|
return { isMismatch: false, severity: "minor", message: "" };
|
|
1671
599
|
}
|
|
@@ -1676,9 +604,9 @@ function detectVersionMismatch(tagVersion, packageVersion) {
|
|
|
1676
604
|
message: `Git tag ${tagVersion} (stable) is ahead of package ${packageVersion} (prerelease). This may indicate a reverted release. Consider deleting tag ${tagVersion} or updating package.json.`
|
|
1677
605
|
};
|
|
1678
606
|
}
|
|
1679
|
-
const tagHigher =
|
|
607
|
+
const tagHigher = semver2.gt(tagVersion, packageVersion);
|
|
1680
608
|
if (tagHigher) {
|
|
1681
|
-
const diff =
|
|
609
|
+
const diff = semver2.diff(packageVersion, tagVersion);
|
|
1682
610
|
if (diff === "major" || diff === "minor") {
|
|
1683
611
|
return {
|
|
1684
612
|
isMismatch: true,
|
|
@@ -1777,7 +705,7 @@ To resolve: delete the conflicting tag, update package.json, or change mismatchS
|
|
|
1777
705
|
};
|
|
1778
706
|
}
|
|
1779
707
|
}
|
|
1780
|
-
if (
|
|
708
|
+
if (semver2.gt(cleanPackageVersion, cleanTagVersion)) {
|
|
1781
709
|
log(`Package version ${packageVersion} is newer than git tag ${tagName}, using package version`, "info");
|
|
1782
710
|
return {
|
|
1783
711
|
source: "package",
|
|
@@ -1786,7 +714,7 @@ To resolve: delete the conflicting tag, update package.json, or change mismatchS
|
|
|
1786
714
|
mismatch: mismatchInfo
|
|
1787
715
|
};
|
|
1788
716
|
}
|
|
1789
|
-
if (
|
|
717
|
+
if (semver2.gt(cleanTagVersion, cleanPackageVersion)) {
|
|
1790
718
|
log(`Git tag ${tagName} is newer than package version ${packageVersion}, using git tag`, "info");
|
|
1791
719
|
return {
|
|
1792
720
|
source: "git",
|
|
@@ -1838,7 +766,7 @@ async function calculateVersion(config, options) {
|
|
|
1838
766
|
try {
|
|
1839
767
|
let buildTagStripPattern2 = function(packageName, prefix) {
|
|
1840
768
|
if (!packageName) return escapeRegExp(prefix);
|
|
1841
|
-
const sanitized =
|
|
769
|
+
const sanitized = sanitizePackageName2(packageName);
|
|
1842
770
|
const escapedRaw = escapeRegExp(`${packageName}@${prefix}`);
|
|
1843
771
|
const escapedDash = escapeRegExp(`${sanitized}-${prefix}`);
|
|
1844
772
|
return `(?:${escapedRaw}|${escapedDash})`;
|
|
@@ -1847,12 +775,12 @@ async function calculateVersion(config, options) {
|
|
|
1847
775
|
if (hasNoTags) {
|
|
1848
776
|
return initialVersion;
|
|
1849
777
|
}
|
|
1850
|
-
const cleanedTag =
|
|
1851
|
-
return
|
|
778
|
+
const cleanedTag = semver3.clean(latestTag) || latestTag;
|
|
779
|
+
return semver3.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
1852
780
|
}
|
|
1853
781
|
if (versionSource.source === "git") {
|
|
1854
|
-
const cleanedTag =
|
|
1855
|
-
return
|
|
782
|
+
const cleanedTag = semver3.clean(versionSource.version) || versionSource.version;
|
|
783
|
+
return semver3.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
|
|
1856
784
|
}
|
|
1857
785
|
return versionSource.version;
|
|
1858
786
|
};
|
|
@@ -1876,7 +804,7 @@ async function calculateVersion(config, options) {
|
|
|
1876
804
|
const specifiedType = type;
|
|
1877
805
|
if (specifiedType) {
|
|
1878
806
|
const currentVersion = getCurrentVersionFromSource2();
|
|
1879
|
-
const isCurrentPrerelease =
|
|
807
|
+
const isCurrentPrerelease = semver3.prerelease(currentVersion);
|
|
1880
808
|
const explicitlyRequestedPrerelease = config.isPrerelease;
|
|
1881
809
|
if (STANDARD_BUMP_TYPES.includes(specifiedType) && (isCurrentPrerelease || explicitlyRequestedPrerelease)) {
|
|
1882
810
|
const prereleaseId2 = explicitlyRequestedPrerelease || isCurrentPrerelease ? normalizedPrereleaseId : void 0;
|
|
@@ -1971,8 +899,8 @@ async function calculateVersion(config, options) {
|
|
|
1971
899
|
}
|
|
1972
900
|
|
|
1973
901
|
// src/package/packageProcessor.ts
|
|
1974
|
-
import * as
|
|
1975
|
-
import
|
|
902
|
+
import * as fs6 from "fs";
|
|
903
|
+
import path4 from "path";
|
|
1976
904
|
|
|
1977
905
|
// src/changelog/commitParser.ts
|
|
1978
906
|
var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
|
|
@@ -1980,8 +908,8 @@ var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
|
|
|
1980
908
|
function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
|
|
1981
909
|
try {
|
|
1982
910
|
const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
|
|
1983
|
-
const
|
|
1984
|
-
const commits =
|
|
911
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
912
|
+
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
1985
913
|
return commits.map((commit) => {
|
|
1986
914
|
const [hash, ...messageParts] = commit.split("|||");
|
|
1987
915
|
const message = messageParts.join("|||").trim();
|
|
@@ -1999,14 +927,14 @@ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
|
|
|
1999
927
|
}
|
|
2000
928
|
function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
|
|
2001
929
|
try {
|
|
2002
|
-
const
|
|
930
|
+
const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
|
|
2003
931
|
cwd: projectDir,
|
|
2004
932
|
encoding: "utf8"
|
|
2005
933
|
}).toString().trim();
|
|
2006
|
-
if (!
|
|
934
|
+
if (!output) {
|
|
2007
935
|
return false;
|
|
2008
936
|
}
|
|
2009
|
-
const changedFiles =
|
|
937
|
+
const changedFiles = output.split("\n");
|
|
2010
938
|
return changedFiles.some((file) => {
|
|
2011
939
|
return packageDirs.some((pkgDir) => {
|
|
2012
940
|
if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
|
|
@@ -2053,8 +981,8 @@ function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
|
|
|
2053
981
|
if (filterToPath) {
|
|
2054
982
|
args.push("--", ".");
|
|
2055
983
|
}
|
|
2056
|
-
const
|
|
2057
|
-
const commits =
|
|
984
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
985
|
+
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
2058
986
|
return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
|
|
2059
987
|
} catch (error) {
|
|
2060
988
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -2176,15 +1104,15 @@ function shouldProcessPackage(packageName, skip = []) {
|
|
|
2176
1104
|
}
|
|
2177
1105
|
|
|
2178
1106
|
// src/package/packageManagement.ts
|
|
2179
|
-
import
|
|
2180
|
-
import
|
|
1107
|
+
import fs5 from "fs";
|
|
1108
|
+
import path3 from "path";
|
|
2181
1109
|
function updatePackageVersion(packagePath, version, dryRun = false) {
|
|
2182
1110
|
if (isCargoToml(packagePath)) {
|
|
2183
1111
|
updateCargoVersion(packagePath, version, dryRun);
|
|
2184
1112
|
return;
|
|
2185
1113
|
}
|
|
2186
1114
|
try {
|
|
2187
|
-
const packageContent =
|
|
1115
|
+
const packageContent = fs5.readFileSync(packagePath, "utf8");
|
|
2188
1116
|
const packageJson = JSON.parse(packageContent);
|
|
2189
1117
|
const packageName = packageJson.name;
|
|
2190
1118
|
const updatedContent = `${JSON.stringify({ ...packageJson, version }, null, 2)}
|
|
@@ -2192,7 +1120,7 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
|
|
|
2192
1120
|
if (dryRun) {
|
|
2193
1121
|
recordPendingWrite(packagePath, updatedContent);
|
|
2194
1122
|
} else {
|
|
2195
|
-
|
|
1123
|
+
fs5.writeFileSync(packagePath, updatedContent);
|
|
2196
1124
|
}
|
|
2197
1125
|
addPackageUpdate(packageName, version, packagePath);
|
|
2198
1126
|
log(
|
|
@@ -2362,9 +1290,9 @@ var PackageProcessor = class {
|
|
|
2362
1290
|
}
|
|
2363
1291
|
let repoUrl;
|
|
2364
1292
|
try {
|
|
2365
|
-
const packageJsonPath2 =
|
|
2366
|
-
if (
|
|
2367
|
-
const packageJson = JSON.parse(
|
|
1293
|
+
const packageJsonPath2 = path4.join(pkgPath, "package.json");
|
|
1294
|
+
if (fs6.existsSync(packageJsonPath2)) {
|
|
1295
|
+
const packageJson = JSON.parse(fs6.readFileSync(packageJsonPath2, "utf8"));
|
|
2368
1296
|
if (packageJson.repository) {
|
|
2369
1297
|
if (typeof packageJson.repository === "string") {
|
|
2370
1298
|
repoUrl = packageJson.repository;
|
|
@@ -2390,8 +1318,8 @@ var PackageProcessor = class {
|
|
|
2390
1318
|
repoUrl: repoUrl || null,
|
|
2391
1319
|
entries: changelogEntries
|
|
2392
1320
|
});
|
|
2393
|
-
const packageJsonPath =
|
|
2394
|
-
if (
|
|
1321
|
+
const packageJsonPath = path4.join(pkgPath, "package.json");
|
|
1322
|
+
if (fs6.existsSync(packageJsonPath)) {
|
|
2395
1323
|
updatePackageVersion(packageJsonPath, nextVersion, this.dryRun);
|
|
2396
1324
|
}
|
|
2397
1325
|
const cargoEnabled = this.fullConfig.cargo?.enabled !== false;
|
|
@@ -2401,9 +1329,9 @@ var PackageProcessor = class {
|
|
|
2401
1329
|
log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
|
|
2402
1330
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
2403
1331
|
for (const cargoPath of cargoPaths) {
|
|
2404
|
-
const resolvedCargoPath =
|
|
1332
|
+
const resolvedCargoPath = path4.resolve(pkgPath, cargoPath, "Cargo.toml");
|
|
2405
1333
|
log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
|
|
2406
|
-
if (
|
|
1334
|
+
if (fs6.existsSync(resolvedCargoPath)) {
|
|
2407
1335
|
log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
|
|
2408
1336
|
updatePackageVersion(resolvedCargoPath, nextVersion, this.dryRun);
|
|
2409
1337
|
} else {
|
|
@@ -2411,9 +1339,9 @@ var PackageProcessor = class {
|
|
|
2411
1339
|
}
|
|
2412
1340
|
}
|
|
2413
1341
|
} else {
|
|
2414
|
-
const cargoTomlPath =
|
|
1342
|
+
const cargoTomlPath = path4.join(pkgPath, "Cargo.toml");
|
|
2415
1343
|
log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
|
|
2416
|
-
if (
|
|
1344
|
+
if (fs6.existsSync(cargoTomlPath)) {
|
|
2417
1345
|
log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
|
|
2418
1346
|
updatePackageVersion(cargoTomlPath, nextVersion, this.dryRun);
|
|
2419
1347
|
} else {
|
|
@@ -2479,8 +1407,8 @@ var PackageProcessor = class {
|
|
|
2479
1407
|
};
|
|
2480
1408
|
|
|
2481
1409
|
// src/core/versionStrategies.ts
|
|
2482
|
-
import
|
|
2483
|
-
import * as
|
|
1410
|
+
import fs7 from "fs";
|
|
1411
|
+
import * as path5 from "path";
|
|
2484
1412
|
function shouldProcessPackage2(pkg, config) {
|
|
2485
1413
|
const pkgName = pkg.packageJson.name;
|
|
2486
1414
|
return shouldProcessPackage(pkgName, config.skip);
|
|
@@ -2494,15 +1422,15 @@ function updateCargoFiles(packageDir, version, cargoConfig, dryRun = false) {
|
|
|
2494
1422
|
const cargoPaths = cargoConfig?.paths;
|
|
2495
1423
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
2496
1424
|
for (const cargoPath of cargoPaths) {
|
|
2497
|
-
const resolvedCargoPath =
|
|
2498
|
-
if (
|
|
1425
|
+
const resolvedCargoPath = path5.resolve(packageDir, cargoPath, "Cargo.toml");
|
|
1426
|
+
if (fs7.existsSync(resolvedCargoPath)) {
|
|
2499
1427
|
updatePackageVersion(resolvedCargoPath, version, dryRun);
|
|
2500
1428
|
updatedFiles.push(resolvedCargoPath);
|
|
2501
1429
|
}
|
|
2502
1430
|
}
|
|
2503
1431
|
} else {
|
|
2504
|
-
const cargoTomlPath =
|
|
2505
|
-
if (
|
|
1432
|
+
const cargoTomlPath = path5.join(packageDir, "Cargo.toml");
|
|
1433
|
+
if (fs7.existsSync(cargoTomlPath)) {
|
|
2506
1434
|
updatePackageVersion(cargoTomlPath, version, dryRun);
|
|
2507
1435
|
updatedFiles.push(cargoTomlPath);
|
|
2508
1436
|
}
|
|
@@ -2582,8 +1510,8 @@ function createSyncStrategy(config) {
|
|
|
2582
1510
|
const processedPaths = /* @__PURE__ */ new Set();
|
|
2583
1511
|
try {
|
|
2584
1512
|
if (packages.root) {
|
|
2585
|
-
const rootPkgPath =
|
|
2586
|
-
if (
|
|
1513
|
+
const rootPkgPath = path5.join(packages.root, "package.json");
|
|
1514
|
+
if (fs7.existsSync(rootPkgPath)) {
|
|
2587
1515
|
updatePackageVersion(rootPkgPath, nextVersion, dryRun);
|
|
2588
1516
|
files.push(rootPkgPath);
|
|
2589
1517
|
updatedPackages.push("root");
|
|
@@ -2602,7 +1530,7 @@ function createSyncStrategy(config) {
|
|
|
2602
1530
|
if (!shouldProcessPackage2(pkg, config)) {
|
|
2603
1531
|
continue;
|
|
2604
1532
|
}
|
|
2605
|
-
const packageJsonPath =
|
|
1533
|
+
const packageJsonPath = path5.join(pkg.dir, "package.json");
|
|
2606
1534
|
if (processedPaths.has(packageJsonPath)) {
|
|
2607
1535
|
continue;
|
|
2608
1536
|
}
|
|
@@ -2661,9 +1589,9 @@ function createSyncStrategy(config) {
|
|
|
2661
1589
|
let repoUrl = null;
|
|
2662
1590
|
for (const searchPath of [mainPkgPath, versionSourcePath].filter(Boolean)) {
|
|
2663
1591
|
try {
|
|
2664
|
-
const pkgJsonPath =
|
|
2665
|
-
if (
|
|
2666
|
-
const pkgJson = JSON.parse(
|
|
1592
|
+
const pkgJsonPath = path5.join(searchPath, "package.json");
|
|
1593
|
+
if (fs7.existsSync(pkgJsonPath)) {
|
|
1594
|
+
const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf8"));
|
|
2667
1595
|
let url;
|
|
2668
1596
|
if (typeof pkgJson.repository === "string") {
|
|
2669
1597
|
url = pkgJson.repository;
|
|
@@ -2830,9 +1758,9 @@ function createSingleStrategy(config) {
|
|
|
2830
1758
|
}
|
|
2831
1759
|
let repoUrl;
|
|
2832
1760
|
try {
|
|
2833
|
-
const packageJsonPath2 =
|
|
2834
|
-
if (
|
|
2835
|
-
const packageJson = JSON.parse(
|
|
1761
|
+
const packageJsonPath2 = path5.join(pkgPath, "package.json");
|
|
1762
|
+
if (fs7.existsSync(packageJsonPath2)) {
|
|
1763
|
+
const packageJson = JSON.parse(fs7.readFileSync(packageJsonPath2, "utf8"));
|
|
2836
1764
|
if (packageJson.repository) {
|
|
2837
1765
|
if (typeof packageJson.repository === "string") {
|
|
2838
1766
|
repoUrl = packageJson.repository;
|
|
@@ -2858,7 +1786,7 @@ function createSingleStrategy(config) {
|
|
|
2858
1786
|
repoUrl: repoUrl || null,
|
|
2859
1787
|
entries: changelogEntries
|
|
2860
1788
|
});
|
|
2861
|
-
const packageJsonPath =
|
|
1789
|
+
const packageJsonPath = path5.join(pkgPath, "package.json");
|
|
2862
1790
|
updatePackageVersion(packageJsonPath, nextVersion, dryRun);
|
|
2863
1791
|
const filesToCommit = [packageJsonPath];
|
|
2864
1792
|
const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo, dryRun);
|
|
@@ -2964,7 +1892,7 @@ var GitError = class extends BaseVersionError {
|
|
|
2964
1892
|
};
|
|
2965
1893
|
|
|
2966
1894
|
// src/utils/packageFiltering.ts
|
|
2967
|
-
import
|
|
1895
|
+
import path6 from "path";
|
|
2968
1896
|
import { minimatch as minimatch2 } from "minimatch";
|
|
2969
1897
|
function filterPackagesByConfig(packages, configTargets, workspaceRoot) {
|
|
2970
1898
|
if (configTargets.length === 0) {
|
|
@@ -2990,7 +1918,7 @@ function filterByDirectoryPattern(packages, pattern, workspaceRoot) {
|
|
|
2990
1918
|
}
|
|
2991
1919
|
const normalizedPattern = pattern.replace(/\\/g, "/");
|
|
2992
1920
|
return packages.filter((pkg) => {
|
|
2993
|
-
const relativePath =
|
|
1921
|
+
const relativePath = path6.relative(workspaceRoot, pkg.dir);
|
|
2994
1922
|
const normalizedRelativePath = relativePath.replace(/\\/g, "/");
|
|
2995
1923
|
if (normalizedPattern === normalizedRelativePath) {
|
|
2996
1924
|
return true;
|
|
@@ -3151,7 +2079,7 @@ function createVersionCommand() {
|
|
|
3151
2079
|
);
|
|
3152
2080
|
}
|
|
3153
2081
|
}
|
|
3154
|
-
const config =
|
|
2082
|
+
const config = loadConfig({ cwd: options.projectDir, configPath: options.config });
|
|
3155
2083
|
log(`Loaded configuration from ${options.config || "releasekit.config.json"}`, "info");
|
|
3156
2084
|
if (options.dryRun) config.dryRun = true;
|
|
3157
2085
|
if (options.sync) config.sync = true;
|
|
@@ -3195,7 +2123,7 @@ function createVersionCommand() {
|
|
|
3195
2123
|
log("Versioning process completed.", "success");
|
|
3196
2124
|
printJsonOutput();
|
|
3197
2125
|
} catch (error) {
|
|
3198
|
-
const { BaseVersionError: BaseVersionError2 } = await import("./baseError-
|
|
2126
|
+
const { BaseVersionError: BaseVersionError2 } = await import("./baseError-6PKATI6Z.js");
|
|
3199
2127
|
if (BaseVersionError2.isVersionError(error)) {
|
|
3200
2128
|
error.logError();
|
|
3201
2129
|
} else {
|
|
@@ -3207,7 +2135,7 @@ function createVersionCommand() {
|
|
|
3207
2135
|
}
|
|
3208
2136
|
|
|
3209
2137
|
export {
|
|
3210
|
-
|
|
2138
|
+
loadConfig,
|
|
3211
2139
|
VersionErrorCode,
|
|
3212
2140
|
createVersionError,
|
|
3213
2141
|
enableJsonOutput,
|