@codluv/versionguard 0.5.0 → 0.6.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/dist/calver.d.ts.map +1 -1
- package/dist/chunks/{index-CwOyEn5L.js → index-DeZAx4Le.js} +80 -25
- package/dist/chunks/index-DeZAx4Le.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +63 -1023
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -12
- package/dist/init-wizard.d.ts +6 -0
- package/dist/init-wizard.d.ts.map +1 -1
- package/dist/scheme-rules.d.ts +32 -0
- package/dist/scheme-rules.d.ts.map +1 -0
- package/dist/semver.d.ts +9 -2
- package/dist/semver.d.ts.map +1 -1
- package/dist/tag/index.d.ts +1 -1
- package/dist/tag/index.d.ts.map +1 -1
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/chunks/index-CwOyEn5L.js.map +0 -1
package/dist/calver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calver.d.ts","sourceRoot":"","sources":["../src/calver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"calver.d.ts","sourceRoot":"","sources":["../src/calver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EAEZ,WAAW,EAEX,gBAAgB,EACjB,MAAM,SAAS,CAAC;AA8BjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,IAAI,YAAY,CAoBhF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CA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AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,CAqB7E;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,CAE5F"}
|
|
@@ -6,6 +6,17 @@ import { parse as parse$2 } from "smol-toml";
|
|
|
6
6
|
import * as yaml from "js-yaml";
|
|
7
7
|
import { globSync } from "glob";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
+
function validateModifier(modifier, schemeRules) {
|
|
10
|
+
if (!modifier || !schemeRules?.allowedModifiers) return null;
|
|
11
|
+
const baseModifier = modifier.replace(/[\d.]+$/, "") || modifier;
|
|
12
|
+
if (!schemeRules.allowedModifiers.includes(baseModifier)) {
|
|
13
|
+
return {
|
|
14
|
+
message: `Modifier "${modifier}" is not allowed. Allowed: ${schemeRules.allowedModifiers.join(", ")}`,
|
|
15
|
+
severity: "error"
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
9
20
|
const VALID_TOKENS = /* @__PURE__ */ new Set([
|
|
10
21
|
"YYYY",
|
|
11
22
|
"YY",
|
|
@@ -200,13 +211,10 @@ function validate$2(version, calverFormat, preventFutureDates = true, schemeRule
|
|
|
200
211
|
});
|
|
201
212
|
}
|
|
202
213
|
}
|
|
203
|
-
if (parsed.modifier
|
|
204
|
-
const
|
|
205
|
-
if (
|
|
206
|
-
errors.push(
|
|
207
|
-
message: `Modifier "${parsed.modifier}" is not allowed. Allowed: ${schemeRules.allowedModifiers.join(", ")}`,
|
|
208
|
-
severity: "error"
|
|
209
|
-
});
|
|
214
|
+
if (parsed.modifier) {
|
|
215
|
+
const modifierError = validateModifier(parsed.modifier, schemeRules);
|
|
216
|
+
if (modifierError) {
|
|
217
|
+
errors.push(modifierError);
|
|
210
218
|
}
|
|
211
219
|
}
|
|
212
220
|
if (schemeRules?.maxNumericSegments) {
|
|
@@ -1336,17 +1344,42 @@ function getStructuralErrors(version) {
|
|
|
1336
1344
|
});
|
|
1337
1345
|
return errors;
|
|
1338
1346
|
}
|
|
1339
|
-
function validate$1(version) {
|
|
1340
|
-
|
|
1347
|
+
function validate$1(version, semverConfig, schemeRules) {
|
|
1348
|
+
let input = version;
|
|
1349
|
+
if (input.startsWith("v") || input.startsWith("V")) {
|
|
1350
|
+
if (semverConfig?.allowVPrefix) {
|
|
1351
|
+
input = input.slice(1);
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
const parsed = parse(input);
|
|
1341
1355
|
if (!parsed) {
|
|
1342
1356
|
return {
|
|
1343
1357
|
valid: false,
|
|
1344
1358
|
errors: getStructuralErrors(version)
|
|
1345
1359
|
};
|
|
1346
1360
|
}
|
|
1361
|
+
const errors = [];
|
|
1362
|
+
if (semverConfig && !semverConfig.allowBuildMetadata && parsed.build.length > 0) {
|
|
1363
|
+
errors.push({
|
|
1364
|
+
message: `Build metadata is not allowed: "${parsed.build.join(".")}"`,
|
|
1365
|
+
severity: "error"
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
if (semverConfig?.requirePrerelease && parsed.prerelease.length === 0) {
|
|
1369
|
+
errors.push({
|
|
1370
|
+
message: "A prerelease label is required (e.g., 1.2.3-alpha.1)",
|
|
1371
|
+
severity: "error"
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
if (parsed.prerelease.length > 0) {
|
|
1375
|
+
const modifierError = validateModifier(parsed.prerelease[0], schemeRules);
|
|
1376
|
+
if (modifierError) {
|
|
1377
|
+
errors.push(modifierError);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1347
1380
|
return {
|
|
1348
|
-
valid:
|
|
1349
|
-
errors
|
|
1381
|
+
valid: errors.filter((e) => e.severity === "error").length === 0,
|
|
1382
|
+
errors,
|
|
1350
1383
|
version: { type: "semver", version: parsed }
|
|
1351
1384
|
};
|
|
1352
1385
|
}
|
|
@@ -1527,6 +1560,14 @@ function checkHardcodedVersions(expectedVersion, config, ignorePatterns, cwd = p
|
|
|
1527
1560
|
}
|
|
1528
1561
|
return mismatches;
|
|
1529
1562
|
}
|
|
1563
|
+
const DEFAULT_SEMVER_CONFIG = {
|
|
1564
|
+
allowVPrefix: false,
|
|
1565
|
+
allowBuildMetadata: true,
|
|
1566
|
+
requirePrerelease: false
|
|
1567
|
+
};
|
|
1568
|
+
function getSemVerConfig(config) {
|
|
1569
|
+
return { ...DEFAULT_SEMVER_CONFIG, ...config.versioning.semver };
|
|
1570
|
+
}
|
|
1530
1571
|
function getCalVerConfig(config) {
|
|
1531
1572
|
if (!config.versioning.calver) {
|
|
1532
1573
|
throw new Error('CalVer configuration is required when versioning.type is "calver"');
|
|
@@ -1703,6 +1744,11 @@ const DEFAULT_CONFIG = {
|
|
|
1703
1744
|
maxNumericSegments: 3,
|
|
1704
1745
|
allowedModifiers: ["dev", "alpha", "beta", "rc"]
|
|
1705
1746
|
},
|
|
1747
|
+
semver: {
|
|
1748
|
+
allowVPrefix: false,
|
|
1749
|
+
allowBuildMetadata: true,
|
|
1750
|
+
requirePrerelease: false
|
|
1751
|
+
},
|
|
1706
1752
|
calver: {
|
|
1707
1753
|
format: "YYYY.MM.PATCH",
|
|
1708
1754
|
preventFutureDates: true,
|
|
@@ -1782,8 +1828,16 @@ function initConfig(cwd = process.cwd()) {
|
|
|
1782
1828
|
}
|
|
1783
1829
|
function generateDefaultConfig() {
|
|
1784
1830
|
return `# VersionGuard Configuration
|
|
1831
|
+
# Change "type" to switch between semver and calver — both blocks are always present.
|
|
1785
1832
|
versioning:
|
|
1786
1833
|
type: semver
|
|
1834
|
+
semver:
|
|
1835
|
+
allowVPrefix: false
|
|
1836
|
+
allowBuildMetadata: true
|
|
1837
|
+
requirePrerelease: false
|
|
1838
|
+
calver:
|
|
1839
|
+
format: "YYYY.MM.PATCH"
|
|
1840
|
+
preventFutureDates: true
|
|
1787
1841
|
|
|
1788
1842
|
sync:
|
|
1789
1843
|
files:
|
|
@@ -2615,7 +2669,7 @@ function getTagPreflightError(config, cwd, expectedVersion, allowAutoFix = false
|
|
|
2615
2669
|
return "Working tree must be clean before creating or validating release tags";
|
|
2616
2670
|
}
|
|
2617
2671
|
const version = expectedVersion ?? getPackageVersion(cwd, config.manifest);
|
|
2618
|
-
const versionResult = config.versioning.type === "semver" ? validate$1(version) : validate$2(
|
|
2672
|
+
const versionResult = config.versioning.type === "semver" ? validate$1(version, getSemVerConfig(config), config.versioning.schemeRules) : validate$2(
|
|
2619
2673
|
version,
|
|
2620
2674
|
config.versioning.calver?.format ?? "YYYY.MM.PATCH",
|
|
2621
2675
|
config.versioning.calver?.preventFutureDates ?? true,
|
|
@@ -2700,7 +2754,7 @@ function suggestTagMessage(version, cwd = process.cwd()) {
|
|
|
2700
2754
|
}
|
|
2701
2755
|
function validateVersion(version, config) {
|
|
2702
2756
|
if (config.versioning.type === "semver") {
|
|
2703
|
-
return validate$1(version);
|
|
2757
|
+
return validate$1(version, getSemVerConfig(config), config.versioning.schemeRules);
|
|
2704
2758
|
}
|
|
2705
2759
|
const calverConfig = getCalVerConfig(config);
|
|
2706
2760
|
return validate$2(
|
|
@@ -2828,6 +2882,7 @@ function isWorktreeClean(cwd) {
|
|
|
2828
2882
|
}
|
|
2829
2883
|
}
|
|
2830
2884
|
export {
|
|
2885
|
+
validateVersion as $,
|
|
2831
2886
|
checkHardcodedVersions as A,
|
|
2832
2887
|
checkHookIntegrity as B,
|
|
2833
2888
|
checkHooksPathOverride as C,
|
|
@@ -2840,21 +2895,21 @@ export {
|
|
|
2840
2895
|
JsonVersionSource as J,
|
|
2841
2896
|
getCalVerConfig as K,
|
|
2842
2897
|
getLatestTag as L,
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2898
|
+
getSemVerConfig as M,
|
|
2899
|
+
getTagFeedback as N,
|
|
2900
|
+
getVersionSource as O,
|
|
2901
|
+
initConfig as P,
|
|
2902
|
+
resolveVersionSource as Q,
|
|
2848
2903
|
RegexVersionSource as R,
|
|
2849
|
-
|
|
2904
|
+
semver as S,
|
|
2850
2905
|
TomlVersionSource as T,
|
|
2851
|
-
|
|
2906
|
+
suggestTagMessage as U,
|
|
2852
2907
|
VersionFileSource as V,
|
|
2853
|
-
|
|
2854
|
-
|
|
2908
|
+
sync as W,
|
|
2909
|
+
syncVersion as X,
|
|
2855
2910
|
YamlVersionSource as Y,
|
|
2856
|
-
|
|
2857
|
-
|
|
2911
|
+
validateChangelog as Z,
|
|
2912
|
+
validateTagForPush as _,
|
|
2858
2913
|
installHooks as a,
|
|
2859
2914
|
getPackageVersion as b,
|
|
2860
2915
|
createCkmEngine as c,
|
|
@@ -2882,4 +2937,4 @@ export {
|
|
|
2882
2937
|
canBump as y,
|
|
2883
2938
|
checkEnforceHooksPolicy as z
|
|
2884
2939
|
};
|
|
2885
|
-
//# sourceMappingURL=index-
|
|
2940
|
+
//# sourceMappingURL=index-DeZAx4Le.js.map
|