package-versioner 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -3
- package/dist/index.cjs +54 -58
- package/dist/index.js +54 -58
- package/docs/CI_CD_INTEGRATION.md +1 -1
- package/docs/versioning.md +8 -7
- package/package-versioner.schema.json +2 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ npx package-versioner --dry-run --json
|
|
|
74
74
|
|
|
75
75
|
By default, `package-versioner` intelligently handles Git tag reachability to provide the best user experience:
|
|
76
76
|
|
|
77
|
-
- **Default
|
|
77
|
+
- **Default behaviour**: Uses reachable tags when available, but falls back to the latest repository tag if needed (common in feature branches)
|
|
78
78
|
- **Strict mode (`--strict-reachable`)**: Only uses tags reachable from the current commit, following strict Git semantics
|
|
79
79
|
|
|
80
80
|
This is particularly useful when working on feature branches that have diverged from the main branch where newer tags exist. The tool will automatically detect the Git context and provide helpful guidance:
|
|
@@ -151,6 +151,7 @@ Customize behaviour by creating a `version.config.json` file in your project roo
|
|
|
151
151
|
- `updateChangelog`: Whether to automatically update changelogs (default: true)
|
|
152
152
|
- `changelogFormat`: Format for changelogs - "keep-a-changelog" or "angular" (default: "keep-a-changelog")
|
|
153
153
|
- `strictReachable`: Only use reachable tags, no fallback to unreachable tags (default: false)
|
|
154
|
+
- `prereleaseIdentifier`: Identifier for prerelease versions (e.g., "alpha", "beta", "next") used in versions like "1.2.0-alpha.3"
|
|
154
155
|
- `cargo`: Options for Rust projects:
|
|
155
156
|
- `enabled`: Whether to handle Cargo.toml files (default: true)
|
|
156
157
|
- `paths`: Directories to search for Cargo.toml files (optional)
|
|
@@ -167,7 +168,7 @@ For more details on CI/CD integration and advanced usage, see [CI/CD Integration
|
|
|
167
168
|
|
|
168
169
|
### Package Targeting
|
|
169
170
|
|
|
170
|
-
The `packages` configuration option
|
|
171
|
+
The `packages` configuration option controls which packages are processed for versioning. It supports several pattern types:
|
|
171
172
|
|
|
172
173
|
#### Exact Package Names
|
|
173
174
|
```json
|
|
@@ -200,7 +201,12 @@ Combine different pattern types:
|
|
|
200
201
|
}
|
|
201
202
|
```
|
|
202
203
|
|
|
203
|
-
**
|
|
204
|
+
**Behaviour:**
|
|
205
|
+
- When `packages` is specified, **only** packages matching those patterns will be processed
|
|
206
|
+
- When `packages` is empty or not specified, **all** workspace packages will be processed
|
|
207
|
+
- The `skip` option can exclude specific packages from the selected set
|
|
208
|
+
|
|
209
|
+
**Note**: Your workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.) determines which packages are available, but the `packages` option directly controls which ones get versioned.
|
|
204
210
|
|
|
205
211
|
### Package-Specific Tagging
|
|
206
212
|
|
package/dist/index.cjs
CHANGED
|
@@ -639,6 +639,30 @@ function createVersionError(code, details) {
|
|
|
639
639
|
return new VersionError(fullMessage, code);
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
+
// src/utils/packageMatching.ts
|
|
643
|
+
function matchesPackageTarget(packageName, target) {
|
|
644
|
+
if (packageName === target) {
|
|
645
|
+
return true;
|
|
646
|
+
}
|
|
647
|
+
if (target.endsWith("/*")) {
|
|
648
|
+
const scope = target.slice(0, -2);
|
|
649
|
+
if (scope.startsWith("@")) {
|
|
650
|
+
return packageName.startsWith(`${scope}/`);
|
|
651
|
+
}
|
|
652
|
+
return packageName.startsWith(`${scope}/`);
|
|
653
|
+
}
|
|
654
|
+
if (target === "*") {
|
|
655
|
+
return true;
|
|
656
|
+
}
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
function shouldMatchPackageTargets(packageName, targets) {
|
|
660
|
+
return targets.some((target) => matchesPackageTarget(packageName, target));
|
|
661
|
+
}
|
|
662
|
+
function shouldProcessPackage(packageName, skip = []) {
|
|
663
|
+
return !skip.includes(packageName);
|
|
664
|
+
}
|
|
665
|
+
|
|
642
666
|
// src/core/versionStrategies.ts
|
|
643
667
|
var import_node_fs7 = __toESM(require("fs"), 1);
|
|
644
668
|
var path7 = __toESM(require("path"), 1);
|
|
@@ -1698,7 +1722,7 @@ To fix this mismatch:
|
|
|
1698
1722
|
const bumper = new import_conventional_recommended_bump.Bumper();
|
|
1699
1723
|
bumper.loadPreset(preset);
|
|
1700
1724
|
const recommendedBump = await bumper.bump();
|
|
1701
|
-
const releaseTypeFromCommits = recommendedBump
|
|
1725
|
+
const releaseTypeFromCommits = recommendedBump && "releaseType" in recommendedBump ? recommendedBump.releaseType : void 0;
|
|
1702
1726
|
if (hasNoTags) {
|
|
1703
1727
|
if (releaseTypeFromCommits) {
|
|
1704
1728
|
return getPackageVersionFallback(
|
|
@@ -1783,37 +1807,9 @@ function calculateNextVersion(version, manifestType, name, releaseType, prerelea
|
|
|
1783
1807
|
return result || initialVersion;
|
|
1784
1808
|
}
|
|
1785
1809
|
|
|
1786
|
-
// src/utils/packageMatching.ts
|
|
1787
|
-
function matchesPackageTarget(packageName, target) {
|
|
1788
|
-
if (packageName === target) {
|
|
1789
|
-
return true;
|
|
1790
|
-
}
|
|
1791
|
-
if (target.endsWith("/*")) {
|
|
1792
|
-
const scope = target.slice(0, -2);
|
|
1793
|
-
if (scope.startsWith("@")) {
|
|
1794
|
-
return packageName.startsWith(`${scope}/`);
|
|
1795
|
-
}
|
|
1796
|
-
return packageName.startsWith(`${scope}/`);
|
|
1797
|
-
}
|
|
1798
|
-
if (target === "*") {
|
|
1799
|
-
return true;
|
|
1800
|
-
}
|
|
1801
|
-
return false;
|
|
1802
|
-
}
|
|
1803
|
-
function shouldProcessPackage(packageName, targets = [], skip = []) {
|
|
1804
|
-
if (skip.includes(packageName)) {
|
|
1805
|
-
return false;
|
|
1806
|
-
}
|
|
1807
|
-
if (targets.length === 0) {
|
|
1808
|
-
return true;
|
|
1809
|
-
}
|
|
1810
|
-
return targets.some((target) => matchesPackageTarget(packageName, target));
|
|
1811
|
-
}
|
|
1812
|
-
|
|
1813
1810
|
// src/package/packageProcessor.ts
|
|
1814
1811
|
var PackageProcessor = class {
|
|
1815
1812
|
skip;
|
|
1816
|
-
targets;
|
|
1817
1813
|
versionPrefix;
|
|
1818
1814
|
tagTemplate;
|
|
1819
1815
|
commitMessageTemplate;
|
|
@@ -1825,7 +1821,6 @@ var PackageProcessor = class {
|
|
|
1825
1821
|
fullConfig;
|
|
1826
1822
|
constructor(options) {
|
|
1827
1823
|
this.skip = options.skip || [];
|
|
1828
|
-
this.targets = options.targets || [];
|
|
1829
1824
|
this.versionPrefix = options.versionPrefix || "v";
|
|
1830
1825
|
this.tagTemplate = options.tagTemplate;
|
|
1831
1826
|
this.commitMessageTemplate = options.commitMessageTemplate || "";
|
|
@@ -1836,13 +1831,7 @@ var PackageProcessor = class {
|
|
|
1836
1831
|
this.fullConfig = options.fullConfig;
|
|
1837
1832
|
}
|
|
1838
1833
|
/**
|
|
1839
|
-
*
|
|
1840
|
-
*/
|
|
1841
|
-
setTargets(targets) {
|
|
1842
|
-
this.targets = targets;
|
|
1843
|
-
}
|
|
1844
|
-
/**
|
|
1845
|
-
* Process packages based on targeting criteria
|
|
1834
|
+
* Process packages based on skip list only (targeting handled at discovery time)
|
|
1846
1835
|
*/
|
|
1847
1836
|
async processPackages(packages) {
|
|
1848
1837
|
var _a, _b, _c, _d, _e;
|
|
@@ -1853,21 +1842,16 @@ var PackageProcessor = class {
|
|
|
1853
1842
|
return { updatedPackages: [], tags: [] };
|
|
1854
1843
|
}
|
|
1855
1844
|
const pkgsToConsider = packages.filter((pkg) => {
|
|
1856
|
-
var _a2;
|
|
1857
1845
|
const pkgName = pkg.packageJson.name;
|
|
1858
|
-
const shouldProcess = shouldProcessPackage(pkgName, this.
|
|
1846
|
+
const shouldProcess = shouldProcessPackage(pkgName, this.skip);
|
|
1859
1847
|
if (!shouldProcess) {
|
|
1860
|
-
|
|
1861
|
-
log(`Skipping package ${pkgName} as it's in the skip list.`, "info");
|
|
1862
|
-
} else {
|
|
1863
|
-
log(`Package ${pkgName} not in target list, skipping.`, "info");
|
|
1864
|
-
}
|
|
1848
|
+
log(`Skipping package ${pkgName} as it's in the skip list.`, "info");
|
|
1865
1849
|
}
|
|
1866
1850
|
return shouldProcess;
|
|
1867
1851
|
});
|
|
1868
|
-
log(`Found ${pkgsToConsider.length}
|
|
1852
|
+
log(`Found ${pkgsToConsider.length} package(s) to process after filtering.`, "info");
|
|
1869
1853
|
if (pkgsToConsider.length === 0) {
|
|
1870
|
-
log("No
|
|
1854
|
+
log("No packages found to process.", "info");
|
|
1871
1855
|
return { updatedPackages: [], tags: [] };
|
|
1872
1856
|
}
|
|
1873
1857
|
for (const pkg of pkgsToConsider) {
|
|
@@ -2050,7 +2034,7 @@ var PackageProcessor = class {
|
|
|
2050
2034
|
updatedPackagesInfo.push({ name, version: nextVersion, path: pkgPath });
|
|
2051
2035
|
}
|
|
2052
2036
|
if (updatedPackagesInfo.length === 0) {
|
|
2053
|
-
log("No
|
|
2037
|
+
log("No packages required a version update.", "info");
|
|
2054
2038
|
return { updatedPackages: [], tags };
|
|
2055
2039
|
}
|
|
2056
2040
|
const filesToCommit = [];
|
|
@@ -2114,9 +2098,9 @@ var PackageProcessor = class {
|
|
|
2114
2098
|
};
|
|
2115
2099
|
|
|
2116
2100
|
// src/core/versionStrategies.ts
|
|
2117
|
-
function shouldProcessPackage2(pkg, config
|
|
2101
|
+
function shouldProcessPackage2(pkg, config) {
|
|
2118
2102
|
const pkgName = pkg.packageJson.name;
|
|
2119
|
-
return shouldProcessPackage(pkgName,
|
|
2103
|
+
return shouldProcessPackage(pkgName, config.skip);
|
|
2120
2104
|
}
|
|
2121
2105
|
function createSyncedStrategy(config) {
|
|
2122
2106
|
return async (packages) => {
|
|
@@ -2332,7 +2316,6 @@ function createAsyncStrategy(config) {
|
|
|
2332
2316
|
};
|
|
2333
2317
|
const processorOptions = {
|
|
2334
2318
|
skip: config.skip || [],
|
|
2335
|
-
targets: config.packages || [],
|
|
2336
2319
|
versionPrefix: config.versionPrefix || "v",
|
|
2337
2320
|
tagTemplate: config.tagTemplate,
|
|
2338
2321
|
commitMessageTemplate: config.commitMessage || "",
|
|
@@ -2349,15 +2332,9 @@ function createAsyncStrategy(config) {
|
|
|
2349
2332
|
}
|
|
2350
2333
|
};
|
|
2351
2334
|
const packageProcessor = new PackageProcessor(processorOptions);
|
|
2352
|
-
return async (packages,
|
|
2335
|
+
return async (packages, _targets = []) => {
|
|
2353
2336
|
try {
|
|
2354
|
-
|
|
2355
|
-
packageProcessor.setTargets(targetPackages);
|
|
2356
|
-
if (targetPackages.length > 0) {
|
|
2357
|
-
log(`Processing targeted packages: ${targetPackages.join(", ")}`, "info");
|
|
2358
|
-
} else {
|
|
2359
|
-
log("No targets specified, processing all non-skipped packages", "info");
|
|
2360
|
-
}
|
|
2337
|
+
log(`Processing ${packages.packages.length} pre-filtered packages`, "info");
|
|
2361
2338
|
const result = await packageProcessor.processPackages(packages.packages);
|
|
2362
2339
|
if (result.updatedPackages.length === 0) {
|
|
2363
2340
|
log("No packages required a version update.", "info");
|
|
@@ -2439,6 +2416,25 @@ var VersionEngine = class {
|
|
|
2439
2416
|
);
|
|
2440
2417
|
pkgsResult.root = (0, import_node_process5.cwd)();
|
|
2441
2418
|
}
|
|
2419
|
+
if (this.config.packages && this.config.packages.length > 0) {
|
|
2420
|
+
const originalCount = pkgsResult.packages.length;
|
|
2421
|
+
const filteredPackages = pkgsResult.packages.filter(
|
|
2422
|
+
(pkg) => shouldMatchPackageTargets(pkg.packageJson.name, this.config.packages)
|
|
2423
|
+
);
|
|
2424
|
+
pkgsResult.packages = filteredPackages;
|
|
2425
|
+
log(
|
|
2426
|
+
`Filtered ${originalCount} workspace packages to ${filteredPackages.length} based on packages config`,
|
|
2427
|
+
"info"
|
|
2428
|
+
);
|
|
2429
|
+
if (filteredPackages.length === 0) {
|
|
2430
|
+
log("Warning: No packages matched the specified patterns in config.packages", "warning");
|
|
2431
|
+
}
|
|
2432
|
+
} else {
|
|
2433
|
+
log(
|
|
2434
|
+
`Processing all ${pkgsResult.packages.length} workspace packages (no packages filter specified)`,
|
|
2435
|
+
"info"
|
|
2436
|
+
);
|
|
2437
|
+
}
|
|
2442
2438
|
this.workspaceCache = pkgsResult;
|
|
2443
2439
|
return pkgsResult;
|
|
2444
2440
|
} catch (error) {
|
package/dist/index.js
CHANGED
|
@@ -606,6 +606,30 @@ function createVersionError(code, details) {
|
|
|
606
606
|
return new VersionError(fullMessage, code);
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
+
// src/utils/packageMatching.ts
|
|
610
|
+
function matchesPackageTarget(packageName, target) {
|
|
611
|
+
if (packageName === target) {
|
|
612
|
+
return true;
|
|
613
|
+
}
|
|
614
|
+
if (target.endsWith("/*")) {
|
|
615
|
+
const scope = target.slice(0, -2);
|
|
616
|
+
if (scope.startsWith("@")) {
|
|
617
|
+
return packageName.startsWith(`${scope}/`);
|
|
618
|
+
}
|
|
619
|
+
return packageName.startsWith(`${scope}/`);
|
|
620
|
+
}
|
|
621
|
+
if (target === "*") {
|
|
622
|
+
return true;
|
|
623
|
+
}
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
function shouldMatchPackageTargets(packageName, targets) {
|
|
627
|
+
return targets.some((target) => matchesPackageTarget(packageName, target));
|
|
628
|
+
}
|
|
629
|
+
function shouldProcessPackage(packageName, skip = []) {
|
|
630
|
+
return !skip.includes(packageName);
|
|
631
|
+
}
|
|
632
|
+
|
|
609
633
|
// src/core/versionStrategies.ts
|
|
610
634
|
import fs9 from "fs";
|
|
611
635
|
import * as path7 from "path";
|
|
@@ -1665,7 +1689,7 @@ To fix this mismatch:
|
|
|
1665
1689
|
const bumper = new Bumper();
|
|
1666
1690
|
bumper.loadPreset(preset);
|
|
1667
1691
|
const recommendedBump = await bumper.bump();
|
|
1668
|
-
const releaseTypeFromCommits = recommendedBump
|
|
1692
|
+
const releaseTypeFromCommits = recommendedBump && "releaseType" in recommendedBump ? recommendedBump.releaseType : void 0;
|
|
1669
1693
|
if (hasNoTags) {
|
|
1670
1694
|
if (releaseTypeFromCommits) {
|
|
1671
1695
|
return getPackageVersionFallback(
|
|
@@ -1750,37 +1774,9 @@ function calculateNextVersion(version, manifestType, name, releaseType, prerelea
|
|
|
1750
1774
|
return result || initialVersion;
|
|
1751
1775
|
}
|
|
1752
1776
|
|
|
1753
|
-
// src/utils/packageMatching.ts
|
|
1754
|
-
function matchesPackageTarget(packageName, target) {
|
|
1755
|
-
if (packageName === target) {
|
|
1756
|
-
return true;
|
|
1757
|
-
}
|
|
1758
|
-
if (target.endsWith("/*")) {
|
|
1759
|
-
const scope = target.slice(0, -2);
|
|
1760
|
-
if (scope.startsWith("@")) {
|
|
1761
|
-
return packageName.startsWith(`${scope}/`);
|
|
1762
|
-
}
|
|
1763
|
-
return packageName.startsWith(`${scope}/`);
|
|
1764
|
-
}
|
|
1765
|
-
if (target === "*") {
|
|
1766
|
-
return true;
|
|
1767
|
-
}
|
|
1768
|
-
return false;
|
|
1769
|
-
}
|
|
1770
|
-
function shouldProcessPackage(packageName, targets = [], skip = []) {
|
|
1771
|
-
if (skip.includes(packageName)) {
|
|
1772
|
-
return false;
|
|
1773
|
-
}
|
|
1774
|
-
if (targets.length === 0) {
|
|
1775
|
-
return true;
|
|
1776
|
-
}
|
|
1777
|
-
return targets.some((target) => matchesPackageTarget(packageName, target));
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
1777
|
// src/package/packageProcessor.ts
|
|
1781
1778
|
var PackageProcessor = class {
|
|
1782
1779
|
skip;
|
|
1783
|
-
targets;
|
|
1784
1780
|
versionPrefix;
|
|
1785
1781
|
tagTemplate;
|
|
1786
1782
|
commitMessageTemplate;
|
|
@@ -1792,7 +1788,6 @@ var PackageProcessor = class {
|
|
|
1792
1788
|
fullConfig;
|
|
1793
1789
|
constructor(options) {
|
|
1794
1790
|
this.skip = options.skip || [];
|
|
1795
|
-
this.targets = options.targets || [];
|
|
1796
1791
|
this.versionPrefix = options.versionPrefix || "v";
|
|
1797
1792
|
this.tagTemplate = options.tagTemplate;
|
|
1798
1793
|
this.commitMessageTemplate = options.commitMessageTemplate || "";
|
|
@@ -1803,13 +1798,7 @@ var PackageProcessor = class {
|
|
|
1803
1798
|
this.fullConfig = options.fullConfig;
|
|
1804
1799
|
}
|
|
1805
1800
|
/**
|
|
1806
|
-
*
|
|
1807
|
-
*/
|
|
1808
|
-
setTargets(targets) {
|
|
1809
|
-
this.targets = targets;
|
|
1810
|
-
}
|
|
1811
|
-
/**
|
|
1812
|
-
* Process packages based on targeting criteria
|
|
1801
|
+
* Process packages based on skip list only (targeting handled at discovery time)
|
|
1813
1802
|
*/
|
|
1814
1803
|
async processPackages(packages) {
|
|
1815
1804
|
var _a, _b, _c, _d, _e;
|
|
@@ -1820,21 +1809,16 @@ var PackageProcessor = class {
|
|
|
1820
1809
|
return { updatedPackages: [], tags: [] };
|
|
1821
1810
|
}
|
|
1822
1811
|
const pkgsToConsider = packages.filter((pkg) => {
|
|
1823
|
-
var _a2;
|
|
1824
1812
|
const pkgName = pkg.packageJson.name;
|
|
1825
|
-
const shouldProcess = shouldProcessPackage(pkgName, this.
|
|
1813
|
+
const shouldProcess = shouldProcessPackage(pkgName, this.skip);
|
|
1826
1814
|
if (!shouldProcess) {
|
|
1827
|
-
|
|
1828
|
-
log(`Skipping package ${pkgName} as it's in the skip list.`, "info");
|
|
1829
|
-
} else {
|
|
1830
|
-
log(`Package ${pkgName} not in target list, skipping.`, "info");
|
|
1831
|
-
}
|
|
1815
|
+
log(`Skipping package ${pkgName} as it's in the skip list.`, "info");
|
|
1832
1816
|
}
|
|
1833
1817
|
return shouldProcess;
|
|
1834
1818
|
});
|
|
1835
|
-
log(`Found ${pkgsToConsider.length}
|
|
1819
|
+
log(`Found ${pkgsToConsider.length} package(s) to process after filtering.`, "info");
|
|
1836
1820
|
if (pkgsToConsider.length === 0) {
|
|
1837
|
-
log("No
|
|
1821
|
+
log("No packages found to process.", "info");
|
|
1838
1822
|
return { updatedPackages: [], tags: [] };
|
|
1839
1823
|
}
|
|
1840
1824
|
for (const pkg of pkgsToConsider) {
|
|
@@ -2017,7 +2001,7 @@ var PackageProcessor = class {
|
|
|
2017
2001
|
updatedPackagesInfo.push({ name, version: nextVersion, path: pkgPath });
|
|
2018
2002
|
}
|
|
2019
2003
|
if (updatedPackagesInfo.length === 0) {
|
|
2020
|
-
log("No
|
|
2004
|
+
log("No packages required a version update.", "info");
|
|
2021
2005
|
return { updatedPackages: [], tags };
|
|
2022
2006
|
}
|
|
2023
2007
|
const filesToCommit = [];
|
|
@@ -2081,9 +2065,9 @@ var PackageProcessor = class {
|
|
|
2081
2065
|
};
|
|
2082
2066
|
|
|
2083
2067
|
// src/core/versionStrategies.ts
|
|
2084
|
-
function shouldProcessPackage2(pkg, config
|
|
2068
|
+
function shouldProcessPackage2(pkg, config) {
|
|
2085
2069
|
const pkgName = pkg.packageJson.name;
|
|
2086
|
-
return shouldProcessPackage(pkgName,
|
|
2070
|
+
return shouldProcessPackage(pkgName, config.skip);
|
|
2087
2071
|
}
|
|
2088
2072
|
function createSyncedStrategy(config) {
|
|
2089
2073
|
return async (packages) => {
|
|
@@ -2299,7 +2283,6 @@ function createAsyncStrategy(config) {
|
|
|
2299
2283
|
};
|
|
2300
2284
|
const processorOptions = {
|
|
2301
2285
|
skip: config.skip || [],
|
|
2302
|
-
targets: config.packages || [],
|
|
2303
2286
|
versionPrefix: config.versionPrefix || "v",
|
|
2304
2287
|
tagTemplate: config.tagTemplate,
|
|
2305
2288
|
commitMessageTemplate: config.commitMessage || "",
|
|
@@ -2316,15 +2299,9 @@ function createAsyncStrategy(config) {
|
|
|
2316
2299
|
}
|
|
2317
2300
|
};
|
|
2318
2301
|
const packageProcessor = new PackageProcessor(processorOptions);
|
|
2319
|
-
return async (packages,
|
|
2302
|
+
return async (packages, _targets = []) => {
|
|
2320
2303
|
try {
|
|
2321
|
-
|
|
2322
|
-
packageProcessor.setTargets(targetPackages);
|
|
2323
|
-
if (targetPackages.length > 0) {
|
|
2324
|
-
log(`Processing targeted packages: ${targetPackages.join(", ")}`, "info");
|
|
2325
|
-
} else {
|
|
2326
|
-
log("No targets specified, processing all non-skipped packages", "info");
|
|
2327
|
-
}
|
|
2304
|
+
log(`Processing ${packages.packages.length} pre-filtered packages`, "info");
|
|
2328
2305
|
const result = await packageProcessor.processPackages(packages.packages);
|
|
2329
2306
|
if (result.updatedPackages.length === 0) {
|
|
2330
2307
|
log("No packages required a version update.", "info");
|
|
@@ -2406,6 +2383,25 @@ var VersionEngine = class {
|
|
|
2406
2383
|
);
|
|
2407
2384
|
pkgsResult.root = cwd4();
|
|
2408
2385
|
}
|
|
2386
|
+
if (this.config.packages && this.config.packages.length > 0) {
|
|
2387
|
+
const originalCount = pkgsResult.packages.length;
|
|
2388
|
+
const filteredPackages = pkgsResult.packages.filter(
|
|
2389
|
+
(pkg) => shouldMatchPackageTargets(pkg.packageJson.name, this.config.packages)
|
|
2390
|
+
);
|
|
2391
|
+
pkgsResult.packages = filteredPackages;
|
|
2392
|
+
log(
|
|
2393
|
+
`Filtered ${originalCount} workspace packages to ${filteredPackages.length} based on packages config`,
|
|
2394
|
+
"info"
|
|
2395
|
+
);
|
|
2396
|
+
if (filteredPackages.length === 0) {
|
|
2397
|
+
log("Warning: No packages matched the specified patterns in config.packages", "warning");
|
|
2398
|
+
}
|
|
2399
|
+
} else {
|
|
2400
|
+
log(
|
|
2401
|
+
`Processing all ${pkgsResult.packages.length} workspace packages (no packages filter specified)`,
|
|
2402
|
+
"info"
|
|
2403
|
+
);
|
|
2404
|
+
}
|
|
2409
2405
|
this.workspaceCache = pkgsResult;
|
|
2410
2406
|
return pkgsResult;
|
|
2411
2407
|
} catch (error) {
|
|
@@ -154,7 +154,7 @@ git push origin "v$NEW_VERSION"
|
|
|
154
154
|
`package-versioner` respects the following environment variables:
|
|
155
155
|
|
|
156
156
|
- `NO_COLOR=1`: Disables colored output in logs (automatically detected in CI environments)
|
|
157
|
-
- `CI=true`: Most CI environments set this automatically, which helps the tool adjust its output
|
|
157
|
+
- `CI=true`: Most CI environments set this automatically, which helps the tool adjust its output behaviour
|
|
158
158
|
|
|
159
159
|
## Skipping CI for Version Commits
|
|
160
160
|
|
package/docs/versioning.md
CHANGED
|
@@ -170,13 +170,6 @@ This dual support makes `package-versioner` suitable for both JavaScript/TypeScr
|
|
|
170
170
|
|
|
171
171
|
When working with monorepos, you can control which packages are processed for versioning using the `packages` configuration option. This provides flexible targeting with support for various pattern types.
|
|
172
172
|
|
|
173
|
-
### Package Discovery vs. Targeting
|
|
174
|
-
|
|
175
|
-
It's important to understand the distinction:
|
|
176
|
-
|
|
177
|
-
- **Package Discovery**: Handled by your workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.)
|
|
178
|
-
- **Package Targeting**: Controlled by the `packages` option in version.config.json to filter which discovered packages to process
|
|
179
|
-
|
|
180
173
|
### Targeting Patterns
|
|
181
174
|
|
|
182
175
|
#### Exact Package Names
|
|
@@ -212,6 +205,12 @@ Combine different pattern types for flexible targeting:
|
|
|
212
205
|
}
|
|
213
206
|
```
|
|
214
207
|
|
|
208
|
+
### Behaviour
|
|
209
|
+
|
|
210
|
+
- **When `packages` is specified**: Only packages matching those patterns will be processed for versioning
|
|
211
|
+
- **When `packages` is empty or not specified**: All workspace packages will be processed
|
|
212
|
+
- **Error handling**: If no packages match the specified patterns, a warning is displayed
|
|
213
|
+
|
|
215
214
|
### Excluding Packages
|
|
216
215
|
|
|
217
216
|
Use the `skip` option to exclude specific packages from processing:
|
|
@@ -224,6 +223,8 @@ Use the `skip` option to exclude specific packages from processing:
|
|
|
224
223
|
|
|
225
224
|
This configuration will process all packages in the `@mycompany` scope except for `@mycompany/deprecated-package`.
|
|
226
225
|
|
|
226
|
+
**Note**: Your workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.) determines which packages are available in your workspace, but the `packages` option directly controls which ones get versioned.
|
|
227
|
+
|
|
227
228
|
## Tag Templates and Configuration
|
|
228
229
|
|
|
229
230
|
`package-versioner` provides flexible configuration for how Git tags are formatted, allowing you to customize the tag structure for both single package repositories and monorepos.
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"packageSpecificTags": {
|
|
22
22
|
"type": "boolean",
|
|
23
23
|
"default": false,
|
|
24
|
-
"description": "Whether to enable package-specific tagging
|
|
24
|
+
"description": "Whether to enable package-specific tagging behaviour"
|
|
25
25
|
},
|
|
26
26
|
"preset": {
|
|
27
27
|
"type": "string",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"minLength": 1
|
|
54
54
|
},
|
|
55
55
|
"default": [],
|
|
56
|
-
"description": "Array of package names or patterns
|
|
56
|
+
"description": "Array of package names or patterns that determines which packages will be processed for versioning. When specified, only packages matching these patterns will be versioned. When empty or not specified, all workspace packages will be processed. Supports exact names (e.g., '@scope/package-a'), scope wildcards (e.g., '@scope/*'), and global wildcards (e.g., '*')"
|
|
57
57
|
},
|
|
58
58
|
"mainPackage": {
|
|
59
59
|
"type": "string",
|
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.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -37,17 +37,17 @@
|
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@biomejs/biome": "^
|
|
40
|
+
"@biomejs/biome": "^2.0.6",
|
|
41
41
|
"@types/figlet": "^1.5.5",
|
|
42
|
-
"@types/node": "^24.0.
|
|
42
|
+
"@types/node": "^24.0.10",
|
|
43
43
|
"@types/semver": "^7.3.13",
|
|
44
|
-
"@vitest/coverage-v8": "^3.2.
|
|
44
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
45
45
|
"husky": "^9.1.7",
|
|
46
46
|
"lint-staged": "^16.1.2",
|
|
47
47
|
"tsup": "^8.5.0",
|
|
48
48
|
"tsx": "^4.20.3",
|
|
49
49
|
"typescript": "^5.8.3",
|
|
50
|
-
"vitest": "^3.2.
|
|
50
|
+
"vitest": "^3.2.4"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@manypkg/get-packages": "^3.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"figlet": "^1.8.1",
|
|
60
60
|
"git-semver-tags": "^8.0.0",
|
|
61
61
|
"semver": "^7.7.2",
|
|
62
|
-
"smol-toml": "^1.
|
|
62
|
+
"smol-toml": "^1.4.1"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|