fix(install): reject prerelease Node toolchains
This commit is contained in:
+4
-3
@@ -1649,8 +1649,9 @@ function Set-GitBashEnvVar {
|
||||
# with the root package.json.
|
||||
function Test-NodeVersionOk {
|
||||
param([string]$Version)
|
||||
if ($Version -match '-') { return $false }
|
||||
try {
|
||||
$v = [version]($Version -replace '^v', '' -replace '-.*$', '')
|
||||
$v = [version]($Version -replace '^v', '')
|
||||
} catch {
|
||||
return $false
|
||||
}
|
||||
@@ -3992,8 +3993,8 @@ function Install-Desktop {
|
||||
|
||||
# Always re-resolve Node here. Stages run in separate PowerShell processes,
|
||||
# so $script:HasNode from Stage-Node isn't visible; more importantly Test-Node
|
||||
# enforces the build floor (Node >=22.22.0) and prepends the Hermes-managed
|
||||
# Node to PATH, so the build never runs on a too-old system Node -- the cause
|
||||
# enforces the supported Node lines and prepends the Hermes-managed Node to
|
||||
# PATH, so the build never runs on an unsupported system Node -- the cause
|
||||
# of the opaque "Build desktop app ... exit code 1" failure (Vite crashes on
|
||||
# old Node).
|
||||
Test-Node | Out-Null
|
||||
|
||||
+3
-2
@@ -889,6 +889,7 @@ check_cxx_compiler() {
|
||||
# replaced with the Hermes-managed Node $NODE_VERSION.
|
||||
node_satisfies_build() {
|
||||
local ver="${1#v}"
|
||||
case "$ver" in *-*) return 1 ;; esac
|
||||
local major="${ver%%.*}"
|
||||
local minor="${ver#*.}"; minor="${minor%%.*}"
|
||||
case "$major" in ''|*[!0-9]*) return 1 ;; esac
|
||||
@@ -3218,8 +3219,8 @@ install_desktop() {
|
||||
# failure, not a silent skip — a silent skip yields a "complete" install
|
||||
# with no app and a confusing "couldn't find a built desktop" at launch.
|
||||
# Always re-resolve Node here. Stages run in separate processes, so we can't
|
||||
# trust an earlier check; more importantly check_node now enforces the build
|
||||
# floor (Node >=26) and prepends the Hermes-managed Node to PATH, so
|
||||
# trust an earlier check; more importantly check_node now enforces the
|
||||
# supported Node lines and prepends the Hermes-managed Node to PATH, so
|
||||
# the build never runs on a too-old system Node — the cause of the opaque
|
||||
# "Build desktop app … exit code 1" failure (Vite crashes on old Node).
|
||||
check_node
|
||||
|
||||
@@ -58,12 +58,9 @@ function satisfiesClause(version: string, clause: string): boolean {
|
||||
}
|
||||
|
||||
function satisfiesRange(version: string, range: string): boolean {
|
||||
return range.split('||').some(alternative =>
|
||||
alternative
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.every(clause => satisfiesClause(version, clause))
|
||||
)
|
||||
const alternatives = range.split('||').map(alternative => alternative.trim().split(/\s+/))
|
||||
alternatives.flat().forEach(clause => satisfiesClause(version, clause))
|
||||
return alternatives.some(clauses => clauses.every(clause => satisfiesClause(version, clause)))
|
||||
}
|
||||
|
||||
const rootManifest = readJson<Manifest>('package.json')
|
||||
@@ -96,4 +93,15 @@ describe('Node engine alignment', () => {
|
||||
assert.equal(nodeRange(lockfile.packages?.[''] ?? {}, 'root lock entry'), rootRange)
|
||||
assert.equal(nodeRange(lockfile.packages?.['apps/desktop'] ?? {}, 'desktop lock entry'), desktopRange)
|
||||
})
|
||||
|
||||
test.each(['~22.22.0', '22.x', '>=26.0.0-rc.1'])(
|
||||
'the alignment helper rejects unsupported semver clause %s instead of misclassifying it',
|
||||
clause => {
|
||||
assert.throws(() => satisfiesRange('26.0.0', clause), /unsupported semver clause/)
|
||||
}
|
||||
)
|
||||
|
||||
test('unsupported clauses are rejected even after a matching alternative', () => {
|
||||
assert.throws(() => satisfiesRange('26.0.0', '>=26.0.0 || ~28.0.0'), /unsupported semver clause/)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user