From 3f44e65d491bed4345b3b313d14dc1529d421c0f Mon Sep 17 00:00:00 2001 From: Matt Votsikas Date: Tue, 28 Jul 2015 10:23:46 +0100 Subject: [PATCH 1/4] Updated xml2json dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 50a28b9..d0f2029 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "grunt-contrib-watch": "~0.6.1", "grunt-contrib-copy": "~0.5.0", "grunt-bump": "git://github.com/logankoester/grunt-bump#gpg-sign", - "xml2json": "~0.4.0", + "xml2json": "~0.7.0", "lodash": "~2.4.0", "hash_file": "~0.1.1", "grunt-readme-generator": "git://github.com/logankoester/grunt-readme-generator#semver-sort" From 439439edd909c05526608d17311e2ceddc44fcda Mon Sep 17 00:00:00 2001 From: Matt Votsikas Date: Tue, 28 Jul 2015 10:38:21 +0100 Subject: [PATCH 2/4] Added variable options to plugins --- src/tasks/build/base/plugin.coffee | 9 +++++++++ tasks/build/base/plugin.js | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/tasks/build/base/plugin.coffee b/src/tasks/build/base/plugin.coffee index a618011..4712d7a 100644 --- a/src/tasks/build/base/plugin.coffee +++ b/src/tasks/build/base/plugin.coffee @@ -7,6 +7,10 @@ module.exports = plugin = (grunt) -> addPlugin = (plugin, fn) -> + if typeof plugin is 'object' + variables = plugin.variables || [] + plugin = plugin.id + # If plugin is on the local filesystem, resolve it's absolute # path from process.cwd() uri = new URI(plugin) @@ -14,6 +18,11 @@ module.exports = plugin = (grunt) -> plugin = path.resolve(uri.path()) cmd = grunt.config.get('phonegap.config.cli') + " plugin add #{plugin} #{helpers.setVerbosity()}" + + if typeof variables isnt 'undefined' + for d, i in variables + cmd += " --variable #{d.name}='#{d.value}'" + helpers.exec cmd, fn add: (plugins, fn) -> diff --git a/tasks/build/base/plugin.js b/tasks/build/base/plugin.js index 40a8eb2..0d8646e 100644 --- a/tasks/build/base/plugin.js +++ b/tasks/build/base/plugin.js @@ -11,12 +11,22 @@ var addPlugin, helpers; helpers = require('../../helpers')(grunt); addPlugin = function(plugin, fn) { - var cmd, uri; + var cmd, d, i, uri, variables, _i, _len; + if (typeof plugin === 'object') { + variables = plugin.variables || []; + plugin = plugin.id; + } uri = new URI(plugin); if (uri.protocol() === '' && (plugin.substr(0, 1) === '.' || plugin.substr(0, 1) === '/')) { plugin = path.resolve(uri.path()); } cmd = grunt.config.get('phonegap.config.cli') + (" plugin add " + plugin + " " + (helpers.setVerbosity())); + if (typeof variables !== 'undefined') { + for (i = _i = 0, _len = variables.length; _i < _len; i = ++_i) { + d = variables[i]; + cmd += " --variable " + d.name + "='" + d.value + "'"; + } + } return helpers.exec(cmd, fn); }; return { From 00285ded82a8dc64e00407cd2303a9316a3ed457 Mon Sep 17 00:00:00 2001 From: Matt Votsikas Date: Wed, 29 Jul 2015 10:49:49 +0100 Subject: [PATCH 3/4] Updated documentation to reflect plugin documentation --- README.md | 18 +++++++++++++++++- docs/overview.md | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b76b83..b6eec4a 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,23 @@ grunt.initConfig({ html : 'index.html', // (Optional) You may change this to any other.html path: 'phonegap', cleanBeforeBuild: true // when false the build path doesn't get regenerated - plugins: ['/local/path/to/plugin', 'http://example.com/path/to/plugin.git'], + plugins: [ + '/local/path/to/plugin', + 'http://example.com/path/to/plugin.git', + { + id: 'git://example.com/example/repository', + variables: [ + { + name: 'APP_ID', + value: 'EXAMPLE_ID' + }, + { + name: 'CLIENT_KEY', + value: 'EXAMPLE_KEY' + } + ] + } + ], platforms: ['android'], maxBuffer: 200, // You may need to raise this for iOS. verbose: false, diff --git a/docs/overview.md b/docs/overview.md index e2ec49d..b8bac4c 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -21,7 +21,23 @@ grunt.initConfig({ html : 'index.html', // (Optional) You may change this to any other.html path: 'phonegap', cleanBeforeBuild: true // when false the build path doesn't get regenerated - plugins: ['/local/path/to/plugin', 'http://example.com/path/to/plugin.git'], + plugins: [ + '/local/path/to/plugin', + 'http://example.com/path/to/plugin.git', + { + id: 'git://example.com/example/repository', + variables: [ + { + name: 'APP_ID', + value: 'EXAMPLE_ID' + }, + { + name: 'CLIENT_KEY', + value: 'EXAMPLE_KEY' + } + ] + } + ], platforms: ['android'], maxBuffer: 200, // You may need to raise this for iOS. verbose: false, From 13908c795d59049511d33869f02c79e447dccb9a Mon Sep 17 00:00:00 2001 From: Matt Votsikas Date: Mon, 3 Aug 2015 15:18:14 +0100 Subject: [PATCH 4/4] Added resources to ios --- src/tasks/build/after/local/ios.coffee | 2 + .../build/after/local/ios/resources.coffee | 23 +++++++++++ tasks/build/after/local/ios.js | 3 +- tasks/build/after/local/ios/resources.js | 38 +++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/tasks/build/after/local/ios/resources.coffee create mode 100644 tasks/build/after/local/ios/resources.js diff --git a/src/tasks/build/after/local/ios.coffee b/src/tasks/build/after/local/ios.coffee index b6fd17b..819a0b4 100644 --- a/src/tasks/build/after/local/ios.coffee +++ b/src/tasks/build/after/local/ios.coffee @@ -4,12 +4,14 @@ module.exports = ios = (grunt) -> tasks = buildIcons: require('./ios/icons')(grunt).build buildScreens: require('./ios/screens')(grunt).build + buildResources: require('./ios/resources')(grunt).build setStatusBar: require('./ios/plist')(grunt).setStatusBar run: (fn) -> fluid(tasks) .buildIcons() .buildScreens() + .buildResources() .setStatusBar() .go (err, result) -> if err then grunt.fatal err diff --git a/src/tasks/build/after/local/ios/resources.coffee b/src/tasks/build/after/local/ios/resources.coffee new file mode 100644 index 0000000..03e41ea --- /dev/null +++ b/src/tasks/build/after/local/ios/resources.coffee @@ -0,0 +1,23 @@ +path = require 'path' + +module.exports = resources = (grunt) -> + helpers = require('../../../../helpers')(grunt) + + build: (fn) -> + resources = helpers.config 'resources' + phonegapPath = helpers.config 'path' + appName = helpers.config 'name' + + dest = path.join phonegapPath, 'platforms', 'ios', appName + + if resources?.ios + for resource in resources?.ios + console.log 'resource from:'+resource.from+", to:"+resource.to + grunt.file.recurse resource.from, (file, root, filepath, filename) -> + console.log "copying "+file+ ","+root+","+filepath+","+filename + if filepath + grunt.file.copy file, path.join dest, resource.to, filepath, filename + else + grunt.file.copy file, path.join dest, resource.to, filename + + if fn then fn() diff --git a/tasks/build/after/local/ios.js b/tasks/build/after/local/ios.js index be57075..252db5e 100644 --- a/tasks/build/after/local/ios.js +++ b/tasks/build/after/local/ios.js @@ -8,11 +8,12 @@ tasks = { buildIcons: require('./ios/icons')(grunt).build, buildScreens: require('./ios/screens')(grunt).build, + buildResources: require('./ios/resources')(grunt).build, setStatusBar: require('./ios/plist')(grunt).setStatusBar }; return { run: function(fn) { - return fluid(tasks).buildIcons().buildScreens().setStatusBar().go(function(err, result) { + return fluid(tasks).buildIcons().buildScreens().buildResources().setStatusBar().go(function(err, result) { if (err) { grunt.fatal(err); } diff --git a/tasks/build/after/local/ios/resources.js b/tasks/build/after/local/ios/resources.js new file mode 100644 index 0000000..705d3fe --- /dev/null +++ b/tasks/build/after/local/ios/resources.js @@ -0,0 +1,38 @@ +(function() { + var path, resources; + + path = require('path'); + + module.exports = resources = function(grunt) { + var helpers; + helpers = require('../../../../helpers')(grunt); + return { + build: function(fn) { + var appName, dest, phonegapPath, resource, _i, _len, _ref; + resources = helpers.config('resources'); + phonegapPath = helpers.config('path'); + appName = helpers.config('name'); + dest = path.join(phonegapPath, 'platforms', 'ios', appName); + if (resources != null ? resources.ios : void 0) { + _ref = resources != null ? resources.ios : void 0; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + resource = _ref[_i]; + console.log('resource from:' + resource.from + ", to:" + resource.to); + grunt.file.recurse(resource.from, function(file, root, filepath, filename) { + console.log("copying " + file + "," + root + "," + filepath + "," + filename); + if (filepath) { + return grunt.file.copy(file, path.join(dest, resource.to, filepath, filename)); + } else { + return grunt.file.copy(file, path.join(dest, resource.to, filename)); + } + }); + } + } + if (fn) { + return fn(); + } + } + }; + }; + +}).call(this);