mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5f60ad65ca
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45184 This is a follow-up to D59055522. > NOTE:This diff will be followed up by a merge of the set-rn-version script into set-version. (I had considered a rename to version-rn-artifacts, intentionally keeping this script separate and distinct from a future [lerna version + this script] setup — however the current UX and confusion with this naming would be too confusing. It can move into a util 👍🏻.) - Rename `set-rn-version` to `set-rn-artifacts-version` (more accurate). - Mark this script as deprecated. - For now, there are too many references to this script in CI test jobs to refactor away this entry point, so I am avoiding this — these should later be standardised to `set-version`. Changelog: [Internal] Reviewed By: christophpurrer Differential Revision: D59058085 fbshipit-source-id: 4123ac73b5c7a2e07a1d1b6da61e0ad94fc31f84
110 lines
2.5 KiB
JavaScript
110 lines
2.5 KiB
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow strict-local
|
|
* @format
|
|
* @oncall react-native
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
/*::
|
|
import type {PackageJson} from '../utils/monorepo';
|
|
*/
|
|
|
|
const {
|
|
getPackages,
|
|
getWorkspaceRoot,
|
|
updatePackageJson,
|
|
} = require('../utils/monorepo');
|
|
const {updateReactNativeArtifacts} = require('./set-rn-artifacts-version');
|
|
const {parseArgs} = require('@pkgjs/parseargs');
|
|
|
|
const config = {
|
|
allowPositionals: true,
|
|
options: {
|
|
skipReactNativeVersion: {
|
|
type: 'boolean',
|
|
},
|
|
help: {type: 'boolean'},
|
|
},
|
|
};
|
|
|
|
async function main() {
|
|
const {
|
|
positionals: [version],
|
|
values: {help, skipReactNativeVersion},
|
|
} = parseArgs(config);
|
|
|
|
if (help) {
|
|
console.log(`
|
|
Usage: node ./scripts/releases/set-version.js <version> [OPTIONS]
|
|
|
|
Bump the version of all packages.
|
|
|
|
- Updates package.json metadata for all workspaces and the project root.
|
|
- Updates relevant native files in the react-native package.
|
|
|
|
If --skipReactNativeVersion is passed, the react-native package version will
|
|
be left unmodified as "1000.0.0" (special static version on main), and native
|
|
files will not be touched.
|
|
|
|
Options:
|
|
--skipReactNativeVersion Don't update the version of the react-native
|
|
package (default: false).
|
|
`);
|
|
return;
|
|
}
|
|
|
|
if (version == null) {
|
|
throw new Error('Missing version argument');
|
|
}
|
|
|
|
await setVersion(version, skipReactNativeVersion);
|
|
}
|
|
|
|
async function setVersion(
|
|
version /*: string */,
|
|
skipReactNativeVersion /*: boolean */ = false,
|
|
) /*: Promise<void> */ {
|
|
const packages = await getPackages({
|
|
includePrivate: true,
|
|
includeReactNative: true,
|
|
});
|
|
const newPackageVersions = Object.fromEntries(
|
|
Object.keys(packages).map(packageName => [
|
|
packageName,
|
|
packageName === 'react-native' && skipReactNativeVersion
|
|
? '1000.0.0'
|
|
: version,
|
|
]),
|
|
);
|
|
|
|
const packagesToUpdate = [
|
|
await getWorkspaceRoot(),
|
|
...Object.values(packages),
|
|
];
|
|
|
|
// Update all workspace packages
|
|
await Promise.all(
|
|
packagesToUpdate.map(pkg => updatePackageJson(pkg, newPackageVersions)),
|
|
);
|
|
|
|
// Update generated files in packages/react-native/
|
|
if (!skipReactNativeVersion) {
|
|
await updateReactNativeArtifacts(version);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
setVersion,
|
|
};
|
|
|
|
if (require.main === module) {
|
|
// eslint-disable-next-line no-void
|
|
void main();
|
|
}
|