{"id":3865,"url":"https://github.com/szhigunov/react-native-npm-version","last_synced_at":"2026-02-19T07:13:55.630Z","repository":{"id":80484768,"uuid":"82671164","full_name":"szhigunov/react-native-npm-version","owner":"szhigunov","description":"Example of React-Native application with version from package.json and npm version bump.","archived":false,"fork":false,"pushed_at":"2017-06-21T13:07:07.000Z","size":110,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-15T00:20:06.342Z","etag":null,"topics":["example","react-native","versioning"],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/szhigunov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-02-21T11:17:40.000Z","updated_at":"2023-11-15T18:35:30.000Z","dependencies_parsed_at":"2023-03-11T08:45:13.025Z","dependency_job_id":null,"html_url":"https://github.com/szhigunov/react-native-npm-version","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szhigunov%2Freact-native-npm-version","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szhigunov%2Freact-native-npm-version/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szhigunov%2Freact-native-npm-version/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szhigunov%2Freact-native-npm-version/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/szhigunov","download_url":"https://codeload.github.com/szhigunov/react-native-npm-version/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228248551,"owners_count":17891447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example","react-native","versioning"],"created_at":"2024-01-05T20:16:53.780Z","updated_at":"2026-02-19T07:13:55.603Z","avatar_url":"https://github.com/szhigunov.png","language":"Objective-C","funding_links":[],"categories":["Articles"],"sub_categories":["Assorted"],"readme":"# react-native-npm-version\n## Example of React-Native application with version from package.json and npm version bump.\n\nWhy not to simpify cross-platform app version increase flow, with only ```npm version``` command ?\n\nThis repository provides an sample application, with integrated solution to minimize amount of monkey job with handling `react-native` applications.\n-----\nRealization consist of few parts:\n* some script `./scripts/version.js` which increase version in iOS project file `Info.plist`.\n* custom npm scripts `version`.\n* extended `./android/build.gradle`\n* modified `./android/app/build.gradle`:\n-----\n\n### To use those solution in your project,\n1. add `version` npm script to `scripts` section in your `package.json`: \n```json\n{\n  \"scripts\": {\n    \"version\": \"node ./scripts/version.js \u0026\u0026 [[ $(git status --porcelain -z | gawk '/version.json/ \u0026\u0026 /Info.plist/' ) ]] \u0026\u0026 git add version.json ios/\"\n  }\n```\n2. copy `./scripts/version.js` to your project root.\n3. extend `./android/app/build.gradle` and `./android/build.gradle` with the following samples:\n\n`./android/app/build.gradle`\n```gradle\n/* ... */\nandroid {\n  /* ... */\n    defaultConfig {\n        // Replace lines with your versionCode and versionName  with two lines below\n        versionCode versionMajor * 10000 + versionMinor * 100 + versionPatch\n        versionName \"${versionMajor}.${versionMinor}.${versionPatch}\"\n        /* ... */\n    }\n  /* ... */\n}\n```\n\n`./android/build.gradle`\n```gradle\nsubprojects {\n    ext {\n        def npmVersion = getNpmVersionArray()\n        versionMajor = npmVersion[0]\n        versionMinor = npmVersion[1]\n        versionPatch = npmVersion[2]\n    }\n}\n\ndef getNpmVersion() {\n    def inputFile = new File(\"../package.json\")\n    def packageJson = new JsonSlurper().parseText(inputFile.text)\n    return packageJson[\"version\"]\n}\n\ndef getNpmVersionArray() { // major [0], minor [1], patch [2]\n    def (major, minor, patch) = getNpmVersion().tokenize('.')\n    return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[]\n}\n```\n\n-----\n\nBased on solution by @AndrewJack [https://github.com/AndrewJack/versioning-react-native-app](https://github.com/AndrewJack/versioning-react-native-app).\nSee [Medium post](https://medium.com/@andr3wjack/versioning-react-native-apps-407469707661)\n\n## Requirements\n\n- ``` gawk ``` for macOS - used in `npm run version`\n- ``` watchman ``` for macOS\n- ``` node ``` higher than **4.2.0**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszhigunov%2Freact-native-npm-version","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fszhigunov%2Freact-native-npm-version","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fszhigunov%2Freact-native-npm-version/lists"}