diff --git a/README.md b/README.md index 2183d7209..ee4d4007f 100644 --- a/README.md +++ b/README.md @@ -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. +## 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 ### General diff --git a/app-template/apply.js b/app-template/apply.js index 191f2b571..2f0015e34 100755 --- a/app-template/apply.js +++ b/app-template/apply.js @@ -5,7 +5,7 @@ // var templates = { - 'package.json': '/', + 'package-template.json': '/', 'index.html': 'www/', 'Makefile': 'cordova/', 'ProjectMakefile': 'cordova/', @@ -64,6 +64,8 @@ Object.keys(templates).forEach(function(k) { if(k === 'config-template.xml'){ k = 'config.xml'; + } else if (k === 'package-template.json') { + k = 'package.json'; } if (!fs.existsSync('../' + targetDir)){ @@ -80,9 +82,22 @@ fs.writeFileSync('../appConfig.json', configBlob, 'utf8'); //////////////// var externalServices; try { - console.log('Copying ' + configDir + '/externalServices.json' + ' to root'); - externalServices = fs.readFileSync(configDir + '/externalServices.json', 'utf8'); + var confName = configDir.toUpperCase(); + 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) { + console.log(err); externalServices = '{}'; console.log('External services not configured'); } diff --git a/app-template/package.json b/app-template/package-template.json similarity index 91% rename from app-template/package.json rename to app-template/package-template.json index 1a56073d7..5ff4ab91e 100644 --- a/app-template/package.json +++ b/app-template/package-template.json @@ -79,8 +79,7 @@ "shelljs": "^0.3.0" }, "scripts": { - "postinstall": "bower install && npm run postapply", - "postapply": "echo && echo \"To finish, choose a distribution by running 'npm run apply:copay' or 'npm run apply:bitpay'.\" && echo", + "postinstall": "bower install", "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:android": "npm run build:www && npm run build:android && npm run run:android", @@ -102,8 +101,8 @@ "run:android": "cordova run android --device", "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", - "apply:copay": "cd app-template && node apply.js copay && cordova prepare", - "apply:bitpay": "cd app-template && node apply.js bitpay && cordova prepare", + "apply:copay": "npm i && cd app-template && node apply.js copay && cordova prepare", + "apply:bitpay": "npm i && cd app-template && node apply.js bitpay && cordova prepare", "test": "./node_modules/.bin/grunt test-coveralls", "clean": "trash platforms && trash plugins && cordova prepare", "unstage-package": "git reset package.json", diff --git a/package.json b/package.json index 9e43644ba..31c9fb832 100644 --- a/package.json +++ b/package.json @@ -2,19 +2,22 @@ "name": "distribution-not-selected", "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", + "pre-commit": "unstage-package", + "changes": "changes to this file can be commited with the --no-verify option", "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", - "preapply": "npm i fs-extra", - "apply:copay": "npm run preapply && cd app-template && node apply.js copay && cd .. && npm i && npm run postapply", - "apply:bitpay": "npm run preapply && cd app-template && node apply.js bitpay && cd .. && npm i && npm run postapply", + "apply:copay": "npm i fs-extra@0.30 && cd app-template && node apply.js copay && cd .. && npm i", + "apply:bitpay": "npm i fs-extra@0.30 && cd app-template && node apply.js bitpay && cd .. && npm i", + "unstage-package": "git reset package.json", "clean-all": "git clean -dfx" }, + "dependencies": { + "pre-commit": "^1.1.3" + }, "license": "MIT", "repository": { - "url": "git://github.com/bitpay/copay.git", "url": "git://github.com/bitpay/bitpay-wallet.git", "type": "git" - }, - "changes": "changes to this file can be commited with the --no-verify option" + } }