package-versioner 0.9.2 → 0.9.3
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 +52 -5
- package/dist/index.js +52 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -677,7 +677,7 @@ var import_node_process = require("process");
|
|
|
677
677
|
function loadConfig(configPath) {
|
|
678
678
|
const localProcess = (0, import_node_process.cwd)();
|
|
679
679
|
const filePath = configPath || `${localProcess}/version.config.json`;
|
|
680
|
-
return new Promise((
|
|
680
|
+
return new Promise((resolve2, reject) => {
|
|
681
681
|
fs2.readFile(filePath, "utf-8", (err, data) => {
|
|
682
682
|
if (err) {
|
|
683
683
|
reject(new Error(`Could not locate the config file at ${filePath}: ${err.message}`));
|
|
@@ -685,7 +685,7 @@ function loadConfig(configPath) {
|
|
|
685
685
|
}
|
|
686
686
|
try {
|
|
687
687
|
const config = JSON.parse(data);
|
|
688
|
-
|
|
688
|
+
resolve2(config);
|
|
689
689
|
} catch (err2) {
|
|
690
690
|
const errorMessage = err2 instanceof Error ? err2.message : String(err2);
|
|
691
691
|
reject(new Error(`Failed to parse config file ${filePath}: ${errorMessage}`));
|
|
@@ -959,7 +959,7 @@ init_logging();
|
|
|
959
959
|
var import_node_child_process3 = require("child_process");
|
|
960
960
|
var execAsync = (command, options) => {
|
|
961
961
|
const defaultOptions = { maxBuffer: 1024 * 1024 * 10, ...options };
|
|
962
|
-
return new Promise((
|
|
962
|
+
return new Promise((resolve2, reject) => {
|
|
963
963
|
(0, import_node_child_process3.exec)(
|
|
964
964
|
command,
|
|
965
965
|
defaultOptions,
|
|
@@ -967,7 +967,7 @@ var execAsync = (command, options) => {
|
|
|
967
967
|
if (error) {
|
|
968
968
|
reject(error);
|
|
969
969
|
} else {
|
|
970
|
-
|
|
970
|
+
resolve2({ stdout: stdout.toString(), stderr: stderr.toString() });
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
);
|
|
@@ -1897,6 +1897,7 @@ var PackageProcessor = class {
|
|
|
1897
1897
|
for (const pkg of pkgsToConsider) {
|
|
1898
1898
|
const name = pkg.packageJson.name;
|
|
1899
1899
|
const pkgPath = pkg.dir;
|
|
1900
|
+
log(`Processing package ${name} at path: ${pkgPath}`, "info");
|
|
1900
1901
|
const formattedPrefix = formatVersionPrefix(this.versionPrefix);
|
|
1901
1902
|
let latestTagResult = "";
|
|
1902
1903
|
try {
|
|
@@ -2029,21 +2030,36 @@ var PackageProcessor = class {
|
|
|
2029
2030
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
2030
2031
|
}
|
|
2031
2032
|
const cargoEnabled = ((_a = this.fullConfig.cargo) == null ? void 0 : _a.enabled) !== false;
|
|
2033
|
+
log(
|
|
2034
|
+
`Cargo enabled for ${name}: ${cargoEnabled}, config: ${JSON.stringify(this.fullConfig.cargo)}`,
|
|
2035
|
+
"debug"
|
|
2036
|
+
);
|
|
2032
2037
|
if (cargoEnabled) {
|
|
2033
2038
|
const cargoPaths = (_b = this.fullConfig.cargo) == null ? void 0 : _b.paths;
|
|
2039
|
+
log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
|
|
2034
2040
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
2035
2041
|
for (const cargoPath of cargoPaths) {
|
|
2036
2042
|
const resolvedCargoPath = import_node_path7.default.resolve(pkgPath, cargoPath, "Cargo.toml");
|
|
2043
|
+
log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
|
|
2037
2044
|
if (fs8.existsSync(resolvedCargoPath)) {
|
|
2045
|
+
log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
|
|
2038
2046
|
updatePackageVersion(resolvedCargoPath, nextVersion);
|
|
2047
|
+
} else {
|
|
2048
|
+
log(`Cargo.toml not found at ${resolvedCargoPath}`, "debug");
|
|
2039
2049
|
}
|
|
2040
2050
|
}
|
|
2041
2051
|
} else {
|
|
2042
2052
|
const cargoTomlPath = import_node_path7.default.join(pkgPath, "Cargo.toml");
|
|
2053
|
+
log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
|
|
2043
2054
|
if (fs8.existsSync(cargoTomlPath)) {
|
|
2055
|
+
log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
|
|
2044
2056
|
updatePackageVersion(cargoTomlPath, nextVersion);
|
|
2057
|
+
} else {
|
|
2058
|
+
log(`Cargo.toml not found for ${name} at ${cargoTomlPath}`, "debug");
|
|
2045
2059
|
}
|
|
2046
2060
|
}
|
|
2061
|
+
} else {
|
|
2062
|
+
log(`Cargo disabled for ${name}`, "debug");
|
|
2047
2063
|
}
|
|
2048
2064
|
const packageTag = formatTag(
|
|
2049
2065
|
nextVersion,
|
|
@@ -2141,6 +2157,30 @@ function shouldProcessPackage2(pkg, config) {
|
|
|
2141
2157
|
const pkgName = pkg.packageJson.name;
|
|
2142
2158
|
return shouldProcessPackage(pkgName, config.skip);
|
|
2143
2159
|
}
|
|
2160
|
+
function updateCargoFiles(packageDir, version, cargoConfig) {
|
|
2161
|
+
const updatedFiles = [];
|
|
2162
|
+
const cargoEnabled = (cargoConfig == null ? void 0 : cargoConfig.enabled) !== false;
|
|
2163
|
+
if (!cargoEnabled) {
|
|
2164
|
+
return updatedFiles;
|
|
2165
|
+
}
|
|
2166
|
+
const cargoPaths = cargoConfig == null ? void 0 : cargoConfig.paths;
|
|
2167
|
+
if (cargoPaths && cargoPaths.length > 0) {
|
|
2168
|
+
for (const cargoPath of cargoPaths) {
|
|
2169
|
+
const resolvedCargoPath = path8.resolve(packageDir, cargoPath, "Cargo.toml");
|
|
2170
|
+
if (import_node_fs7.default.existsSync(resolvedCargoPath)) {
|
|
2171
|
+
updatePackageVersion(resolvedCargoPath, version);
|
|
2172
|
+
updatedFiles.push(resolvedCargoPath);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
} else {
|
|
2176
|
+
const cargoTomlPath = path8.join(packageDir, "Cargo.toml");
|
|
2177
|
+
if (import_node_fs7.default.existsSync(cargoTomlPath)) {
|
|
2178
|
+
updatePackageVersion(cargoTomlPath, version);
|
|
2179
|
+
updatedFiles.push(cargoTomlPath);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
return updatedFiles;
|
|
2183
|
+
}
|
|
2144
2184
|
function createSyncStrategy(config) {
|
|
2145
2185
|
return async (packages) => {
|
|
2146
2186
|
try {
|
|
@@ -2220,6 +2260,8 @@ function createSyncStrategy(config) {
|
|
|
2220
2260
|
files.push(rootPkgPath);
|
|
2221
2261
|
updatedPackages.push("root");
|
|
2222
2262
|
processedPaths.add(rootPkgPath);
|
|
2263
|
+
const rootCargoFiles = updateCargoFiles(packages.root, nextVersion, config.cargo);
|
|
2264
|
+
files.push(...rootCargoFiles);
|
|
2223
2265
|
}
|
|
2224
2266
|
} else {
|
|
2225
2267
|
log("Root package path is undefined, skipping root package.json update", "warning");
|
|
@@ -2240,6 +2282,8 @@ function createSyncStrategy(config) {
|
|
|
2240
2282
|
files.push(packageJsonPath);
|
|
2241
2283
|
updatedPackages.push(pkg.packageJson.name);
|
|
2242
2284
|
processedPaths.add(packageJsonPath);
|
|
2285
|
+
const pkgCargoFiles = updateCargoFiles(pkg.dir, nextVersion, config.cargo);
|
|
2286
|
+
files.push(...pkgCargoFiles);
|
|
2243
2287
|
}
|
|
2244
2288
|
if (updatedPackages.length > 0) {
|
|
2245
2289
|
log(`Updated ${updatedPackages.length} package(s) to version ${nextVersion}`, "success");
|
|
@@ -2402,6 +2446,9 @@ function createSingleStrategy(config) {
|
|
|
2402
2446
|
}
|
|
2403
2447
|
const packageJsonPath = path8.join(pkgPath, "package.json");
|
|
2404
2448
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
2449
|
+
const filesToCommit = [packageJsonPath];
|
|
2450
|
+
const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo);
|
|
2451
|
+
filesToCommit.push(...cargoFiles);
|
|
2405
2452
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
2406
2453
|
const tagName = formatTag(
|
|
2407
2454
|
nextVersion,
|
|
@@ -2412,7 +2459,7 @@ function createSingleStrategy(config) {
|
|
|
2412
2459
|
);
|
|
2413
2460
|
const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
2414
2461
|
if (!dryRun) {
|
|
2415
|
-
await createGitCommitAndTag(
|
|
2462
|
+
await createGitCommitAndTag(filesToCommit, tagName, commitMsg, skipHooks, dryRun);
|
|
2416
2463
|
log(`Created tag: ${tagName}`, "success");
|
|
2417
2464
|
} else {
|
|
2418
2465
|
log(`Would create tag: ${tagName}`, "info");
|
package/dist/index.js
CHANGED
|
@@ -513,7 +513,7 @@ import { cwd } from "process";
|
|
|
513
513
|
function loadConfig(configPath) {
|
|
514
514
|
const localProcess = cwd();
|
|
515
515
|
const filePath = configPath || `${localProcess}/version.config.json`;
|
|
516
|
-
return new Promise((
|
|
516
|
+
return new Promise((resolve2, reject) => {
|
|
517
517
|
fs2.readFile(filePath, "utf-8", (err, data) => {
|
|
518
518
|
if (err) {
|
|
519
519
|
reject(new Error(`Could not locate the config file at ${filePath}: ${err.message}`));
|
|
@@ -521,7 +521,7 @@ function loadConfig(configPath) {
|
|
|
521
521
|
}
|
|
522
522
|
try {
|
|
523
523
|
const config = JSON.parse(data);
|
|
524
|
-
|
|
524
|
+
resolve2(config);
|
|
525
525
|
} catch (err2) {
|
|
526
526
|
const errorMessage = err2 instanceof Error ? err2.message : String(err2);
|
|
527
527
|
reject(new Error(`Failed to parse config file ${filePath}: ${errorMessage}`));
|
|
@@ -783,7 +783,7 @@ import { cwd as cwd2 } from "process";
|
|
|
783
783
|
import { exec, execSync as nativeExecSync } from "child_process";
|
|
784
784
|
var execAsync = (command, options) => {
|
|
785
785
|
const defaultOptions = { maxBuffer: 1024 * 1024 * 10, ...options };
|
|
786
|
-
return new Promise((
|
|
786
|
+
return new Promise((resolve2, reject) => {
|
|
787
787
|
exec(
|
|
788
788
|
command,
|
|
789
789
|
defaultOptions,
|
|
@@ -791,7 +791,7 @@ var execAsync = (command, options) => {
|
|
|
791
791
|
if (error) {
|
|
792
792
|
reject(error);
|
|
793
793
|
} else {
|
|
794
|
-
|
|
794
|
+
resolve2({ stdout: stdout.toString(), stderr: stderr.toString() });
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
797
|
);
|
|
@@ -1707,6 +1707,7 @@ var PackageProcessor = class {
|
|
|
1707
1707
|
for (const pkg of pkgsToConsider) {
|
|
1708
1708
|
const name = pkg.packageJson.name;
|
|
1709
1709
|
const pkgPath = pkg.dir;
|
|
1710
|
+
log(`Processing package ${name} at path: ${pkgPath}`, "info");
|
|
1710
1711
|
const formattedPrefix = formatVersionPrefix(this.versionPrefix);
|
|
1711
1712
|
let latestTagResult = "";
|
|
1712
1713
|
try {
|
|
@@ -1839,21 +1840,36 @@ var PackageProcessor = class {
|
|
|
1839
1840
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
1840
1841
|
}
|
|
1841
1842
|
const cargoEnabled = ((_a = this.fullConfig.cargo) == null ? void 0 : _a.enabled) !== false;
|
|
1843
|
+
log(
|
|
1844
|
+
`Cargo enabled for ${name}: ${cargoEnabled}, config: ${JSON.stringify(this.fullConfig.cargo)}`,
|
|
1845
|
+
"debug"
|
|
1846
|
+
);
|
|
1842
1847
|
if (cargoEnabled) {
|
|
1843
1848
|
const cargoPaths = (_b = this.fullConfig.cargo) == null ? void 0 : _b.paths;
|
|
1849
|
+
log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
|
|
1844
1850
|
if (cargoPaths && cargoPaths.length > 0) {
|
|
1845
1851
|
for (const cargoPath of cargoPaths) {
|
|
1846
1852
|
const resolvedCargoPath = path7.resolve(pkgPath, cargoPath, "Cargo.toml");
|
|
1853
|
+
log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
|
|
1847
1854
|
if (fs8.existsSync(resolvedCargoPath)) {
|
|
1855
|
+
log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
|
|
1848
1856
|
updatePackageVersion(resolvedCargoPath, nextVersion);
|
|
1857
|
+
} else {
|
|
1858
|
+
log(`Cargo.toml not found at ${resolvedCargoPath}`, "debug");
|
|
1849
1859
|
}
|
|
1850
1860
|
}
|
|
1851
1861
|
} else {
|
|
1852
1862
|
const cargoTomlPath = path7.join(pkgPath, "Cargo.toml");
|
|
1863
|
+
log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
|
|
1853
1864
|
if (fs8.existsSync(cargoTomlPath)) {
|
|
1865
|
+
log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
|
|
1854
1866
|
updatePackageVersion(cargoTomlPath, nextVersion);
|
|
1867
|
+
} else {
|
|
1868
|
+
log(`Cargo.toml not found for ${name} at ${cargoTomlPath}`, "debug");
|
|
1855
1869
|
}
|
|
1856
1870
|
}
|
|
1871
|
+
} else {
|
|
1872
|
+
log(`Cargo disabled for ${name}`, "debug");
|
|
1857
1873
|
}
|
|
1858
1874
|
const packageTag = formatTag(
|
|
1859
1875
|
nextVersion,
|
|
@@ -1950,6 +1966,30 @@ function shouldProcessPackage2(pkg, config) {
|
|
|
1950
1966
|
const pkgName = pkg.packageJson.name;
|
|
1951
1967
|
return shouldProcessPackage(pkgName, config.skip);
|
|
1952
1968
|
}
|
|
1969
|
+
function updateCargoFiles(packageDir, version, cargoConfig) {
|
|
1970
|
+
const updatedFiles = [];
|
|
1971
|
+
const cargoEnabled = (cargoConfig == null ? void 0 : cargoConfig.enabled) !== false;
|
|
1972
|
+
if (!cargoEnabled) {
|
|
1973
|
+
return updatedFiles;
|
|
1974
|
+
}
|
|
1975
|
+
const cargoPaths = cargoConfig == null ? void 0 : cargoConfig.paths;
|
|
1976
|
+
if (cargoPaths && cargoPaths.length > 0) {
|
|
1977
|
+
for (const cargoPath of cargoPaths) {
|
|
1978
|
+
const resolvedCargoPath = path8.resolve(packageDir, cargoPath, "Cargo.toml");
|
|
1979
|
+
if (fs9.existsSync(resolvedCargoPath)) {
|
|
1980
|
+
updatePackageVersion(resolvedCargoPath, version);
|
|
1981
|
+
updatedFiles.push(resolvedCargoPath);
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
} else {
|
|
1985
|
+
const cargoTomlPath = path8.join(packageDir, "Cargo.toml");
|
|
1986
|
+
if (fs9.existsSync(cargoTomlPath)) {
|
|
1987
|
+
updatePackageVersion(cargoTomlPath, version);
|
|
1988
|
+
updatedFiles.push(cargoTomlPath);
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
return updatedFiles;
|
|
1992
|
+
}
|
|
1953
1993
|
function createSyncStrategy(config) {
|
|
1954
1994
|
return async (packages) => {
|
|
1955
1995
|
try {
|
|
@@ -2029,6 +2069,8 @@ function createSyncStrategy(config) {
|
|
|
2029
2069
|
files.push(rootPkgPath);
|
|
2030
2070
|
updatedPackages.push("root");
|
|
2031
2071
|
processedPaths.add(rootPkgPath);
|
|
2072
|
+
const rootCargoFiles = updateCargoFiles(packages.root, nextVersion, config.cargo);
|
|
2073
|
+
files.push(...rootCargoFiles);
|
|
2032
2074
|
}
|
|
2033
2075
|
} else {
|
|
2034
2076
|
log("Root package path is undefined, skipping root package.json update", "warning");
|
|
@@ -2049,6 +2091,8 @@ function createSyncStrategy(config) {
|
|
|
2049
2091
|
files.push(packageJsonPath);
|
|
2050
2092
|
updatedPackages.push(pkg.packageJson.name);
|
|
2051
2093
|
processedPaths.add(packageJsonPath);
|
|
2094
|
+
const pkgCargoFiles = updateCargoFiles(pkg.dir, nextVersion, config.cargo);
|
|
2095
|
+
files.push(...pkgCargoFiles);
|
|
2052
2096
|
}
|
|
2053
2097
|
if (updatedPackages.length > 0) {
|
|
2054
2098
|
log(`Updated ${updatedPackages.length} package(s) to version ${nextVersion}`, "success");
|
|
@@ -2211,6 +2255,9 @@ function createSingleStrategy(config) {
|
|
|
2211
2255
|
}
|
|
2212
2256
|
const packageJsonPath = path8.join(pkgPath, "package.json");
|
|
2213
2257
|
updatePackageVersion(packageJsonPath, nextVersion);
|
|
2258
|
+
const filesToCommit = [packageJsonPath];
|
|
2259
|
+
const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo);
|
|
2260
|
+
filesToCommit.push(...cargoFiles);
|
|
2214
2261
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
2215
2262
|
const tagName = formatTag(
|
|
2216
2263
|
nextVersion,
|
|
@@ -2221,7 +2268,7 @@ function createSingleStrategy(config) {
|
|
|
2221
2268
|
);
|
|
2222
2269
|
const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
2223
2270
|
if (!dryRun) {
|
|
2224
|
-
await createGitCommitAndTag(
|
|
2271
|
+
await createGitCommitAndTag(filesToCommit, tagName, commitMsg, skipHooks, dryRun);
|
|
2225
2272
|
log(`Created tag: ${tagName}`, "success");
|
|
2226
2273
|
} else {
|
|
2227
2274
|
log(`Would create tag: ${tagName}`, "info");
|
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.9.
|
|
4
|
+
"version": "0.9.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|