dsh 0.2.0-rc.2: in-container update (experimental channel), path-agnostic compose, upstream patches adapted to 0.1.x/0.2.x
This commit is contained in:
commit
e6dcef9bf5
302 files changed
+75178
No files matched your search
@@ -0,0 +1,31 @@
|
||||
export function parseBootstrapVersion(value, label = 'Bootstrap VERSION') {
|
||||
if (typeof value !== 'string') throw new Error(`${label} is invalid`)
|
||||
const normalized = value.endsWith('\r\n')
|
||||
? value.slice(0, -2)
|
||||
: value.endsWith('\n') ? value.slice(0, -1) : value
|
||||
if (!/^\d+\.\d+\.\d+$/.test(normalized)) {
|
||||
throw new Error(`${label} is invalid`)
|
||||
}
|
||||
if (normalized.split('.').some(part => !Number.isSafeInteger(Number(part)))) {
|
||||
throw new Error(`${label} is invalid`)
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
function compareBootstrapVersions(left, right) {
|
||||
const leftParts = left.split('.').map(Number)
|
||||
const rightParts = right.split('.').map(Number)
|
||||
for (let index = 0; index < leftParts.length; index += 1) {
|
||||
if (leftParts[index] !== rightParts[index]) return leftParts[index] - rightParts[index]
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
export function validateBootstrapContentTransition({ previousVersion, previousSha256, nextVersion, nextSha256 }) {
|
||||
parseBootstrapVersion(previousVersion, 'previous Bootstrap version')
|
||||
parseBootstrapVersion(nextVersion, 'next Bootstrap version')
|
||||
if (previousSha256 === nextSha256) return
|
||||
if (compareBootstrapVersions(nextVersion, previousVersion) <= 0) {
|
||||
throw new Error('Bootstrap content changed without increasing Bootstrap VERSION')
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user