@releasekit/version 0.7.44 → 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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseVersionError
3
- } from "./chunk-Q3FHZORY.js";
3
+ } from "./chunk-3FG6RVHS.js";
4
4
  export {
5
5
  BaseVersionError
6
6
  };
@@ -0,0 +1,18 @@
1
+ // src/errors/baseError.ts
2
+ import { ReleaseKitError } from "@releasekit/core";
3
+ var BaseVersionError = class _BaseVersionError extends ReleaseKitError {
4
+ code;
5
+ suggestions;
6
+ constructor(message, code, suggestions) {
7
+ super(message);
8
+ this.code = code;
9
+ this.suggestions = suggestions ?? [];
10
+ }
11
+ static isVersionError(error) {
12
+ return error instanceof _BaseVersionError;
13
+ }
14
+ };
15
+
16
+ export {
17
+ BaseVersionError
18
+ };
@@ -1,413 +1,13 @@
1
1
  import {
2
- BaseVersionError,
3
- ReleaseKitError,
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
- // ../config/dist/index.js
12
- import * as fs from "fs";
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 loadConfig2(options) {
452
- const fullConfig = loadConfig(options);
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 fs4 from "fs";
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(path10, content) {
134
+ function recordPendingWrite(path7, content) {
535
135
  if (!_jsonOutputMode) return;
536
- _pendingWrites.push({ path: path10, content });
136
+ _pendingWrites.push({ path: path7, content });
537
137
  }
538
138
  function flushPendingWrites() {
539
139
  try {
540
- for (const { path: path10, content } of _pendingWrites) {
541
- fs4.writeFileSync(path10, content);
140
+ for (const { path: path7, content } of _pendingWrites) {
141
+ fs.writeFileSync(path7, content);
542
142
  }
543
143
  } finally {
544
144
  _pendingWrites.length = 0;
@@ -582,12 +182,13 @@ function printJsonOutput() {
582
182
 
583
183
  // src/core/versionCalculator.ts
584
184
  import { cwd } from "process";
185
+ import { sanitizePackageName as sanitizePackageName2 } from "@releasekit/core";
585
186
  import { Bumper } from "conventional-recommended-bump";
586
187
  import semver3 from "semver";
587
188
 
588
189
  // src/git/repository.ts
589
- import { existsSync as existsSync3, statSync } from "fs";
590
- import { join as join3 } from "path";
190
+ import { existsSync, statSync } from "fs";
191
+ import { join } from "path";
591
192
  function getCurrentBranch() {
592
193
  const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
593
194
  return result.toString().trim();
@@ -597,6 +198,9 @@ function getCurrentBranch() {
597
198
  import { getSemverTags } from "git-semver-tags";
598
199
  import semver from "semver";
599
200
 
201
+ // src/utils/formatting.ts
202
+ import { sanitizePackageName } from "@releasekit/core";
203
+
600
204
  // src/utils/logging.ts
601
205
  import chalk from "chalk";
602
206
  import figlet from "figlet";
@@ -806,15 +410,16 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
806
410
  }
807
411
 
808
412
  // src/utils/manifestHelpers.ts
809
- import fs6 from "fs";
810
- import path5 from "path";
413
+ import fs3 from "fs";
414
+ import path2 from "path";
811
415
 
812
416
  // src/cargo/cargoHandler.ts
813
- import fs5 from "fs";
814
- import path4 from "path";
815
- import * as TOML2 from "smol-toml";
417
+ import fs2 from "fs";
418
+ import path from "path";
419
+ import { isCargoToml, parseCargoToml } from "@releasekit/config";
420
+ import * as TOML from "smol-toml";
816
421
  function getCargoInfo(cargoPath) {
817
- if (!fs5.existsSync(cargoPath)) {
422
+ if (!fs2.existsSync(cargoPath)) {
818
423
  log(`Cargo.toml file not found at: ${cargoPath}`, "error");
819
424
  throw new Error(`Cargo.toml file not found at: ${cargoPath}`);
820
425
  }
@@ -828,7 +433,7 @@ function getCargoInfo(cargoPath) {
828
433
  name: cargo.package.name,
829
434
  version: cargo.package.version || "0.0.0",
830
435
  path: cargoPath,
831
- dir: path4.dirname(cargoPath),
436
+ dir: path.dirname(cargoPath),
832
437
  content: cargo
833
438
  };
834
439
  } catch (error) {
@@ -852,11 +457,11 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
852
457
  } else {
853
458
  cargo.package.version = version;
854
459
  }
855
- const updatedContent = TOML2.stringify(cargo);
460
+ const updatedContent = TOML.stringify(cargo);
856
461
  if (dryRun) {
857
462
  recordPendingWrite(cargoPath, updatedContent);
858
463
  } else {
859
- fs5.writeFileSync(cargoPath, updatedContent);
464
+ fs2.writeFileSync(cargoPath, updatedContent);
860
465
  }
861
466
  addPackageUpdate(packageName, version, cargoPath);
862
467
  log(`${dryRun ? "[DRY RUN] Would update" : "Updated"} Cargo.toml at ${cargoPath} to version ${version}`, "success");
@@ -871,11 +476,11 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
871
476
 
872
477
  // src/utils/manifestHelpers.ts
873
478
  function getVersionFromManifests(packageDir) {
874
- const packageJsonPath = path5.join(packageDir, "package.json");
875
- const cargoTomlPath = path5.join(packageDir, "Cargo.toml");
876
- if (fs6.existsSync(packageJsonPath)) {
479
+ const packageJsonPath = path2.join(packageDir, "package.json");
480
+ const cargoTomlPath = path2.join(packageDir, "Cargo.toml");
481
+ if (fs3.existsSync(packageJsonPath)) {
877
482
  try {
878
- const packageJson = JSON.parse(fs6.readFileSync(packageJsonPath, "utf-8"));
483
+ const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
879
484
  if (packageJson.version) {
880
485
  log(`Found version ${packageJson.version} in package.json`, "debug");
881
486
  return {
@@ -891,7 +496,7 @@ function getVersionFromManifests(packageDir) {
891
496
  log(`Error reading package.json: ${errMsg}`, "warning");
892
497
  }
893
498
  }
894
- if (fs6.existsSync(cargoTomlPath)) {
499
+ if (fs3.existsSync(cargoTomlPath)) {
895
500
  try {
896
501
  const cargoInfo = getCargoInfo(cargoTomlPath);
897
502
  if (cargoInfo.version) {
@@ -918,7 +523,8 @@ function getVersionFromManifests(packageDir) {
918
523
  }
919
524
 
920
525
  // src/utils/versionUtils.ts
921
- import fs7 from "fs";
526
+ import fs4 from "fs";
527
+ import { parseCargoToml as parseCargoToml2 } from "@releasekit/config";
922
528
  import semver2 from "semver";
923
529
 
924
530
  // src/git/tagVerification.ts
@@ -1160,7 +766,7 @@ async function calculateVersion(config, options) {
1160
766
  try {
1161
767
  let buildTagStripPattern2 = function(packageName, prefix) {
1162
768
  if (!packageName) return escapeRegExp(prefix);
1163
- const sanitized = sanitizePackageName(packageName);
769
+ const sanitized = sanitizePackageName2(packageName);
1164
770
  const escapedRaw = escapeRegExp(`${packageName}@${prefix}`);
1165
771
  const escapedDash = escapeRegExp(`${sanitized}-${prefix}`);
1166
772
  return `(?:${escapedRaw}|${escapedDash})`;
@@ -1293,8 +899,8 @@ async function calculateVersion(config, options) {
1293
899
  }
1294
900
 
1295
901
  // src/package/packageProcessor.ts
1296
- import * as fs9 from "fs";
1297
- import path7 from "path";
902
+ import * as fs6 from "fs";
903
+ import path4 from "path";
1298
904
 
1299
905
  // src/changelog/commitParser.ts
1300
906
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
@@ -1498,15 +1104,15 @@ function shouldProcessPackage(packageName, skip = []) {
1498
1104
  }
1499
1105
 
1500
1106
  // src/package/packageManagement.ts
1501
- import fs8 from "fs";
1502
- import path6 from "path";
1107
+ import fs5 from "fs";
1108
+ import path3 from "path";
1503
1109
  function updatePackageVersion(packagePath, version, dryRun = false) {
1504
1110
  if (isCargoToml(packagePath)) {
1505
1111
  updateCargoVersion(packagePath, version, dryRun);
1506
1112
  return;
1507
1113
  }
1508
1114
  try {
1509
- const packageContent = fs8.readFileSync(packagePath, "utf8");
1115
+ const packageContent = fs5.readFileSync(packagePath, "utf8");
1510
1116
  const packageJson = JSON.parse(packageContent);
1511
1117
  const packageName = packageJson.name;
1512
1118
  const updatedContent = `${JSON.stringify({ ...packageJson, version }, null, 2)}
@@ -1514,7 +1120,7 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
1514
1120
  if (dryRun) {
1515
1121
  recordPendingWrite(packagePath, updatedContent);
1516
1122
  } else {
1517
- fs8.writeFileSync(packagePath, updatedContent);
1123
+ fs5.writeFileSync(packagePath, updatedContent);
1518
1124
  }
1519
1125
  addPackageUpdate(packageName, version, packagePath);
1520
1126
  log(
@@ -1684,9 +1290,9 @@ var PackageProcessor = class {
1684
1290
  }
1685
1291
  let repoUrl;
1686
1292
  try {
1687
- const packageJsonPath2 = path7.join(pkgPath, "package.json");
1688
- if (fs9.existsSync(packageJsonPath2)) {
1689
- const packageJson = JSON.parse(fs9.readFileSync(packageJsonPath2, "utf8"));
1293
+ const packageJsonPath2 = path4.join(pkgPath, "package.json");
1294
+ if (fs6.existsSync(packageJsonPath2)) {
1295
+ const packageJson = JSON.parse(fs6.readFileSync(packageJsonPath2, "utf8"));
1690
1296
  if (packageJson.repository) {
1691
1297
  if (typeof packageJson.repository === "string") {
1692
1298
  repoUrl = packageJson.repository;
@@ -1712,8 +1318,8 @@ var PackageProcessor = class {
1712
1318
  repoUrl: repoUrl || null,
1713
1319
  entries: changelogEntries
1714
1320
  });
1715
- const packageJsonPath = path7.join(pkgPath, "package.json");
1716
- if (fs9.existsSync(packageJsonPath)) {
1321
+ const packageJsonPath = path4.join(pkgPath, "package.json");
1322
+ if (fs6.existsSync(packageJsonPath)) {
1717
1323
  updatePackageVersion(packageJsonPath, nextVersion, this.dryRun);
1718
1324
  }
1719
1325
  const cargoEnabled = this.fullConfig.cargo?.enabled !== false;
@@ -1723,9 +1329,9 @@ var PackageProcessor = class {
1723
1329
  log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
1724
1330
  if (cargoPaths && cargoPaths.length > 0) {
1725
1331
  for (const cargoPath of cargoPaths) {
1726
- const resolvedCargoPath = path7.resolve(pkgPath, cargoPath, "Cargo.toml");
1332
+ const resolvedCargoPath = path4.resolve(pkgPath, cargoPath, "Cargo.toml");
1727
1333
  log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
1728
- if (fs9.existsSync(resolvedCargoPath)) {
1334
+ if (fs6.existsSync(resolvedCargoPath)) {
1729
1335
  log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
1730
1336
  updatePackageVersion(resolvedCargoPath, nextVersion, this.dryRun);
1731
1337
  } else {
@@ -1733,9 +1339,9 @@ var PackageProcessor = class {
1733
1339
  }
1734
1340
  }
1735
1341
  } else {
1736
- const cargoTomlPath = path7.join(pkgPath, "Cargo.toml");
1342
+ const cargoTomlPath = path4.join(pkgPath, "Cargo.toml");
1737
1343
  log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
1738
- if (fs9.existsSync(cargoTomlPath)) {
1344
+ if (fs6.existsSync(cargoTomlPath)) {
1739
1345
  log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
1740
1346
  updatePackageVersion(cargoTomlPath, nextVersion, this.dryRun);
1741
1347
  } else {
@@ -1801,8 +1407,8 @@ var PackageProcessor = class {
1801
1407
  };
1802
1408
 
1803
1409
  // src/core/versionStrategies.ts
1804
- import fs10 from "fs";
1805
- import * as path8 from "path";
1410
+ import fs7 from "fs";
1411
+ import * as path5 from "path";
1806
1412
  function shouldProcessPackage2(pkg, config) {
1807
1413
  const pkgName = pkg.packageJson.name;
1808
1414
  return shouldProcessPackage(pkgName, config.skip);
@@ -1816,15 +1422,15 @@ function updateCargoFiles(packageDir, version, cargoConfig, dryRun = false) {
1816
1422
  const cargoPaths = cargoConfig?.paths;
1817
1423
  if (cargoPaths && cargoPaths.length > 0) {
1818
1424
  for (const cargoPath of cargoPaths) {
1819
- const resolvedCargoPath = path8.resolve(packageDir, cargoPath, "Cargo.toml");
1820
- if (fs10.existsSync(resolvedCargoPath)) {
1425
+ const resolvedCargoPath = path5.resolve(packageDir, cargoPath, "Cargo.toml");
1426
+ if (fs7.existsSync(resolvedCargoPath)) {
1821
1427
  updatePackageVersion(resolvedCargoPath, version, dryRun);
1822
1428
  updatedFiles.push(resolvedCargoPath);
1823
1429
  }
1824
1430
  }
1825
1431
  } else {
1826
- const cargoTomlPath = path8.join(packageDir, "Cargo.toml");
1827
- if (fs10.existsSync(cargoTomlPath)) {
1432
+ const cargoTomlPath = path5.join(packageDir, "Cargo.toml");
1433
+ if (fs7.existsSync(cargoTomlPath)) {
1828
1434
  updatePackageVersion(cargoTomlPath, version, dryRun);
1829
1435
  updatedFiles.push(cargoTomlPath);
1830
1436
  }
@@ -1904,8 +1510,8 @@ function createSyncStrategy(config) {
1904
1510
  const processedPaths = /* @__PURE__ */ new Set();
1905
1511
  try {
1906
1512
  if (packages.root) {
1907
- const rootPkgPath = path8.join(packages.root, "package.json");
1908
- if (fs10.existsSync(rootPkgPath)) {
1513
+ const rootPkgPath = path5.join(packages.root, "package.json");
1514
+ if (fs7.existsSync(rootPkgPath)) {
1909
1515
  updatePackageVersion(rootPkgPath, nextVersion, dryRun);
1910
1516
  files.push(rootPkgPath);
1911
1517
  updatedPackages.push("root");
@@ -1924,7 +1530,7 @@ function createSyncStrategy(config) {
1924
1530
  if (!shouldProcessPackage2(pkg, config)) {
1925
1531
  continue;
1926
1532
  }
1927
- const packageJsonPath = path8.join(pkg.dir, "package.json");
1533
+ const packageJsonPath = path5.join(pkg.dir, "package.json");
1928
1534
  if (processedPaths.has(packageJsonPath)) {
1929
1535
  continue;
1930
1536
  }
@@ -1983,9 +1589,9 @@ function createSyncStrategy(config) {
1983
1589
  let repoUrl = null;
1984
1590
  for (const searchPath of [mainPkgPath, versionSourcePath].filter(Boolean)) {
1985
1591
  try {
1986
- const pkgJsonPath = path8.join(searchPath, "package.json");
1987
- if (fs10.existsSync(pkgJsonPath)) {
1988
- const pkgJson = JSON.parse(fs10.readFileSync(pkgJsonPath, "utf8"));
1592
+ const pkgJsonPath = path5.join(searchPath, "package.json");
1593
+ if (fs7.existsSync(pkgJsonPath)) {
1594
+ const pkgJson = JSON.parse(fs7.readFileSync(pkgJsonPath, "utf8"));
1989
1595
  let url;
1990
1596
  if (typeof pkgJson.repository === "string") {
1991
1597
  url = pkgJson.repository;
@@ -2152,9 +1758,9 @@ function createSingleStrategy(config) {
2152
1758
  }
2153
1759
  let repoUrl;
2154
1760
  try {
2155
- const packageJsonPath2 = path8.join(pkgPath, "package.json");
2156
- if (fs10.existsSync(packageJsonPath2)) {
2157
- const packageJson = JSON.parse(fs10.readFileSync(packageJsonPath2, "utf8"));
1761
+ const packageJsonPath2 = path5.join(pkgPath, "package.json");
1762
+ if (fs7.existsSync(packageJsonPath2)) {
1763
+ const packageJson = JSON.parse(fs7.readFileSync(packageJsonPath2, "utf8"));
2158
1764
  if (packageJson.repository) {
2159
1765
  if (typeof packageJson.repository === "string") {
2160
1766
  repoUrl = packageJson.repository;
@@ -2180,7 +1786,7 @@ function createSingleStrategy(config) {
2180
1786
  repoUrl: repoUrl || null,
2181
1787
  entries: changelogEntries
2182
1788
  });
2183
- const packageJsonPath = path8.join(pkgPath, "package.json");
1789
+ const packageJsonPath = path5.join(pkgPath, "package.json");
2184
1790
  updatePackageVersion(packageJsonPath, nextVersion, dryRun);
2185
1791
  const filesToCommit = [packageJsonPath];
2186
1792
  const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo, dryRun);
@@ -2286,7 +1892,7 @@ var GitError = class extends BaseVersionError {
2286
1892
  };
2287
1893
 
2288
1894
  // src/utils/packageFiltering.ts
2289
- import path9 from "path";
1895
+ import path6 from "path";
2290
1896
  import { minimatch as minimatch2 } from "minimatch";
2291
1897
  function filterPackagesByConfig(packages, configTargets, workspaceRoot) {
2292
1898
  if (configTargets.length === 0) {
@@ -2312,7 +1918,7 @@ function filterByDirectoryPattern(packages, pattern, workspaceRoot) {
2312
1918
  }
2313
1919
  const normalizedPattern = pattern.replace(/\\/g, "/");
2314
1920
  return packages.filter((pkg) => {
2315
- const relativePath = path9.relative(workspaceRoot, pkg.dir);
1921
+ const relativePath = path6.relative(workspaceRoot, pkg.dir);
2316
1922
  const normalizedRelativePath = relativePath.replace(/\\/g, "/");
2317
1923
  if (normalizedPattern === normalizedRelativePath) {
2318
1924
  return true;
@@ -2473,7 +2079,7 @@ function createVersionCommand() {
2473
2079
  );
2474
2080
  }
2475
2081
  }
2476
- const config = loadConfig2({ cwd: options.projectDir, configPath: options.config });
2082
+ const config = loadConfig({ cwd: options.projectDir, configPath: options.config });
2477
2083
  log(`Loaded configuration from ${options.config || "releasekit.config.json"}`, "info");
2478
2084
  if (options.dryRun) config.dryRun = true;
2479
2085
  if (options.sync) config.sync = true;
@@ -2517,7 +2123,7 @@ function createVersionCommand() {
2517
2123
  log("Versioning process completed.", "success");
2518
2124
  printJsonOutput();
2519
2125
  } catch (error) {
2520
- const { BaseVersionError: BaseVersionError2 } = await import("./baseError-DQHIJACF.js");
2126
+ const { BaseVersionError: BaseVersionError2 } = await import("./baseError-6PKATI6Z.js");
2521
2127
  if (BaseVersionError2.isVersionError(error)) {
2522
2128
  error.logError();
2523
2129
  } else {
@@ -2529,7 +2135,7 @@ function createVersionCommand() {
2529
2135
  }
2530
2136
 
2531
2137
  export {
2532
- loadConfig2 as loadConfig,
2138
+ loadConfig,
2533
2139
  VersionErrorCode,
2534
2140
  createVersionError,
2535
2141
  enableJsonOutput,
package/dist/cli.js CHANGED
@@ -1,15 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createVersionCommand
4
- } from "./chunk-UBCKZYTO.js";
5
- import {
6
- readPackageVersion
7
- } from "./chunk-Q3FHZORY.js";
4
+ } from "./chunk-V44UWRAP.js";
5
+ import "./chunk-3FG6RVHS.js";
8
6
  import "./chunk-LMPZV35Z.js";
9
7
 
10
8
  // src/cli.ts
11
9
  import * as fs from "fs";
12
10
  import { fileURLToPath } from "url";
11
+ import { readPackageVersion } from "@releasekit/core";
13
12
  import { Command } from "commander";
14
13
  var isMain = (() => {
15
14
  try {
package/dist/index.js CHANGED
@@ -12,10 +12,10 @@ import {
12
12
  flushPendingWrites,
13
13
  getJsonData,
14
14
  loadConfig
15
- } from "./chunk-UBCKZYTO.js";
15
+ } from "./chunk-V44UWRAP.js";
16
16
  import {
17
17
  BaseVersionError
18
- } from "./chunk-Q3FHZORY.js";
18
+ } from "./chunk-3FG6RVHS.js";
19
19
  import "./chunk-LMPZV35Z.js";
20
20
  export {
21
21
  BaseVersionError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@releasekit/version",
3
- "version": "0.7.44",
3
+ "version": "0.7.46",
4
4
  "description": "Semantic versioning based on Git history and conventional commits",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,89 +0,0 @@
1
- // ../core/dist/index.js
2
- import * as fs from "fs";
3
- import * as path from "path";
4
- import { fileURLToPath } from "url";
5
- import chalk from "chalk";
6
- function readPackageVersion(importMetaUrl) {
7
- try {
8
- const dir = path.dirname(fileURLToPath(importMetaUrl));
9
- const packageJsonPath = path.resolve(dir, "../package.json");
10
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
11
- return packageJson.version ?? "0.0.0";
12
- } catch {
13
- return "0.0.0";
14
- }
15
- }
16
- var LOG_LEVELS = {
17
- error: 0,
18
- warn: 1,
19
- info: 2,
20
- debug: 3,
21
- trace: 4
22
- };
23
- var PREFIXES = {
24
- error: "[ERROR]",
25
- warn: "[WARN]",
26
- info: "[INFO]",
27
- debug: "[DEBUG]",
28
- trace: "[TRACE]"
29
- };
30
- var COLORS = {
31
- error: chalk.red,
32
- warn: chalk.yellow,
33
- info: chalk.blue,
34
- debug: chalk.gray,
35
- trace: chalk.dim
36
- };
37
- var currentLevel = "info";
38
- var quietMode = false;
39
- function shouldLog(level) {
40
- if (quietMode && level !== "error") return false;
41
- return LOG_LEVELS[level] <= LOG_LEVELS[currentLevel];
42
- }
43
- function log(message, level = "info") {
44
- if (!shouldLog(level)) return;
45
- const formatted = COLORS[level](`${PREFIXES[level]} ${message}`);
46
- console.error(formatted);
47
- }
48
- var ReleaseKitError = class _ReleaseKitError extends Error {
49
- constructor(message) {
50
- super(message);
51
- this.name = this.constructor.name;
52
- }
53
- logError() {
54
- log(this.message, "error");
55
- if (this.suggestions.length > 0) {
56
- log("\nSuggested solutions:", "info");
57
- for (const [i, suggestion] of this.suggestions.entries()) {
58
- log(`${i + 1}. ${suggestion}`, "info");
59
- }
60
- }
61
- }
62
- static isReleaseKitError(error2) {
63
- return error2 instanceof _ReleaseKitError;
64
- }
65
- };
66
- function sanitizePackageName(name) {
67
- return name.startsWith("@") ? name.slice(1).replace(/\//g, "-") : name;
68
- }
69
-
70
- // src/errors/baseError.ts
71
- var BaseVersionError = class _BaseVersionError extends ReleaseKitError {
72
- code;
73
- suggestions;
74
- constructor(message, code, suggestions) {
75
- super(message);
76
- this.code = code;
77
- this.suggestions = suggestions ?? [];
78
- }
79
- static isVersionError(error) {
80
- return error instanceof _BaseVersionError;
81
- }
82
- };
83
-
84
- export {
85
- readPackageVersion,
86
- ReleaseKitError,
87
- sanitizePackageName,
88
- BaseVersionError
89
- };