Skip to content

Commit

Permalink
Merge pull request #2 from purplecabbage/CB-5392
Browse files Browse the repository at this point in the history
Cb 5392
  • Loading branch information
purplecabbage committed Nov 26, 2013
2 parents 5977d74 + 4e7def9 commit b9badb3
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 30 deletions.
12 changes: 8 additions & 4 deletions platforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ module.exports = {
'wp7' : {
parser : './src/metadata/wp7_parser',
url : 'https://git-wip-us.apache.org/repos/asf?p=cordova-wp8.git',
version: '3.2.0'
version: '3.2.0',
subdirectory: 'wp7'
},
'wp8' : {
parser : './src/metadata/wp8_parser',
url : 'https://git-wip-us.apache.org/repos/asf?p=cordova-wp8.git',
version: '3.2.0'
version: '3.2.0',
subdirectory: 'wp8'
},
'blackberry10' : {
parser : './src/metadata/blackberry10_parser',
url : 'https://git-wip-us.apache.org/repos/asf?p=cordova-blackberry.git',
version: '3.2.0'
version: '3.2.0',
subdirectory: 'blackberry10'
},
'www':{
url : 'https://git-wip-us.apache.org/repos/asf?p=cordova-app-hello-world.git',
Expand All @@ -55,7 +58,8 @@ module.exports = {
'windows8':{
parser: './src/metadata/windows8_parser',
url : 'https://git-wip-us.apache.org/repos/asf?p=cordova-windows.git',
version: '3.2.0'
version: '3.2.0',
subdirectory: 'windows8'
}
};

Expand Down
5 changes: 0 additions & 5 deletions spec/metadata/windows8_parser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ describe('windows8 project parser', function() {
var config, www, overrides, staging, svn;
beforeEach(function() {
config = spyOn(p, 'update_from_config');
www = spyOn(p, 'update_www');
staging = spyOn(p, 'update_staging');
svn = spyOn(util, 'deleteSvnFolders');
});
Expand All @@ -243,10 +242,6 @@ describe('windows8 project parser', function() {
expect(err).toEqual(err);
});
});
it('should call update_www', function() {
p.update_project();
expect(www).toHaveBeenCalled();
});
it('should call update_staging', function() {
p.update_project();
expect(staging).toHaveBeenCalled();
Expand Down
4 changes: 2 additions & 2 deletions spec/platform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ describe('platform command', function() {

fakeLazyLoad = function(id, platform, version) {
if (platform == 'wp7' || platform == 'wp8') {
return Q(path.join('lib', 'wp', id, version));
return Q(path.join('lib', 'wp', id, version, platform));
} else {
return Q(path.join('lib', platform, id, version));
return Q(path.join('lib', platform, id, version, platforms[platform] && platforms[platform].subdirectory ? platforms[platform].subdirectory : ''));
}
};
lazyLoadVersion = '3.1.0';
Expand Down
15 changes: 10 additions & 5 deletions src/lazy_load.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ module.exports = {
custom:function(url, id, platform, version) {
var download_dir = (platform == 'wp7' || platform == 'wp8' ? path.join(util.libDirectory, 'wp', id, version) :
path.join(util.libDirectory, platform, id, version));

var lib_dir = platforms[platform] && platforms[platform].subdirectory ? path.join(download_dir, platforms[platform].subdirectory) : download_dir;

if (fs.existsSync(download_dir)) {
events.emit('verbose', id + ' library for "' + platform + '" already exists. No need to download. Continuing.');
return Q(download_dir);
return Q(lib_dir);
}
events.emit('log', 'Downloading ' + id + ' library for ' + platform + '...');
return hooker.fire('before_library_download', {
Expand Down Expand Up @@ -99,14 +102,14 @@ module.exports = {
events.emit('log', 'Download complete');
var entries = fs.readdirSync(download_dir);
var entry = path.join(download_dir, entries[0]);
shell.mv('-f', path.join(entry, (platform=='blackberry10'?'blackberry10':''), '*'), download_dir);
shell.mv('-f', path.join(entry, '*'), download_dir);
shell.rm('-rf', entry);
d.resolve(hooker.fire('after_library_download', {
platform:platform,
url:url,
id:id,
version:version,
path:download_dir,
path: lib_dir,
size:size,
symlink:false
}));
Expand All @@ -116,16 +119,18 @@ module.exports = {
// Local path.
// Do nothing here; users of this code should be using the returned path.
download_dir = uri.protocol && uri.protocol[1] == ':' ? uri.href : uri.path;
lib_dir = platforms[platform] && platforms[platform].subdirectory ? path.join(download_dir, platforms[platform].subdirectory) : download_dir;

d.resolve(hooker.fire('after_library_download', {
platform:platform,
url:url,
id:id,
version:version,
path:download_dir,
path: lib_dir,
symlink:false
}));
}
return d.promise.then(function() { return download_dir; });
return d.promise.then(function () { return lib_dir; });
});
},
// Returns a promise for the path to the lazy-loaded directory.
Expand Down
5 changes: 1 addition & 4 deletions src/metadata/windows8_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ module.exports.prototype = {

// Used for creating platform_www in projects created by older versions.
cordovajs_path:function(libDir) {
var jsPath = path.join(libDir, 'windows8', "template", 'www', 'cordova.js');
var jsPath = path.join(libDir, "template", 'www', 'cordova.js');
return path.resolve(jsPath);
},

Expand Down Expand Up @@ -287,9 +287,6 @@ module.exports.prototype = {
return Q.reject(e);
}
// overrides (merges) are handled in update_www()
// CB-5340 Windows8 build does no write cordova_plugins.js
//var libDir = path.join(util.libDirectory, 'windows8', 'cordova', require('../../platforms').windows8.version);
//this.update_www(libDir);
this.update_staging();
this.add_bom();

Expand Down
2 changes: 1 addition & 1 deletion src/metadata/wp7_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports.prototype = {

// Used for creating platform_www in projects created by older versions.
cordovajs_path:function(libDir) {
var jsPath = path.join(libDir, 'common', 'www', 'cordova.js');
var jsPath = path.join(libDir, '..', 'common', 'www', 'cordova.js');
return path.resolve(jsPath);
},

Expand Down
2 changes: 1 addition & 1 deletion src/metadata/wp8_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module.exports.prototype = {

// Used for creating platform_www in projects created by older versions.
cordovajs_path:function(libDir) {
var jsPath = path.join(libDir, 'common', 'www', 'cordova.js');
var jsPath = path.join(libDir, '..', 'common', 'www', 'cordova.js');
return path.resolve(jsPath);
},

Expand Down
8 changes: 0 additions & 8 deletions src/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ module.exports = function platform(command, targets) {
.then(function() {
return lazy_load.based_on_config(projectRoot, plat);
}).then(function(libDir) {
// Check for platforms are in subdirectories into repositories
if (["wp7", "wp8", "windows8", "windows81", "blackberry10"].indexOf(plat) !== -1)
libDir = path.join(libDir, target);

var script = path.join(libDir, 'bin', 'update');
var d = Q.defer();
child_process.exec(script + ' "' + path.join(projectRoot, 'platforms', plat) + '"', function(err, stdout, stderr) {
Expand Down Expand Up @@ -226,10 +222,6 @@ function call_into_create(target, projectRoot, cfg, libDir, template_dir) {
events.emit('verbose', 'Checking if platform "' + target + '" passes minimum requirements...');
return module.exports.supports(projectRoot, target)
.then(function() {
// Check for platforms are in subdirectories into repositories
if (["wp7", "wp8", "windows8", "windows81"].indexOf(target) !== -1)
libDir = path.join(libDir, target);

// Create a platform app using the ./bin/create scripts that exist in each repo.
var bin = path.join(libDir, 'bin', 'create');
var args = (target=='ios') ? '--arc' : '';
Expand Down

0 comments on commit b9badb3

Please sign in to comment.