@wyxos/zephyr 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/package.json +1 -1
- package/src/release/release-type.mjs +24 -2
package/package.json
CHANGED
|
@@ -16,6 +16,15 @@ export const RELEASE_TYPES = [
|
|
|
16
16
|
'prerelease'
|
|
17
17
|
]
|
|
18
18
|
const STABLE_RELEASE_TYPES = ['major', 'minor', 'patch']
|
|
19
|
+
const RELEASE_TYPE_WEIGHTS = {
|
|
20
|
+
prerelease: 0,
|
|
21
|
+
prepatch: 1,
|
|
22
|
+
patch: 1,
|
|
23
|
+
preminor: 2,
|
|
24
|
+
minor: 2,
|
|
25
|
+
premajor: 3,
|
|
26
|
+
major: 3
|
|
27
|
+
}
|
|
19
28
|
|
|
20
29
|
function sanitizeSuggestedReleaseType(message, allowedTypes = RELEASE_TYPES) {
|
|
21
30
|
if (typeof message !== 'string') {
|
|
@@ -70,6 +79,17 @@ function inferReleaseTypeHeuristically({
|
|
|
70
79
|
return 'patch'
|
|
71
80
|
}
|
|
72
81
|
|
|
82
|
+
function applyHeuristicFloor(releaseType, heuristicReleaseType) {
|
|
83
|
+
const releaseWeight = RELEASE_TYPE_WEIGHTS[releaseType] ?? -1
|
|
84
|
+
const heuristicWeight = RELEASE_TYPE_WEIGHTS[heuristicReleaseType] ?? -1
|
|
85
|
+
|
|
86
|
+
if (heuristicWeight > releaseWeight) {
|
|
87
|
+
return heuristicReleaseType
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return releaseType
|
|
91
|
+
}
|
|
92
|
+
|
|
73
93
|
function resolveSuggestedReleaseTypeOptions(currentVersion = '0.0.0') {
|
|
74
94
|
const parsedVersion = semver.parse(currentVersion)
|
|
75
95
|
|
|
@@ -234,10 +254,12 @@ async function suggestReleaseType(rootDir = process.cwd(), {
|
|
|
234
254
|
}
|
|
235
255
|
}
|
|
236
256
|
|
|
257
|
+
const flooredReleaseType = applyHeuristicFloor(releaseType, heuristicReleaseType)
|
|
258
|
+
|
|
237
259
|
return {
|
|
238
260
|
...context,
|
|
239
|
-
releaseType,
|
|
240
|
-
source: 'codex'
|
|
261
|
+
releaseType: flooredReleaseType,
|
|
262
|
+
source: flooredReleaseType === releaseType ? 'codex' : 'codex+heuristic-floor'
|
|
241
263
|
}
|
|
242
264
|
} catch (error) {
|
|
243
265
|
logWarning?.(`Codex could not suggest a release type: ${error.message}`)
|