Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.2.1 - Phoenix #337

Merged
merged 7 commits into from
Jul 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ node_modules
cache
tmp/
test/temp/
.DS_Store
.DS_Store

example/build
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- "0.11"
- "0.10"
- "4.0"
- "6.0"
notifications:
webhooks:
urls:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Or use the module:
var NwBuilder = require('nw-builder');
var nw = new NwBuilder({
files: './path/to/nwfiles/**/**', // use the glob format
platforms: ['osx32', 'osx64', 'win32', 'win64'],
version: '0.12.3'
platforms: ['osx32', 'win32', 'win64'],
version: '0.14.6'
});

//Log stuff you want
Expand Down Expand Up @@ -257,6 +257,7 @@ To get around it, run `ulimit -n 1024` (or add it to your `~/.bash_profile`). Fo
See [CONTRIBUTING.md](CONTRIBUTING.md).

## Release History
- 2016-07-02 `2.2.1` supports newer NW.js versions (via http://nwjs.io/versions.json), plus other fixes.
- 2015-12-18 `2.2.0` added `zip` option.
- 2015-12-06 `2.1.0` added `cacheDir` command-line option, fix for no info being passed back, etc.
- 2015-06-28 `2.0.2` put upper bound to semver check for windows.
Expand Down
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Test against these versions of Node.js.
environment:
matrix:
- nodejs_version: "0.10"
- nodejs_version: "0.11"
- nodejs_version: "4.0"
- nodejs_version: "6.0"

# Allow failing jobs for bleeding-edge Node.js versions.
matrix:
Expand Down
6 changes: 3 additions & 3 deletions example/Gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
var NwBuilder = require('nw-builder');
var NwBuilder = require('../');
var gulp = require('gulp');
var gutil = require('gulp-util');

gulp.task('nw', function () {

var nw = new NwBuilder({
version: '0.11.0',
version: '0.14.6',
files: './nwapp/**',
macIcns: './icons/icon.icns',
macPlist: {mac_bundle_id: 'myPkg'},
platforms: ['win32', 'win64', 'osx32', 'osx64']
platforms: ['win32', 'win64', 'osx64']
});

// Log stuff you want
Expand Down
55 changes: 55 additions & 0 deletions lib/Version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
var platforms = require('./platforms');
var _ = require('lodash');
var semver = require('semver');

/**
* Represents a version.
* @constructor
* @param {string} args.version.
* @param {array} args.supportedPlatforms - array of strings like `osx64`.
* @param {string} args.downloadUrl.
*/
module.exports = function Version(args){
var generatePlatformUrls,
result = {
isLegacy: semver.satisfies(args.version, '<0.12.3'),
name: semver.satisfies(args.version, '>=0.12.0 || ~0.12.0-alpha') ? 'nwjs' : 'node-webkit',
version: args.version
};

// 0.12.3 is an exception that is in the manifest but is pretty much a legacy version
if(result.isLegacy || args.version === '0.12.3'){
generatePlatformUrls = function(version, supportedPlatforms){
var platformUrls = {};
supportedPlatforms.forEach(function (supportedPlatform) {
platformUrls[supportedPlatform] = args.downloadUrl + _.template(platforms[supportedPlatform].versionNameTemplate, result);
});
return platformUrls;
};
}
else {
var fixPlatformName = function(platform){
return platform.replace('32', '-ia32').replace('64', '-x64');
};

var mapPlatformToExtension = function(platform){
if(platform.indexOf('linux') === 0){
return 'tar.gz'
}

return 'zip'
};

generatePlatformUrls = function(version, supportedPlatforms){
var platformUrls = {};
supportedPlatforms.forEach(function(platform){
platformUrls[platform] = args.downloadUrl + 'v' + version + '/nwjs-sdk-v' + version + '-' + fixPlatformName(platform)
+ '.' + mapPlatformToExtension(platform);
});
return platformUrls;
};
}

result.platforms = generatePlatformUrls(args.version, args.supportedPlatforms);
return result;
};
7 changes: 7 additions & 0 deletions lib/downloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ var bar;
module.exports = {
checkCache: function(cachepath, files) {
var missing;

// if the version is >=0.12.3, then we don't which files we want from the archives, so just check that the folder
// exists and has at least 4 files in it.
if(files.length === 1 && files[0] === '*'){
return fs.existsSync(cachepath) && fs.readdirSync(cachepath).length > 3;
}

files.forEach(function(file) {
if (missing) {
return;
Expand Down
Loading