mirror of
https://github.com/facebook/react-native.git
synced 2024-11-22 06:29:46 +00:00
Refactor publish-npm args to be more safe (#39532)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39532 This change refactors how we handle the parameters of publish-npm so we can only accept the build types we actually support. ## Changelog: [Internal] - Make publish-npm args stricter Reviewed By: cortinico Differential Revision: D49374263 fbshipit-source-id: a17ddecc0ddcb30858dd0baaab8990ae765d304f
This commit is contained in:
parent
eaec4f7fda
commit
780567c727
@ -1224,7 +1224,7 @@ jobs:
|
||||
else
|
||||
export ORG_GRADLE_PROJECT_reactNativeArchitectures="armeabi-v7a,arm64-v8a,x86,x86_64"
|
||||
fi
|
||||
node ./scripts/publish-npm.js --<< parameters.release_type >>
|
||||
node ./scripts/publish-npm.js -t << parameters.release_type >>
|
||||
|
||||
- run:
|
||||
name: Zip Maven Artifacts from /tmp/maven-local
|
||||
|
@ -62,6 +62,14 @@ describe('publish-npm', () => {
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
describe('publish-npm.js', () => {
|
||||
it('Fails when invalid build type is passed', () => {
|
||||
expect(() => publishNpm('invalid')).toThrowError(
|
||||
'Unsupported build type: invalid',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('dry-run', () => {
|
||||
it('should set version and not publish', () => {
|
||||
publishNpm('dry-run');
|
||||
|
@ -45,28 +45,15 @@ const yargs = require('yargs');
|
||||
|
||||
if (require.main === module) {
|
||||
const argv = yargs
|
||||
.option('n', {
|
||||
alias: 'nightly',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
})
|
||||
.option('d', {
|
||||
alias: 'dry-run',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
})
|
||||
.option('r', {
|
||||
alias: 'release',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
.option('t', {
|
||||
alias: 'builtType',
|
||||
describe: 'The type of build you want to perform.',
|
||||
choices: ['dry-run', 'nightly', 'release', 'prealpha'],
|
||||
default: 'dry-run',
|
||||
})
|
||||
.strict().argv;
|
||||
|
||||
const buildType = argv.release
|
||||
? 'release'
|
||||
: argv.nightly
|
||||
? 'nightly'
|
||||
: 'dry-run';
|
||||
const buildType = argv.builtType;
|
||||
|
||||
publishNpm(buildType);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user