@@ -23,8 +23,8 @@ const templateRepoMap = Object.freeze({
2323} ) ;
2424
2525// nodeVersions is sorted
26- const getLatestNodeVersion = ( nodeVersions , majorVersion ) => nodeVersions
27- . find ( ( version ) => version . startsWith ( `${ majorVersion } .` ) ) ;
26+ const getLatestNodeVersion = ( nodeVersions , majorVersion ) =>
27+ nodeVersions . find ( ( version ) => version . startsWith ( `${ majorVersion } .` ) ) ;
2828
2929const getTemplate = ( variant ) => {
3030 if ( variant . startsWith ( 'alpine' ) ) {
@@ -39,7 +39,10 @@ const getTemplate = (variant) => {
3939} ;
4040
4141const getDockerfileMetadata = ( nodeVersions , file ) => {
42- const [ nodeMajorVersion , variant ] = path . dirname ( file ) . split ( path . sep ) . slice ( - 2 ) ;
42+ const [ nodeMajorVersion , variant ] = path
43+ . dirname ( file )
44+ . split ( path . sep )
45+ . slice ( - 2 ) ;
4346 const fileNodeVersion = getDockerfileNodeVersion ( file ) ;
4447
4548 return {
@@ -52,8 +55,8 @@ const getDockerfileMetadata = (nodeVersions, file) => {
5255 } ;
5356} ;
5457
55- const isDockerfileOutdated = ( { fileNodeVersion, latestVersion } ) => fileNodeVersion
56- !== latestVersion ;
58+ const isDockerfileOutdated = ( { fileNodeVersion, latestVersion } ) =>
59+ fileNodeVersion !== latestVersion ;
5760
5861const fetchLatestNodeVersions = async ( ) => {
5962 const nodeDist = await fetch ( 'https://nodejs.org/dist/index.json' ) ;
@@ -64,25 +67,27 @@ const fetchLatestNodeVersions = async () => {
6467const findOutdated = async ( updateAll ) => {
6568 const nodeVersions = await fetchLatestNodeVersions ( ) ;
6669
67- const dockerfileMetadatas = getAllDockerfiles ( __dirname )
68- . map ( ( file ) => getDockerfileMetadata ( nodeVersions , file ) ) ;
70+ const dockerfileMetadatas = getAllDockerfiles ( __dirname ) . map ( ( file ) =>
71+ getDockerfileMetadata ( nodeVersions , file ) ,
72+ ) ;
6973
7074 return updateAll
7175 ? dockerfileMetadatas
7276 : dockerfileMetadatas . filter ( isDockerfileOutdated ) ;
7377} ;
7478
75- const getKeys = ( basename ) => readFileSync ( path . resolve ( __dirname , 'keys' , basename ) )
76- . toString ( ) . trim ( ) . split ( '\n' ) ;
79+ const getKeys = ( basename ) =>
80+ readFileSync ( path . resolve ( __dirname , 'keys' , basename ) )
81+ . toString ( )
82+ . trim ( )
83+ . split ( '\n' ) ;
7784
78- const readTemplate = ( template ) => readFileSync (
79- path . resolve ( __dirname , templateFileMap [ template ] ) ,
80- ) . toString ( ) ;
85+ const readTemplate = ( template ) =>
86+ readFileSync ( path . resolve ( __dirname , templateFileMap [ template ] ) ) . toString ( ) ;
8187
8288const getBaseImage = ( { template, variant } ) => {
83- const tag = template === templates . alpine
84- ? variant . replace ( / a l p i n e / , '' )
85- : variant ;
89+ const tag =
90+ template === templates . alpine ? variant . replace ( / a l p i n e / , '' ) : variant ;
8691
8792 return `${ templateRepoMap [ template ] } :${ tag } ` ;
8893} ;
@@ -93,47 +98,65 @@ const formatTemplate = (nodeKeys, muslChecksum, base, metadata) => {
9398 const { latestVersion, template, nodeMajorVersion } = metadata ;
9499 const baseImage = getBaseImage ( metadata ) ;
95100 const arches = versionJson [ nodeMajorVersion ] . variants [ metadata . variant ] ;
96- let initialFormat = base . replace ( / ^ F R O M .+ $ / m, `FROM ${ baseImage } ` )
101+ let initialFormat = base
102+ . replace ( / ^ F R O M .+ $ / m, `FROM ${ baseImage } ` )
97103 . replace ( / ^ E N V N O D E _ V E R S I O N = .+ $ / m, `ENV NODE_VERSION=${ latestVersion } ` )
98- . replace ( / ^ ( \s * ) " \$ { NODE_ K E Y S \[ @ ] } " .* $ / m, formatKeys ( nodeKeys ) )
104+ . replace ( / ^ ( \s * ) " \$ { NODE_ K E Y S \[ @ ] } " .* $ / m, formatKeys ( nodeKeys ) ) ;
99105
100106 if ( parseInt ( nodeMajorVersion , 10 ) >= 26 ) {
101107 initialFormat = initialFormat . replace ( / E N V Y A R N _ V E R S I O N .* \* \n / s, '' ) ;
102108 }
103109
104110 if ( template === templates . alpine ) {
105111 let archString = '' ;
106- if ( arches . includes ( 'amd64' ) ) archString += `x86_64) ARCH='x64' CHECKSUM="${ muslChecksum } " OPENSSL_ARCH=linux-x86_64;; \\\n `
107- if ( arches . includes ( 'arm64v8' ) ) archString += `aarch64) OPENSSL_ARCH=linux-aarch64;; \\\n `
108- if ( arches . includes ( 'arm32v6' ) || arches . includes ( 'arm32v7' ) ) archString += `arm*) OPENSSL_ARCH=linux-armv4;; \\\n `
109- if ( arches . includes ( 'ppc64le' ) ) archString += `ppc64le) OPENSSL_ARCH=linux-ppc64le;; \\\n `
110- if ( arches . includes ( 's390x' ) ) archString += `s390x) OPENSSL_ARCH=linux-s390x;; \\\n `
111- archString += '*) ;; \\'
112-
113- initialFormat = initialFormat . replace ( / " \$ \{ A L P I N E _ A R C H \[ @ \] \} " / s, archString ) ;
112+ if ( arches . includes ( 'amd64' ) )
113+ archString += `x86_64) ARCH='x64' CHECKSUM="${ muslChecksum } " OPENSSL_ARCH=linux-x86_64;; \\\n ` ;
114+ if ( arches . includes ( 'arm64v8' ) )
115+ archString += `aarch64) OPENSSL_ARCH=linux-aarch64;; \\\n ` ;
116+ if ( arches . includes ( 'arm32v6' ) || arches . includes ( 'arm32v7' ) )
117+ archString += `arm*) OPENSSL_ARCH=linux-armv4;; \\\n ` ;
118+ if ( arches . includes ( 'ppc64le' ) )
119+ archString += `ppc64le) OPENSSL_ARCH=linux-ppc64le;; \\\n ` ;
120+ if ( arches . includes ( 's390x' ) )
121+ archString += `s390x) OPENSSL_ARCH=linux-s390x;; \\\n ` ;
122+ archString += '*) ;; \\' ;
123+
124+ initialFormat = initialFormat . replace (
125+ / " \$ \{ A L P I N E _ A R C H \[ @ \] \} " / s,
126+ archString ,
127+ ) ;
114128
115129 // Strip out rust and cargo packages for Node.js < 26
116130 if ( parseInt ( nodeMajorVersion , 10 ) < 26 ) {
117131 initialFormat = initialFormat . replace ( / r u s t \\ .* c a r g o \\ \s * / s, '' ) ;
118132 }
119133 } else if ( template === templates . debianSlim ) {
120134 let archString = '' ;
121- if ( arches . includes ( 'amd64' ) ) archString += `amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \\\n `
122- if ( arches . includes ( 'ppc64le' ) ) archString += `ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \\\n `
123- if ( arches . includes ( 's390x' ) ) archString += `s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \\\n `
124- if ( arches . includes ( 'arm64v8' ) ) archString += `arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \\\n `
125- if ( arches . includes ( 'arm32v7' ) ) archString += `armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \\\n `
126- archString += '*) echo "unsupported architecture"; exit 1 ;; \\'
135+ if ( arches . includes ( 'amd64' ) )
136+ archString += `amd64) ARCH='x64' OPENSSL_ARCH='linux-x86_64';; \\\n ` ;
137+ if ( arches . includes ( 'ppc64le' ) )
138+ archString += `ppc64el) ARCH='ppc64le' OPENSSL_ARCH='linux-ppc64le';; \\\n ` ;
139+ if ( arches . includes ( 's390x' ) )
140+ archString += `s390x) ARCH='s390x' OPENSSL_ARCH='linux*-s390x';; \\\n ` ;
141+ if ( arches . includes ( 'arm64v8' ) )
142+ archString += `arm64) ARCH='arm64' OPENSSL_ARCH='linux-aarch64';; \\\n ` ;
143+ if ( arches . includes ( 'arm32v7' ) )
144+ archString += `armhf) ARCH='armv7l' OPENSSL_ARCH='linux-armv4';; \\\n ` ;
145+ archString += '*) echo "unsupported architecture"; exit 1 ;; \\' ;
127146
128147 initialFormat = initialFormat . replace ( / " \$ \{ D E B _ A R C H \[ @ \] \} " / s, archString ) ;
129148 } else if ( template === templates . debian ) {
130149 let archString = '' ;
131- if ( arches . includes ( 'amd64' ) ) archString += `amd64) ARCH='x64';; \\\n `
132- if ( arches . includes ( 'ppc64le' ) ) archString += `ppc64el) ARCH='ppc64le';; \\\n `
133- if ( arches . includes ( 's390x' ) ) archString += `s390x) ARCH='s390x';; \\\n `
134- if ( arches . includes ( 'arm64v8' ) ) archString += `arm64) ARCH='arm64';; \\\n `
135- if ( arches . includes ( 'arm32v7' ) ) archString += `armhf) ARCH='armv7l';; \\\n `
136- archString += '*) echo "unsupported architecture"; exit 1 ;; \\'
150+ if ( arches . includes ( 'amd64' ) ) archString += `amd64) ARCH='x64';; \\\n ` ;
151+ if ( arches . includes ( 'ppc64le' ) )
152+ archString += `ppc64el) ARCH='ppc64le';; \\\n ` ;
153+ if ( arches . includes ( 's390x' ) )
154+ archString += `s390x) ARCH='s390x';; \\\n ` ;
155+ if ( arches . includes ( 'arm64v8' ) )
156+ archString += `arm64) ARCH='arm64';; \\\n ` ;
157+ if ( arches . includes ( 'arm32v7' ) )
158+ archString += `armhf) ARCH='armv7l';; \\\n ` ;
159+ archString += '*) echo "unsupported architecture"; exit 1 ;; \\' ;
137160
138161 initialFormat = initialFormat . replace ( / " \$ \{ D E B _ A R C H \[ @ \] \} " / s, archString ) ;
139162 }
0 commit comments