Git Product home page Git Product logo

capacitor-sync-version's Introduction

capacitor-sync-version

npm package version PRs Welcome

Syncing version from package.json to target platform in the capacitor projects.

Currently supported platforms are: [android, ios].

Installation

npm add --save-dev capacitor-sync-version

Additional preparation for Android only

Step 1. Create a file named app.properties in ./android/app/, then add the following properties:

versionName=0.0.1
versionCode=1

These properties will be updated when capacitor-sync-version running.

Step 2. Adjust codes to referrence these properties in ./android/app/build.gradle.

  • Add the following codes after apply plugin: 'com.android.application':

    def appProperties = new Properties();
    file("app.properties").withInputStream { appProperties.load(it) }
    
  • Update properties in defaultConfig {} block:

    defaultConfig {
      versionCode appProperties.getProperty("versionCode").toInteger()
      versionName appProperties.getProperty("versionName")
    }
    

Usage

The simplest way to use capacitor-sync-version is running it in the capacitor hooks.

Just adding the following script to package.json:

{
  "scripts": {
    "capacitor:copy:before": "capacitor-sync-version"
  }
}

In this way, capacitor-sync-version will be run before capacitor copy command, e.g., npx cap copy.

Other ways to run capacitor-sync-version are:

# sync for android only
capacitor-sync-version android

# sync for both android and ios
capacitor-sync-version android ios

Licence

MIT

capacitor-sync-version's People

Contributors

arzyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

iantearle trancee

capacitor-sync-version's Issues

Do we ignore "npx cap sync"?

Hey, this plugin works well! thx

Just want to affirm, that in using this plugin, you would always use capacitor-sync-version android ios instead of the regular Capacitor sync command (which in my setup, is npx cap sync)?

I didn't see an explicit statement on this in the readme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.