Skip to content

Commit

Permalink
Merge pull request #1 from Grohden/bugfix/ios-marketing-version
Browse files Browse the repository at this point in the history
Fix issue with MARKETING_VERSION being updated only at one place
  • Loading branch information
Grohden committed Mar 27, 2020
2 parents 88565e0 + eb02014 commit 3b8be35
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-cli-bump-version",
"version": "1.0.0",
"version": "1.0.1",
"main": "src/index.ts",
"types": "lib/index.d.ts",
"license": "MIT",
Expand All @@ -14,6 +14,7 @@
},
"devDependencies": {
"@types/node": "^13.9.1",
"@types/ramda": "^0.27.0",
"ts-node": "8.6.2",
"typescript": "3.8.3"
}
Expand Down
13 changes: 8 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import fs from 'fs'
import path from 'path'
import chalk from 'chalk'
// @ts-ignore
import { pipe, match, split, curry, map, replace } from 'ramda'
import { pipe, split, curry, map, replace } from 'ramda'

export type SemVer = 'major' | 'minor' | 'patch'
export type Platforms = 'android' | 'ios' | 'all'
Expand All @@ -26,7 +25,11 @@ const parseDecimal = (it: string) => parseInt(it, 10)

const parseSemVer = pipe(split('.'), map(parseDecimal))

const matchFirst = curry((reg: RegExp, value: string) => match(reg, value)[1])
const matchFirst = curry((reg: RegExp, value: string) => {
const [, first] = ([] as string[]).concat(reg.exec(value)!)

return first
})

const incrementSemVer = (version: string, type: SemVer | undefined) => {
const [major, minor, patch] = parseSemVer(version)
Expand Down Expand Up @@ -72,7 +75,7 @@ abstract class BaseFileManager {
class PBXManager extends BaseFileManager {
bumpProjectVersion() {
const currentFile = this.read()
const codeRegex = /CURRENT_PROJECT_VERSION = (\d+);/
const codeRegex = /CURRENT_PROJECT_VERSION = (\d+);/g
const currentCode = pipe(
matchFirst(codeRegex),
parseDecimal
Expand All @@ -93,7 +96,7 @@ class PBXManager extends BaseFileManager {

setMarketingVersion(nextVersion: string) {
const currentFile = this.read()
const versionRegex = /MARKETING_VERSION = (.*);/
const versionRegex = /MARKETING_VERSION = (.*);/g
const currentVersion = matchFirst(versionRegex, currentFile)

this.content = replace(
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.9.1.tgz#96f606f8cd67fb018847d9b61e93997dabdefc72"
integrity sha512-E6M6N0blf/jiZx8Q3nb0vNaswQeEyn0XlupO+xN6DtJ6r6IT4nXrTry7zhIfYvFCl3/8Cu6WIysmUBKiqV0bqQ==

"@types/ramda@^0.27.0":
version "0.27.0"
resolved "https://registry.yarnpkg.com/@types/ramda/-/ramda-0.27.0.tgz#e6df564a5f9637c93e708b4fdb948c6a5457ecad"
integrity sha512-/Iw94cBUhU8RS6HvFs0WNrxLrOHS4VdCbaWWemrqaXM4GqNYdw/wtWQXk8nAjMj4YC4EXMumbYGO+D9yhACCLQ==
dependencies:
ts-toolbelt "^6.3.3"

ansi-styles@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
Expand Down Expand Up @@ -101,6 +108,11 @@ ts-node@8.6.2:
source-map-support "^0.5.6"
yn "3.1.1"

ts-toolbelt@^6.3.3:
version "6.3.6"
resolved "https://registry.yarnpkg.com/ts-toolbelt/-/ts-toolbelt-6.3.6.tgz#2bde29106c013ed520c32f30e1248daf8fd4f5f9"
integrity sha512-eVzym+LyQodOCfyVyQDQ6FGYbO2Xf9Nc4dGLRKlKSUpAs+8qQWHG+grDiA3ciEuNPNZ0qJnNIYkdqBW1rCWuUA==

typescript@3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
Expand Down

0 comments on commit 3b8be35

Please sign in to comment.