Skip to content

Commit 608c154

Browse files
feat: Add ability to add Version manually (#3)
Added a flag to be able to direct set semVer string on package json and platform files
1 parent 4c5a63c commit 608c154

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

react-native.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = {
2323
pbxprojPath: config.project.ios.pbxprojPath,
2424
buildGradlePath: appGradlePath,
2525
type: args.type,
26+
version: args.version,
2627
skipCodeFor: args.skipCodeFor
2728
? args.skipCodeFor.split(' ')
2829
: [],
@@ -36,6 +37,10 @@ module.exports = {
3637
name: '--type [major|minor|patch]',
3738
description: 'SemVer release type, optional if --skip-semver-for all is passed'
3839
},
40+
{
41+
name: '--version [String]',
42+
description: 'Pass release version if known. Overwrites calculated SemVer. Optional.'
43+
},
3944
{
4045
name: '--skip-semver-for [android|ios|all]',
4146
description: 'Skips bump SemVer for specified platform'

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type Platforms = 'android' | 'ios' | 'all'
88

99
type Configs = {
1010
type?: SemVer
11+
version?: string
1112
skipSemVerFor: Platforms[]
1213
skipCodeFor: Platforms[]
1314
root: string
@@ -30,8 +31,8 @@ const matchFirst = curry((reg: RegExp, value: string) => {
3031
return first
3132
})
3233

33-
const incrementSemVer = (version: string, type: SemVer | undefined) => {
34-
const [major, minor, patch] = parseSemVer(version)
34+
const incrementSemVer = (current: string, type: SemVer | undefined) => {
35+
const [major, minor, patch] = parseSemVer(current)
3536

3637
if (type === 'major') {
3738
return [major + 1, 0, 0].join('.')
@@ -272,9 +273,9 @@ export class ProjectFilesManager {
272273
* This executes changes but don't actually write anything to fs
273274
*/
274275
dryRun() {
275-
const { type, skipSemVerFor, skipCodeFor } = this.configs
276+
const { type, version, skipSemVerFor, skipCodeFor } = this.configs
276277
const current = this.packageJSON.getVersion()
277-
const next = incrementSemVer(current, type ?? 'minor')
278+
const next = version ?? incrementSemVer(current, type ?? 'minor')
278279

279280
if (!skipCodeFor.includes('all')) {
280281
this.bumpCodes()

0 commit comments

Comments
 (0)