|
2 | 2 |
|
3 | 3 | /* eslint-disable no-for-of-loops/no-for-of-loops */ |
4 | 4 |
|
5 | | -const crypto = require('node:crypto'); |
6 | 5 | const fs = require('fs'); |
7 | 6 | const fse = require('fs-extra'); |
8 | 7 | const {spawnSync} = require('child_process'); |
@@ -41,7 +40,10 @@ if (dateString.startsWith("'")) { |
41 | 40 |
|
42 | 41 | // Build the artifacts using a placeholder React version. We'll then do a string |
43 | 42 | // replace to swap it with the correct version per release channel. |
44 | | -const PLACEHOLDER_REACT_VERSION = ReactVersion + '-PLACEHOLDER'; |
| 43 | +// |
| 44 | +// The placeholder version is the same format that the "next" channel uses |
| 45 | +const PLACEHOLDER_REACT_VERSION = |
| 46 | + ReactVersion + '-' + nextChannelLabel + '-' + sha + '-' + dateString; |
45 | 47 |
|
46 | 48 | // TODO: We should inject the React version using a build-time parameter |
47 | 49 | // instead of overwriting the source files. |
@@ -158,27 +160,19 @@ function processStable(buildDir) { |
158 | 160 | } |
159 | 161 |
|
160 | 162 | if (fs.existsSync(buildDir + '/facebook-www')) { |
161 | | - const hash = crypto.createHash('sha1'); |
162 | | - for (const fileName of fs.readdirSync(buildDir + '/facebook-www').sort()) { |
| 163 | + for (const fileName of fs.readdirSync(buildDir + '/facebook-www')) { |
163 | 164 | const filePath = buildDir + '/facebook-www/' + fileName; |
164 | 165 | const stats = fs.statSync(filePath); |
165 | 166 | if (!stats.isDirectory()) { |
166 | | - hash.update(fs.readFileSync(filePath)); |
167 | 167 | fs.renameSync(filePath, filePath.replace('.js', '.classic.js')); |
168 | 168 | } |
169 | 169 | } |
170 | 170 | updatePlaceholderReactVersionInCompiledArtifacts( |
171 | 171 | buildDir + '/facebook-www', |
172 | | - ReactVersion + '-www-classic-' + hash.digest('hex').slice(0, 8) |
| 172 | + ReactVersion + '-www-classic-' + sha + '-' + dateString |
173 | 173 | ); |
174 | 174 | } |
175 | 175 |
|
176 | | - // Update remaining placeholders with next channel version |
177 | | - updatePlaceholderReactVersionInCompiledArtifacts( |
178 | | - buildDir, |
179 | | - ReactVersion + '-' + canaryChannelLabel + '-' + sha + '-' + dateString |
180 | | - ); |
181 | | - |
182 | 176 | if (fs.existsSync(buildDir + '/sizes')) { |
183 | 177 | fs.renameSync(buildDir + '/sizes', buildDir + '/sizes-stable'); |
184 | 178 | } |
@@ -212,27 +206,19 @@ function processExperimental(buildDir, version) { |
212 | 206 | } |
213 | 207 |
|
214 | 208 | if (fs.existsSync(buildDir + '/facebook-www')) { |
215 | | - const hash = crypto.createHash('sha1'); |
216 | | - for (const fileName of fs.readdirSync(buildDir + '/facebook-www').sort()) { |
| 209 | + for (const fileName of fs.readdirSync(buildDir + '/facebook-www')) { |
217 | 210 | const filePath = buildDir + '/facebook-www/' + fileName; |
218 | 211 | const stats = fs.statSync(filePath); |
219 | 212 | if (!stats.isDirectory()) { |
220 | | - hash.update(fs.readFileSync(filePath)); |
221 | 213 | fs.renameSync(filePath, filePath.replace('.js', '.modern.js')); |
222 | 214 | } |
223 | 215 | } |
224 | 216 | updatePlaceholderReactVersionInCompiledArtifacts( |
225 | 217 | buildDir + '/facebook-www', |
226 | | - ReactVersion + '-www-modern-' + hash.digest('hex').slice(0, 8) |
| 218 | + ReactVersion + '-www-modern-' + sha + '-' + dateString |
227 | 219 | ); |
228 | 220 | } |
229 | 221 |
|
230 | | - // Update remaining placeholders with canary channel version |
231 | | - updatePlaceholderReactVersionInCompiledArtifacts( |
232 | | - buildDir, |
233 | | - ReactVersion + '-' + canaryChannelLabel + '-' + sha + '-' + dateString |
234 | | - ); |
235 | | - |
236 | 222 | if (fs.existsSync(buildDir + '/sizes')) { |
237 | 223 | fs.renameSync(buildDir + '/sizes', buildDir + '/sizes-experimental'); |
238 | 224 | } |
|
0 commit comments