Skip to content

Commit

Permalink
feat: add first draft of standard version for expo
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Jan 6, 2020
0 parents commit 7f821d2
Show file tree
Hide file tree
Showing 37 changed files with 6,584 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
indent_style = tab
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
indent_style = space
24 changes: 24 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
'jest',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
env: {
node: true,
'jest/globals': true,
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
'@typescript-eslint/indent': ['error', 'tab'],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-use-before-define': 'off',
},
};
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# project
/build

# dependencies
/node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock

# testing
/.jest
/coverage

# misc
.DS_Store
.vscode
22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# The MIT License (MIT)

Copyright (c) 2019-present Cedric van Putten <me@bycedric.com>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<div align="center">
<h1>Standard Version Expo</h1>
<p>Automatic <a href="https://github.com/expo/expo">Expo</a> versioning with <a href="https://github.com/conventional-changelog/standard-version">Standard Version</a></p>
<sup>
<a href="https://github.com/bycedric/standard-version-expo/releases">
<img src="https://img.shields.io/github/release/byCedric/standard-version-expo/all.svg" alt="releases" />
</a>
<a href="https://travis-ci.com/byCedric/standard-version-expo">
<img src="https://img.shields.io/travis/com/byCedric/standard-version-expo/master.svg" alt="builds" />
</a>
</sup>
<br />
<br />
<pre>npm i -D standard-version@next standard-version-expo</pre>
</div>

## What's inside?

Standard version is a tool to automate the versioning of your project using semver and [conventional commits][link-conventional].
This package includes some helpful bumpers to update the Expo manifest automatically.
With these bumpers you can automate updating the [`version`][link-expo-version], [Android `versionCode`][link-expo-android], and/or [iOS `buildNumber`][link-expo-ios].
Combining this, you should be able to automate versioning of your app by using a single command.

## Getting started

It's recommended to install both Standard Version and this package as `devDependency`.
You can do this with the npm command listed above.
After you installed the packages, we need to [configure Standard Version using any of the configuration methods listed here][link-standard-version].
Here is an example configuration that updates the version, Android `versionCode`, and iOS `buildNumber` using the recommended approaches.

```json
// .versionrc
{
"bumpFiles": [
{
"filename": "app.json",
"updater": "node_modules/standard-version-expo"
},
{
"filename": "app.json",
"updater": "node_modules/standard-version-expo/android"
},
{
"filename": "app.json",
"updater": "node_modules/standard-version-expo/ios"
}
]
}
```

To test if your configuration works as expected, you can run standard version in dry mode.
This shows you what will happen, without actually applying the versions and tags.

```bash
$ npx standard-version --dry-mode
```

## Usage

Standard Version's version bumpers are pretty simple; each bump only updates a single file using a single updater.
This package exposes multiple kinds of updaters, for different areas of the manifest.
You can "compose" your own set of `bumpFiles` entries to suit your needs.

updater | example | description
--- | --- | ---
`<root>` | `3.2.1` | _alias of `manifest/version`_
`manifest` | `3.2.1` | _alias of `manifest/version`_
`manifest/version` | `3.2.1` | Replace `expo.version` with the exact calculated semver. (**recommended**)
`android` | `360030201` | _alias of `android/code`_
`android/code` | `350010000` | Replace `expo.android.versionCode` with the [method described by Maxi Rosson][link-version-code]. (**recommended**)
`android/increment` | `8` | Replace `expo.android.versionCode` with an incremental version.
`ios` | `3.2.1` | _alias of `ios/version`_
`ios/code` | `360030201` | Replace `expo.ios.buildNumber` with the [method described by Maxi Rosson][link-version-code].
`ios/increment` | `9` | Replace `expo.ios.buildNumber` with an incremental version.
`ios/version` | `3.2.1` | Replace `expo.ios.buildNumber` with the exact calculated semver. (**recommended**)

### Version code

Semver is one of the most popular versioning methods; it generates a string with a syntax that even humans can read.
Unfortunately, in Android, we are limited to use a numeric `versionCode` as version.
The version code uses an approach from [Maxi Rosson][link-version-code] to calculate a numeric value from semver.
It's a deterministic solution that removes some of the ambiguity of incremental build numbers, like security-patching old versions.

> The method initially uses the Android minimum API level. For Expo, we replaced this with the major Expo SDK version.
<div align="center">
<br />
<br />
with :heart: <strong>byCedric</strong>
<br />
</div>

[link-conventional]: https://www.conventionalcommits.org/en/v1.0.0/
[link-expo-android]: https://docs.expo.io/versions/latest/workflow/configuration#android
[link-expo-ios]: https://docs.expo.io/versions/latest/workflow/configuration#ios
[link-expo-version]: https://docs.expo.io/versions/latest/workflow/configuration#version
[link-standard-version]: https://github.com/conventional-changelog/standard-version#configuration
[link-version-code]: https://medium.com/@maxirosson/versioning-android-apps-d6ec171cfd82
1 change: 1 addition & 0 deletions android/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/android-code');
1 change: 1 addition & 0 deletions android/increment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/android-increment');
1 change: 1 addition & 0 deletions android/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/android-code');
1 change: 1 addition & 0 deletions ios/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/ios-version');
1 change: 1 addition & 0 deletions ios/ios-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/ios-code');
1 change: 1 addition & 0 deletions ios/ios-increment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/ios-increment');
1 change: 1 addition & 0 deletions ios/ios-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/ios-version');
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
preset: 'ts-jest',
};
1 change: 1 addition & 0 deletions manifest/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/manifest-version');
1 change: 1 addition & 0 deletions manifest/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../build/bumpers/manifest-version');

0 comments on commit 7f821d2

Please sign in to comment.