diff --git a/react-native.config.js b/react-native.config.js index 1d5bc96..465a188 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -23,6 +23,7 @@ module.exports = { pbxprojPath: config.project.ios.pbxprojPath, buildGradlePath: appGradlePath, type: args.type, + version: args.version, skipCodeFor: args.skipCodeFor ? args.skipCodeFor.split(' ') : [], @@ -36,6 +37,10 @@ module.exports = { name: '--type [major|minor|patch]', description: 'SemVer release type, optional if --skip-semver-for all is passed' }, + { + name: '--version [String]', + description: 'Pass release version if known. Overwrites calculated SemVer. Optional.' + }, { name: '--skip-semver-for [android|ios|all]', description: 'Skips bump SemVer for specified platform' diff --git a/src/index.ts b/src/index.ts index 854ae8b..58a84b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ export type Platforms = 'android' | 'ios' | 'all' type Configs = { type?: SemVer + version?: string skipSemVerFor: Platforms[] skipCodeFor: Platforms[] root: string @@ -30,8 +31,8 @@ const matchFirst = curry((reg: RegExp, value: string) => { return first }) -const incrementSemVer = (version: string, type: SemVer | undefined) => { - const [major, minor, patch] = parseSemVer(version) +const incrementSemVer = (current: string, type: SemVer | undefined) => { + const [major, minor, patch] = parseSemVer(current) if (type === 'major') { return [major + 1, 0, 0].join('.') @@ -272,9 +273,9 @@ export class ProjectFilesManager { * This executes changes but don't actually write anything to fs */ dryRun() { - const { type, skipSemVerFor, skipCodeFor } = this.configs + const { type, version, skipSemVerFor, skipCodeFor } = this.configs const current = this.packageJSON.getVersion() - const next = incrementSemVer(current, type ?? 'minor') + const next = version ?? incrementSemVer(current, type ?? 'minor') if (!skipCodeFor.includes('all')) { this.bumpCodes()