From f7d2a077236eefb9c2c7669ad084798ceaaf4dd2 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 14:56:53 -0400 Subject: [PATCH 01/31] chore(dependencies): add gulp --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c55b0068..5ce33a48 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "xml2js": "^0.4.16" }, "devDependencies": { + "gulp": "^3.9.1", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", "plist": "^1.2.0", From 3ac1e2e2b33ee028ac51eea64392a8d3585593b5 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 16:23:05 -0400 Subject: [PATCH 02/31] refactor(plugin.xml): generate ios references based on build target --- gulpfile.js | 49 ++++++++++++++++++++ plugin.template.xml | 108 ++++++++++++++++++++++++++++++++++++++++++++ plugin.xml | 38 ++++++++-------- 3 files changed, 176 insertions(+), 19 deletions(-) create mode 100644 gulpfile.js create mode 100644 plugin.template.xml diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..8303c81d --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,49 @@ +var gulp = require('gulp'); +var fs = require('fs'); + +//generate plugin.xml for use as a cordova plugin +//here we explode the contents of the frameworks +gulp.task('gen-npm-plugin-xml', function(){ + var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); + + var files = []; + var root = 'src/ios/dependencies/'; + files = files.concat(emitFiles(root + 'Fabric/')); + files = files.concat(emitFiles(root + 'Branch-SDK/')); + files = files.concat(emitFiles(root + 'Branch-SDK/Requests/')); + + var newLineIndent = '\n '; + xml = xml.replace('', newLineIndent + + files.join(newLineIndent)); + + fs.writeFileSync('plugin.xml', xml); +}); + +//generate plugin.xml for local development +//here we reference the frameworks instead of all the files directly +gulp.task('gen-dev-plugin-xml', function(){ + var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); + + xml = xml.replace('', + ''); + + fs.writeFileSync('plugin.xml', xml); +}); + +//emit array of cordova file references for all .h/.m files in path +function emitFiles(path){ + var ret = []; + for(filename of fs.readdirSync(path)){ + var fileType = null; + if(filename.match(/\.m$/)){ + fileType = 'source'; + }else if(filename.match(/\.h$/) || filename.match(/\.pch$/)){ + fileType = 'header'; + } + if(fileType){ + ret.push('<' + fileType + '-file src="' + path + filename + '" />'); + } + } + ret.push(''); + return ret; +} \ No newline at end of file diff --git a/plugin.template.xml b/plugin.template.xml new file mode 100644 index 00000000..5165dac0 --- /dev/null +++ b/plugin.template.xml @@ -0,0 +1,108 @@ + + + + + branch-cordova-sdk + Branch SDK Plugin + Apache 2.0 + cordova,branch + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $BRANCH_KEY + + + + + CFBundleURLName + io.branch.sdk + CFBundleURLSchemes + + $URI_SCHEME + + + + + + + + + + diff --git a/plugin.xml b/plugin.xml index 17420318..4ab7bb93 100644 --- a/plugin.xml +++ b/plugin.xml @@ -103,24 +103,26 @@ SOFTWARE. - - - - + + + From dbed3cc963f194030c02602f7032652373e80301 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 16:27:34 -0400 Subject: [PATCH 03/31] chore: delete local log file that ended up in repo --- testbed/npm-debug.log | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 testbed/npm-debug.log diff --git a/testbed/npm-debug.log b/testbed/npm-debug.log deleted file mode 100644 index 15585cf1..00000000 --- a/testbed/npm-debug.log +++ /dev/null @@ -1,39 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/Users/alexaustin/.nvm/v0.10.29/bin/node', -1 verbose cli '/Users/alexaustin/.nvm/v0.10.29/bin/npm', -1 verbose cli 'publish' ] -2 info using npm@1.4.14 -3 info using node@v0.10.29 -4 verbose publish [ '.' ] -5 verbose cache add [ '.', null ] -6 verbose cache add name=undefined spec="." args=[".",null] -7 verbose parsed url { protocol: null, -7 verbose parsed url slashes: null, -7 verbose parsed url auth: null, -7 verbose parsed url host: null, -7 verbose parsed url port: null, -7 verbose parsed url hostname: null, -7 verbose parsed url hash: null, -7 verbose parsed url search: null, -7 verbose parsed url query: null, -7 verbose parsed url pathname: '.', -7 verbose parsed url path: '.', -7 verbose parsed url href: '.' } -8 silly lockFile 3a52ce78- . -9 verbose lock . /Users/alexaustin/.npm/3a52ce78-.lock -10 silly lockFile 3a52ce78- . -11 silly lockFile 3a52ce78- . -12 error addLocal Could not install . -13 error Error: ENOENT, open 'package.json' -14 error If you need help, you may report this *entire* log, -14 error including the npm and node versions, at: -14 error -15 error System Darwin 15.5.0 -16 error command "/Users/alexaustin/.nvm/v0.10.29/bin/node" "/Users/alexaustin/.nvm/v0.10.29/bin/npm" "publish" -17 error cwd /Users/alexaustin/Documents/Javascript/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/testbed -18 error node -v v0.10.29 -19 error npm -v 1.4.14 -20 error path package.json -21 error code ENOENT -22 error errno 34 -23 verbose exit [ 34, true ] From aa96258f23a472d218fa0d28af79c9b9d1c83094 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 17:30:28 -0400 Subject: [PATCH 04/31] refactor(ios): automatically set correct header paths based on deployment --- .gitignore | 3 + gulpfile.js | 31 +++++- plugin.template.xml | 6 + plugin.xml | 192 -------------------------------- src/ios/AppDelegate+BranchSdk.m | 9 +- src/ios/BranchSDK.h | 15 ++- 6 files changed, 56 insertions(+), 200 deletions(-) delete mode 100644 plugin.xml diff --git a/.gitignore b/.gitignore index 83631f70..692b8299 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ testbed/hooks node_modules testbed/ul_web_hooks/ .installed + +/plugin.xml +src/ios/BranchNPM.h \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 8303c81d..4bf68ceb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,9 +1,21 @@ var gulp = require('gulp'); var fs = require('fs'); +//setup for development use +gulp.task('setupDev', function(){ + getDevPluginXML(); + setIosNpmOrDev('dev'); +}) + +//setup for npm deployment +gulp.task('setupNpm', function(){ + genNpmPluginXML(); + setIosNpmOrDev('npm'); +}); + //generate plugin.xml for use as a cordova plugin //here we explode the contents of the frameworks -gulp.task('gen-npm-plugin-xml', function(){ +function genNpmPluginXML(){ var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); var files = []; @@ -17,18 +29,29 @@ gulp.task('gen-npm-plugin-xml', function(){ + files.join(newLineIndent)); fs.writeFileSync('plugin.xml', xml); -}); +}; //generate plugin.xml for local development //here we reference the frameworks instead of all the files directly -gulp.task('gen-dev-plugin-xml', function(){ +function getDevPluginXML(){ var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); xml = xml.replace('', ''); fs.writeFileSync('plugin.xml', xml); -}); +}; + +function setIosNpmOrDev(npmOrDev){ + if(npmOrDev === 'npm'){ + content = '#define BRANCH_NPM true'; + }else if(npmOrDev === 'dev'){ + content = '//empty'; + }else{ + throw new Error('expected deployed|local, not ' + deployedOrLocal); + } + fs.writeFileSync('src/ios/BranchNPM.h', content + '\n'); +} //emit array of cordova file references for all .h/.m files in path function emitFiles(path){ diff --git a/plugin.template.xml b/plugin.template.xml index 5165dac0..f415dbde 100644 --- a/plugin.template.xml +++ b/plugin.template.xml @@ -1,3 +1,8 @@ + + + + + - - - branch-cordova-sdk - Branch SDK Plugin - Apache 2.0 - cordova,branch - https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git - https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $BRANCH_KEY - - - - - CFBundleURLName - io.branch.sdk - CFBundleURLSchemes - - $URI_SCHEME - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ios/AppDelegate+BranchSdk.m b/src/ios/AppDelegate+BranchSdk.m index bd0a480e..7e66c75a 100644 --- a/src/ios/AppDelegate+BranchSdk.m +++ b/src/ios/AppDelegate+BranchSdk.m @@ -7,7 +7,14 @@ // #import "AppDelegate.h" -#import + +#import "BranchNPM.h" + +#ifdef BRANCH_NPM + #import "Branch.h" +#else + #import +#endif @interface AppDelegate (BranchSDK) diff --git a/src/ios/BranchSDK.h b/src/ios/BranchSDK.h index c48f9ee6..020789f7 100644 --- a/src/ios/BranchSDK.h +++ b/src/ios/BranchSDK.h @@ -5,9 +5,18 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import -#import -#import +#import "BranchNPM.h" + +#ifdef BRANCH_NPM + #import "Branch.h" + #import "BranchLinkProperties.h" + #import "BranchUniversalObject.h" +#else + #import + #import + #import +#endif + #import @interface BranchSDK : CDVPlugin From 3353831c4d131f6f3890bbf60b2e33f033648dbd Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 18:23:34 -0400 Subject: [PATCH 05/31] fix(gulp): make plugin template comments valid xml --- plugin.template.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugin.template.xml b/plugin.template.xml index f415dbde..bd03c0ef 100644 --- a/plugin.template.xml +++ b/plugin.template.xml @@ -1,7 +1,4 @@ - - - + + + + + + branch-cordova-sdk + Branch SDK Plugin + Apache 2.0 + cordova,branch + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $BRANCH_KEY + + + + + CFBundleURLName + io.branch.sdk + CFBundleURLSchemes + + $URI_SCHEME + + + + + + + + + + + diff --git a/src/ios/BranchNPM.h b/src/ios/BranchNPM.h new file mode 100644 index 00000000..90fe1bcc --- /dev/null +++ b/src/ios/BranchNPM.h @@ -0,0 +1 @@ +//empty From 6acf939c9e01be059336dcf31ce4ca48b7b8f1b5 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Mon, 1 Aug 2016 17:32:12 -0400 Subject: [PATCH 08/31] chore(ios): add script to update ios dependencies --- src/ios/dependencies/update.sh | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 src/ios/dependencies/update.sh diff --git a/src/ios/dependencies/update.sh b/src/ios/dependencies/update.sh new file mode 100755 index 00000000..7a133115 --- /dev/null +++ b/src/ios/dependencies/update.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +#update the ios dependencies in this directory to those storied under passed tag on github + +#fail fast on errors +set -e + +#cd into directory containing this script +cd "$(dirname "$0")" + +#check first parameter is set to tag to download +if [ -z ${1+x} ]; then + echo "You must pass this script the tag to download" + exit -1 +else + echo "downloading tag '$1'" +fi + +#this is the git tag that we'll be updating to, +#we expecct it to be the first parameter to this script +tag_name=$1 +tag_url="https://github.com/BranchMetrics/ios-branch-deep-linking/archive/$tag_name.zip" +#extract is where we stick the extracted archive of the tag +tag_extract=ios-branch-deep-linking-$tag_name + + +#check that tag exists +tag_url_status=`curl -L -o /dev/null --silent --head --write-out '%{http_code}\n' $tag_url` +if [ $tag_url_status = "200" ]; then + echo "found tag" +else + echo "could not find '$tag_url'" + echo "curl returned status '$tag_url_status'" + exit -1 +fi + +#this will overwripte existing versions of sdk.zip +curl -L -o sdk.zip $tag_url + +#delete old extracted content or do nothing if we don't have any +rm -rf $tag_extract + +#silently (-q) extract download +unzip -q -x sdk.zip +rm -f sdk.zip + +#copy in new dependencies +rm -rf Branch-SDK +mv $tag_extract/Branch-SDK/Branch-SDK . + +rm -rf Branch.framework +mv $tag_extract/Branch.framework . + +rm -rf Fabric +mv $tag_extract/Branch-SDK/Fabric . + +#clean up +rm -rf $tag_extract + +#replace all instances of '#import "../Fabric/' with '#import "' in .m files +find . -type f -name '*.m' \ + -exec perl -i -pe 's/\#import \"\.\.\/Fabric\//#import "/' '{}' + From 9aed4f2736aa3d6432d74171c646570dfc27d8b6 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Mon, 1 Aug 2016 17:43:40 -0400 Subject: [PATCH 09/31] chore(deployment): remove npmDeployment.txt it is now automated --- NPMdeployment.txt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 NPMdeployment.txt diff --git a/NPMdeployment.txt b/NPMdeployment.txt deleted file mode 100644 index 0f7bf0ec..00000000 --- a/NPMdeployment.txt +++ /dev/null @@ -1,5 +0,0 @@ -NPM deployment - -1. comment out iOS framework in plugin.xml -2. change header file references of Cordova iOS libs from to "Branch.h" -3. remove "../Fabric" from all Fabric related imports \ No newline at end of file From fcebba4938ca71a7d958b0aee4b70e7a23c88be8 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 13:11:47 -0400 Subject: [PATCH 10/31] chore(gulp): add `npm run commit` command --- package.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package.json b/package.json index 5ce33a48..c6dbe4ae 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,9 @@ "ios" ], "license": "MIT", + "scripts": { + "commit": "git-cz" + }, "dependencies": { "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", @@ -38,11 +41,16 @@ "xml2js": "^0.4.16" }, "devDependencies": { + "commitizen": "^2.8.2", + "cz-conventional-changelog": "^1.1.6", "gulp": "^3.9.1", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", "plist": "^1.2.0", "rimraf": "^2.5.2", "xml2js": "^0.4.16" + }, + "czConfig": { + "path": "node_modules/cz-conventional-changelog" } } From 04ed411e3f1e9037bd7e2e10473f9cdab08d534b Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 15:59:13 -0400 Subject: [PATCH 11/31] chore(commitizen): use modern commitizen config style --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c6dbe4ae..d70d69dd 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,9 @@ "rimraf": "^2.5.2", "xml2js": "^0.4.16" }, - "czConfig": { - "path": "node_modules/cz-conventional-changelog" + "config": { + "commitizen": { + "path": "node_modules/cz-conventional-changelog" + } } } From 20c41679c0d2b598c3aba584d795b1dddb1da50a Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 14:56:53 -0400 Subject: [PATCH 12/31] chore(dependencies): add gulp --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c55b0068..5ce33a48 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "xml2js": "^0.4.16" }, "devDependencies": { + "gulp": "^3.9.1", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", "plist": "^1.2.0", From c5711be53f04e4c0d39e6f6d4d49e1218398fb6c Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 16:23:05 -0400 Subject: [PATCH 13/31] refactor(plugin.xml): generate ios references based on build target --- gulpfile.js | 49 ++++++++++++++++++++ plugin.template.xml | 108 ++++++++++++++++++++++++++++++++++++++++++++ plugin.xml | 38 ++++++++-------- 3 files changed, 176 insertions(+), 19 deletions(-) create mode 100644 gulpfile.js create mode 100644 plugin.template.xml diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..8303c81d --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,49 @@ +var gulp = require('gulp'); +var fs = require('fs'); + +//generate plugin.xml for use as a cordova plugin +//here we explode the contents of the frameworks +gulp.task('gen-npm-plugin-xml', function(){ + var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); + + var files = []; + var root = 'src/ios/dependencies/'; + files = files.concat(emitFiles(root + 'Fabric/')); + files = files.concat(emitFiles(root + 'Branch-SDK/')); + files = files.concat(emitFiles(root + 'Branch-SDK/Requests/')); + + var newLineIndent = '\n '; + xml = xml.replace('', newLineIndent + + files.join(newLineIndent)); + + fs.writeFileSync('plugin.xml', xml); +}); + +//generate plugin.xml for local development +//here we reference the frameworks instead of all the files directly +gulp.task('gen-dev-plugin-xml', function(){ + var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); + + xml = xml.replace('', + ''); + + fs.writeFileSync('plugin.xml', xml); +}); + +//emit array of cordova file references for all .h/.m files in path +function emitFiles(path){ + var ret = []; + for(filename of fs.readdirSync(path)){ + var fileType = null; + if(filename.match(/\.m$/)){ + fileType = 'source'; + }else if(filename.match(/\.h$/) || filename.match(/\.pch$/)){ + fileType = 'header'; + } + if(fileType){ + ret.push('<' + fileType + '-file src="' + path + filename + '" />'); + } + } + ret.push(''); + return ret; +} \ No newline at end of file diff --git a/plugin.template.xml b/plugin.template.xml new file mode 100644 index 00000000..5165dac0 --- /dev/null +++ b/plugin.template.xml @@ -0,0 +1,108 @@ + + + + + branch-cordova-sdk + Branch SDK Plugin + Apache 2.0 + cordova,branch + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $BRANCH_KEY + + + + + CFBundleURLName + io.branch.sdk + CFBundleURLSchemes + + $URI_SCHEME + + + + + + + + + + diff --git a/plugin.xml b/plugin.xml index 17420318..4ab7bb93 100644 --- a/plugin.xml +++ b/plugin.xml @@ -103,24 +103,26 @@ SOFTWARE. - - - - + + + From 1684e50c6039b361509cefd8c52f35b1b9a86e87 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 17:30:28 -0400 Subject: [PATCH 14/31] refactor(ios): automatically set correct header paths based on deployment --- .gitignore | 3 + gulpfile.js | 31 +++++- plugin.template.xml | 6 + plugin.xml | 192 -------------------------------- src/ios/AppDelegate+BranchSdk.m | 9 +- src/ios/BranchSDK.h | 15 ++- 6 files changed, 56 insertions(+), 200 deletions(-) delete mode 100644 plugin.xml diff --git a/.gitignore b/.gitignore index 83631f70..692b8299 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ testbed/hooks node_modules testbed/ul_web_hooks/ .installed + +/plugin.xml +src/ios/BranchNPM.h \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 8303c81d..4bf68ceb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,9 +1,21 @@ var gulp = require('gulp'); var fs = require('fs'); +//setup for development use +gulp.task('setupDev', function(){ + getDevPluginXML(); + setIosNpmOrDev('dev'); +}) + +//setup for npm deployment +gulp.task('setupNpm', function(){ + genNpmPluginXML(); + setIosNpmOrDev('npm'); +}); + //generate plugin.xml for use as a cordova plugin //here we explode the contents of the frameworks -gulp.task('gen-npm-plugin-xml', function(){ +function genNpmPluginXML(){ var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); var files = []; @@ -17,18 +29,29 @@ gulp.task('gen-npm-plugin-xml', function(){ + files.join(newLineIndent)); fs.writeFileSync('plugin.xml', xml); -}); +}; //generate plugin.xml for local development //here we reference the frameworks instead of all the files directly -gulp.task('gen-dev-plugin-xml', function(){ +function getDevPluginXML(){ var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); xml = xml.replace('', ''); fs.writeFileSync('plugin.xml', xml); -}); +}; + +function setIosNpmOrDev(npmOrDev){ + if(npmOrDev === 'npm'){ + content = '#define BRANCH_NPM true'; + }else if(npmOrDev === 'dev'){ + content = '//empty'; + }else{ + throw new Error('expected deployed|local, not ' + deployedOrLocal); + } + fs.writeFileSync('src/ios/BranchNPM.h', content + '\n'); +} //emit array of cordova file references for all .h/.m files in path function emitFiles(path){ diff --git a/plugin.template.xml b/plugin.template.xml index 5165dac0..f415dbde 100644 --- a/plugin.template.xml +++ b/plugin.template.xml @@ -1,3 +1,8 @@ + + + + + - - - branch-cordova-sdk - Branch SDK Plugin - Apache 2.0 - cordova,branch - https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git - https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $BRANCH_KEY - - - - - CFBundleURLName - io.branch.sdk - CFBundleURLSchemes - - $URI_SCHEME - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/ios/AppDelegate+BranchSdk.m b/src/ios/AppDelegate+BranchSdk.m index bd0a480e..7e66c75a 100644 --- a/src/ios/AppDelegate+BranchSdk.m +++ b/src/ios/AppDelegate+BranchSdk.m @@ -7,7 +7,14 @@ // #import "AppDelegate.h" -#import + +#import "BranchNPM.h" + +#ifdef BRANCH_NPM + #import "Branch.h" +#else + #import +#endif @interface AppDelegate (BranchSDK) diff --git a/src/ios/BranchSDK.h b/src/ios/BranchSDK.h index c48f9ee6..020789f7 100644 --- a/src/ios/BranchSDK.h +++ b/src/ios/BranchSDK.h @@ -5,9 +5,18 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import -#import -#import +#import "BranchNPM.h" + +#ifdef BRANCH_NPM + #import "Branch.h" + #import "BranchLinkProperties.h" + #import "BranchUniversalObject.h" +#else + #import + #import + #import +#endif + #import @interface BranchSDK : CDVPlugin From f7f537682416be6b9c3a862cb541d56c919154c7 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 26 Jul 2016 18:23:34 -0400 Subject: [PATCH 15/31] fix(gulp): make plugin template comments valid xml --- plugin.template.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugin.template.xml b/plugin.template.xml index f415dbde..bd03c0ef 100644 --- a/plugin.template.xml +++ b/plugin.template.xml @@ -1,7 +1,4 @@ - - - + + + + + + branch-cordova-sdk + Branch SDK Plugin + Apache 2.0 + cordova,branch + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $BRANCH_KEY + + + + + CFBundleURLName + io.branch.sdk + CFBundleURLSchemes + + $URI_SCHEME + + + + + + + + + + + diff --git a/src/ios/BranchNPM.h b/src/ios/BranchNPM.h new file mode 100644 index 00000000..90fe1bcc --- /dev/null +++ b/src/ios/BranchNPM.h @@ -0,0 +1 @@ +//empty From 13b8846497275b452191bb5e008f116f5d69f221 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Mon, 1 Aug 2016 17:32:12 -0400 Subject: [PATCH 18/31] chore(ios): add script to update ios dependencies --- src/ios/dependencies/update.sh | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 src/ios/dependencies/update.sh diff --git a/src/ios/dependencies/update.sh b/src/ios/dependencies/update.sh new file mode 100755 index 00000000..7a133115 --- /dev/null +++ b/src/ios/dependencies/update.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +#update the ios dependencies in this directory to those storied under passed tag on github + +#fail fast on errors +set -e + +#cd into directory containing this script +cd "$(dirname "$0")" + +#check first parameter is set to tag to download +if [ -z ${1+x} ]; then + echo "You must pass this script the tag to download" + exit -1 +else + echo "downloading tag '$1'" +fi + +#this is the git tag that we'll be updating to, +#we expecct it to be the first parameter to this script +tag_name=$1 +tag_url="https://github.com/BranchMetrics/ios-branch-deep-linking/archive/$tag_name.zip" +#extract is where we stick the extracted archive of the tag +tag_extract=ios-branch-deep-linking-$tag_name + + +#check that tag exists +tag_url_status=`curl -L -o /dev/null --silent --head --write-out '%{http_code}\n' $tag_url` +if [ $tag_url_status = "200" ]; then + echo "found tag" +else + echo "could not find '$tag_url'" + echo "curl returned status '$tag_url_status'" + exit -1 +fi + +#this will overwripte existing versions of sdk.zip +curl -L -o sdk.zip $tag_url + +#delete old extracted content or do nothing if we don't have any +rm -rf $tag_extract + +#silently (-q) extract download +unzip -q -x sdk.zip +rm -f sdk.zip + +#copy in new dependencies +rm -rf Branch-SDK +mv $tag_extract/Branch-SDK/Branch-SDK . + +rm -rf Branch.framework +mv $tag_extract/Branch.framework . + +rm -rf Fabric +mv $tag_extract/Branch-SDK/Fabric . + +#clean up +rm -rf $tag_extract + +#replace all instances of '#import "../Fabric/' with '#import "' in .m files +find . -type f -name '*.m' \ + -exec perl -i -pe 's/\#import \"\.\.\/Fabric\//#import "/' '{}' + From 604c85f5b2384f8afc390379bdf49a86189140fb Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Mon, 1 Aug 2016 17:43:40 -0400 Subject: [PATCH 19/31] chore(deployment): remove npmDeployment.txt it is now automated --- NPMdeployment.txt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 NPMdeployment.txt diff --git a/NPMdeployment.txt b/NPMdeployment.txt deleted file mode 100644 index 0f7bf0ec..00000000 --- a/NPMdeployment.txt +++ /dev/null @@ -1,5 +0,0 @@ -NPM deployment - -1. comment out iOS framework in plugin.xml -2. change header file references of Cordova iOS libs from to "Branch.h" -3. remove "../Fabric" from all Fabric related imports \ No newline at end of file From 6f054a156658c29cd3cee73f24930ff2e2792fc6 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 13:11:47 -0400 Subject: [PATCH 20/31] chore(gulp): add `npm run commit` command --- package.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package.json b/package.json index 5ce33a48..c6dbe4ae 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,9 @@ "ios" ], "license": "MIT", + "scripts": { + "commit": "git-cz" + }, "dependencies": { "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", @@ -38,11 +41,16 @@ "xml2js": "^0.4.16" }, "devDependencies": { + "commitizen": "^2.8.2", + "cz-conventional-changelog": "^1.1.6", "gulp": "^3.9.1", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", "plist": "^1.2.0", "rimraf": "^2.5.2", "xml2js": "^0.4.16" + }, + "czConfig": { + "path": "node_modules/cz-conventional-changelog" } } From 9ea986f7123896241d396d37a94d5320536f54aa Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 15:59:13 -0400 Subject: [PATCH 21/31] chore(commitizen): use modern commitizen config style --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c6dbe4ae..d70d69dd 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,9 @@ "rimraf": "^2.5.2", "xml2js": "^0.4.16" }, - "czConfig": { - "path": "node_modules/cz-conventional-changelog" + "config": { + "commitizen": { + "path": "node_modules/cz-conventional-changelog" + } } } From 81b672516b50978b19463411efa660f8a9b92d47 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 18:08:39 -0400 Subject: [PATCH 22/31] chore(babel): add es6 transpiler to gulpfile --- gulpfile.js | 32 +++++++++++++++++++++++++++++++- package.json | 5 +++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 4bf68ceb..614df6e1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,7 @@ var gulp = require('gulp'); var fs = require('fs'); +var sourcemaps = require('gulp-sourcemaps'); +var babel = require('gulp-babel'); //setup for development use gulp.task('setupDev', function(){ @@ -69,4 +71,32 @@ function emitFiles(path){ } ret.push(''); return ret; -} \ No newline at end of file +} + +//copy resources and compile es6 from corresponding directory +function babelize(taskName, dir){ + if(!dir){ + dir = taskName; + } + var srcDir = dir + '.es6/'; + var srcPattern = dir + '.es6/**/*.js' + var destDir = dir + '/'; + gulp.task(taskName + '-copy', () => { + return gulp.src(srcDir + '**/*.*').pipe(gulp.dest(destDir)); + }); + gulp.task(taskName + '-babel', [taskName + '-copy'], () => { + return gulp.src(srcPattern) + .pipe(sourcemaps.init()) + .pipe(babel({ + presets: ['es2015', 'stage-2'], + plugins: ['transform-runtime'] + })) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(destDir)); + }); +} + +babelize('hooks'); +babelize('www'); +babelize('tests'); +babelize('testbed', 'testbed/www/js'); \ No newline at end of file diff --git a/package.json b/package.json index d70d69dd..7790bdb2 100644 --- a/package.json +++ b/package.json @@ -41,9 +41,14 @@ "xml2js": "^0.4.16" }, "devDependencies": { + "babel-plugin-transform-runtime": "^6.12.0", + "babel-preset-es2015": "^6.9.0", + "babel-preset-stage-2": "^6.11.0", "commitizen": "^2.8.2", "cz-conventional-changelog": "^1.1.6", "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", + "gulp-sourcemaps": "^1.6.0", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", "plist": "^1.2.0", From 482737c8d50af7e11767ae51c8fb7cf01619be56 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 18:09:15 -0400 Subject: [PATCH 23/31] chore: use arrow functions instead of 'function' --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 614df6e1..94a6c789 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,13 +4,13 @@ var sourcemaps = require('gulp-sourcemaps'); var babel = require('gulp-babel'); //setup for development use -gulp.task('setupDev', function(){ +gulp.task('setupDev', () => { getDevPluginXML(); setIosNpmOrDev('dev'); }) //setup for npm deployment -gulp.task('setupNpm', function(){ +gulp.task('setupNpm', () => { genNpmPluginXML(); setIosNpmOrDev('npm'); }); From 9417503efbf2c9b270d51ef5aaff7c3f9c5efb13 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 18:13:46 -0400 Subject: [PATCH 24/31] chore(babel): add task to run all babel subtasks in parallel --- gulpfile.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 94a6c789..8712f8e0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -15,6 +15,8 @@ gulp.task('setupNpm', () => { setIosNpmOrDev('npm'); }); +gulp.task('build-npm', ['setupNpm', 'babel']); + //generate plugin.xml for use as a cordova plugin //here we explode the contents of the frameworks function genNpmPluginXML(){ @@ -74,7 +76,9 @@ function emitFiles(path){ } //copy resources and compile es6 from corresponding directory +babelTasks = []; //list of all babel tasks so we can build all of them function babelize(taskName, dir){ + babelTasks.push(taskName + '-babel'); if(!dir){ dir = taskName; } @@ -89,7 +93,7 @@ function babelize(taskName, dir){ .pipe(sourcemaps.init()) .pipe(babel({ presets: ['es2015', 'stage-2'], - plugins: ['transform-runtime'] + plugins: ['transform-runtime'] //needed for generators etc })) .pipe(sourcemaps.write('.')) .pipe(gulp.dest(destDir)); @@ -99,4 +103,5 @@ function babelize(taskName, dir){ babelize('hooks'); babelize('www'); babelize('tests'); -babelize('testbed', 'testbed/www/js'); \ No newline at end of file +babelize('testbed', 'testbed/www/js'); +gulp.task('babel', babelTasks); \ No newline at end of file From 699ea466dfcc331d01424cd868788a20809846a4 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 18:19:34 -0400 Subject: [PATCH 25/31] chore(lint): add branch's code style prefs --- .eslintrc | 19 +++++++++++++++++++ .jscs | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .eslintrc create mode 100644 .jscs diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..c22590e4 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,19 @@ +{ + "parser": "babel-eslint", + "env": { "browser": true }, + "rules": { + "quotes": 0, + "strict": 0, + "no-underscore-dangle": 0, + "eqeqeq": 0, + "camelcase": 0, + "consistent-return": 0, + "new-cap": 0 + }, + "globals": { + "module": true, + "require": false, + "mixpanel": false, + "File": false + } +} \ No newline at end of file diff --git a/.jscs b/.jscs new file mode 100644 index 00000000..8385caae --- /dev/null +++ b/.jscs @@ -0,0 +1,42 @@ +{ + "fileExtensions": [".js", ".jsx"], + "esnext": true, + + "requireCurlyBraces": [ "if", "else", "for", "while", "do", "try", "catch" ], + "requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return", "try", "catch" ], + "requireSpaceBeforeBlockStatements": true, + "requireParenthesesAroundIIFE": true, + "requireSpacesInConditionalExpression": { "afterTest": true, "beforeConsequent": true, "afterConsequent": true, "beforeAlternate": true }, + "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunction": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunction": { "beforeOpeningRoundBrace": true }, + "disallowSpacesInsideParentheses": true, + "requireSpacesInsideObjectBrackets": "all", + "requireSpacesInsideArrayBrackets": "all", + "disallowSpaceAfterObjectKeys": true, + "requireCommaBeforeLineBreak": true, + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--", ";"], + "disallowSpaceBeforeBinaryOperators": [ "," ], + "requireSpaceBeforeBinaryOperators": [ "=", "+", "-", "/", "*", "==", "===", "!=", "!==" ], + "requireSpaceAfterBinaryOperators": [ "=", ",", "+", "-", "/", "*", "==", "===", "!=", "!==" ], + "disallowMultipleLineStrings": true, + "validateLineBreaks": "LF", + "disallowMixedSpacesAndTabs": "smart", + "disallowTrailingWhitespace": true, + "disallowTrailingComma": true, + "requireKeywordsOnNewLine": [ "else" ], + "requireLineFeedAtFileEnd": true, + "requireCapitalizedConstructors": true, + "safeContextKeyword": [ "self" ], + "disallowYodaConditions": true, + "requireSpaceAfterLineComment": true, + "disallowNewlineBeforeBlockStatements": true +} \ No newline at end of file From 78cd30dcc943cf94680ad6e97855d02ca7fa1001 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 18:29:15 -0400 Subject: [PATCH 26/31] chore(lint): remove File and mixpanel from eslintrc globals --- .eslintrc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index c22590e4..763a8e94 100644 --- a/.eslintrc +++ b/.eslintrc @@ -12,8 +12,6 @@ }, "globals": { "module": true, - "require": false, - "mixpanel": false, - "File": false + "require": false } } \ No newline at end of file From 6b6819c02a0c629c78289fa5290771f38fd07dc1 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 18:30:51 -0400 Subject: [PATCH 27/31] chore(gulp): add dividers to gulpfile --- gulpfile.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8712f8e0..656fb8f4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,9 @@ var fs = require('fs'); var sourcemaps = require('gulp-sourcemaps'); var babel = require('gulp-babel'); +gulp.task('build-npm', ['setupNpm', 'babel', 'lint']); + +//------------------------------------------------------------------------------ //setup for development use gulp.task('setupDev', () => { getDevPluginXML(); @@ -15,8 +18,6 @@ gulp.task('setupNpm', () => { setIosNpmOrDev('npm'); }); -gulp.task('build-npm', ['setupNpm', 'babel']); - //generate plugin.xml for use as a cordova plugin //here we explode the contents of the frameworks function genNpmPluginXML(){ @@ -75,7 +76,8 @@ function emitFiles(path){ return ret; } -//copy resources and compile es6 from corresponding directory +//------------------------------------------------------------------------------ +//copy resources and compile es6 from corresponding directories babelTasks = []; //list of all babel tasks so we can build all of them function babelize(taskName, dir){ babelTasks.push(taskName + '-babel'); From ec921f7c19214956af197789e8c649626d1a12ec Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 19:01:34 -0400 Subject: [PATCH 28/31] chore(lint): implement linting in gulpfile --- .jscs => .jscsrc | 2 -- gulpfile.js | 43 +++++++++++++++++++++++++++++++++++++++---- package.json | 3 +++ 3 files changed, 42 insertions(+), 6 deletions(-) rename .jscs => .jscsrc (99%) diff --git a/.jscs b/.jscsrc similarity index 99% rename from .jscs rename to .jscsrc index 8385caae..d2e9477e 100644 --- a/.jscs +++ b/.jscsrc @@ -1,7 +1,5 @@ { "fileExtensions": [".js", ".jsx"], - "esnext": true, - "requireCurlyBraces": [ "if", "else", "for", "while", "do", "try", "catch" ], "requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return", "try", "catch" ], "requireSpaceBeforeBlockStatements": true, diff --git a/gulpfile.js b/gulpfile.js index 656fb8f4..c333bf75 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,7 +1,9 @@ -var gulp = require('gulp'); -var fs = require('fs'); +var gulp = require('gulp'); +var fs = require('fs'); var sourcemaps = require('gulp-sourcemaps'); -var babel = require('gulp-babel'); +var babel = require('gulp-babel'); +var eslint = require('gulp-eslint'); +var jscs = require('gulp-jscs'); gulp.task('build-npm', ['setupNpm', 'babel', 'lint']); @@ -106,4 +108,37 @@ babelize('hooks'); babelize('www'); babelize('tests'); babelize('testbed', 'testbed/www/js'); -gulp.task('babel', babelTasks); \ No newline at end of file +gulp.task('babel', babelTasks); + +//------------------------------------------------------------------------------ +//linting + +gulp.task('lint', ['eslint', 'jscs-lint']); + +var srcs = [ + '**/*.js', + '!node_modules/**', + '!testbed/platforms/ios/cordova/node_modules/**' +]; + +gulp.task('lint', () => { + return gulp.src(srcs) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +function jscsTask(fix){ + var ret = gulp.src(srcs) + .pipe(jscs({fix: fix})) + .pipe(jscs.reporter()) + .pipe(jscs.reporter('fail')); + + if(fix){ + ret.pipe(gulp.dest('.')); + } + return ret; +} + +gulp.task('jscs-fix', jscsTask.bind(null, true)); +gulp.task('jscs-lint', jscsTask.bind(null, false)); \ No newline at end of file diff --git a/package.json b/package.json index 7790bdb2..7ace4acc 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "xml2js": "^0.4.16" }, "devDependencies": { + "babel-eslint": "^6.1.2", "babel-plugin-transform-runtime": "^6.12.0", "babel-preset-es2015": "^6.9.0", "babel-preset-stage-2": "^6.11.0", @@ -48,6 +49,8 @@ "cz-conventional-changelog": "^1.1.6", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", + "gulp-eslint": "^3.0.1", + "gulp-jscs": "^4.0.0", "gulp-sourcemaps": "^1.6.0", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", From b292a53375251a874c8b2d8b705a132d2c79c9d3 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Tue, 2 Aug 2016 19:19:49 -0400 Subject: [PATCH 29/31] chore(gulpfile): fix linting errors --- gulpfile.js | 87 +++++++++++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index c333bf75..c673f654 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,26 +5,26 @@ var babel = require('gulp-babel'); var eslint = require('gulp-eslint'); var jscs = require('gulp-jscs'); -gulp.task('build-npm', ['setupNpm', 'babel', 'lint']); +gulp.task('build-npm', [ 'setupNpm', 'babel', 'lint' ]); -//------------------------------------------------------------------------------ -//setup for development use +// ----------------------------------------------------------------------------- +// setup for development use gulp.task('setupDev', () => { getDevPluginXML(); setIosNpmOrDev('dev'); }) -//setup for npm deployment +// setup for npm deployment gulp.task('setupNpm', () => { genNpmPluginXML(); setIosNpmOrDev('npm'); }); -//generate plugin.xml for use as a cordova plugin -//here we explode the contents of the frameworks -function genNpmPluginXML(){ +// generate plugin.xml for use as a cordova plugin +// here we explode the contents of the frameworks +function genNpmPluginXML() { var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); - + var files = []; var root = 'src/ios/dependencies/'; files = files.concat(emitFiles(root + 'Fabric/')); @@ -34,43 +34,46 @@ function genNpmPluginXML(){ var newLineIndent = '\n '; xml = xml.replace('', newLineIndent + files.join(newLineIndent)); - + fs.writeFileSync('plugin.xml', xml); }; -//generate plugin.xml for local development -//here we reference the frameworks instead of all the files directly -function getDevPluginXML(){ +// generate plugin.xml for local development +// here we reference the frameworks instead of all the files directly +function getDevPluginXML() { var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); - - xml = xml.replace('', + + xml = xml.replace('', ''); fs.writeFileSync('plugin.xml', xml); }; -function setIosNpmOrDev(npmOrDev){ - if(npmOrDev === 'npm'){ +function setIosNpmOrDev(npmOrDev) { + if (npmOrDev === 'npm') { content = '#define BRANCH_NPM true'; - }else if(npmOrDev === 'dev'){ + } +else if (npmOrDev === 'dev') { content = '//empty'; - }else{ + } +else { throw new Error('expected deployed|local, not ' + deployedOrLocal); } fs.writeFileSync('src/ios/BranchNPM.h', content + '\n'); } -//emit array of cordova file references for all .h/.m files in path -function emitFiles(path){ +// emit array of cordova file references for all .h/.m files in path +function emitFiles(path) { var ret = []; - for(filename of fs.readdirSync(path)){ + for (filename of fs.readdirSync(path)) { var fileType = null; - if(filename.match(/\.m$/)){ + if (filename.match(/\.m$/)) { fileType = 'source'; - }else if(filename.match(/\.h$/) || filename.match(/\.pch$/)){ + } +else if (filename.match(/\.h$/) || filename.match(/\.pch$/)) { fileType = 'header'; } - if(fileType){ + if (fileType) { ret.push('<' + fileType + '-file src="' + path + filename + '" />'); } } @@ -78,12 +81,12 @@ function emitFiles(path){ return ret; } -//------------------------------------------------------------------------------ -//copy resources and compile es6 from corresponding directories -babelTasks = []; //list of all babel tasks so we can build all of them -function babelize(taskName, dir){ +// ----------------------------------------------------------------------------- +// copy resources and compile es6 from corresponding directories +babelTasks = []; // list of all babel tasks so we can build all of them +function babelize(taskName, dir) { babelTasks.push(taskName + '-babel'); - if(!dir){ + if (!dir) { dir = taskName; } var srcDir = dir + '.es6/'; @@ -92,12 +95,12 @@ function babelize(taskName, dir){ gulp.task(taskName + '-copy', () => { return gulp.src(srcDir + '**/*.*').pipe(gulp.dest(destDir)); }); - gulp.task(taskName + '-babel', [taskName + '-copy'], () => { + gulp.task(taskName + '-babel', [ taskName + '-copy' ], () => { return gulp.src(srcPattern) .pipe(sourcemaps.init()) .pipe(babel({ - presets: ['es2015', 'stage-2'], - plugins: ['transform-runtime'] //needed for generators etc + presets: [ 'es2015', 'stage-2' ], + plugins: [ 'transform-runtime' ] // needed for generators etc })) .pipe(sourcemaps.write('.')) .pipe(gulp.dest(destDir)); @@ -110,35 +113,35 @@ babelize('tests'); babelize('testbed', 'testbed/www/js'); gulp.task('babel', babelTasks); -//------------------------------------------------------------------------------ -//linting +// ----------------------------------------------------------------------------- +// linting + +gulp.task('lint', [ 'eslint', 'jscs-lint' ]); -gulp.task('lint', ['eslint', 'jscs-lint']); - var srcs = [ '**/*.js', '!node_modules/**', '!testbed/platforms/ios/cordova/node_modules/**' ]; -gulp.task('lint', () => { +gulp.task('eslint', () => { return gulp.src(srcs) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failAfterError()); }); -function jscsTask(fix){ - var ret = gulp.src(srcs) - .pipe(jscs({fix: fix})) +function jscsTask(fix) { + var ret = gulp.src('gulpfile.js') + .pipe(jscs({ fix: fix })) .pipe(jscs.reporter()) .pipe(jscs.reporter('fail')); - if(fix){ + if (fix) { ret.pipe(gulp.dest('.')); } return ret; } gulp.task('jscs-fix', jscsTask.bind(null, true)); -gulp.task('jscs-lint', jscsTask.bind(null, false)); \ No newline at end of file +gulp.task('jscs-lint', jscsTask.bind(null, false)); From 07df48dea8334878de3e16bc4416a65490c7a7c5 Mon Sep 17 00:00:00 2001 From: Amit Bansil Date: Wed, 3 Aug 2016 12:17:13 -0400 Subject: [PATCH 30/31] chore(gulpfile): whitespace --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index c673f654..0b70f893 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -144,4 +144,4 @@ function jscsTask(fix) { } gulp.task('jscs-fix', jscsTask.bind(null, true)); -gulp.task('jscs-lint', jscsTask.bind(null, false)); +gulp.task('jscs-lint', jscsTask.bind(null, false)); \ No newline at end of file From a2eb241e001c0187abd1a71e3da908959cacc749 Mon Sep 17 00:00:00 2001 From: Alex Austin Date: Wed, 3 Aug 2016 10:30:24 -0700 Subject: [PATCH 31/31] chore(travis): setup travis CI --- .travis.yml | 26 ++++++++++++++++++++++++++ package.json | 13 +++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..901a7bf3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +sudo: false +language: node_js +cache: + directories: + - node_modules +notifications: + email: false +node_js: + - '4' + - iojs-v3 + - iojs-v2 + - iojs-v1 + - '0.12' + - '0.10' +before_install: + - npm i -g npm@^2.0.0 +before_script: + - npm prune +after_success: + - 'curl -Lo travis_after_all.py https://git.io/travis_after_all' + - python travis_after_all.py + - export $(cat .to_export_back) &> /dev/null + - npm run semantic-release +branches: + except: + - /^v\d+\.\d+\.\d+$/ diff --git a/package.json b/package.json index 7ace4acc..22ab49ae 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,14 @@ { - "version": "2.1.10", "name": "branch-cordova-sdk", "description": "Branch Metrics Cordova SDK", "main": "www/branch.js", - "homepage": "https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK", + "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", - "url": "https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git" + "url": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking.git" }, "bugs": { - "url": "https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues" + "url": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/issues" }, "keywords": [ "ecosystem:cordova", @@ -31,7 +30,8 @@ ], "license": "MIT", "scripts": { - "commit": "git-cz" + "commit": "git-cz", + "semantic-release": "semantic-release pre && npm publish && semantic-release post" }, "dependencies": { "mkpath": "^1.0.0", @@ -56,7 +56,8 @@ "node-version-compare": "^1.0.1", "plist": "^1.2.0", "rimraf": "^2.5.2", - "xml2js": "^0.4.16" + "xml2js": "^0.4.16", + "semantic-release": "^4.3.5" }, "config": { "commitizen": {