Skip to content

Commit

Permalink
fix: change version flag to semver
Browse files Browse the repository at this point in the history
* To avoid conflicting issues with react-native cli
* Also added change logs and made tests build before running
  • Loading branch information
Grohden committed Oct 22, 2020
1 parent 3ac1353 commit 0c5b789
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 1.1.0

Changed `--version` flag to `--semver` due to issues with react-native
cli with that argument
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Options:
--type [major|minor|patch] SemVer release type, optional if --skip-semver-for all is passed
--skip-semver-for [android|ios|all] Skips bump SemVer for specified platform
--skip-code-for [android|ios|all] Skips bump version codes for specified platform
--version Pass release version if known. Overwrites calculated SemVer. Optional.
--semver Pass release version if known. Overwrites calculated SemVer. Optional.
-h, --help output usage information
```
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "react-native-cli-bump-version",
"version": "1.0.4",
"version": "1.1.0",
"main": "src/index.ts",
"types": "lib/index.d.ts",
"license": "MIT",
"scripts": {
"test": "jest",
"test": "yarn build && jest",
"build": "tsc",
"prepare": "rm -rf ./lib/* && yarn build && yarn test"
"prepare": "rm -rf ./lib/* && yarn test"
},
"dependencies": {
"chalk": "3.0.0",
Expand Down
5 changes: 2 additions & 3 deletions react-native.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module.exports = {
commands: [{
name: 'bump-version',
func: (_, config, args) => {

if (args.skipCodeFor === 'all' && args.skipSemverFor === 'all') {
// https://i.kym-cdn.com/photos/images/newsfeed/001/240/075/90f.png
console.log('My work here is done.')
Expand All @@ -23,7 +22,7 @@ module.exports = {
pbxprojPath: config.project.ios.pbxprojPath,
buildGradlePath: appGradlePath,
type: args.type,
version: args.version,
semver: args.semver,
skipCodeFor: args.skipCodeFor
? args.skipCodeFor.split(' ')
: [],
Expand All @@ -38,7 +37,7 @@ module.exports = {
description: 'SemVer release type, optional if --skip-semver-for all is passed'
},
{
name: '--version [String]',
name: '--semver [String]',
description: 'Pass release version if known. Overwrites calculated SemVer. Optional.'
},
{
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Platforms = 'android' | 'ios' | 'all'

type Configs = {
type?: SemVer
version?: string
semver?: string
skipSemVerFor: Platforms[]
skipCodeFor: Platforms[]
root: string
Expand Down Expand Up @@ -273,9 +273,9 @@ export class ProjectFilesManager {
* This executes changes but don't actually write anything to fs
*/
dryRun() {
const { type, version, skipSemVerFor, skipCodeFor } = this.configs
const { type, semver, skipSemVerFor, skipCodeFor } = this.configs
const current = this.packageJSON.getVersion()
const next = version ?? incrementSemVer(current, type ?? 'minor')
const next = semver ?? incrementSemVer(current, type ?? 'minor')

if (!skipCodeFor.includes('all')) {
this.bumpCodes()
Expand Down
6 changes: 3 additions & 3 deletions tests/android.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const path = require('path')
const { ProjectFilesManager } = require('../lib/index')

const makeDefaultManager = ({
version,
semver,
type = 'minor',
skipSemVerFor = 'ios',
skipCodeFor = 'ios',
gradleFileName = 'double.gradle'
} = {}) => new ProjectFilesManager({
type,
version,
semver,
skipSemVerFor,
skipCodeFor,
root: path.join(__dirname, 'android'),
Expand All @@ -36,7 +36,7 @@ test('preserve quotes style', () => {
})

test('direct set semver string', () => {
const manager = makeDefaultManager({ version: '1.1.2' }).dryRun()
const manager = makeDefaultManager({ semver: '1.1.2' }).dryRun()

expect(manager.buildGradle.content).toMatchSnapshot()
expect(manager.packageJSON.content).toMatchSnapshot()
Expand Down
6 changes: 3 additions & 3 deletions tests/ios.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ const path = require('path')
const { ProjectFilesManager } = require('../lib/index')

const makeDefaultManager = ({
version,
semver,
type = 'minor',
skipSemVerFor = 'android',
skipCodeFor = 'android',
pbxFileName = 'project.pbxproj'
} = {}) => new ProjectFilesManager({
type,
version,
semver,
skipSemVerFor,
skipCodeFor,
root: path.join(__dirname, 'ios'),
Expand All @@ -30,7 +30,7 @@ test('skip semVer when asked', () => {
})

test('direct set semver string', () => {
const manager = makeDefaultManager({ version: '1.1.2' }).dryRun()
const manager = makeDefaultManager({ semver: '1.1.2' }).dryRun()

expect(manager.pbx.content).toMatchSnapshot()
expect(manager.packageJSON.content).toMatchSnapshot()
Expand Down

0 comments on commit 0c5b789

Please sign in to comment.