mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
7819fef988
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37555 Changelog: [Internal] Refactor some npm commands and centralize in npm-utils. For now, centralize `getPackageVersionStrByTag` and `publishPackage` and update: 1. `publish-npm` to use utilities. This is how we publish `react-native` for commitlies, releases, and nightlies 2. Update `find-and-publish-all-bumped-packages.js` where we publish our monorepo dependencies Reviewed By: cortinico, hoxyq Differential Revision: D46131120 fbshipit-source-id: e6020058eb94b4f8d95068b8cd87cc765711be5b
38 lines
932 B
JavaScript
38 lines
932 B
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`);
|
|
|
|
if (result.code) {
|
|
throw `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);
|
|
}
|
|
|
|
module.exports = {
|
|
getPackageVersionStrByTag,
|
|
publishPackage,
|
|
};
|