@@ -15,14 +15,14 @@ const nvmrc = (await readFile('../.nvmrc', 'utf-8'))
1515 // We don’t care about leading or trailing whitespace
1616 . trim ( ) ;
1717
18- /** Matches `x.y.z ` pattern */
19- const nodeVersionPattern = / ^ \d + \. \d + \. \d + $ / ;
18+ /** Matches `x` pattern */
19+ const nodeVersionPattern = / ^ \d + $ / ;
2020const nodeVersion = nvmrc . match ( nodeVersionPattern ) ?. [ 0 ] ?? undefined ;
2121
2222if ( ! nodeVersion ) {
2323 warn (
2424 'Node version in .nvmrc has incorrect pattern:' ,
25- `\` ${ nvmrc } \` does not match \`x.y.z\`` ,
25+ `Please specify a major version only (e.g. \`20\`). Full semantic versions ( \`x.y.z\`) are not supported. You entered: \` ${ nvmrc } \`` ,
2626 ) ;
2727 process . exit ( 1 ) ;
2828} else {
@@ -36,13 +36,13 @@ const requiredNodeVersionMatches =
3636 /** @type {const } @satisfies {ReadonlyArray<{filepath: string, pattern: RegExp, matchLevel: MatchLevel}> }*/ ( [
3737 {
3838 filepath : 'Containerfile' ,
39- pattern : / ^ F R O M n o d e : ( . + ) - a l p i n e $ / m,
40- matchLevel : 'patch ' ,
39+ pattern : / ^ F R O M n o d e : ( \d + ) / m,
40+ matchLevel : 'major ' ,
4141 } ,
4242 {
4343 filepath : 'scripts/deploy/riff-raff.yaml' ,
44- pattern : / ^ + R e c i p e : d o t c o m - r e n d e r i n g .* - n o d e - ( \d + \. \d + \. \d + ) .* ?$ / m,
45- matchLevel : 'patch ' ,
44+ pattern : / ^ + R e c i p e : d o t c o m - r e n d e r i n g .* - n o d e - ( \d + ) .* ?$ / m,
45+ matchLevel : 'major ' ,
4646 } ,
4747 {
4848 filepath : 'package.json' ,
@@ -68,15 +68,22 @@ const requiredNodeVersionMatches =
6868 * @returns boolean
6969 */
7070const versionMatches = ( a , b , matchLevel ) => {
71- const semverA = semverParse ( a ) ;
71+ const semverA = semverParse ( a ) ?? semverParse ( `${ a } .0.0` ) ;
72+ const semverB = semverParse ( b ) ?? semverParse ( `${ b } .0.0` ) ;
7273
7374 switch ( matchLevel ) {
7475 case 'major' :
75- return semverSatisfies ( b , ` ${ semverA ?. major } .x.x` ) ;
76+ return semverA ?. major === semverB ?. major ;
7677 case 'minor' :
77- return semverSatisfies ( b , `${ semverA ?. major } .${ semverA ?. minor } .x` ) ;
78+ return semverSatisfies (
79+ semverB ?. version ?? b ,
80+ `${ semverA ?. major } .${ semverA ?. minor } .x` ,
81+ ) ;
7882 case 'patch' :
79- return semverSatisfies ( b , a ) ;
83+ return semverSatisfies (
84+ semverB ?. version ?? b ,
85+ semverA ?. version ?? a ,
86+ ) ;
8087 }
8188} ;
8289
0 commit comments