From 0c5b78946bceced8aad5d5e739e494ce22e1b937 Mon Sep 17 00:00:00 2001 From: Gabriel Rohden Date: Wed, 21 Oct 2020 23:35:56 -0300 Subject: [PATCH] fix: change version flag to semver * To avoid conflicting issues with react-native cli * Also added change logs and made tests build before running --- CHANGELOG.md | 4 ++++ README.md | 2 +- package.json | 6 +++--- react-native.config.js | 5 ++--- src/index.ts | 6 +++--- tests/android.test.js | 6 +++--- tests/ios.test.js | 6 +++--- 7 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7731f6c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# 1.1.0 + +Changed `--version` flag to `--semver` due to issues with react-native +cli with that argument diff --git a/README.md b/README.md index 09011dc..1b354b9 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/package.json b/package.json index e8d0f61..70ac84c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/react-native.config.js b/react-native.config.js index 465a188..2d471d7 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -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.') @@ -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(' ') : [], @@ -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.' }, { diff --git a/src/index.ts b/src/index.ts index 58a84b6..906180f 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 + semver?: string skipSemVerFor: Platforms[] skipCodeFor: Platforms[] root: string @@ -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() diff --git a/tests/android.test.js b/tests/android.test.js index dbd66c8..60fa30b 100644 --- a/tests/android.test.js +++ b/tests/android.test.js @@ -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'), @@ -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() diff --git a/tests/ios.test.js b/tests/ios.test.js index 918581d..7063875 100644 --- a/tests/ios.test.js +++ b/tests/ios.test.js @@ -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'), @@ -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()