Skip to content

Commit

Permalink
build(cordova): simplify build, use cordova in a more standard way
Browse files Browse the repository at this point in the history
  • Loading branch information
bitjson committed Oct 6, 2016
1 parent 4ccf10d commit d5e6b8f
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 133 deletions.
26 changes: 13 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ i18n/crowdin_api_key.txt
src/js/translations.js

# cordova
plugins
platforms
cordova/project-*/*
cordova/*.keystore

Expand Down Expand Up @@ -89,13 +91,15 @@ Session.vim
src/sass/*.css
.sass-cache

# copay public
public/css/*
public/lib/*
public/js/*
public/fonts
# copay www
www/css/*
www/lib/*
www/js/*
www/fonts

## templates
/config.xml
/ionic.config.json
/appConfig.json
externalServices.json
cordova/Makefile
Expand All @@ -104,8 +108,8 @@ app-template/bpapp
cordova/ProjectMakefile
cordova/config.xml
cordova/wp/Package.appxmanifest
public/img/logo-negative.svg
public/img/logo.svg
www/img/logo-negative.svg
www/img/logo.svg
src/js/appConfig.js
src/js/externalServices.js

Expand All @@ -116,8 +120,8 @@ app-template/bpapp
cordova/ProjectMakefile
cordova/config.xml
cordova/wp/Package.appxmanifest
public/img/logo-negative.svg
public/img/logo.svg
www/img/logo-negative.svg
www/img/logo.svg
src/js/appConfig.js

cordova/android/res/
Expand All @@ -127,7 +131,3 @@ cordova/wp/*.jpg
cordova/ios/splash/
cordova/ios/icons/
cordova/project/




48 changes: 27 additions & 21 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,23 @@ module.exports = function(grunt) {
wpcopy: {
command: 'make -C cordova wp-copy',
},
ios-debug: {
command: 'npm run build:ios',
},
ios: {
command: 'make -C cordova ios',
command: 'npm run build:ios-release',
},
xcode: {
command: 'open cordova/project-ios/platforms/ios/*.xcodeproj',
command: 'npm run open:ios',
},
android-debug: {
command: 'npm run build:android',
},
android: {
command: 'make -C cordova android',
command: 'npm run build:android-release',
},
androidrun: {
command: 'make -C cordova androidrun',
command: 'npm run run:android && npm run log:android',
},
androidbuild: {
command: 'cd cordova/project && cordova build android --release',
Expand Down Expand Up @@ -125,7 +131,7 @@ module.exports = function(grunt) {
'angular-pbkdf2/angular-pbkdf2.js',
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'
],
dest: 'public/lib/angular.js'
dest: 'www/lib/angular.js'
},
js: {
src: [
Expand All @@ -144,11 +150,11 @@ module.exports = function(grunt) {
'bower_components/trezor-connect/login.js',
'node_modules/cordova-plugin-qrscanner/dist/cordova-plugin-qrscanner-lib.min.js'
],
dest: 'public/js/copay.js'
dest: 'www/js/copay.js'
},
css: {
src: ['src/sass/*.css', 'src/css/*.css'],
dest: 'public/css/copay.css'
dest: 'www/css/copay.css'
}
},
uglify: {
Expand All @@ -157,17 +163,17 @@ module.exports = function(grunt) {
},
prod: {
files: {
'public/js/copay.js': ['public/js/copay.js'],
'public/lib/angular.js': ['public/lib/angular.js']
'www/js/copay.js': ['www/js/copay.js'],
'www/lib/angular.js': ['www/lib/angular.js']
}
}
},
nggettext_extract: {
pot: {
files: {
'i18n/po/template.pot': [
'public/index.html',
'public/views/**/*.html',
'www/index.html',
'www/views/**/*.html',
'src/js/routes.js',
'src/js/services/*.js',
'src/js/controllers/**/*.js'
Expand All @@ -190,19 +196,19 @@ module.exports = function(grunt) {
expand: true,
flatten: true,
src: 'bower_components/ionic/release/fonts/ionicons.*',
dest: 'public/fonts/'
dest: 'www/fonts/'
},
ionic_js: {
expand: true,
flatten: true,
src: 'bower_components/ionic/release/js/ionic.bundle.min.js',
dest: 'public/lib/'
dest: 'www/lib/'
},
linux: {
files: [{
expand: true,
cwd: 'webkitbuilds/',
src: ['.desktop', '../public/img/icons/favicon.ico', '../public/img/icons/icon-256.png'],
src: ['.desktop', '../www/img/icons/favicon.ico', '../www/img/icons/icon-256.png'],
dest: 'webkitbuilds/Copay/linux64/',
flatten: true,
filter: 'isFile'
Expand All @@ -224,10 +230,10 @@ module.exports = function(grunt) {
platforms: ['win64', 'osx64', 'linux64'],
buildDir: './webkitbuilds',
version: '0.16.0',
macIcns: './public/img/icons/icon.icns',
exeIco: './public/img/icons/icon.ico'
macIcns: './www/img/icons/icon.icns',
exeIco: './www/img/icons/icon.ico'
},
src: ['./package.json', './public/**/*']
src: ['./package.json', './www/**/*']
},
compress: {
linux: {
Expand Down Expand Up @@ -261,12 +267,12 @@ module.exports = function(grunt) {
grunt.registerTask('wp', ['prod', 'exec:wp']);
grunt.registerTask('wp-copy', ['default', 'exec:wpcopy']);
grunt.registerTask('wp-init', ['default', 'exec:wpinit']);
grunt.registerTask('ios', ['prod', 'exec:ios']);
grunt.registerTask('ios-debug', ['default', 'exec:ios']);
grunt.registerTask('ios', ['exec:ios']);
grunt.registerTask('ios-debug', ['exec:ios-debug']);
grunt.registerTask('ios-run', ['exec:xcode']);
grunt.registerTask('cordovaclean', ['exec:cordovaclean']);
grunt.registerTask('android-debug', ['default', 'exec:android', 'exec:androidrun']);
grunt.registerTask('android', ['prod', 'exec:android']);
grunt.registerTask('android-debug', ['exec:android-debug', 'exec:androidrun']);
grunt.registerTask('android', ['exec:android-release']);
grunt.registerTask('android-release', ['prod', 'exec:android', 'exec:androidsign']);
grunt.registerTask('desktopsign', ['exec:desktopsign', 'exec:desktopverify']);

Expand Down
1 change: 0 additions & 1 deletion Makefile

This file was deleted.

29 changes: 2 additions & 27 deletions app-template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,11 @@ all:
clean:
rm -Rf $(WORKDIR)*


$(WORKDIR)android $(WORKDIR)ios: config.xml
cordova create $@ com.bitpay.*BUNDLENAME* "*USERVISIBLENAME*" || echo "Project Path Existed"
cp ProjectMakefile $@/Makefile
rm -r $@/www && ln -sF ../../public $@/www
cp config.xml $@/config.xml
make -C $@ $(subst $(WORKDIR),, $@)

ios: $(WORKDIR)ios
make -C $(WORKDIR)ios build-ios

android: project-android
mkdir -p android/platforms/android/res/xml/
mkdir -p $(WORKDIR)android/scripts
cp -R scripts/* $(WORKDIR)android/scripts
cp android/build-extras.gradle $(WORKDIR)android/platforms/android/build-extras.gradle
cp android/project.properties $(WORKDIR)android/platforms/android/project.properties
cp -R android/res/* $(WORKDIR)android/platforms/android/res
make -C $(WORKDIR)android build-android

wp-init: config.xml
cordova create $(WORKDIR)$@ com.bitpay.*BUNDLENAME* "*USERVISIBLENAME*" || echo "Project Path Existed"
cp ProjectMakefile $(WORKDIR)$@/Makefile
mkdir -p $(WORKDIR)$@/www
cp -Rf ../public/* $(WORKDIR)$@/www
cp -Rf ../www/* $(WORKDIR)$@/www
cp config.xml $(WORKDIR)$@/config.xml
make -C $(WORKDIR)$@ $(subst $(WORKDIR),, $(WORKDIR)$@)

Expand All @@ -43,10 +23,5 @@ wp-copy:
cp -rvf wp/SplashScreenImage.jpg $(WORKDIR)wp/platforms/wp8/
cp -rvf wp/ApplicationIcon.png $(WORKDIR)wp/platforms/wp8/
cp -rvf wp/Background.png $(WORKDIR)wp/platforms/wp8/
cp -rvf ../public/* $(WORKDIR)wp/www
cp -rvf ../www/* $(WORKDIR)wp/www
wp/fix-svg.sh


androidrun:
make -C $(WORKDIR)android run
adb logcat | grep chromium
12 changes: 2 additions & 10 deletions app-template/ProjectMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@ plugins:
cordova prepare
rm -rf platforms/android/res/values-es

ios-platform android-platform wp8-platform:
wp8-platform:
cordova platforms add $(subst -platform,,$@) || echo "Platform already added"

ios: ios-platform plugins
cordova plugin add https://github.com/tjwoon/csZBar.git
cordova plugin add [email protected]

android: android-platform plugins
cordova plugin add https://github.com/jrontend/phonegap-plugin-barcodescanner
cordova plugin add [email protected]

wp: wp8-platform plugins
cordova plugin add https://github.com/jrontend/phonegap-plugin-barcodescanner

build-ios build-android build-wp8:
build-wp8:
cordova build $(subst build-,,$@)

run:
Expand Down
8 changes: 6 additions & 2 deletions app-template/apply.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
//

var templates = {
'package.json': '/',
'Makefile': 'cordova/',
'ProjectMakefile': 'cordova/',
'config.xml': 'cordova/',
'config-template.xml': '/',
'ionic.config.json': '/',
'Package.appxmanifest': 'cordova/wp/',
'.desktop': 'webkitbuilds/',
'setup-win.iss': 'webkitbuilds/',
Expand Down Expand Up @@ -60,6 +61,9 @@ Object.keys(templates).forEach(function(k) {
process.exit(1);
}

if(k === 'config-template.xml'){
k = 'config.xml';
}
fs.writeFileSync('../' + targetDir + k, content, 'utf8');
});

Expand Down Expand Up @@ -113,7 +117,7 @@ function copyDir(from, to, cb) {
}


copyDir(configDir + '/img/', '../public/img/', function() {
copyDir(configDir + '/img/', '../www/img/', function() {
copyDir(configDir + '/androidRes/', '../cordova/android/res/', function() {
copyDir(configDir + '/iosIcons/', '../cordova/ios/icons/', function() {
copyDir(configDir + '/iosSplash/', '../cordova/ios/splash/', function() {
Expand Down
82 changes: 82 additions & 0 deletions app-template/config-template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.bitpay.*BUNDLENAME*"
version="*VERSION*"
android-versionCode="*ANDROIDVERSION*"
ios-CFBundleVersion="*VERSION*">
<name>*USERVISIBLENAME*</name>
<description>
*PURPOSELINE*
</description>
<author email="[email protected]" href="*URL*">
BitPay Inc.
</author>
<content src="index.html" />
<access origin="*" />
<preference name="AndroidPersistentFileLocation" value="Internal" />
<preference name="iosPersistentFileLocation" value="Library" />
<preference name="DisallowOverscroll" value="true"/>
<preference name="HideKeyboardFormAccessoryBar" value="true"/>
<preference name="SplashScreen" value="copayscreen" />
<preference name="ShowSplashScreenSpinner" value="false" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="FadeSplashScreen" value="true" />
<preference name="FadeSplashScreenDuration" value="1" />
<preference name="StatusBarOverlaysWebView" value="true" />
<preference name="StatusBarBackgroundColor" value="#1e3186" />
<preference name="StatusBarStyle" value="lightcontent" />
<preference name="BackupWebStorage" value="none"/>
<preference name="windows-target-version" value="8.1"/>
<preference name="Orientation" value="default" />

<!-- Plugins -->
<plugin name="cordova-plugin-globalization" spec="~1.0.4" />
<plugin name="cordova.plugins.diagnostic" spec="~3.2.1" />
<plugin name="cordova-plugin-splashscreen" spec="~4.0.0" />
<plugin name="cordova-plugin-statusbar" spec="~2.2.0" />
<plugin name="cordova-plugin-inappbrowser" spec="~1.5.0" />
<plugin name="cordova-plugin-x-toast" spec="~2.5.2" />
<plugin name="com.verso.cordova.clipboard" spec="https://github.com/VersoSolutions/CordovaClipboard" />
<plugin name="cordova-plugin-x-socialsharing" spec="https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git" />
<plugin name="cordova-plugin-spinner-dialog" spec="~1.3.1" />
<plugin name="cordova-plugin-dialogs" spec="~1.3.0" />
<plugin name="cordova-plugin-network-information" spec="~1.3.0" />
<plugin name="cordova-plugin-console" spec="~1.0.4" />
<plugin name="cordova-plugin-uniquedeviceid" spec="~1.3.2" />
<plugin name="cordova-plugin-file" spec="~4.3.0" />
<plugin name="cordova-plugin-touch-id" spec="~3.2.0" />
<plugin name="cordova-plugin-transport-security" spec="~0.1.2" />
<plugin name="cordova-ios-requires-fullscreen" spec="~0.0.2" />
<plugin name="cordova-plugin-android-fingerprint-auth" spec="~0.2.0" />
<plugin name="cordova-plugin-screen-orientation" spec="~1.4.2" />
<plugin name="ionic-plugin-keyboard" spec="~2.2.1" />
<plugin name="cordova-plugin-whitelist" spec="~1.3.0" />
<plugin name="cordova-plugin-wkwebview-engine" spec="https://github.com/driftyco/cordova-plugin-wkwebview-engine.git" />
<plugin name="cordova-plugin-qrscanner" spec="~2.4.0" />
<plugin name="cordova-plugin-customurlscheme" spec="~4.2.0">
<variable name="URL_SCHEME" value="UNUSED" />
</plugin>

<!-- Supported Platforms -->
<engine name="ios" spec="~4.2.1" />
<engine name="android" spec="~5.2.2" />
<engine name="wp8" spec="~3.8.2" />

<!-- Platform Specific Settings -->
<platform name="ios">
<plugin name="phonegap-plugin-push" spec="1.5.3" />
<!-- <hook type="after_prepare" src="util/hooks/ios/add-custom-urls-to-plist.js" />
<hook type="after_prepare" src="util/hooks/ios/add-uistatusbarhidden-to-plist.js" /> -->
</platform>

<platform name="android">
<hook type="after_prepare" src="util/hooks/android/add-custom-urls-to-android-manifest.js" />
<hook type="after_prepare" src="util/hooks/android/prohibit-cloud-backups-in-android-manifest.js" />
<!-- https://github.com/phonegap/phonegap-plugin-push/issues/424 -->
<plugin name="phonegap-plugin-push" spec="1.2.3" />
</platform>

<platform name="wp8">
<plugin name="phonegap-plugin-barcodescanner" spec="https://github.com/jrontend/phonegap-plugin-barcodescanner" />
</platform>

</widget>
4 changes: 4 additions & 0 deletions app-template/ionic.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "*USERVISIBLENAME*",
"app_id": "com.bitpay.*BUNDLENAME*"
}
4 changes: 2 additions & 2 deletions app-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
"multisignature",
"bitcore"
],
"main": "public/index.html",
"main": "www/index.html",
"window": {
"title": "*USERVISIBLENAME* - *PURPOSELINE*",
"icon": "./public/img/icons/icon-256.png",
"icon": "./www/img/icons/icon-256.png",
"toolbar": false,
"show": true,
"visible": true,
Expand Down
2 changes: 1 addition & 1 deletion app-template/setup-win.iss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{
[Files]
Source: "*PACKAGENAME*\win64\*PACKAGENAME*.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "*PACKAGENAME*\win64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "../public/img/icons/favicon.ico"; DestDir: "{app}"; DestName: "icon.ico"; Flags: ignoreversion
Source: "../www/img/icons/favicon.ico"; DestDir: "{app}"; DestName: "icon.ico"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Expand Down
Loading

0 comments on commit d5e6b8f

Please sign in to comment.