From 70ab844ab745962a8a598b3e097343fcd354f74b Mon Sep 17 00:00:00 2001 From: Andrei Popov Date: Sun, 6 Sep 2020 11:14:00 +0200 Subject: [PATCH 1/3] feat: Add ability to add Version manually User Story: As a developer I want to be able to define the Version manually. Background: If for example you use CLI on CI level, you probably use Semantic Release (https://www.npmjs.com/package/semantic-release) to define the Versions of the Application. In this case, the versions created by react-native-cli-bump-version and Semantic Release will be different. To be able to use it with SR it will be good to add additional parameter to this CLI --- src/index.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 854ae8b..a2aecc3 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,12 @@ 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, version: string | null, type: SemVer | undefined) => { + const [major, minor, patch] = parseSemVer(current) + + if(version) { + return version + } if (type === 'major') { return [major + 1, 0, 0].join('.') @@ -272,9 +277,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 = incrementSemVer(current, version, type ?? 'minor') if (!skipCodeFor.includes('all')) { this.bumpCodes() From 03303e65af705be80680fb64b3feca908c60d670 Mon Sep 17 00:00:00 2001 From: Andrei Popov Date: Sun, 6 Sep 2020 21:41:11 +0200 Subject: [PATCH 2/3] fix: review --- src/index.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index a2aecc3..58a84b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ export type Platforms = 'android' | 'ios' | 'all' type Configs = { type?: SemVer - version: string + version?: string skipSemVerFor: Platforms[] skipCodeFor: Platforms[] root: string @@ -31,12 +31,8 @@ const matchFirst = curry((reg: RegExp, value: string) => { return first }) -const incrementSemVer = (current: string, version: string | null, type: SemVer | undefined) => { +const incrementSemVer = (current: string, type: SemVer | undefined) => { const [major, minor, patch] = parseSemVer(current) - - if(version) { - return version - } if (type === 'major') { return [major + 1, 0, 0].join('.') @@ -279,7 +275,7 @@ export class ProjectFilesManager { dryRun() { const { type, version, skipSemVerFor, skipCodeFor } = this.configs const current = this.packageJSON.getVersion() - const next = incrementSemVer(current, version, type ?? 'minor') + const next = version ?? incrementSemVer(current, type ?? 'minor') if (!skipCodeFor.includes('all')) { this.bumpCodes() From a4e412c2f017973212469fde74b91a202fc53dae Mon Sep 17 00:00:00 2001 From: Andrei Popov Date: Sun, 6 Sep 2020 21:46:31 +0200 Subject: [PATCH 3/3] fix: read Version from config --- react-native.config.js | 5 +++++ 1 file changed, 5 insertions(+) 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'