Skip to content
Permalink
Browse files
Revert "Merge branch 'master' into browserify"
This reverts commit 013adc6, reversing
changes made to 8aca4cb.
  • Loading branch information
agrieve committed Apr 25, 2014
1 parent 013adc6 commit 0a0d3841e4d570b5ca71b434fdaf0bc681e78a72
Showing 5 changed files with 22 additions and 120 deletions.
@@ -54,7 +54,7 @@ if (cli_opts.plugins_dir || cli_opts.project) {

process.on('uncaughtException', function(error) {
if (cli_opts.debug) {
console.error(error.message, error.stack);
console.error(error.stack);
} else {
console.error(error.message);
}
@@ -31,8 +31,7 @@
"npm": "1.3.4",
"rc": "0.3.0",
"tar": "0.1.x",
"request": "2.22.0",
"cordova-js": "3.x.x"
"request": "2.22.0"
},
"devDependencies": {
"temp": "0.6.x",
@@ -153,9 +153,9 @@ module.exports = {
// there is now double caching of iOS project files.
// Remove the cache here when install can handle
// a list of plugins at once.
// if (cachedProjectFiles[project_dir]) {
// return cachedProjectFiles[project_dir];
// }
if (cachedProjectFiles[project_dir]) {
return cachedProjectFiles[project_dir];
}
// grab and parse pbxproj
// we don't want CordovaLib's xcode project
var project_files = glob.sync(path.join(project_dir, '*.xcodeproj', 'project.pbxproj'));
@@ -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,31 +198,18 @@ 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;
}
});

// 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 */
};

This file was deleted.

0 comments on commit 0a0d384

Please sign in to comment.