MCPcopy Index your code
hub / github.com/react/react / updateVersionsForNext

Function updateVersionsForNext

scripts/release/utils.js:207–256  ·  view source on GitHub ↗
(cwd, reactVersion, version)

Source from the content-addressed store, hash-verified

205// It is based on the version of React in the local package.json (e.g. 16.12.0-01974a867-20200129).
206// Both numbers will be replaced if the "next" release is promoted to a stable release.
207const updateVersionsForNext = async (cwd, reactVersion, version) => {
208 const isExperimental = reactVersion.includes('experimental');
209 const packages = getPublicPackages(isExperimental);
210 const packagesDir = join(cwd, 'packages');
211
212 // Update the shared React version source file.
213 // This is bundled into built renderers.
214 // The promote script will replace this with a final version later.
215 const sourceReactVersionPath = join(cwd, 'packages/shared/ReactVersion.js');
216 const sourceReactVersion = readFileSync(
217 sourceReactVersionPath,
218 'utf8'
219 ).replace(/export default '[^']+';/, `export default '${reactVersion}';`);
220 writeFileSync(sourceReactVersionPath, sourceReactVersion);
221
222 // Update the root package.json.
223 // This is required to pass a later version check script.
224 {
225 const packageJSONPath = join(cwd, 'package.json');
226 const packageJSON = await readJson(packageJSONPath);
227 packageJSON.version = version;
228 await writeJson(packageJSONPath, packageJSON, {spaces: 2});
229 }
230
231 for (let i = 0; i < packages.length; i++) {
232 const packageName = packages[i];
233 const packagePath = join(packagesDir, packageName);
234
235 // Update version numbers in package JSONs
236 const packageJSONPath = join(packagePath, 'package.json');
237 const packageJSON = await readJson(packageJSONPath);
238 packageJSON.version = version;
239
240 // Also update inter-package dependencies.
241 // Next releases always have exact version matches.
242 // The promote script may later relax these (e.g. "^x.x.x") based on source package JSONs.
243 const {dependencies, peerDependencies} = packageJSON;
244 for (let j = 0; j < packages.length; j++) {
245 const dependencyName = packages[j];
246 if (dependencies && dependencies[dependencyName]) {
247 dependencies[dependencyName] = version;
248 }
249 if (peerDependencies && peerDependencies[dependencyName]) {
250 peerDependencies[dependencyName] = version;
251 }
252 }
253
254 await writeJson(packageJSONPath, packageJSON, {spaces: 2});
255 }
256};
257
258module.exports = {
259 addDefaultParamValue,

Callers 1

Calls 1

getPublicPackagesFunction · 0.85

Tested by

no test coverage detected