You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2014/05/06 03:21:41 UTC
[1/4] git commit: adding flag for browserify
Repository: cordova-plugman
Updated Branches:
refs/heads/browserify [created] 17ae9332b
adding flag for browserify
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/2b707e5b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/2b707e5b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/2b707e5b
Branch: refs/heads/browserify
Commit: 2b707e5bf28f8818b5368186f4f39098eeeafb41
Parents: 013adc6
Author: Anis Kadri <an...@apache.org>
Authored: Wed Apr 30 14:22:55 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Apr 30 14:22:55 2014 -0700
----------------------------------------------------------------------
plugman.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/2b707e5b/plugman.js
----------------------------------------------------------------------
diff --git a/plugman.js b/plugman.js
index 4aa1843..258ef08 100644
--- a/plugman.js
+++ b/plugman.js
@@ -64,7 +64,7 @@ addProperty(plugman, 'help', './src/help');
addProperty(plugman, 'install', './src/install', true);
addProperty(plugman, 'uninstall', './src/uninstall', true);
addProperty(plugman, 'fetch', './src/fetch', true);
-addProperty(plugman, 'prepare', './src/prepare');
+//addProperty(plugman, 'prepare', './src/prepare');
addProperty(plugman, 'config', './src/config', true);
addProperty(plugman, 'owner', './src/owner', true);
addProperty(plugman, 'adduser', './src/adduser', true);
@@ -90,6 +90,8 @@ plugman.commands = {
if(!cli_opts.platform || !cli_opts.project || !cli_opts.plugin) {
return console.log(plugman.help());
}
+ cli_opts.browserify === true ? addProperty(plugman, 'prepare', './src/prepare-browserify') :
+ addProperty(plugman, 'prepare', './src/prepare');
var cli_variables = {}
if (cli_opts.variable) {
cli_opts.variable.forEach(function (variable) {
@@ -118,6 +120,9 @@ plugman.commands = {
if(!cli_opts.platform || !cli_opts.project || !cli_opts.plugin) {
return console.log(plugman.help());
}
+
+ cli_opts.browserify === true ? addProperty(plugman, 'prepare', './src/prepare-browserify') :
+ addProperty(plugman, 'prepare', './src/prepare');
var p = Q();
cli_opts.plugin.forEach(function (pluginSrc) {
[2/4] git commit: browserify behind a cli flag
Posted by an...@apache.org.
browserify behind a cli flag
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/572c72b9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/572c72b9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/572c72b9
Branch: refs/heads/browserify
Commit: 572c72b9e9221d5bd5160a291f72da6360e0c20e
Parents: 2b707e5
Author: Anis Kadri <an...@apache.org>
Authored: Wed Apr 30 14:31:01 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Wed Apr 30 14:31:01 2014 -0700
----------------------------------------------------------------------
main.js | 1 +
src/prepare-browserify.js | 184 +++++++++++++++++++++++++++++++++++++++++
src/prepare.js | 91 ++++----------------
3 files changed, 202 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/572c72b9/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 68273fd..b55c971 100755
--- a/main.js
+++ b/main.js
@@ -39,6 +39,7 @@ var known_opts = { 'platform' : [ 'ios', 'android', 'amazon-fireos', 'blackberry
, 'variable' : Array
, 'www': path
, 'searchpath' : [path, Array]
+ , 'browserify': Boolean
}, shortHands = { 'var' : ['--variable'], 'v': ['--version'], 'h': ['--help'] };
var cli_opts = nopt(known_opts, shortHands);
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/572c72b9/src/prepare-browserify.js
----------------------------------------------------------------------
diff --git a/src/prepare-browserify.js b/src/prepare-browserify.js
new file mode 100644
index 0000000..4fc764e
--- /dev/null
+++ b/src/prepare-browserify.js
@@ -0,0 +1,184 @@
+/**
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+*/
+
+/* jshint node:true */
+
+var platform_modules = require('./platforms'),
+ path = require('path'),
+ config_changes = require('./util/config-changes'),
+ xml_helpers = require('./util/xml-helpers'),
+ prepareNamespace = require('./util/prepare-namespace'),
+ wp7 = require('./platforms/wp7'),
+ wp8 = require('./platforms/wp8'),
+ windows8 = require('./platforms/windows8'),
+ common = require('./platforms/common'),
+ events = require('./events'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ util = require('util'),
+ plugman = require('../plugman'),
+ et = require('elementtree'),
+ bundle = require('cordova-js/tasks/lib/bundle-browserify'),
+ requireTr = require('cordova-js/tasks/lib/require-tr'),
+ writeLicenseHeader = require('cordova-js/tasks/lib/write-license-header');
+
+// Called on --prepare.
+// Sets up each plugin's Javascript code to be loaded properly.
+// Expects a path to the project (platforms/android in CLI, . in plugman-only),
+// a path to where the plugins are downloaded, the www dir, and the platform ('android', 'ios', etc.).
+module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_dir) {
+ // Process:
+ // - Do config munging by calling into config-changes module
+ // - List all plugins in plugins_dir
+ // - Load and parse their plugin.xml files.
+ // - Skip those without support for this platform. (No <platform> tags means JS-only!)
+ // - Build a list of all their js-modules, including platform-specific js-modules.
+ // - For each js-module (general first, then platform) build up an object storing the path and any clobbers, merges and runs for it.
+ events.emit('verbose', 'Preparing ' + platform + ' browserify project');
+ var platform_json = config_changes.get_platform_json(plugins_dir, platform);
+ var wwwDir = www_dir || platform_modules[platform].www_dir(project_dir);
+
+ // Check if there are any plugins queued for uninstallation, and if so, remove any of their plugin web assets loaded in
+ // via <js-module> elements
+ var plugins_to_uninstall = platform_json.prepare_queue.uninstalled;
+ if (plugins_to_uninstall && plugins_to_uninstall.length) {
+ var plugins_www = path.join(wwwDir, 'plugins');
+ if (fs.existsSync(plugins_www)) {
+ plugins_to_uninstall.forEach(function(plug) {
+ var id = plug.id;
+ var plugin_modules = path.join(plugins_www, id);
+ if (fs.existsSync(plugin_modules)) {
+ events.emit('verbose', 'Removing plugins directory from www "'+plugin_modules+'"');
+ shell.rm('-rf', plugin_modules);
+ }
+ });
+ }
+ }
+
+ events.emit('verbose', 'Processing configuration changes for plugins.');
+ config_changes.process(plugins_dir, project_dir, platform);
+
+ requireTr.platform = platform;
+ var libraryRelease = bundle(platform, false, 'N/A');
+
+ platform_json = config_changes.get_platform_json(plugins_dir, platform);
+ var plugins = Object.keys(platform_json.installed_plugins).concat(Object.keys(platform_json.dependent_plugins));
+ events.emit('verbose', 'Iterating over installed plugins:', plugins);
+
+ plugins && plugins.forEach(function(plugin) {
+ var pluginDir = path.join(plugins_dir, plugin),
+ pluginXML = path.join(pluginDir, 'plugin.xml');
+ if (!fs.existsSync(pluginXML)) {
+ plugman.emit('warn', 'Missing file: ' + pluginXML);
+ return;
+ }
+ var xml = xml_helpers.parseElementtreeSync(pluginXML);
+
+ var plugin_id = xml.getroot().attrib.id;
+
+ // add the plugins dir to the platform's www.
+ var platformPluginsDir = path.join(wwwDir, 'plugins');
+ // XXX this should not be here if there are no js-module. It leaves an empty plugins/ directory
+ shell.mkdir('-p', platformPluginsDir);
+
+ var jsModules = xml.findall('./js-module');
+ var assets = xml.findall('asset');
+ var platformTag = xml.find(util.format('./platform[@name="%s"]', platform));
+
+ if (platformTag) {
+ assets = assets.concat(platformTag.findall('./asset'));
+ jsModules = jsModules.concat(platformTag.findall('./js-module'));
+ }
+
+ // Copy www assets described in <asset> tags.
+ assets = assets || [];
+ assets.forEach(function(asset) {
+ common.asset.install(asset, pluginDir, wwwDir);
+ });
+
+ jsModules.forEach(function(module) {
+ // Copy the plugin's files into the www directory.
+ // NB: We can't always use path.* functions here, because they will use platform slashes.
+ // But the path in the plugin.xml and in the cordova_plugins.js should be always forward slashes.
+ var pathParts = module.attrib.src.split('/');
+
+ var fsDirname = path.join.apply(path, pathParts.slice(0, -1));
+ var fsDir = path.join(platformPluginsDir, plugin_id, fsDirname);
+ shell.mkdir('-p', fsDir);
+
+ // Read in the file, prepend the cordova.define, and write it back out.
+ var moduleName = plugin_id + '.';
+ if (module.attrib.name) {
+ moduleName += module.attrib.name;
+ } else {
+ // var result = module.attrib.src.match(/([^\/]+)\.js/);
+ // moduleName += result[1];
+ moduleName = path.basename(module.attrib.src, '.js');
+ }
+
+ var fsPath = path.join.apply(path, pathParts);
+ var scriptPath = path.join(pluginDir, fsPath);
+
+ var bScriptPath = util.format("%s.%s", scriptPath, 'browserify');
+ requireTr.addModule({symbol: new RegExp(moduleName), path: bScriptPath});
+
+ // Loop over the children of the js-module tag, collecting clobbers, merges and runs.
+ module.getchildren().forEach(function(child) {
+ if (child.tag.toLowerCase() == 'clobbers') {
+ fs.appendFileSync(bScriptPath,
+ prepareNamespace(child.attrib.target, 'c'),
+ 'utf-8');
+ } else if (child.tag.toLowerCase() == 'merges') {
+ fs.appendFileSync(bScriptPath,
+ prepareNamespace(child.attrib.target, 'm'),
+ 'utf-8');
+ /* end browserify guettho clobber */
+ }
+ });
+
+ /* begin browserify */
+ libraryRelease.transform(requireTr.transform);
+ libraryRelease.add(bScriptPath);
+ /* end browserify */
+ });
+ });
+
+ var outReleaseFile = path.join(wwwDir, 'cordova.js');
+ var outReleaseFileStream = fs.createWriteStream(outReleaseFile);
+ var commitId = 'N/A';
+ var time = new Date().valueOf();
+
+ writeLicenseHeader(outReleaseFileStream, platform, commitId);
+
+ releaseBundle = libraryRelease.bundle();
+
+ releaseBundle.pipe(outReleaseFileStream);
+
+ outReleaseFileStream.on('finish', function() {
+ var newtime = new Date().valueOf() - time;
+ plugman.emit('verbose', 'generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
+ // TODO clean up all the *.browserify files
+ });
+
+ outReleaseFileStream.on('error', function(err) {
+ var newtime = new Date().valueOf() - time;
+ console.log('error while generating cordova_b.js');
+ plugman.emit('verbose', 'error while generating cordova.js');
+ });
+};
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/572c72b9/src/prepare.js
----------------------------------------------------------------------
diff --git a/src/prepare.js b/src/prepare.js
index 02f9a67..c650306 100644
--- a/src/prepare.js
+++ b/src/prepare.js
@@ -19,24 +19,20 @@
/* jshint node:true */
-var platform_modules = require('./platforms'),
- path = require('path'),
- config_changes = require('./util/config-changes'),
- xml_helpers = require('./util/xml-helpers'),
- prepareNamespace = require('./util/prepare-namespace'),
- wp7 = require('./platforms/wp7'),
- wp8 = require('./platforms/wp8'),
- windows8 = require('./platforms/windows8'),
- common = require('./platforms/common'),
- events = require('./events'),
- fs = require('fs'),
- shell = require('shelljs'),
- util = require('util'),
- plugman = require('../plugman'),
- et = require('elementtree'),
- bundle = require('cordova-js/tasks/lib/bundle-browserify'),
- requireTr = require('cordova-js/tasks/lib/require-tr'),
- writeLicenseHeader = require('cordova-js/tasks/lib/write-license-header');
+var platform_modules = require('./platforms'),
+ path = require('path'),
+ config_changes = require('./util/config-changes'),
+ xml_helpers = require('./util/xml-helpers'),
+ wp7 = require('./platforms/wp7'),
+ wp8 = require('./platforms/wp8'),
+ windows8 = require('./platforms/windows8'),
+ common = require('./platforms/common');
+ fs = require('fs'),
+ shell = require('shelljs'),
+ util = require('util'),
+ events = require('./events'),
+ plugman = require('../plugman'),
+ et = require('elementtree');
// Called on --prepare.
// Sets up each plugin's Javascript code to be loaded properly.
@@ -120,11 +116,6 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
}
}
-
- /* begin browserify */
- requireTr.platform = platform;
- var libraryRelease = bundle(platform, false, 'N/A');
- /* end browserify */
platform_json = config_changes.get_platform_json(plugins_dir, platform);
// This array holds all the metadata for each module and ends up in cordova_plugins.json
@@ -182,22 +173,12 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
if (module.attrib.name) {
moduleName += module.attrib.name;
} else {
- // var result = module.attrib.src.match(/([^\/]+)\.js/);
- // moduleName += result[1];
- moduleName = path.basename(module.attrib.src, '.js');
+ var result = module.attrib.src.match(/([^\/]+)\.js/);
+ moduleName += result[1];
}
var fsPath = path.join.apply(path, pathParts);
- var scriptPath = path.join(pluginDir, fsPath);
-
- /* begin browserify */
- var bScriptPath = util.format("%s.%s", scriptPath, 'browserify');
- requireTr.addModule({symbol: new RegExp(moduleName), path: bScriptPath});
- /* end browserify */
-
- var scriptContent = fs.readFileSync(scriptPath, 'utf-8');
- fs.writeFileSync(bScriptPath, scriptContent, 'utf-8');
-
+ var scriptContent = fs.readFileSync(path.join(pluginDir, fsPath), 'utf-8');
scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) { ' + scriptContent + '\n});\n';
fs.writeFileSync(path.join(platformPluginsDir, plugin_id, fsPath), scriptContent, 'utf-8');
if(platform == 'wp7' || platform == 'wp8' || platform == "windows8") {
@@ -217,20 +198,11 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
obj.clobbers = [];
}
obj.clobbers.push(child.attrib.target);
- //console.log(prepareNamespace(child.attrib.target, 'c'));
- fs.appendFileSync(bScriptPath,
- prepareNamespace(child.attrib.target, 'c'),
- 'utf-8');
} else if (child.tag.toLowerCase() == 'merges') {
if (!obj.merges) {
obj.merges = [];
}
obj.merges.push(child.attrib.target);
- /* FIXME: browserify guettho clobber */
- fs.appendFileSync(bScriptPath,
- prepareNamespace(child.attrib.target, 'm'),
- 'utf-8');
- /* end browserify guettho clobber */
} else if (child.tag.toLowerCase() == 'runs') {
obj.runs = true;
}
@@ -238,10 +210,6 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
// Add it to the list of module objects bound for cordova_plugins.json
moduleObjects.push(obj);
- /* begin browserify */
- libraryRelease.transform(requireTr.transform);
- libraryRelease.add(bScriptPath);
- /* end browserify */
});
});
@@ -261,29 +229,4 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
wp_csproj.addSourceFile(path.join('www', 'cordova_plugins.js'));
wp_csproj.write();
}
-
- /* begin browserify */
- var outReleaseFile = path.join(wwwDir, 'cordova-b.js');
- var outReleaseFileStream = fs.createWriteStream(outReleaseFile);
- var commitId = 'N/A';
- var time = new Date().valueOf();
-
- writeLicenseHeader(outReleaseFileStream, platform, commitId);
-
- releaseBundle = libraryRelease.bundle();
-
- releaseBundle.pipe(outReleaseFileStream);
-
- outReleaseFileStream.on('finish', function() {
- var newtime = new Date().valueOf() - time;
- plugman.emit('verbose', 'generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
- // TODO clean up all the *.browserify files
- });
-
- outReleaseFileStream.on('error', function(err) {
- var newtime = new Date().valueOf() - time;
- console.log('error while generating cordova_b.js');
- plugman.emit('verbose', 'error while generating cordova.js');
- });
- /* end browserify */
};
[3/4] git commit: updating npm-shrinkwrap
Posted by an...@apache.org.
updating npm-shrinkwrap
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/72ea55e5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/72ea55e5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/72ea55e5
Branch: refs/heads/browserify
Commit: 72ea55e5d670036a872f519a59824ddfbf20b58e
Parents: 572c72b
Author: Anis Kadri <an...@apache.org>
Authored: Fri May 2 13:47:43 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Fri May 2 13:47:43 2014 -0700
----------------------------------------------------------------------
npm-shrinkwrap.json | 94 +++++++++++++++++++++++++-----------------------
1 file changed, 49 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/72ea55e5/npm-shrinkwrap.json
----------------------------------------------------------------------
diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json
index 5c38496..6fc6a48 100644
--- a/npm-shrinkwrap.json
+++ b/npm-shrinkwrap.json
@@ -1,10 +1,14 @@
{
"name": "plugman",
- "version": "0.20.3-dev",
+ "version": "0.21.1-dev",
"dependencies": {
"bplist-parser": {
"version": "0.0.5",
- "from": "bplist-parser@0.0.x"
+ "from": "bplist-parser@0.0.5"
+ },
+ "cordova-js": {
+ "version": "3.5.3",
+ "from": "cordova-js@"
},
"dep-graph": {
"version": "1.1.0",
@@ -28,35 +32,35 @@
},
"glob": {
"version": "3.2.9",
- "from": "glob@3.2.x",
+ "from": "glob@3.2.9",
"dependencies": {
"minimatch": {
"version": "0.2.14",
- "from": "minimatch@~0.2.11",
+ "from": "minimatch@0.2.14",
"dependencies": {
"lru-cache": {
"version": "2.5.0",
- "from": "lru-cache@2"
+ "from": "lru-cache@2.5.0"
},
"sigmund": {
"version": "1.0.0",
- "from": "sigmund@~1.0.0"
+ "from": "sigmund@1.0.0"
}
}
},
"inherits": {
"version": "2.0.1",
- "from": "inherits@2"
+ "from": "inherits@2.0.1"
}
}
},
"nopt": {
"version": "1.0.10",
- "from": "nopt@1.0.x",
+ "from": "nopt@1.0.10",
"dependencies": {
"abbrev": {
"version": "1.0.4",
- "from": "abbrev@1"
+ "from": "abbrev@1.0.4"
}
}
},
@@ -409,21 +413,21 @@
},
"plist-with-patches": {
"version": "0.5.1",
- "from": "plist-with-patches@0.5.x",
+ "from": "plist-with-patches@0.5.1",
"dependencies": {
"xmlbuilder": {
"version": "0.4.3",
- "from": "xmlbuilder@0.4.x"
+ "from": "xmlbuilder@0.4.3"
},
"xmldom": {
"version": "0.1.19",
- "from": "xmldom@0.1.x"
+ "from": "xmldom@0.1.19"
}
}
},
"q": {
"version": "0.9.7",
- "from": "q@~0.9"
+ "from": "q@0.9.7"
},
"rc": {
"version": "0.3.0",
@@ -431,21 +435,21 @@
"dependencies": {
"optimist": {
"version": "0.3.7",
- "from": "optimist@~0.3.4",
+ "from": "optimist@0.3.7",
"dependencies": {
"wordwrap": {
"version": "0.0.2",
- "from": "wordwrap@~0.0.2"
+ "from": "wordwrap@0.0.2"
}
}
},
"deep-extend": {
"version": "0.2.8",
- "from": "deep-extend@~0.2.5"
+ "from": "deep-extend@0.2.8"
},
"ini": {
"version": "1.1.0",
- "from": "ini@~1.1.0"
+ "from": "ini@1.1.0"
}
}
},
@@ -455,23 +459,23 @@
"dependencies": {
"qs": {
"version": "0.6.6",
- "from": "qs@~0.6.0"
+ "from": "qs@0.6.6"
},
"json-stringify-safe": {
"version": "4.0.0",
- "from": "json-stringify-safe@~4.0.0"
+ "from": "json-stringify-safe@4.0.0"
},
"forever-agent": {
"version": "0.5.2",
- "from": "forever-agent@~0.5.0"
+ "from": "forever-agent@0.5.2"
},
"tunnel-agent": {
"version": "0.3.0",
- "from": "tunnel-agent@~0.3.0"
+ "from": "tunnel-agent@0.3.0"
},
"http-signature": {
"version": "0.10.0",
- "from": "http-signature@~0.10.0",
+ "from": "http-signature@0.10.0",
"dependencies": {
"assert-plus": {
"version": "0.1.2",
@@ -489,33 +493,33 @@
},
"hawk": {
"version": "0.13.1",
- "from": "hawk@~0.13.0",
+ "from": "hawk@0.13.1",
"dependencies": {
"hoek": {
"version": "0.8.5",
- "from": "hoek@0.8.x"
+ "from": "hoek@0.8.5"
},
"boom": {
"version": "0.4.2",
- "from": "boom@0.4.x",
+ "from": "boom@0.4.2",
"dependencies": {
"hoek": {
"version": "0.9.1",
- "from": "hoek@0.9.x"
+ "from": "hoek@0.9.1"
}
}
},
"cryptiles": {
"version": "0.2.2",
- "from": "cryptiles@0.2.x"
+ "from": "cryptiles@0.2.2"
},
"sntp": {
"version": "0.2.4",
- "from": "sntp@0.2.x",
+ "from": "sntp@0.2.4",
"dependencies": {
"hoek": {
"version": "0.9.1",
- "from": "hoek@0.9.x"
+ "from": "hoek@0.9.1"
}
}
}
@@ -523,23 +527,23 @@
},
"aws-sign": {
"version": "0.3.0",
- "from": "aws-sign@~0.3.0"
+ "from": "aws-sign@0.3.0"
},
"oauth-sign": {
"version": "0.3.0",
- "from": "oauth-sign@~0.3.0"
+ "from": "oauth-sign@0.3.0"
},
"cookie-jar": {
"version": "0.3.0",
- "from": "cookie-jar@~0.3.0"
+ "from": "cookie-jar@0.3.0"
},
"node-uuid": {
"version": "1.4.1",
- "from": "node-uuid@~1.4.0"
+ "from": "node-uuid@1.4.1"
},
"mime": {
"version": "1.2.11",
- "from": "mime@~1.2.9"
+ "from": "mime@1.2.11"
},
"form-data": {
"version": "0.0.8",
@@ -547,7 +551,7 @@
"dependencies": {
"combined-stream": {
"version": "0.0.4",
- "from": "combined-stream@~0.0.4",
+ "from": "combined-stream@0.0.4",
"dependencies": {
"delayed-stream": {
"version": "0.0.5",
@@ -557,7 +561,7 @@
},
"async": {
"version": "0.2.10",
- "from": "async@~0.2.7"
+ "from": "async@0.2.10"
}
}
}
@@ -565,39 +569,39 @@
},
"semver": {
"version": "2.0.11",
- "from": "semver@2.0.x"
+ "from": "semver@2.0.11"
},
"shelljs": {
"version": "0.1.4",
- "from": "shelljs@0.1.x"
+ "from": "shelljs@0.1.4"
},
"tar": {
"version": "0.1.19",
- "from": "tar@0.1.x",
+ "from": "tar@0.1.19",
"dependencies": {
"inherits": {
"version": "2.0.1",
- "from": "inherits@2"
+ "from": "inherits@2.0.1"
},
"block-stream": {
"version": "0.0.7",
- "from": "block-stream@*"
+ "from": "block-stream@0.0.7"
},
"fstream": {
"version": "0.1.25",
- "from": "fstream@~0.1.8",
+ "from": "fstream@0.1.25",
"dependencies": {
"rimraf": {
"version": "2.2.6",
- "from": "rimraf@2"
+ "from": "rimraf@2.2.6"
},
"mkdirp": {
"version": "0.3.5",
- "from": "mkdirp@0.3"
+ "from": "mkdirp@~0.3.5"
},
"graceful-fs": {
"version": "2.0.2",
- "from": "graceful-fs@~2.0.0"
+ "from": "graceful-fs@2.0.2"
}
}
}
[4/4] git commit: performance improvement and fixed too many files
open problem
Posted by an...@apache.org.
performance improvement and fixed too many files open problem
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/17ae9332
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/17ae9332
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/17ae9332
Branch: refs/heads/browserify
Commit: 17ae9332beaf6f1a92b63ba266ea51c12d5fb07b
Parents: 72ea55e
Author: Anis Kadri <an...@apache.org>
Authored: Mon May 5 18:21:29 2014 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Mon May 5 18:21:29 2014 -0700
----------------------------------------------------------------------
npm-shrinkwrap.json | 2 +-
src/install.js | 11 ++--
src/prepare-browserify.js | 111 ++++++++++++++++++++++-------------------
3 files changed, 67 insertions(+), 57 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/17ae9332/npm-shrinkwrap.json
----------------------------------------------------------------------
diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json
index 6fc6a48..17e7368 100644
--- a/npm-shrinkwrap.json
+++ b/npm-shrinkwrap.json
@@ -7,7 +7,7 @@
"from": "bplist-parser@0.0.5"
},
"cordova-js": {
- "version": "3.5.3",
+ "version": "3.6.0",
"from": "cordova-js@"
},
"dep-graph": {
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/17ae9332/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index cce145d..bf249c7 100644
--- a/src/install.js
+++ b/src/install.js
@@ -300,7 +300,7 @@ var runInstall = module.exports.runInstall = function runInstall(actions, platfo
copyPlugin(plugin_dir, plugins_dir, options.link);
}
- return handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, install_plugin_dir, filtered_variables, options.www_dir, options.is_top_level);
+ return handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, install_plugin_dir, filtered_variables, options);
}
).fail(
function (error) {
@@ -491,13 +491,12 @@ function installDependency(dep, install, options) {
};
}
-function handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_dir, filtered_variables, www_dir, is_top_level) {
-
+function handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plugins_dir, plugin_dir, filtered_variables, options) {
// @tests - important this event is checked spec/install.spec.js
events.emit('verbose', 'Install start for "' + plugin_id + '" on ' + platform + '.');
var handler = platform_modules[platform];
- www_dir = www_dir || handler.www_dir(project_dir);
+ www_dir = options.www_dir || handler.www_dir(project_dir);
var platformTag = plugin_et.find('./platform[@name="'+platform+'"]');
var assets = plugin_et.findall('asset');
@@ -553,9 +552,9 @@ function handleInstall(actions, plugin_id, plugin_et, platform, project_dir, plu
return actions.process(platform, project_dir)
.then(function(err) {
// queue up the plugin so prepare knows what to do.
- config_changes.add_installed_plugin_to_prepare_queue(plugins_dir, plugin_id, platform, filtered_variables, is_top_level);
+ config_changes.add_installed_plugin_to_prepare_queue(plugins_dir, plugin_id, platform, filtered_variables, options.is_top_level);
// call prepare after a successful install
- plugman.prepare(project_dir, platform, plugins_dir, www_dir);
+ plugman.prepare(project_dir, platform, plugins_dir, www_dir, options.is_top_level);
events.emit('verbose', 'Install complete for ' + plugin_id + ' on ' + platform + '.');
// WIN!
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/17ae9332/src/prepare-browserify.js
----------------------------------------------------------------------
diff --git a/src/prepare-browserify.js b/src/prepare-browserify.js
index 4fc764e..fd94210 100644
--- a/src/prepare-browserify.js
+++ b/src/prepare-browserify.js
@@ -38,22 +38,7 @@ var platform_modules = require('./platforms'),
requireTr = require('cordova-js/tasks/lib/require-tr'),
writeLicenseHeader = require('cordova-js/tasks/lib/write-license-header');
-// Called on --prepare.
-// Sets up each plugin's Javascript code to be loaded properly.
-// Expects a path to the project (platforms/android in CLI, . in plugman-only),
-// a path to where the plugins are downloaded, the www dir, and the platform ('android', 'ios', etc.).
-module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_dir) {
- // Process:
- // - Do config munging by calling into config-changes module
- // - List all plugins in plugins_dir
- // - Load and parse their plugin.xml files.
- // - Skip those without support for this platform. (No <platform> tags means JS-only!)
- // - Build a list of all their js-modules, including platform-specific js-modules.
- // - For each js-module (general first, then platform) build up an object storing the path and any clobbers, merges and runs for it.
- events.emit('verbose', 'Preparing ' + platform + ' browserify project');
- var platform_json = config_changes.get_platform_json(plugins_dir, platform);
- var wwwDir = www_dir || platform_modules[platform].www_dir(project_dir);
-
+function uninstallQueuedPlugins(platform_json) {
// Check if there are any plugins queued for uninstallation, and if so, remove any of their plugin web assets loaded in
// via <js-module> elements
var plugins_to_uninstall = platform_json.prepare_queue.uninstalled;
@@ -70,10 +55,58 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
});
}
}
+}
+
+function generateFinalBundle(platform, libraryRelease, outReleaseFile) {
+
+ var outReleaseFileStream = fs.createWriteStream(outReleaseFile);
+ var commitId = 'N/A';
+ var time = new Date().valueOf();
+
+ writeLicenseHeader(outReleaseFileStream, platform, commitId);
+
+ releaseBundle = libraryRelease.bundle();
+
+ releaseBundle.pipe(outReleaseFileStream);
+
+ outReleaseFileStream.on('finish', function() {
+ var newtime = new Date().valueOf() - time;
+ plugman.emit('verbose', 'generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
+ // TODO clean up all the *.browserify files
+ });
+
+ outReleaseFileStream.on('error', function(err) {
+ var newtime = new Date().valueOf() - time;
+ console.log('error while generating cordova_b.js');
+ plugman.emit('verbose', 'error while generating cordova.js');
+ });
+
+}
+
+// Called on --prepare.
+// Sets up each plugin's Javascript code to be loaded properly.
+// Expects a path to the project (platforms/android in CLI, . in plugman-only),
+// a path to where the plugins are downloaded, the www dir, and the platform ('android', 'ios', etc.).
+module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_dir, is_top_level) {
+ // Process:
+ // - Do config munging by calling into config-changes module
+ // - List all plugins in plugins_dir
+ // - Load and parse their plugin.xml files.
+ // - Skip those without support for this platform. (No <platform> tags means JS-only!)
+ // - Build a list of all their js-modules, including platform-specific js-modules.
+ // - For each js-module (general first, then platform) build up an object storing the path and any clobbers, merges and runs for it.
+ events.emit('verbose', 'Preparing ' + platform + ' browserify project');
+ var platform_json = config_changes.get_platform_json(plugins_dir, platform);
+ var wwwDir = www_dir || platform_modules[platform].www_dir(project_dir);
+ var scripts = [];
+
+ uninstallQueuedPlugins(platform_json);
events.emit('verbose', 'Processing configuration changes for plugins.');
config_changes.process(plugins_dir, project_dir, platform);
+ if(!is_top_level) return;
+
requireTr.platform = platform;
var libraryRelease = bundle(platform, false, 'N/A');
@@ -111,7 +144,6 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
assets.forEach(function(asset) {
common.asset.install(asset, pluginDir, wwwDir);
});
-
jsModules.forEach(function(module) {
// Copy the plugin's files into the www directory.
// NB: We can't always use path.* functions here, because they will use platform slashes.
@@ -127,58 +159,37 @@ module.exports = function handlePrepare(project_dir, platform, plugins_dir, www_
if (module.attrib.name) {
moduleName += module.attrib.name;
} else {
- // var result = module.attrib.src.match(/([^\/]+)\.js/);
- // moduleName += result[1];
- moduleName = path.basename(module.attrib.src, '.js');
+ moduleName = path.basename(module.attrib.src, '.js');
}
var fsPath = path.join.apply(path, pathParts);
var scriptPath = path.join(pluginDir, fsPath);
- var bScriptPath = util.format("%s.%s", scriptPath, 'browserify');
- requireTr.addModule({symbol: new RegExp(moduleName), path: bScriptPath});
+ requireTr.addModule({symbol: new RegExp(moduleName), path: scriptPath});
- // Loop over the children of the js-module tag, collecting clobbers, merges and runs.
module.getchildren().forEach(function(child) {
if (child.tag.toLowerCase() == 'clobbers') {
- fs.appendFileSync(bScriptPath,
+ fs.appendFileSync(scriptPath,
prepareNamespace(child.attrib.target, 'c'),
'utf-8');
} else if (child.tag.toLowerCase() == 'merges') {
- fs.appendFileSync(bScriptPath,
+ fs.appendFileSync(scriptPath,
prepareNamespace(child.attrib.target, 'm'),
'utf-8');
- /* end browserify guettho clobber */
}
});
-
- /* begin browserify */
- libraryRelease.transform(requireTr.transform);
- libraryRelease.add(bScriptPath);
- /* end browserify */
+ scripts.push(scriptPath);
});
});
-
- var outReleaseFile = path.join(wwwDir, 'cordova.js');
- var outReleaseFileStream = fs.createWriteStream(outReleaseFile);
- var commitId = 'N/A';
- var time = new Date().valueOf();
-
- writeLicenseHeader(outReleaseFileStream, platform, commitId);
- releaseBundle = libraryRelease.bundle();
-
- releaseBundle.pipe(outReleaseFileStream);
+ libraryRelease.transform(requireTr.transform);
- outReleaseFileStream.on('finish', function() {
- var newtime = new Date().valueOf() - time;
- plugman.emit('verbose', 'generated cordova.' + platform + '.js @ ' + commitId + ' in ' + newtime + 'ms');
- // TODO clean up all the *.browserify files
+ scripts.forEach(function(script) {
+ libraryRelease.add(script);
});
+
+ var outReleaseFile = path.join(wwwDir, 'cordova.js');
+
+ generateFinalBundle(platform, libraryRelease, outReleaseFile);
- outReleaseFileStream.on('error', function(err) {
- var newtime = new Date().valueOf() - time;
- console.log('error while generating cordova_b.js');
- plugman.emit('verbose', 'error while generating cordova.js');
- });
};