Skip to content
Permalink
Browse files
CB-9156 removed platforms as devDependencies, assuming they are sibli…
…ngs instead
  • Loading branch information
stevengill committed Jun 20, 2015
1 parent a3daab8 commit 9ade05ccd0ecffa6211c9a95f173a6ff5f93542d
Showing 4 changed files with 59 additions and 24 deletions.
@@ -71,21 +71,23 @@
"jasmine-node": "1.14.5",
"jsdom-nogyp": "0.8.3",
"mkdirp": "^0.5.0",
"grunt-cli": "0.1.13",
"cordova-android": "4.0.x",
"cordova-ios": "3.8.x",
"cordova-blackberry10": "3.7.x" ,
"cordova-firefoxos": "3.6.x",
"cordova-ubuntu": "4.0.x",
"cordova-amazon-fireos": "3.6.x",
"cordova-wp8": "3.8.x",
"cordova-windows": "3.8.x",
"cordova-browser": "3.6.x"

"grunt-cli": "0.1.13"
},
"dependencies": {
"browserify": "10.1.3",
"through": "2.3.4",
"uglify-js": "^2.4.15"
},
"cordova-platforms": {
"cordova-android" : "../cordova-android",
"cordova-ios": "../cordova-ios",
"cordova-blackberry10": "../cordova-blackberry" ,
"cordova-firefoxos": "../cordova-firefoxos",
"cordova-ubuntu": "../cordova-ubuntu",
"cordova-amazon-fireos": "../cordova-amazon-fireos",
"cordova-wp8": "../cordova-wp8",
"cordova-windows": "../cordova-windows",
"cordova-osx": "../cordova-osx",
"cordova-browser": "../cordova-browser"
}
}
@@ -18,6 +18,7 @@
*/
var fs = require('fs');
var path = require('path');
var pkgJson = require(process.cwd() + '/package.json');

try {
require('browserify');
@@ -44,8 +45,8 @@ module.exports = function(grunt) {
}
});
if(!platformVersion){
if(fs.existsSync(path.join('node_modules','cordova-'+platformName))) {
var platformPkgJson = require('../node_modules/cordova-'+platformName+'/package.json');
if(pkgJson['cordova-platforms']['cordova-'+platformName] && fs.existsSync(path.join(pkgJson['cordova-platforms']['cordova-'+platformName]))) {
var platformPkgJson = require('../' + pkgJson['cordova-platforms']['cordova-'+platformName] +'/package.json');
platformVersion = platformPkgJson.version;
} else {
console.log('platformVersion not supplied. Setting platformVersion to N/A');
@@ -19,6 +19,7 @@
var generate = require('./lib/packager');
var fs = require('fs');
var path = require('path');
var pkgJson = require(process.cwd() + '/package.json');

module.exports = function(grunt) {
grunt.registerMultiTask('compile', 'Packages cordova.js', function() {
@@ -37,14 +38,14 @@ module.exports = function(grunt) {
}
});
if(!platformVersion) {
if(fs.existsSync(path.join('node_modules','cordova-'+platformName))) {
var platformPkgJson = require('../node_modules/cordova-'+platformName+'/package.json');
//grab platformVersion from sibling platform directoreis
if(pkgJson['cordova-platforms']['cordova-'+platformName] && fs.existsSync(path.join(pkgJson['cordova-platforms']['cordova-'+platformName]))) {
var platformPkgJson = require('../' + pkgJson['cordova-platforms']['cordova-'+platformName]+'/package.json');
platformVersion = platformPkgJson.version;
} else {
platformVersion="N/A";
}
}

generate(platformName, useWindowsLineEndings, platformVersion, done);
});
}
@@ -22,17 +22,34 @@ var collectFiles = require('./collect-files');
var copyProps = require('./copy-props');
var writeModule = require('./write-module');
var writeScript = require('./write-script');
var licensePath = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
var licensePath = path.join(__dirname, '..', 'templates', 'LICENSE-for-js-file.txt');
var pkgJson = require(process.cwd()+'/package.json');

module.exports = function bundle(platform, debug, commitId, platformVersion) {
console.log(__dirname);
//console.log(pkgJson);

module.exports = function bundle(platform, debug, commitId, platformVersion, platformPath) {
var modules = collectFiles(path.join('src', 'common'));
var scripts = collectFiles(path.join('src', 'scripts'));
var platformDep;
modules[''] = path.join('src', 'cordova.js');

var platformDep = path.join('node_modules', 'cordova-'+platform);
//Use passed in platformPath if it exists
if(platformPath) {
//USE PLATFORM PATH passed in

//see if platform location exists in package.json
} else if(pkgJson['cordova-platforms']['cordova-'+platform]){
platformDep = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-'+platform]);
} else {
platformDep = undefined;
}
console.log(platform +' '+ platformDep)
console.log(process.cwd());
//check to see if platform dependency has cordova-js-src directory
if(fs.existsSync(platformDep) && fs.existsSync(path.join(platformDep, 'cordova-js-src'))) {
copyProps(modules, collectFiles(path.join('node_modules', 'cordova-'+platform, 'cordova-js-src')));
copyProps(modules, collectFiles(path.join(platformDep, 'cordova-js-src')));
console.log('using sibiling directories');
} else {
if(platform !== 'test') {
//for platforms that don't have a release with cordova-js-src yet
@@ -44,11 +61,25 @@ module.exports = function bundle(platform, debug, commitId, platformVersion) {

}
if (platform === 'test') {
// Add any platform-specific modules that have tests to the test bundle.
var testFilesPath = path.join('node_modules', 'cordova-android', 'cordova-js-src', 'android');
var testFilesPath;
// Add android platform-specific modules that have tests to the test bundle.
if(fs.existsSync(path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-android']))) {
testFilesPath = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-android'], 'cordova-js-src', 'android');
modules['android/exec'] = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-android'], 'cordova-js-src', 'exec.js');
console.log('android test sibling');
} else {
testFilesPath = path.join('src', 'legacy-exec', 'android');
modules['android/exec'] = path.join('src', 'legacy-exec', 'android', 'exec.js');
}
copyProps(modules, collectFiles(testFilesPath, 'android'));
modules['android/exec'] = path.join('node_modules', 'cordova-android', 'cordova-js-src', 'exec.js');
modules['ios/exec'] = path.join('node_modules', 'cordova-ios', 'cordova-js-src', 'exec.js');

//Add iOS platform-specific modules that have tests for the test bundle.
if(fs.existsSync(path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-ios']))) {
modules['ios/exec'] = path.join(process.cwd(), pkgJson['cordova-platforms']['cordova-ios'], 'cordova-js-src', 'exec.js');
console.log('ios test sibiling');
} else {
modules['ios/exec'] = path.join('src', 'legacy-exec', 'ios', 'exec.js');
}
}

var output = [];

0 comments on commit 9ade05c

Please sign in to comment.