Merge pull request #642 from bitjson/feature/external-services-via-env-var

Configure external services via environment variable
This commit is contained in:
Jason Dreyzehner 2016-10-22 11:04:05 -04:00 committed by GitHub
commit b3bfc1e6df
4 changed files with 43 additions and 14 deletions

View file

@ -133,6 +133,18 @@ npm run final:desktop
On success, the Chrome extension will be located at: `browser-extensions/chrome/copay-chrome-extension`. To install it go to `chrome://extensions/` in your browser and ensure you have the 'developer mode' option enabled in the settings. Then click on "Load unpacked chrome extension" and choose the directory mentioned above. On success, the Chrome extension will be located at: `browser-extensions/chrome/copay-chrome-extension`. To install it go to `chrome://extensions/` in your browser and ensure you have the 'developer mode' option enabled in the settings. Then click on "Load unpacked chrome extension" and choose the directory mentioned above.
## Configuration
### Enable External Services
To enable external services, set the `COPAY_EXTERNAL_SERVICES_CONFIG_LOCATION` or `BITPAY_EXTERNAL_SERVICES_CONFIG_LOCATION` environment variable to the location of your configuration before running the `apply` task.
```sh
COPAY_EXTERNAL_SERVICES_CONFIG_LOCATION="~/.copay/externalServices.json" npm run apply:copay
# or
BITPAY_EXTERNAL_SERVICES_CONFIG_LOCATION="~/.bitpay/externalServices.json" npm run apply:bitpay
```
## About Copay ## About Copay
### General ### General

View file

@ -5,7 +5,7 @@
// //
var templates = { var templates = {
'package.json': '/', 'package-template.json': '/',
'index.html': 'www/', 'index.html': 'www/',
'Makefile': 'cordova/', 'Makefile': 'cordova/',
'ProjectMakefile': 'cordova/', 'ProjectMakefile': 'cordova/',
@ -64,6 +64,8 @@ Object.keys(templates).forEach(function(k) {
if(k === 'config-template.xml'){ if(k === 'config-template.xml'){
k = 'config.xml'; k = 'config.xml';
} else if (k === 'package-template.json') {
k = 'package.json';
} }
if (!fs.existsSync('../' + targetDir)){ if (!fs.existsSync('../' + targetDir)){
@ -80,9 +82,22 @@ fs.writeFileSync('../appConfig.json', configBlob, 'utf8');
//////////////// ////////////////
var externalServices; var externalServices;
try { try {
console.log('Copying ' + configDir + '/externalServices.json' + ' to root'); var confName = configDir.toUpperCase();
externalServices = fs.readFileSync(configDir + '/externalServices.json', 'utf8'); var externalServicesConf = confName + '_EXTERNAL_SERVICES_CONFIG_LOCATION';
console.log('Looking for ' + externalServicesConf + '...');
if(typeof process.env[externalServicesConf] !== 'undefined') {
var location = process.env[externalServicesConf]
if(location.charAt(0) === '~') {
location = location.replace(/^\~/, process.env.HOME || process.env.USERPROFILE);
}
console.log('Found at: ' + location);
console.log('Copying ' + location + ' to root');
externalServices = fs.readFileSync(location, 'utf8');
} else {
throw externalServicesConf + ' environment variable not set.';
}
} catch(err) { } catch(err) {
console.log(err);
externalServices = '{}'; externalServices = '{}';
console.log('External services not configured'); console.log('External services not configured');
} }

View file

@ -79,8 +79,7 @@
"shelljs": "^0.3.0" "shelljs": "^0.3.0"
}, },
"scripts": { "scripts": {
"postinstall": "bower install && npm run postapply", "postinstall": "bower install",
"postapply": "echo && echo \"To finish, choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.\" && echo",
"start": "npm run build:www && ionic serve --nolivereload --nogulp -s", "start": "npm run build:www && ionic serve --nolivereload --nogulp -s",
"start:ios": "npm run build:www && npm run build:ios && npm run open:ios", "start:ios": "npm run build:www && npm run build:ios && npm run open:ios",
"start:android": "npm run build:www && npm run build:android && npm run run:android", "start:android": "npm run build:www && npm run build:android && npm run run:android",
@ -102,8 +101,8 @@
"run:android": "cordova run android --device", "run:android": "cordova run android --device",
"log:android": "adb logcat | grep chromium", "log:android": "adb logcat | grep chromium",
"sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play && ../android-sdk-macosx/build-tools/21.1.1/zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk", "sign:android": "rm -f platforms/android/build/outputs/apk/android-release-signed-aligned.apk; jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore ../copay.keystore -signedjar platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-unsigned.apk copay_play && ../android-sdk-macosx/build-tools/21.1.1/zipalign -v 4 platforms/android/build/outputs/apk/android-release-signed.apk platforms/android/build/outputs/apk/android-release-signed-aligned.apk",
"apply:copay": "cd app-template && node apply.js copay && cordova prepare", "apply:copay": "npm i && cd app-template && node apply.js copay && cordova prepare",
"apply:bitpay": "cd app-template && node apply.js bitpay && cordova prepare", "apply:bitpay": "npm i && cd app-template && node apply.js bitpay && cordova prepare",
"test": "./node_modules/.bin/grunt test-coveralls", "test": "./node_modules/.bin/grunt test-coveralls",
"clean": "trash platforms && trash plugins && cordova prepare", "clean": "trash platforms && trash plugins && cordova prepare",
"unstage-package": "git reset package.json", "unstage-package": "git reset package.json",

View file

@ -2,19 +2,22 @@
"name": "distribution-not-selected", "name": "distribution-not-selected",
"description": "Choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.", "description": "Choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.",
"primary-package-json": "See the tempate in app-template/package.json", "primary-package-json": "See the tempate in app-template/package.json",
"pre-commit": "unstage-package",
"changes": "changes to this file can be commited with the --no-verify option",
"scripts": { "scripts": {
"postinstall": "npm run apply:copay", "postinstall": "npm run apply:copay && echo && echo \"Repo configured for standard Copay distribution. To switch to the BitPay distribution, run 'npm run apply:bitpay'.\" && echo",
"start": "echo && echo \"Choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.\" && echo", "start": "echo && echo \"Choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.\" && echo",
"preapply": "npm i fs-extra", "apply:copay": "npm i fs-extra@0.30 && cd app-template && node apply.js copay && cd .. && npm i",
"apply:copay": "npm run preapply && cd app-template && node apply.js copay && cd .. && npm i && npm run postapply", "apply:bitpay": "npm i fs-extra@0.30 && cd app-template && node apply.js bitpay && cd .. && npm i",
"apply:bitpay": "npm run preapply && cd app-template && node apply.js bitpay && cd .. && npm i && npm run postapply", "unstage-package": "git reset package.json",
"clean-all": "git clean -dfx" "clean-all": "git clean -dfx"
}, },
"dependencies": {
"pre-commit": "^1.1.3"
},
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"url": "git://github.com/bitpay/copay.git",
"url": "git://github.com/bitpay/bitpay-wallet.git", "url": "git://github.com/bitpay/bitpay-wallet.git",
"type": "git" "type": "git"
}, }
"changes": "changes to this file can be commited with the --no-verify option"
} }