update-stable-version-numbers.js — react Source File
Architecture documentation for update-stable-version-numbers.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
#!/usr/bin/env node
'use strict';
const clear = require('clear');
const {readFileSync, writeFileSync} = require('fs');
const {readJson, writeJson} = require('fs-extra');
const {join, relative} = require('path');
const {confirm, execRead, printDiff} = require('../utils');
const theme = require('../theme');
const run = async ({cwd, packages, version, ci}, versionsMap) => {
const nodeModulesPath = join(cwd, 'build/node_modules');
// Cache all package JSONs for easy lookup below.
const sourcePackageJSONs = new Map();
for (let i = 0; i < packages.length; i++) {
const packageName = packages[i];
const sourcePackageJSON = await readJson(
join(cwd, 'packages', packageName, 'package.json')
);
sourcePackageJSONs.set(packageName, sourcePackageJSON);
}
const updateDependencies = async (targetPackageJSON, key) => {
const targetDependencies = targetPackageJSON[key];
if (targetDependencies) {
const sourceDependencies = sourcePackageJSONs.get(targetPackageJSON.name)[
key
];
for (let i = 0; i < packages.length; i++) {
const dependencyName = packages[i];
const targetDependency = targetDependencies[dependencyName];
if (targetDependency) {
// For example, say we're updating react-dom's dependency on scheduler.
// We compare source packages to determine what the new scheduler dependency constraint should be.
// To do this, we look at both the local version of the scheduler (e.g. 0.11.0),
// and the dependency constraint in the local version of react-dom (e.g. scheduler@^0.11.0).
const sourceDependencyVersion =
sourcePackageJSONs.get(dependencyName).version;
const sourceDependencyConstraint = sourceDependencies[dependencyName];
// If the source dependency's version and the constraint match,
// we will need to update the constraint to point at the dependency's new release version,
// (e.g. scheduler@^0.11.0 becomes scheduler@^0.12.0 when we release scheduler 0.12.0).
// Otherwise we leave the constraint alone (e.g. react@^16.0.0 doesn't change between releases).
// Note that in both cases, we must update the target package JSON,
// since "next" releases are all locked to the version (e.g. 0.0.0-0e526bcec-20210202).
if (
sourceDependencyVersion ===
sourceDependencyConstraint.replace(/^[\^\~]/, '')
) {
targetDependencies[dependencyName] =
sourceDependencyConstraint.replace(
sourceDependencyVersion,
versionsMap.get(dependencyName)
);
} else {
// ... (108 more lines)
Domain
Subdomains
Functions
Source
Frequently Asked Questions
What does update-stable-version-numbers.js do?
update-stable-version-numbers.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What functions are defined in update-stable-version-numbers.js?
update-stable-version-numbers.js defines 1 function(s): run.
Where is update-stable-version-numbers.js in the architecture?
update-stable-version-numbers.js is located at scripts/release/prepare-release-from-npm-commands/update-stable-version-numbers.js (domain: BabelCompiler, subdomain: Optimization, directory: scripts/release/prepare-release-from-npm-commands).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free