This script takes a Cordova 5+ project folder and create a Phonegap Build compliant .zip file and upload it to Phonegap Build. Really useful into a Continuos Integration build system.
npm install -g cordova-to-phonegap-build
You can import this script inside your NodeJS application:
First you need it installed locally:
npm install cordova-to-phonegap-build
then you can invoke it within you application
const cdvPgb = require('cordova-to-phonegap-build')
cdvPgb.upload(process.cwd(), '$yourPhonegapToken', 'resources')
Script needs the Phonegap Token loaded as Enviromental Variable in order to connect to Phonegap Build, you can retrieve it into Account settings on Phonegap Build site.
export PGToken="$yourPhonegapToken"
tobuild $cordovaProjectDirectory -f resources
The script creates a .zip file to upload to PhoneGap: Build with "config.xml" and the "www" folder
Load the config.xml from a different location and override the one on main folder.
Indicate any other folder to be added to the uploaded file. Required if you use splash/icons external resources folder. Could be used more times as needed. folderName is relative to the project path.
i.e.: tobuild --folder resources --folder fonts
You could use your token as params instead of environment variable.
Token could be obtained also from NPM config.
i.e.: npm config set pgToken "$yourPhonegapToken"
will save it in you ~/.npmrc
and you do not need to use in your command or you can save it in your npm package.json config
"config": {
"token": "$yourPhonegapToken"
}
Before update the app on PG:B a version check is made: if the version of the uploaded is less or equals than the existing one than an exception is throwed.
Keeps process running after upload to look at the current status of the build for every platforms.
After a build succeed it starts to download into current folder
Defines a path where to download the build
Specifies the max amount of minutes to wait for download or lookup. Defaults to 10, if reached exits with an error.
Keys options are supposed to be defined inside package.json config
prop in that form:
"config": {
"keys": {
"android": {
"name": "Foo",
"password": "keyBar",
},
"ios": {
"name": "Faa",
"password": "bor",
}
}
}
Keys can also be defined by CLI params that override package.json entries.
Key name of Android and ios key on Phonegap:Build. It could also be defined as NPM config.
Password for keystore of the Android keystore and iOS certificate.