claude-git-hooks 2.18.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/CLAUDE.md +12 -8
- package/README.md +2 -1
- package/bin/claude-hooks +75 -89
- package/lib/cli-metadata.js +301 -0
- package/lib/commands/analyze-diff.js +12 -10
- package/lib/commands/analyze.js +9 -5
- package/lib/commands/bump-version.js +66 -43
- package/lib/commands/create-pr.js +71 -34
- package/lib/commands/debug.js +4 -7
- package/lib/commands/generate-changelog.js +11 -4
- package/lib/commands/help.js +47 -27
- package/lib/commands/helpers.js +66 -43
- package/lib/commands/hooks.js +15 -13
- package/lib/commands/install.js +546 -39
- package/lib/commands/migrate-config.js +8 -11
- package/lib/commands/presets.js +6 -13
- package/lib/commands/setup-github.js +12 -3
- package/lib/commands/telemetry-cmd.js +8 -6
- package/lib/commands/update.js +1 -2
- package/lib/config.js +36 -31
- package/lib/hooks/pre-commit.js +34 -54
- package/lib/hooks/prepare-commit-msg.js +39 -58
- package/lib/utils/analysis-engine.js +28 -21
- package/lib/utils/changelog-generator.js +162 -34
- package/lib/utils/claude-client.js +438 -377
- package/lib/utils/claude-diagnostics.js +20 -10
- package/lib/utils/file-operations.js +51 -79
- package/lib/utils/file-utils.js +46 -9
- package/lib/utils/git-operations.js +140 -123
- package/lib/utils/git-tag-manager.js +24 -23
- package/lib/utils/github-api.js +85 -61
- package/lib/utils/github-client.js +12 -14
- package/lib/utils/installation-diagnostics.js +4 -4
- package/lib/utils/interactive-ui.js +29 -17
- package/lib/utils/logger.js +4 -1
- package/lib/utils/pr-metadata-engine.js +67 -33
- package/lib/utils/preset-loader.js +20 -62
- package/lib/utils/prompt-builder.js +50 -55
- package/lib/utils/resolution-prompt.js +33 -44
- package/lib/utils/sanitize.js +20 -19
- package/lib/utils/task-id.js +27 -40
- package/lib/utils/telemetry.js +29 -17
- package/lib/utils/version-manager.js +173 -126
- package/lib/utils/which-command.js +23 -12
- package/package.json +69 -69
|
@@ -14,6 +14,7 @@ import fs from 'fs';
|
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import { getRepoRoot } from './git-operations.js';
|
|
16
16
|
import logger from './logger.js';
|
|
17
|
+
import { walkDirectoryTree } from './file-utils.js';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Cache for discovery result
|
|
@@ -44,16 +45,21 @@ function extractPomProjectVersion(content) {
|
|
|
44
45
|
// Section-level elements that mark the end of the project coordinates region.
|
|
45
46
|
// Any <version> tag inside these sections belongs to dependencies, plugins, etc.
|
|
46
47
|
const sectionTags = [
|
|
47
|
-
'properties',
|
|
48
|
-
'
|
|
49
|
-
'
|
|
48
|
+
'properties',
|
|
49
|
+
'dependencies',
|
|
50
|
+
'dependencyManagement',
|
|
51
|
+
'build',
|
|
52
|
+
'profiles',
|
|
53
|
+
'modules',
|
|
54
|
+
'reporting',
|
|
55
|
+
'distributionManagement',
|
|
56
|
+
'repositories',
|
|
57
|
+
'pluginRepositories',
|
|
50
58
|
'\\/project'
|
|
51
59
|
].join('|');
|
|
52
60
|
|
|
53
61
|
// Extract the "header" region: between </parent> and the first section element
|
|
54
|
-
const headerRegex = new RegExp(
|
|
55
|
-
`<\\/parent>([\\s\\S]*?)(?=<(?:${sectionTags})\\b)`
|
|
56
|
-
);
|
|
62
|
+
const headerRegex = new RegExp(`<\\/parent>([\\s\\S]*?)(?=<(?:${sectionTags})\\b)`);
|
|
57
63
|
const headerMatch = content.match(headerRegex);
|
|
58
64
|
|
|
59
65
|
if (headerMatch) {
|
|
@@ -98,10 +104,14 @@ const VERSION_FILE_TYPES = {
|
|
|
98
104
|
const packageData = JSON.parse(content);
|
|
99
105
|
return packageData.version || null;
|
|
100
106
|
} catch (error) {
|
|
101
|
-
logger.debug(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
logger.debug(
|
|
108
|
+
'version-manager - VERSION_FILE_TYPES',
|
|
109
|
+
'Failed to read package.json',
|
|
110
|
+
{
|
|
111
|
+
filePath,
|
|
112
|
+
error: error.message
|
|
113
|
+
}
|
|
114
|
+
);
|
|
105
115
|
return null;
|
|
106
116
|
}
|
|
107
117
|
},
|
|
@@ -136,7 +146,8 @@ const VERSION_FILE_TYPES = {
|
|
|
136
146
|
let newContent;
|
|
137
147
|
if (inherited) {
|
|
138
148
|
// Version is inherited from parent — update <parent><version> tag
|
|
139
|
-
const parentRegex =
|
|
149
|
+
const parentRegex =
|
|
150
|
+
/(<parent>[\s\S]*?<version>)[^<]+(<\/version>[\s\S]*?<\/parent>)/;
|
|
140
151
|
newContent = content.replace(parentRegex, `$1${newVersion}$2`);
|
|
141
152
|
} else {
|
|
142
153
|
const hasParent = /<parent>[\s\S]*?<\/parent>/.test(content);
|
|
@@ -144,7 +155,8 @@ const VERSION_FILE_TYPES = {
|
|
|
144
155
|
const afterParentRegex = /(<\/parent>[\s\S]*?<version>)[^<]+(<\/version>)/;
|
|
145
156
|
newContent = content.replace(afterParentRegex, `$1${newVersion}$2`);
|
|
146
157
|
} else {
|
|
147
|
-
const projectVersionRegex =
|
|
158
|
+
const projectVersionRegex =
|
|
159
|
+
/(<project[^>]*>[\s\S]*?<version>)[^<]+(<\/version>)/;
|
|
148
160
|
newContent = content.replace(projectVersionRegex, `$1${newVersion}$2`);
|
|
149
161
|
}
|
|
150
162
|
}
|
|
@@ -200,11 +212,7 @@ const VERSION_FILE_TYPES = {
|
|
|
200
212
|
* @returns {Object} DiscoveryResult: { files, resolvedVersion, mismatch, types }
|
|
201
213
|
*/
|
|
202
214
|
export function discoverVersionFiles(options = {}) {
|
|
203
|
-
const {
|
|
204
|
-
maxDepth = 3,
|
|
205
|
-
fileTypes = Object.keys(VERSION_FILE_TYPES),
|
|
206
|
-
ignoreDirs = []
|
|
207
|
-
} = options;
|
|
215
|
+
const { maxDepth = 3, fileTypes = Object.keys(VERSION_FILE_TYPES), ignoreDirs = [] } = options;
|
|
208
216
|
|
|
209
217
|
logger.debug('version-manager - discoverVersionFiles', 'Starting discovery', {
|
|
210
218
|
maxDepth,
|
|
@@ -232,69 +240,38 @@ export function discoverVersionFiles(options = {}) {
|
|
|
232
240
|
];
|
|
233
241
|
const ignoreSet = new Set([...defaultIgnore, ...ignoreDirs]);
|
|
234
242
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
// Recurse into subdirectory
|
|
258
|
-
walkDirectory(fullPath, depth + 1);
|
|
259
|
-
} else if (entry.isFile()) {
|
|
260
|
-
// Check if this file matches any registered type
|
|
261
|
-
for (const fileType of fileTypes) {
|
|
262
|
-
const registry = VERSION_FILE_TYPES[fileType];
|
|
263
|
-
if (registry && entry.name === registry.filename) {
|
|
264
|
-
// Read version from file
|
|
265
|
-
const version = registry.readVersion(fullPath);
|
|
266
|
-
|
|
267
|
-
// Create descriptor
|
|
268
|
-
const descriptor = {
|
|
269
|
-
path: fullPath,
|
|
270
|
-
relativePath: path.relative(repoRoot, fullPath),
|
|
271
|
-
type: fileType,
|
|
272
|
-
projectLabel: registry.projectLabel,
|
|
273
|
-
version,
|
|
274
|
-
selected: true // Default: all files selected
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
discoveredFiles.push(descriptor);
|
|
278
|
-
|
|
279
|
-
logger.debug('version-manager - discoverVersionFiles', 'Found version file', {
|
|
280
|
-
relativePath: descriptor.relativePath,
|
|
281
|
-
type: fileType,
|
|
282
|
-
version
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
}
|
|
243
|
+
walkDirectoryTree(repoRoot, {
|
|
244
|
+
maxDepth,
|
|
245
|
+
ignoreSet,
|
|
246
|
+
onFile: (entry, fullPath) => {
|
|
247
|
+
for (const fileType of fileTypes) {
|
|
248
|
+
const registry = VERSION_FILE_TYPES[fileType];
|
|
249
|
+
if (registry && entry.name === registry.filename) {
|
|
250
|
+
const version = registry.readVersion(fullPath);
|
|
251
|
+
const descriptor = {
|
|
252
|
+
path: fullPath,
|
|
253
|
+
relativePath: path.relative(repoRoot, fullPath),
|
|
254
|
+
type: fileType,
|
|
255
|
+
projectLabel: registry.projectLabel,
|
|
256
|
+
version,
|
|
257
|
+
selected: true
|
|
258
|
+
};
|
|
259
|
+
discoveredFiles.push(descriptor);
|
|
260
|
+
logger.debug('version-manager - discoverVersionFiles', 'Found version file', {
|
|
261
|
+
relativePath: descriptor.relativePath,
|
|
262
|
+
type: fileType,
|
|
263
|
+
version
|
|
264
|
+
});
|
|
286
265
|
}
|
|
287
266
|
}
|
|
288
|
-
}
|
|
267
|
+
},
|
|
268
|
+
onError: (dir, error) => {
|
|
289
269
|
logger.debug('version-manager - discoverVersionFiles', 'Error reading directory', {
|
|
290
270
|
dir,
|
|
291
271
|
error: error.message
|
|
292
272
|
});
|
|
293
273
|
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Start walking from repo root at depth 0
|
|
297
|
-
walkDirectory(repoRoot, 0);
|
|
274
|
+
});
|
|
298
275
|
|
|
299
276
|
// Sort results: root files first, then by depth, then alphabetically
|
|
300
277
|
discoveredFiles.sort((a, b) => {
|
|
@@ -310,24 +287,22 @@ export function discoverVersionFiles(options = {}) {
|
|
|
310
287
|
|
|
311
288
|
// Determine resolved version (prefer root-level file, then first found)
|
|
312
289
|
let resolvedVersion = null;
|
|
313
|
-
const rootFile = discoveredFiles.find(f => !f.relativePath.includes(path.sep));
|
|
290
|
+
const rootFile = discoveredFiles.find((f) => !f.relativePath.includes(path.sep));
|
|
314
291
|
if (rootFile && rootFile.version) {
|
|
315
292
|
resolvedVersion = rootFile.version;
|
|
316
293
|
} else if (discoveredFiles.length > 0) {
|
|
317
294
|
// Use first file's version as fallback
|
|
318
|
-
const firstWithVersion = discoveredFiles.find(f => f.version !== null);
|
|
295
|
+
const firstWithVersion = discoveredFiles.find((f) => f.version !== null);
|
|
319
296
|
resolvedVersion = firstWithVersion ? firstWithVersion.version : null;
|
|
320
297
|
}
|
|
321
298
|
|
|
322
299
|
// Check for version mismatch
|
|
323
|
-
const versions = discoveredFiles
|
|
324
|
-
.filter(f => f.version !== null)
|
|
325
|
-
.map(f => f.version);
|
|
300
|
+
const versions = discoveredFiles.filter((f) => f.version !== null).map((f) => f.version);
|
|
326
301
|
const uniqueVersions = [...new Set(versions)];
|
|
327
302
|
const mismatch = uniqueVersions.length > 1;
|
|
328
303
|
|
|
329
304
|
// Collect unique types
|
|
330
|
-
const types = [...new Set(discoveredFiles.map(f => f.type))];
|
|
305
|
+
const types = [...new Set(discoveredFiles.map((f) => f.type))];
|
|
331
306
|
|
|
332
307
|
const result = {
|
|
333
308
|
files: discoveredFiles,
|
|
@@ -446,7 +421,6 @@ export function updateVersionFiles(files, newVersion) {
|
|
|
446
421
|
type: file.type,
|
|
447
422
|
version: targetVersion
|
|
448
423
|
});
|
|
449
|
-
|
|
450
424
|
} catch (error) {
|
|
451
425
|
logger.error('version-manager - updateVersionFiles', 'Failed to update file', {
|
|
452
426
|
path: file.relativePath,
|
|
@@ -457,7 +431,7 @@ export function updateVersionFiles(files, newVersion) {
|
|
|
457
431
|
}
|
|
458
432
|
|
|
459
433
|
if (errors.length > 0) {
|
|
460
|
-
const errorMsg = errors.map(e => `${e.file}: ${e.error}`).join(', ');
|
|
434
|
+
const errorMsg = errors.map((e) => `${e.file}: ${e.error}`).join(', ');
|
|
461
435
|
throw new Error(`Failed to update some files: ${errorMsg}`);
|
|
462
436
|
}
|
|
463
437
|
|
|
@@ -508,7 +482,9 @@ export function modifySuffix(version, options = {}) {
|
|
|
508
482
|
* @returns {string|null} Version string or null if not found
|
|
509
483
|
*/
|
|
510
484
|
function readGradleVersion(filePath) {
|
|
511
|
-
logger.debug('version-manager - readGradleVersion', 'Reading version from build.gradle', {
|
|
485
|
+
logger.debug('version-manager - readGradleVersion', 'Reading version from build.gradle', {
|
|
486
|
+
filePath
|
|
487
|
+
});
|
|
512
488
|
|
|
513
489
|
try {
|
|
514
490
|
if (!fs.existsSync(filePath)) {
|
|
@@ -523,15 +499,20 @@ function readGradleVersion(filePath) {
|
|
|
523
499
|
const match = content.match(versionRegex);
|
|
524
500
|
|
|
525
501
|
if (!match) {
|
|
526
|
-
logger.debug(
|
|
502
|
+
logger.debug(
|
|
503
|
+
'version-manager - readGradleVersion',
|
|
504
|
+
'Version not found in build.gradle'
|
|
505
|
+
);
|
|
527
506
|
return null;
|
|
528
507
|
}
|
|
529
508
|
|
|
530
509
|
const version = match[1].trim();
|
|
531
|
-
logger.debug('version-manager - readGradleVersion', 'Version read', {
|
|
510
|
+
logger.debug('version-manager - readGradleVersion', 'Version read', {
|
|
511
|
+
version,
|
|
512
|
+
path: filePath
|
|
513
|
+
});
|
|
532
514
|
|
|
533
515
|
return version;
|
|
534
|
-
|
|
535
516
|
} catch (error) {
|
|
536
517
|
logger.error('version-manager - readGradleVersion', 'Failed to read version', error);
|
|
537
518
|
throw new Error(`Failed to read build.gradle: ${error.message}`);
|
|
@@ -546,7 +527,11 @@ function readGradleVersion(filePath) {
|
|
|
546
527
|
* @returns {string|null} Version string or null if not found
|
|
547
528
|
*/
|
|
548
529
|
function readGradleKtsVersion(filePath) {
|
|
549
|
-
logger.debug(
|
|
530
|
+
logger.debug(
|
|
531
|
+
'version-manager - readGradleKtsVersion',
|
|
532
|
+
'Reading version from build.gradle.kts',
|
|
533
|
+
{ filePath }
|
|
534
|
+
);
|
|
550
535
|
|
|
551
536
|
try {
|
|
552
537
|
if (!fs.existsSync(filePath)) {
|
|
@@ -561,15 +546,20 @@ function readGradleKtsVersion(filePath) {
|
|
|
561
546
|
const match = content.match(versionRegex);
|
|
562
547
|
|
|
563
548
|
if (!match) {
|
|
564
|
-
logger.debug(
|
|
549
|
+
logger.debug(
|
|
550
|
+
'version-manager - readGradleKtsVersion',
|
|
551
|
+
'Version not found in build.gradle.kts'
|
|
552
|
+
);
|
|
565
553
|
return null;
|
|
566
554
|
}
|
|
567
555
|
|
|
568
556
|
const version = match[1].trim();
|
|
569
|
-
logger.debug('version-manager - readGradleKtsVersion', 'Version read', {
|
|
557
|
+
logger.debug('version-manager - readGradleKtsVersion', 'Version read', {
|
|
558
|
+
version,
|
|
559
|
+
path: filePath
|
|
560
|
+
});
|
|
570
561
|
|
|
571
562
|
return version;
|
|
572
|
-
|
|
573
563
|
} catch (error) {
|
|
574
564
|
logger.error('version-manager - readGradleKtsVersion', 'Failed to read version', error);
|
|
575
565
|
throw new Error(`Failed to read build.gradle.kts: ${error.message}`);
|
|
@@ -584,7 +574,9 @@ function readGradleKtsVersion(filePath) {
|
|
|
584
574
|
* @returns {string|null} Version string or null if not found
|
|
585
575
|
*/
|
|
586
576
|
function readPyprojectVersion(filePath) {
|
|
587
|
-
logger.debug('version-manager - readPyprojectVersion', 'Reading version from pyproject.toml', {
|
|
577
|
+
logger.debug('version-manager - readPyprojectVersion', 'Reading version from pyproject.toml', {
|
|
578
|
+
filePath
|
|
579
|
+
});
|
|
588
580
|
|
|
589
581
|
try {
|
|
590
582
|
if (!fs.existsSync(filePath)) {
|
|
@@ -605,15 +597,20 @@ function readPyprojectVersion(filePath) {
|
|
|
605
597
|
}
|
|
606
598
|
|
|
607
599
|
if (!match) {
|
|
608
|
-
logger.debug(
|
|
600
|
+
logger.debug(
|
|
601
|
+
'version-manager - readPyprojectVersion',
|
|
602
|
+
'Version not found in pyproject.toml'
|
|
603
|
+
);
|
|
609
604
|
return null;
|
|
610
605
|
}
|
|
611
606
|
|
|
612
607
|
const version = match[1].trim();
|
|
613
|
-
logger.debug('version-manager - readPyprojectVersion', 'Version read', {
|
|
608
|
+
logger.debug('version-manager - readPyprojectVersion', 'Version read', {
|
|
609
|
+
version,
|
|
610
|
+
path: filePath
|
|
611
|
+
});
|
|
614
612
|
|
|
615
613
|
return version;
|
|
616
|
-
|
|
617
614
|
} catch (error) {
|
|
618
615
|
logger.error('version-manager - readPyprojectVersion', 'Failed to read version', error);
|
|
619
616
|
throw new Error(`Failed to read pyproject.toml: ${error.message}`);
|
|
@@ -628,7 +625,9 @@ function readPyprojectVersion(filePath) {
|
|
|
628
625
|
* @returns {string|null} Version string or null if not found
|
|
629
626
|
*/
|
|
630
627
|
function readCargoVersion(filePath) {
|
|
631
|
-
logger.debug('version-manager - readCargoVersion', 'Reading version from Cargo.toml', {
|
|
628
|
+
logger.debug('version-manager - readCargoVersion', 'Reading version from Cargo.toml', {
|
|
629
|
+
filePath
|
|
630
|
+
});
|
|
632
631
|
|
|
633
632
|
try {
|
|
634
633
|
if (!fs.existsSync(filePath)) {
|
|
@@ -648,10 +647,12 @@ function readCargoVersion(filePath) {
|
|
|
648
647
|
}
|
|
649
648
|
|
|
650
649
|
const version = match[1].trim();
|
|
651
|
-
logger.debug('version-manager - readCargoVersion', 'Version read', {
|
|
650
|
+
logger.debug('version-manager - readCargoVersion', 'Version read', {
|
|
651
|
+
version,
|
|
652
|
+
path: filePath
|
|
653
|
+
});
|
|
652
654
|
|
|
653
655
|
return version;
|
|
654
|
-
|
|
655
656
|
} catch (error) {
|
|
656
657
|
logger.error('version-manager - readCargoVersion', 'Failed to read version', error);
|
|
657
658
|
throw new Error(`Failed to read Cargo.toml: ${error.message}`);
|
|
@@ -666,7 +667,9 @@ function readCargoVersion(filePath) {
|
|
|
666
667
|
* @returns {string|null} Version string or null if not found
|
|
667
668
|
*/
|
|
668
669
|
function readSbtVersion(filePath) {
|
|
669
|
-
logger.debug('version-manager - readSbtVersion', 'Reading version from version.sbt', {
|
|
670
|
+
logger.debug('version-manager - readSbtVersion', 'Reading version from version.sbt', {
|
|
671
|
+
filePath
|
|
672
|
+
});
|
|
670
673
|
|
|
671
674
|
try {
|
|
672
675
|
if (!fs.existsSync(filePath)) {
|
|
@@ -686,10 +689,12 @@ function readSbtVersion(filePath) {
|
|
|
686
689
|
}
|
|
687
690
|
|
|
688
691
|
const version = match[1].trim();
|
|
689
|
-
logger.debug('version-manager - readSbtVersion', 'Version read', {
|
|
692
|
+
logger.debug('version-manager - readSbtVersion', 'Version read', {
|
|
693
|
+
version,
|
|
694
|
+
path: filePath
|
|
695
|
+
});
|
|
690
696
|
|
|
691
697
|
return version;
|
|
692
|
-
|
|
693
698
|
} catch (error) {
|
|
694
699
|
logger.error('version-manager - readSbtVersion', 'Failed to read version', error);
|
|
695
700
|
throw new Error(`Failed to read version.sbt: ${error.message}`);
|
|
@@ -722,7 +727,10 @@ function readChangelogVersion() {
|
|
|
722
727
|
const match = content.match(versionRegex);
|
|
723
728
|
|
|
724
729
|
if (!match) {
|
|
725
|
-
logger.debug(
|
|
730
|
+
logger.debug(
|
|
731
|
+
'version-manager - readChangelogVersion',
|
|
732
|
+
'No version found in CHANGELOG.md'
|
|
733
|
+
);
|
|
726
734
|
return null;
|
|
727
735
|
}
|
|
728
736
|
|
|
@@ -730,14 +738,21 @@ function readChangelogVersion() {
|
|
|
730
738
|
|
|
731
739
|
// Skip [Unreleased]
|
|
732
740
|
if (version.toLowerCase() === 'unreleased') {
|
|
733
|
-
logger.debug(
|
|
741
|
+
logger.debug(
|
|
742
|
+
'version-manager - readChangelogVersion',
|
|
743
|
+
'Latest entry is [Unreleased], looking for next version'
|
|
744
|
+
);
|
|
734
745
|
|
|
735
746
|
// Find next version entry
|
|
736
747
|
const allMatches = content.match(/##\s*\[([^\]]+)\]/g);
|
|
737
748
|
if (allMatches && allMatches.length > 1) {
|
|
738
749
|
const secondMatch = allMatches[1].match(/\[([^\]]+)\]/);
|
|
739
750
|
const actualVersion = secondMatch ? secondMatch[1].trim() : null;
|
|
740
|
-
logger.debug(
|
|
751
|
+
logger.debug(
|
|
752
|
+
'version-manager - readChangelogVersion',
|
|
753
|
+
'Version read from second entry',
|
|
754
|
+
{ version: actualVersion }
|
|
755
|
+
);
|
|
741
756
|
return actualVersion;
|
|
742
757
|
}
|
|
743
758
|
|
|
@@ -746,7 +761,6 @@ function readChangelogVersion() {
|
|
|
746
761
|
|
|
747
762
|
logger.debug('version-manager - readChangelogVersion', 'Version read', { version });
|
|
748
763
|
return version;
|
|
749
|
-
|
|
750
764
|
} catch (error) {
|
|
751
765
|
logger.error('version-manager - readChangelogVersion', 'Failed to read CHANGELOG', error);
|
|
752
766
|
return null; // Non-critical, return null instead of throwing
|
|
@@ -846,7 +860,10 @@ export function incrementVersion(currentVersion, bumpType, suffix = null) {
|
|
|
846
860
|
* @param {string} newVersion - New version string
|
|
847
861
|
*/
|
|
848
862
|
function updateGradleVersion(filePath, newVersion) {
|
|
849
|
-
logger.debug('version-manager - updateGradleVersion', 'Updating build.gradle', {
|
|
863
|
+
logger.debug('version-manager - updateGradleVersion', 'Updating build.gradle', {
|
|
864
|
+
filePath,
|
|
865
|
+
newVersion
|
|
866
|
+
});
|
|
850
867
|
|
|
851
868
|
try {
|
|
852
869
|
if (!fs.existsSync(filePath)) {
|
|
@@ -865,10 +882,15 @@ function updateGradleVersion(filePath, newVersion) {
|
|
|
865
882
|
|
|
866
883
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
867
884
|
|
|
868
|
-
logger.debug('version-manager - updateGradleVersion', 'build.gradle updated', {
|
|
869
|
-
|
|
885
|
+
logger.debug('version-manager - updateGradleVersion', 'build.gradle updated', {
|
|
886
|
+
path: filePath
|
|
887
|
+
});
|
|
870
888
|
} catch (error) {
|
|
871
|
-
logger.error(
|
|
889
|
+
logger.error(
|
|
890
|
+
'version-manager - updateGradleVersion',
|
|
891
|
+
'Failed to update build.gradle',
|
|
892
|
+
error
|
|
893
|
+
);
|
|
872
894
|
throw new Error(`Failed to update build.gradle: ${error.message}`);
|
|
873
895
|
}
|
|
874
896
|
}
|
|
@@ -881,7 +903,10 @@ function updateGradleVersion(filePath, newVersion) {
|
|
|
881
903
|
* @param {string} newVersion - New version string
|
|
882
904
|
*/
|
|
883
905
|
function updateGradleKtsVersion(filePath, newVersion) {
|
|
884
|
-
logger.debug('version-manager - updateGradleKtsVersion', 'Updating build.gradle.kts', {
|
|
906
|
+
logger.debug('version-manager - updateGradleKtsVersion', 'Updating build.gradle.kts', {
|
|
907
|
+
filePath,
|
|
908
|
+
newVersion
|
|
909
|
+
});
|
|
885
910
|
|
|
886
911
|
try {
|
|
887
912
|
if (!fs.existsSync(filePath)) {
|
|
@@ -900,10 +925,15 @@ function updateGradleKtsVersion(filePath, newVersion) {
|
|
|
900
925
|
|
|
901
926
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
902
927
|
|
|
903
|
-
logger.debug('version-manager - updateGradleKtsVersion', 'build.gradle.kts updated', {
|
|
904
|
-
|
|
928
|
+
logger.debug('version-manager - updateGradleKtsVersion', 'build.gradle.kts updated', {
|
|
929
|
+
path: filePath
|
|
930
|
+
});
|
|
905
931
|
} catch (error) {
|
|
906
|
-
logger.error(
|
|
932
|
+
logger.error(
|
|
933
|
+
'version-manager - updateGradleKtsVersion',
|
|
934
|
+
'Failed to update build.gradle.kts',
|
|
935
|
+
error
|
|
936
|
+
);
|
|
907
937
|
throw new Error(`Failed to update build.gradle.kts: ${error.message}`);
|
|
908
938
|
}
|
|
909
939
|
}
|
|
@@ -916,7 +946,10 @@ function updateGradleKtsVersion(filePath, newVersion) {
|
|
|
916
946
|
* @param {string} newVersion - New version string
|
|
917
947
|
*/
|
|
918
948
|
function updatePyprojectVersion(filePath, newVersion) {
|
|
919
|
-
logger.debug('version-manager - updatePyprojectVersion', 'Updating pyproject.toml', {
|
|
949
|
+
logger.debug('version-manager - updatePyprojectVersion', 'Updating pyproject.toml', {
|
|
950
|
+
filePath,
|
|
951
|
+
newVersion
|
|
952
|
+
});
|
|
920
953
|
|
|
921
954
|
try {
|
|
922
955
|
if (!fs.existsSync(filePath)) {
|
|
@@ -945,10 +978,15 @@ function updatePyprojectVersion(filePath, newVersion) {
|
|
|
945
978
|
|
|
946
979
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
947
980
|
|
|
948
|
-
logger.debug('version-manager - updatePyprojectVersion', 'pyproject.toml updated', {
|
|
949
|
-
|
|
981
|
+
logger.debug('version-manager - updatePyprojectVersion', 'pyproject.toml updated', {
|
|
982
|
+
path: filePath
|
|
983
|
+
});
|
|
950
984
|
} catch (error) {
|
|
951
|
-
logger.error(
|
|
985
|
+
logger.error(
|
|
986
|
+
'version-manager - updatePyprojectVersion',
|
|
987
|
+
'Failed to update pyproject.toml',
|
|
988
|
+
error
|
|
989
|
+
);
|
|
952
990
|
throw new Error(`Failed to update pyproject.toml: ${error.message}`);
|
|
953
991
|
}
|
|
954
992
|
}
|
|
@@ -961,7 +999,10 @@ function updatePyprojectVersion(filePath, newVersion) {
|
|
|
961
999
|
* @param {string} newVersion - New version string
|
|
962
1000
|
*/
|
|
963
1001
|
function updateCargoVersion(filePath, newVersion) {
|
|
964
|
-
logger.debug('version-manager - updateCargoVersion', 'Updating Cargo.toml', {
|
|
1002
|
+
logger.debug('version-manager - updateCargoVersion', 'Updating Cargo.toml', {
|
|
1003
|
+
filePath,
|
|
1004
|
+
newVersion
|
|
1005
|
+
});
|
|
965
1006
|
|
|
966
1007
|
try {
|
|
967
1008
|
if (!fs.existsSync(filePath)) {
|
|
@@ -980,8 +1021,9 @@ function updateCargoVersion(filePath, newVersion) {
|
|
|
980
1021
|
|
|
981
1022
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
982
1023
|
|
|
983
|
-
logger.debug('version-manager - updateCargoVersion', 'Cargo.toml updated', {
|
|
984
|
-
|
|
1024
|
+
logger.debug('version-manager - updateCargoVersion', 'Cargo.toml updated', {
|
|
1025
|
+
path: filePath
|
|
1026
|
+
});
|
|
985
1027
|
} catch (error) {
|
|
986
1028
|
logger.error('version-manager - updateCargoVersion', 'Failed to update Cargo.toml', error);
|
|
987
1029
|
throw new Error(`Failed to update Cargo.toml: ${error.message}`);
|
|
@@ -996,7 +1038,10 @@ function updateCargoVersion(filePath, newVersion) {
|
|
|
996
1038
|
* @param {string} newVersion - New version string
|
|
997
1039
|
*/
|
|
998
1040
|
function updateSbtVersion(filePath, newVersion) {
|
|
999
|
-
logger.debug('version-manager - updateSbtVersion', 'Updating version.sbt', {
|
|
1041
|
+
logger.debug('version-manager - updateSbtVersion', 'Updating version.sbt', {
|
|
1042
|
+
filePath,
|
|
1043
|
+
newVersion
|
|
1044
|
+
});
|
|
1000
1045
|
|
|
1001
1046
|
try {
|
|
1002
1047
|
if (!fs.existsSync(filePath)) {
|
|
@@ -1015,8 +1060,9 @@ function updateSbtVersion(filePath, newVersion) {
|
|
|
1015
1060
|
|
|
1016
1061
|
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
1017
1062
|
|
|
1018
|
-
logger.debug('version-manager - updateSbtVersion', 'version.sbt updated', {
|
|
1019
|
-
|
|
1063
|
+
logger.debug('version-manager - updateSbtVersion', 'version.sbt updated', {
|
|
1064
|
+
path: filePath
|
|
1065
|
+
});
|
|
1020
1066
|
} catch (error) {
|
|
1021
1067
|
logger.error('version-manager - updateSbtVersion', 'Failed to update version.sbt', error);
|
|
1022
1068
|
throw new Error(`Failed to update version.sbt: ${error.message}`);
|
|
@@ -1031,13 +1077,17 @@ function updateSbtVersion(filePath, newVersion) {
|
|
|
1031
1077
|
* @returns {boolean} True if valid, false otherwise
|
|
1032
1078
|
*/
|
|
1033
1079
|
export function validateVersionFormat(version) {
|
|
1034
|
-
logger.debug('version-manager - validateVersionFormat', 'Validating version format', {
|
|
1080
|
+
logger.debug('version-manager - validateVersionFormat', 'Validating version format', {
|
|
1081
|
+
version
|
|
1082
|
+
});
|
|
1035
1083
|
|
|
1036
1084
|
try {
|
|
1037
1085
|
parseVersion(version);
|
|
1038
1086
|
return true;
|
|
1039
1087
|
} catch (error) {
|
|
1040
|
-
logger.debug('version-manager - validateVersionFormat', 'Invalid version format', {
|
|
1088
|
+
logger.debug('version-manager - validateVersionFormat', 'Invalid version format', {
|
|
1089
|
+
version
|
|
1090
|
+
});
|
|
1041
1091
|
return false;
|
|
1042
1092
|
}
|
|
1043
1093
|
}
|
|
@@ -1084,7 +1134,6 @@ export function compareVersions(version1, version2) {
|
|
|
1084
1134
|
|
|
1085
1135
|
// Both have suffixes or both don't
|
|
1086
1136
|
return 0;
|
|
1087
|
-
|
|
1088
1137
|
} catch (error) {
|
|
1089
1138
|
// Log at debug level instead of error - non-semver versions are expected
|
|
1090
1139
|
logger.debug('version-manager - compareVersions', 'Cannot compare versions (not semver)', {
|
|
@@ -1171,7 +1220,6 @@ export async function validateVersionAlignment() {
|
|
|
1171
1220
|
logger.debug('version-manager - validateVersionAlignment', 'Validation complete', result);
|
|
1172
1221
|
|
|
1173
1222
|
return result;
|
|
1174
|
-
|
|
1175
1223
|
} catch (error) {
|
|
1176
1224
|
logger.error('version-manager - validateVersionAlignment', 'Validation failed', error);
|
|
1177
1225
|
return {
|
|
@@ -1183,4 +1231,3 @@ export async function validateVersionAlignment() {
|
|
|
1183
1231
|
};
|
|
1184
1232
|
}
|
|
1185
1233
|
}
|
|
1186
|
-
|