package-versioner 0.8.5 → 0.8.6
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/index.cjs +33 -14
- package/dist/index.js +33 -14
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -472,7 +472,7 @@ function getAllVersionTags(since, versionPrefix = "v") {
|
|
|
472
472
|
const allTags = tagOutput.split("\n").filter((tag) => !!tag);
|
|
473
473
|
let filteredTags = allTags;
|
|
474
474
|
if (since) {
|
|
475
|
-
const sinceIndex = allTags.
|
|
475
|
+
const sinceIndex = allTags.indexOf(since);
|
|
476
476
|
if (sinceIndex >= 0) {
|
|
477
477
|
filteredTags = allTags.slice(sinceIndex);
|
|
478
478
|
} else {
|
|
@@ -556,7 +556,7 @@ async function regenerateChangelog(options) {
|
|
|
556
556
|
const allTagsCmd = `git tag --list "${versionPrefix}*" --sort=creatordate`;
|
|
557
557
|
const allTagsOutput = (0, import_node_child_process2.execSync)(allTagsCmd, { encoding: "utf8" }).trim();
|
|
558
558
|
const allTags = allTagsOutput.split("\n").filter((tag) => !!tag);
|
|
559
|
-
const sinceIndex = allTags.
|
|
559
|
+
const sinceIndex = allTags.indexOf(since);
|
|
560
560
|
const actualPreviousTag = sinceIndex > 0 ? allTags[sinceIndex - 1] : null;
|
|
561
561
|
if (actualPreviousTag) {
|
|
562
562
|
tagRange = `${actualPreviousTag}..${currentTag.tag}`;
|
|
@@ -694,8 +694,12 @@ function filterPackagesByConfig(packages, configTargets, workspaceRoot) {
|
|
|
694
694
|
for (const target of configTargets) {
|
|
695
695
|
const dirMatches = filterByDirectoryPattern(packages, target, workspaceRoot);
|
|
696
696
|
const nameMatches = filterByPackageNamePattern(packages, target);
|
|
697
|
-
|
|
698
|
-
|
|
697
|
+
for (const pkg of dirMatches) {
|
|
698
|
+
matchedPackages.add(pkg);
|
|
699
|
+
}
|
|
700
|
+
for (const pkg of nameMatches) {
|
|
701
|
+
matchedPackages.add(pkg);
|
|
702
|
+
}
|
|
699
703
|
}
|
|
700
704
|
return Array.from(matchedPackages);
|
|
701
705
|
}
|
|
@@ -1561,14 +1565,21 @@ async function calculateVersion(config, options) {
|
|
|
1561
1565
|
const specifiedType = type;
|
|
1562
1566
|
if (specifiedType) {
|
|
1563
1567
|
const currentVersion = getCurrentVersionFromSource2();
|
|
1564
|
-
|
|
1568
|
+
const isCurrentPrerelease = import_semver3.default.prerelease(currentVersion);
|
|
1569
|
+
const explicitlyRequestedPrerelease = config.isPrerelease;
|
|
1570
|
+
if (STANDARD_BUMP_TYPES.includes(specifiedType) && (isCurrentPrerelease || explicitlyRequestedPrerelease)) {
|
|
1571
|
+
const prereleaseId2 = explicitlyRequestedPrerelease || isCurrentPrerelease ? normalizedPrereleaseId : void 0;
|
|
1565
1572
|
log(
|
|
1566
|
-
|
|
1573
|
+
explicitlyRequestedPrerelease ? `Creating prerelease version with identifier '${prereleaseId2}' using ${specifiedType}` : `Cleaning prerelease identifier from ${currentVersion} for ${specifiedType} bump`,
|
|
1567
1574
|
"debug"
|
|
1568
1575
|
);
|
|
1569
|
-
return bumpVersion(currentVersion, specifiedType,
|
|
1576
|
+
return bumpVersion(currentVersion, specifiedType, prereleaseId2);
|
|
1570
1577
|
}
|
|
1571
|
-
|
|
1578
|
+
const isPrereleaseBumpType = ["prerelease", "premajor", "preminor", "prepatch"].includes(
|
|
1579
|
+
specifiedType
|
|
1580
|
+
);
|
|
1581
|
+
const prereleaseId = config.isPrerelease || isPrereleaseBumpType ? normalizedPrereleaseId : void 0;
|
|
1582
|
+
return bumpVersion(currentVersion, specifiedType, prereleaseId);
|
|
1572
1583
|
}
|
|
1573
1584
|
if (branchPattern && branchPattern.length > 0) {
|
|
1574
1585
|
const currentBranch = getCurrentBranch();
|
|
@@ -1592,7 +1603,11 @@ async function calculateVersion(config, options) {
|
|
|
1592
1603
|
if (branchVersionType) {
|
|
1593
1604
|
const currentVersion = getCurrentVersionFromSource2();
|
|
1594
1605
|
log(`Applying ${branchVersionType} bump based on branch pattern`, "debug");
|
|
1595
|
-
|
|
1606
|
+
const isPrereleaseBumpType = ["prerelease", "premajor", "preminor", "prepatch"].includes(
|
|
1607
|
+
branchVersionType
|
|
1608
|
+
);
|
|
1609
|
+
const prereleaseId = config.isPrerelease || isPrereleaseBumpType ? normalizedPrereleaseId : void 0;
|
|
1610
|
+
return bumpVersion(currentVersion, branchVersionType, prereleaseId);
|
|
1596
1611
|
}
|
|
1597
1612
|
}
|
|
1598
1613
|
try {
|
|
@@ -1628,7 +1643,11 @@ async function calculateVersion(config, options) {
|
|
|
1628
1643
|
}
|
|
1629
1644
|
return "";
|
|
1630
1645
|
}
|
|
1631
|
-
|
|
1646
|
+
const isPrereleaseBumpType = ["prerelease", "premajor", "preminor", "prepatch"].includes(
|
|
1647
|
+
releaseTypeFromCommits
|
|
1648
|
+
);
|
|
1649
|
+
const prereleaseId = config.isPrerelease || isPrereleaseBumpType ? normalizedPrereleaseId : void 0;
|
|
1650
|
+
return bumpVersion(currentVersion, releaseTypeFromCommits, prereleaseId);
|
|
1632
1651
|
} catch (error) {
|
|
1633
1652
|
log(`Failed to calculate version for ${name || "project"}`, "error");
|
|
1634
1653
|
console.error(error);
|
|
@@ -2331,11 +2350,10 @@ function createStrategyMap(config) {
|
|
|
2331
2350
|
// src/core/versionEngine.ts
|
|
2332
2351
|
var VersionEngine = class {
|
|
2333
2352
|
config;
|
|
2334
|
-
jsonMode;
|
|
2335
2353
|
workspaceCache = null;
|
|
2336
2354
|
strategies;
|
|
2337
2355
|
currentStrategy;
|
|
2338
|
-
constructor(config,
|
|
2356
|
+
constructor(config, _jsonMode = false) {
|
|
2339
2357
|
if (!config) {
|
|
2340
2358
|
throw createVersionError("CONFIG_REQUIRED" /* CONFIG_REQUIRED */);
|
|
2341
2359
|
}
|
|
@@ -2344,7 +2362,6 @@ var VersionEngine = class {
|
|
|
2344
2362
|
log("No preset specified, using default: conventional-commits", "warning");
|
|
2345
2363
|
}
|
|
2346
2364
|
this.config = config;
|
|
2347
|
-
this.jsonMode = jsonMode;
|
|
2348
2365
|
this.strategies = createStrategyMap(config);
|
|
2349
2366
|
this.currentStrategy = createStrategy(config);
|
|
2350
2367
|
}
|
|
@@ -2481,8 +2498,10 @@ async function run() {
|
|
|
2481
2498
|
if (options.dryRun) config.dryRun = true;
|
|
2482
2499
|
if (options.synced) config.synced = true;
|
|
2483
2500
|
if (options.bump) config.type = options.bump;
|
|
2484
|
-
if (options.prerelease)
|
|
2501
|
+
if (options.prerelease) {
|
|
2485
2502
|
config.prereleaseIdentifier = options.prerelease === true ? "next" : options.prerelease;
|
|
2503
|
+
config.isPrerelease = true;
|
|
2504
|
+
}
|
|
2486
2505
|
const cliTargets = options.target ? options.target.split(",").map((t) => t.trim()) : [];
|
|
2487
2506
|
const engine = new VersionEngine(config, !!options.json);
|
|
2488
2507
|
const pkgsResult = await engine.getWorkspacePackages();
|
package/dist/index.js
CHANGED
|
@@ -439,7 +439,7 @@ function getAllVersionTags(since, versionPrefix = "v") {
|
|
|
439
439
|
const allTags = tagOutput.split("\n").filter((tag) => !!tag);
|
|
440
440
|
let filteredTags = allTags;
|
|
441
441
|
if (since) {
|
|
442
|
-
const sinceIndex = allTags.
|
|
442
|
+
const sinceIndex = allTags.indexOf(since);
|
|
443
443
|
if (sinceIndex >= 0) {
|
|
444
444
|
filteredTags = allTags.slice(sinceIndex);
|
|
445
445
|
} else {
|
|
@@ -523,7 +523,7 @@ async function regenerateChangelog(options) {
|
|
|
523
523
|
const allTagsCmd = `git tag --list "${versionPrefix}*" --sort=creatordate`;
|
|
524
524
|
const allTagsOutput = execSync2(allTagsCmd, { encoding: "utf8" }).trim();
|
|
525
525
|
const allTags = allTagsOutput.split("\n").filter((tag) => !!tag);
|
|
526
|
-
const sinceIndex = allTags.
|
|
526
|
+
const sinceIndex = allTags.indexOf(since);
|
|
527
527
|
const actualPreviousTag = sinceIndex > 0 ? allTags[sinceIndex - 1] : null;
|
|
528
528
|
if (actualPreviousTag) {
|
|
529
529
|
tagRange = `${actualPreviousTag}..${currentTag.tag}`;
|
|
@@ -661,8 +661,12 @@ function filterPackagesByConfig(packages, configTargets, workspaceRoot) {
|
|
|
661
661
|
for (const target of configTargets) {
|
|
662
662
|
const dirMatches = filterByDirectoryPattern(packages, target, workspaceRoot);
|
|
663
663
|
const nameMatches = filterByPackageNamePattern(packages, target);
|
|
664
|
-
|
|
665
|
-
|
|
664
|
+
for (const pkg of dirMatches) {
|
|
665
|
+
matchedPackages.add(pkg);
|
|
666
|
+
}
|
|
667
|
+
for (const pkg of nameMatches) {
|
|
668
|
+
matchedPackages.add(pkg);
|
|
669
|
+
}
|
|
666
670
|
}
|
|
667
671
|
return Array.from(matchedPackages);
|
|
668
672
|
}
|
|
@@ -1528,14 +1532,21 @@ async function calculateVersion(config, options) {
|
|
|
1528
1532
|
const specifiedType = type;
|
|
1529
1533
|
if (specifiedType) {
|
|
1530
1534
|
const currentVersion = getCurrentVersionFromSource2();
|
|
1531
|
-
|
|
1535
|
+
const isCurrentPrerelease = semver3.prerelease(currentVersion);
|
|
1536
|
+
const explicitlyRequestedPrerelease = config.isPrerelease;
|
|
1537
|
+
if (STANDARD_BUMP_TYPES.includes(specifiedType) && (isCurrentPrerelease || explicitlyRequestedPrerelease)) {
|
|
1538
|
+
const prereleaseId2 = explicitlyRequestedPrerelease || isCurrentPrerelease ? normalizedPrereleaseId : void 0;
|
|
1532
1539
|
log(
|
|
1533
|
-
|
|
1540
|
+
explicitlyRequestedPrerelease ? `Creating prerelease version with identifier '${prereleaseId2}' using ${specifiedType}` : `Cleaning prerelease identifier from ${currentVersion} for ${specifiedType} bump`,
|
|
1534
1541
|
"debug"
|
|
1535
1542
|
);
|
|
1536
|
-
return bumpVersion(currentVersion, specifiedType,
|
|
1543
|
+
return bumpVersion(currentVersion, specifiedType, prereleaseId2);
|
|
1537
1544
|
}
|
|
1538
|
-
|
|
1545
|
+
const isPrereleaseBumpType = ["prerelease", "premajor", "preminor", "prepatch"].includes(
|
|
1546
|
+
specifiedType
|
|
1547
|
+
);
|
|
1548
|
+
const prereleaseId = config.isPrerelease || isPrereleaseBumpType ? normalizedPrereleaseId : void 0;
|
|
1549
|
+
return bumpVersion(currentVersion, specifiedType, prereleaseId);
|
|
1539
1550
|
}
|
|
1540
1551
|
if (branchPattern && branchPattern.length > 0) {
|
|
1541
1552
|
const currentBranch = getCurrentBranch();
|
|
@@ -1559,7 +1570,11 @@ async function calculateVersion(config, options) {
|
|
|
1559
1570
|
if (branchVersionType) {
|
|
1560
1571
|
const currentVersion = getCurrentVersionFromSource2();
|
|
1561
1572
|
log(`Applying ${branchVersionType} bump based on branch pattern`, "debug");
|
|
1562
|
-
|
|
1573
|
+
const isPrereleaseBumpType = ["prerelease", "premajor", "preminor", "prepatch"].includes(
|
|
1574
|
+
branchVersionType
|
|
1575
|
+
);
|
|
1576
|
+
const prereleaseId = config.isPrerelease || isPrereleaseBumpType ? normalizedPrereleaseId : void 0;
|
|
1577
|
+
return bumpVersion(currentVersion, branchVersionType, prereleaseId);
|
|
1563
1578
|
}
|
|
1564
1579
|
}
|
|
1565
1580
|
try {
|
|
@@ -1595,7 +1610,11 @@ async function calculateVersion(config, options) {
|
|
|
1595
1610
|
}
|
|
1596
1611
|
return "";
|
|
1597
1612
|
}
|
|
1598
|
-
|
|
1613
|
+
const isPrereleaseBumpType = ["prerelease", "premajor", "preminor", "prepatch"].includes(
|
|
1614
|
+
releaseTypeFromCommits
|
|
1615
|
+
);
|
|
1616
|
+
const prereleaseId = config.isPrerelease || isPrereleaseBumpType ? normalizedPrereleaseId : void 0;
|
|
1617
|
+
return bumpVersion(currentVersion, releaseTypeFromCommits, prereleaseId);
|
|
1599
1618
|
} catch (error) {
|
|
1600
1619
|
log(`Failed to calculate version for ${name || "project"}`, "error");
|
|
1601
1620
|
console.error(error);
|
|
@@ -2298,11 +2317,10 @@ function createStrategyMap(config) {
|
|
|
2298
2317
|
// src/core/versionEngine.ts
|
|
2299
2318
|
var VersionEngine = class {
|
|
2300
2319
|
config;
|
|
2301
|
-
jsonMode;
|
|
2302
2320
|
workspaceCache = null;
|
|
2303
2321
|
strategies;
|
|
2304
2322
|
currentStrategy;
|
|
2305
|
-
constructor(config,
|
|
2323
|
+
constructor(config, _jsonMode = false) {
|
|
2306
2324
|
if (!config) {
|
|
2307
2325
|
throw createVersionError("CONFIG_REQUIRED" /* CONFIG_REQUIRED */);
|
|
2308
2326
|
}
|
|
@@ -2311,7 +2329,6 @@ var VersionEngine = class {
|
|
|
2311
2329
|
log("No preset specified, using default: conventional-commits", "warning");
|
|
2312
2330
|
}
|
|
2313
2331
|
this.config = config;
|
|
2314
|
-
this.jsonMode = jsonMode;
|
|
2315
2332
|
this.strategies = createStrategyMap(config);
|
|
2316
2333
|
this.currentStrategy = createStrategy(config);
|
|
2317
2334
|
}
|
|
@@ -2447,8 +2464,10 @@ async function run() {
|
|
|
2447
2464
|
if (options.dryRun) config.dryRun = true;
|
|
2448
2465
|
if (options.synced) config.synced = true;
|
|
2449
2466
|
if (options.bump) config.type = options.bump;
|
|
2450
|
-
if (options.prerelease)
|
|
2467
|
+
if (options.prerelease) {
|
|
2451
2468
|
config.prereleaseIdentifier = options.prerelease === true ? "next" : options.prerelease;
|
|
2469
|
+
config.isPrerelease = true;
|
|
2470
|
+
}
|
|
2452
2471
|
const cliTargets = options.target ? options.target.split(",").map((t) => t.trim()) : [];
|
|
2453
2472
|
const engine = new VersionEngine(config, !!options.json);
|
|
2454
2473
|
const pkgsResult = await engine.getWorkspacePackages();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "package-versioner",
|
|
3
3
|
"description": "A lightweight yet powerful CLI tool for automated semantic versioning based on Git history and conventional commits.",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -37,34 +37,34 @@
|
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@biomejs/biome": "^2.
|
|
40
|
+
"@biomejs/biome": "^2.2.2",
|
|
41
41
|
"@types/figlet": "^1.5.5",
|
|
42
|
-
"@types/node": "^24.0
|
|
42
|
+
"@types/node": "^24.3.0",
|
|
43
43
|
"@types/semver": "^7.3.13",
|
|
44
44
|
"@vitest/coverage-v8": "^3.2.4",
|
|
45
|
-
"cross-env": "^
|
|
45
|
+
"cross-env": "^10.0.0",
|
|
46
46
|
"husky": "^9.1.7",
|
|
47
|
-
"lint-staged": "^16.1.
|
|
47
|
+
"lint-staged": "^16.1.5",
|
|
48
48
|
"tsup": "^8.5.0",
|
|
49
|
-
"tsx": "^4.20.
|
|
50
|
-
"typescript": "^5.
|
|
49
|
+
"tsx": "^4.20.5",
|
|
50
|
+
"typescript": "^5.9.2",
|
|
51
51
|
"vitest": "^3.2.4"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@manypkg/get-packages": "^3.
|
|
54
|
+
"@manypkg/get-packages": "^3.1.0",
|
|
55
55
|
"@types/micromatch": "^4.0.9",
|
|
56
|
-
"chalk": "^5.
|
|
56
|
+
"chalk": "^5.6.0",
|
|
57
57
|
"commander": "^14.0.0",
|
|
58
58
|
"conventional-changelog-angular": "^8.0.0",
|
|
59
59
|
"conventional-changelog-conventional-commits": "npm:conventional-changelog-conventionalcommits@^9.0.0",
|
|
60
|
-
"conventional-changelog-conventionalcommits": "^9.
|
|
60
|
+
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
61
61
|
"conventional-commits-filter": "^5.0.0",
|
|
62
62
|
"conventional-recommended-bump": "^11.2.0",
|
|
63
|
-
"figlet": "^1.8.
|
|
63
|
+
"figlet": "^1.8.2",
|
|
64
64
|
"git-semver-tags": "^8.0.0",
|
|
65
65
|
"micromatch": "^4.0.8",
|
|
66
66
|
"semver": "^7.7.2",
|
|
67
|
-
"smol-toml": "^1.4.
|
|
67
|
+
"smol-toml": "^1.4.2"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|