mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fd9e295bef
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37556 Changelog: [Internal] Before making this change, we need to publish `nightly` versions of all existing monorepo dependencies. Reviewed By: hoxyq Differential Revision: D46117197 fbshipit-source-id: bcf6364e068579e63ca19e8161dcd32de4353e56
65 lines
1.5 KiB
JavaScript
65 lines
1.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.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const {exec} = require('shelljs');
|
|
|
|
function getPackageVersionStrByTag(packageName, tag) {
|
|
const result = exec(`npm view ${packageName}@${tag} version`, {silent: true});
|
|
|
|
if (result.code) {
|
|
throw new Error(`Failed to get ${tag} version from npm\n${result.stderr}`);
|
|
}
|
|
return result.stdout.trim();
|
|
}
|
|
|
|
function publishPackage(packagePath, packageOptions, execOptions) {
|
|
const {tag, otp} = packageOptions;
|
|
const tagFlag = tag ? ` --tag ${tag}` : '';
|
|
const otpFlag = otp ? ` --otp ${otp}` : '';
|
|
const options = execOptions
|
|
? {...execOptions, cwd: packagePath}
|
|
: {cwd: packagePath};
|
|
|
|
return exec(`npm publish${tagFlag}${otpFlag}`, options);
|
|
}
|
|
|
|
function diffPackages(packageSpecA, packageSpecB, options) {
|
|
const result = exec(
|
|
`npm diff --diff=${packageSpecA} --diff=${packageSpecB} --diff-name-only`,
|
|
options,
|
|
);
|
|
|
|
if (result.code) {
|
|
throw new Error(
|
|
`Failed to diff ${packageSpecA} and ${packageSpecB}\n${result.stderr}`,
|
|
);
|
|
}
|
|
|
|
return result.stdout;
|
|
}
|
|
|
|
function pack(packagePath) {
|
|
const result = exec('npm pack', {
|
|
cwd: packagePath,
|
|
});
|
|
|
|
if (result.code !== 0) {
|
|
throw new Error(result.stderr);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
getPackageVersionStrByTag,
|
|
publishPackage,
|
|
diffPackages,
|
|
pack,
|
|
};
|