nw-builder 3.5.7 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{CHANGELOG.md → .github/CHANGELOG.md} +18 -2
- package/.github/ISSUE_REQUEST_TEMPLATE.md +16 -0
- package/{LICENSE → .github/LICENSE} +0 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +5 -0
- package/.github/workflows/cd.yml +24 -0
- package/.github/workflows/ci.yml +27 -0
- package/README.md +94 -96
- package/bin/nwbuild +19 -22
- package/demo.js +22 -0
- package/example/icons/README.md +7 -0
- package/example/icons/icon.icns +0 -0
- package/example/icons/icon.ico +0 -0
- package/example/nwapp/Credits.html +9 -0
- package/example/nwapp/README.md +7 -0
- package/example/nwapp/images/README.md +7 -0
- package/example/nwapp/images/kitten.jpg +0 -0
- package/example/nwapp/index.html +22 -0
- package/example/nwapp/package.json +23 -0
- package/example/package.json +7 -0
- package/lib/index.js +16 -6
- package/package.json +65 -60
- package/test/downloader.js +87 -0
- package/test/expected/README.md +7 -0
- package/test/expected/merged +1 -0
- package/test/expected/oneOveriddenRestNot/README.md +7 -0
- package/test/expected/oneOveriddenRestNot/osx32.json +9 -0
- package/test/expected/oneOveriddenRestNot/osx64.json +9 -0
- package/test/expected/osx-plist/1.plist +47 -0
- package/test/expected/osx-plist/2.plist +40 -0
- package/test/expected/osx-plist/README.md +7 -0
- package/test/expected/platformOverrides/README.md +7 -0
- package/test/expected/platformOverrides/linux32.json +13 -0
- package/test/expected/platformOverrides/linux64.json +9 -0
- package/test/expected/platformOverrides/osx32.json +12 -0
- package/test/expected/platformOverrides/osx64.json +12 -0
- package/test/expected/platformOverrides/win32.json +12 -0
- package/test/expected/platformOverrides/win64.json +12 -0
- package/test/fixtures/README.md +7 -0
- package/test/fixtures/invalid.json +3 -0
- package/test/fixtures/manifest/README.md +7 -0
- package/test/fixtures/manifest/versions.json +23 -0
- package/test/fixtures/nwapp/README.md +7 -0
- package/test/fixtures/nwapp/images/imagefile.img +1 -0
- package/test/fixtures/nwapp/index.html +10 -0
- package/test/fixtures/nwapp/javascript/bower_packages/simple/package.json +1 -0
- package/test/fixtures/nwapp/javascript/jsfile.js +1 -0
- package/test/fixtures/nwapp/package.json +5 -0
- package/test/fixtures/oneOveriddenRestNot/README.md +7 -0
- package/test/fixtures/oneOveriddenRestNot/package.json +16 -0
- package/test/fixtures/osx-plist/Info.plist +93 -0
- package/test/fixtures/osx-plist/README.md +7 -0
- package/test/fixtures/platformOverrides/README.md +7 -0
- package/test/fixtures/platformOverrides/package.json +52 -0
- package/test/fixtures/test-strip.zip +0 -0
- package/test/fixtures/test.tar.gz +0 -0
- package/test/fixtures/test.zip +0 -0
- package/test/fixtures/testVersions.html +17 -0
- package/test/nwBuilder.js +237 -0
- package/test/utils.js +232 -0
- package/test/versions.js +330 -0
- package/bin/README.md +0 -7
- package/lib/README.md +0 -7
package/test/utils.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
var test = require('tape');
|
|
2
|
+
var testSetup = require('redtape');
|
|
3
|
+
var temp = require('temp');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var utils = require('./../lib/utils');
|
|
7
|
+
var DecompressZip = require('decompress-zip');
|
|
8
|
+
var _ = require('lodash');
|
|
9
|
+
var EventEmitter = require('events').EventEmitter;
|
|
10
|
+
var del = require('rimraf');
|
|
11
|
+
var thenify = require('thenify');
|
|
12
|
+
var isWindows = process.platform === 'win32';
|
|
13
|
+
var tempFile = thenify(temp.open);
|
|
14
|
+
|
|
15
|
+
var tempFileCleanup = function(){
|
|
16
|
+
return new Promise(function(resolve, reject){
|
|
17
|
+
temp.cleanup(function(err, result){
|
|
18
|
+
if(err){
|
|
19
|
+
return reject(err);
|
|
20
|
+
}
|
|
21
|
+
resolve(result);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
test('getPackageInfo invalid', function (t) {
|
|
27
|
+
t.plan(1);
|
|
28
|
+
utils.getPackageInfo('./test/fixtures/invalid.json').catch(function (error) {
|
|
29
|
+
t.ok(error);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('getPackageInfo valid', function (t) {
|
|
34
|
+
t.plan(2);
|
|
35
|
+
var pkg = utils.getPackageInfo('./test/fixtures/nwapp/package.json').then(function (pkg) {
|
|
36
|
+
t.equal(pkg.name, 'nw-demo', 'get package name');
|
|
37
|
+
t.equal(pkg.version, '0.1.0', 'get package version');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('generate and write a valid plist file', function (t) {
|
|
43
|
+
t.plan(2);
|
|
44
|
+
var tests = [];
|
|
45
|
+
|
|
46
|
+
// custom properties
|
|
47
|
+
tests.push(tempFile('plist-1').then(function (info) {
|
|
48
|
+
var options = utils.getPlistOptions(
|
|
49
|
+
{
|
|
50
|
+
name: 'TestApp',
|
|
51
|
+
version: '1.3.3.7',
|
|
52
|
+
copyright: '(c) by me'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
CFBundleDisplayName: 'My cool TestApp',
|
|
56
|
+
LSEnvironment: {
|
|
57
|
+
PATH: '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin'
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
return utils.editPlist('./test/fixtures/osx-plist/Info.plist', info.path, options).then(function () {
|
|
62
|
+
var actual = fs.readFileSync(info.path).toString().replace(/\r|\n/gm, '');
|
|
63
|
+
var expected = fs.readFileSync('./test/expected/osx-plist/1.plist').toString().replace(/\r|\n/gm, '');
|
|
64
|
+
t.equal(actual, expected, 'with custom properties');
|
|
65
|
+
});
|
|
66
|
+
}));
|
|
67
|
+
|
|
68
|
+
// without copyright information
|
|
69
|
+
tests.push(tempFile('plist-2').then(function (info) {
|
|
70
|
+
var options = utils.getPlistOptions(
|
|
71
|
+
{
|
|
72
|
+
name: 'TestApp',
|
|
73
|
+
version: '1.3.3.7'
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
return utils.editPlist('./test/fixtures/osx-plist/Info.plist', info.path, options).then(function () {
|
|
77
|
+
var actual = fs.readFileSync(info.path).toString().replace(/\r|\n/gm, '');
|
|
78
|
+
var expected = fs.readFileSync('./test/expected/osx-plist/2.plist').toString().replace(/\r|\n/gm, '');
|
|
79
|
+
t.equal(actual, expected, 'without copyright information');
|
|
80
|
+
});
|
|
81
|
+
}));
|
|
82
|
+
|
|
83
|
+
Promise.all(tests).then(tempFileCleanup).then(function () {
|
|
84
|
+
t.end();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('getFileList', function (t) {
|
|
90
|
+
t.plan(5);
|
|
91
|
+
|
|
92
|
+
utils.getFileList(['./test/fixtures/nwapp/**', '!./test/fixtures/nwapp/README.md']).then(function(data) {
|
|
93
|
+
t.equal(data.json, path.normalize('test/fixtures/nwapp/package.json'), 'figure out the right json');
|
|
94
|
+
var expected = [{
|
|
95
|
+
"src" : path.normalize("test/fixtures/nwapp/images/imagefile.img"),
|
|
96
|
+
"dest": path.normalize("images/imagefile.img")
|
|
97
|
+
}, {
|
|
98
|
+
"src" : path.normalize("test/fixtures/nwapp/index.html"),
|
|
99
|
+
"dest": path.normalize("index.html")
|
|
100
|
+
}, {
|
|
101
|
+
"src" : path.normalize("test/fixtures/nwapp/javascript/bower_packages/simple/package.json"),
|
|
102
|
+
"dest": path.normalize("javascript/bower_packages/simple/package.json")
|
|
103
|
+
}, {
|
|
104
|
+
"src" : path.normalize("test/fixtures/nwapp/javascript/jsfile.js"),
|
|
105
|
+
"dest": path.normalize("javascript/jsfile.js")
|
|
106
|
+
}, {
|
|
107
|
+
"src" : path.normalize("test/fixtures/nwapp/node_modules/package/package.json"),
|
|
108
|
+
"dest": path.normalize("node_modules/package/package.json")
|
|
109
|
+
}, {
|
|
110
|
+
"src" : path.normalize("test/fixtures/nwapp/package.json"),
|
|
111
|
+
"dest": path.normalize("package.json")
|
|
112
|
+
}];
|
|
113
|
+
t.deepEqual(data.files, expected);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
utils.getFileList('./test/fixtures/nwapp/images/**').then(function(data) {
|
|
117
|
+
}, function (error) {
|
|
118
|
+
t.equal(error, 'Could not find a package.json in your src folder', 'throw an error if there is no package json');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
utils.getFileList('./test/fixtures/nwapp/images/*.js').then(function(data) {
|
|
122
|
+
}, function (error) {
|
|
123
|
+
t.equal(error, 'No files matching');
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
utils.getFileList(['./test/fixtures/nwapp/**/*', '!./test/fixtures/nwapp/node_modules/**/*', '!./test/fixtures/nwapp/javascript/**/*', '!./test/fixtures/nwapp/README.md']).then(function(data) {
|
|
127
|
+
var expected = [{
|
|
128
|
+
"src" : path.normalize("test/fixtures/nwapp/images/imagefile.img"),
|
|
129
|
+
"dest": path.normalize("images/imagefile.img")
|
|
130
|
+
}, {
|
|
131
|
+
"src" : path.normalize("test/fixtures/nwapp/index.html"),
|
|
132
|
+
"dest": path.normalize("index.html")
|
|
133
|
+
}, {
|
|
134
|
+
"src" : path.normalize("test/fixtures/nwapp/package.json"),
|
|
135
|
+
"dest": path.normalize("package.json")
|
|
136
|
+
}];
|
|
137
|
+
t.deepEqual(data.files, expected);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test('should zip the app and create the app.nw file + log it', function (t) {
|
|
143
|
+
t.plan(6);
|
|
144
|
+
|
|
145
|
+
var files = [{
|
|
146
|
+
"src" : path.normalize("test/fixtures/nwapp/images/imagefile.img"),
|
|
147
|
+
"dest": path.normalize("images/imagefile.img")
|
|
148
|
+
}, {
|
|
149
|
+
"src" : path.normalize("test/fixtures/nwapp/javascript/bower_packages/simple/package.json"),
|
|
150
|
+
"dest": path.normalize("javascript/bower_packages/simple/package.json")
|
|
151
|
+
}, {
|
|
152
|
+
"src" : path.normalize("test/fixtures/nwapp/javascript/jsfile.js"),
|
|
153
|
+
"dest": path.normalize("javascript/jsfile.js")
|
|
154
|
+
}, {
|
|
155
|
+
"src" : path.normalize("test/fixtures/nwapp/node_modules/package/package.json"),
|
|
156
|
+
"dest": path.normalize("node_modules/package/package.json")
|
|
157
|
+
}, {
|
|
158
|
+
"src" : path.normalize("test/fixtures/nwapp/package.json"),
|
|
159
|
+
"dest": path.normalize("package.json")
|
|
160
|
+
}], expected = _.map(files, 'dest').sort();
|
|
161
|
+
|
|
162
|
+
var _evt = new EventEmitter();
|
|
163
|
+
_evt.on('log', function (logging) {
|
|
164
|
+
t.ok(logging, 'LOG: ' + logging);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
utils.generateZipFile(files, _evt).then(function(nwfile) {
|
|
168
|
+
var unzipper = new DecompressZip(nwfile);
|
|
169
|
+
unzipper.on('list', function (files) {
|
|
170
|
+
t.deepEqual(files.sort(), expected);
|
|
171
|
+
});
|
|
172
|
+
unzipper.list();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
testSetup({
|
|
178
|
+
afterEach: function(done){
|
|
179
|
+
del('./test/temp/platform-specific-unzipped', done);
|
|
180
|
+
}
|
|
181
|
+
})('should zip but use platform-specific manifest with overrides in package.json', function (t) {
|
|
182
|
+
t.plan(3);
|
|
183
|
+
|
|
184
|
+
var files = [{
|
|
185
|
+
"src" : path.normalize("test/fixtures/nwapp/images/imagefile.img"),
|
|
186
|
+
"dest": path.normalize("images/imagefile.img")
|
|
187
|
+
}, {
|
|
188
|
+
"src" : path.normalize("test/fixtures/nwapp/package.json"),
|
|
189
|
+
"dest": path.normalize("package.json")
|
|
190
|
+
}], expectedPackage = "{hello: 'world'}";
|
|
191
|
+
|
|
192
|
+
var _evt = new EventEmitter();
|
|
193
|
+
_evt.on('log', function (logging) {
|
|
194
|
+
t.ok(logging, 'LOG: ' + logging);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
utils.generateZipFile(files, _evt, expectedPackage).then(function(nwfile) {
|
|
198
|
+
var unzipper = new DecompressZip(nwfile),
|
|
199
|
+
unzipDestination = 'test/temp/platform-specific-unzipped';
|
|
200
|
+
|
|
201
|
+
unzipper.on('extract', function (log) {
|
|
202
|
+
t.equal(fs.readFileSync(path.join(unzipDestination, 'package.json')).toString(), expectedPackage);
|
|
203
|
+
t.end();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
unzipper.extract({
|
|
207
|
+
path: unzipDestination
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
test('mergeFiles', function (t) {
|
|
214
|
+
t.plan(isWindows ? 1 : 2);
|
|
215
|
+
|
|
216
|
+
var releasefile = temp.openSync();
|
|
217
|
+
fs.writeFileSync(releasefile.path, 'A');
|
|
218
|
+
|
|
219
|
+
var zipFile = temp.openSync();
|
|
220
|
+
fs.writeFileSync(zipFile.path, 'B');
|
|
221
|
+
|
|
222
|
+
utils.mergeFiles(releasefile.path, zipFile.path, '0755').then(function() {
|
|
223
|
+
var contents = fs.readFileSync(releasefile.path);
|
|
224
|
+
var stats = fs.lstatSync(releasefile.path);
|
|
225
|
+
t.equal(contents.toString(), 'AB', 'merge two files');
|
|
226
|
+
|
|
227
|
+
if(!isWindows) {
|
|
228
|
+
t.equal(stats.mode.toString(8), '100755', 'fix the permission'); // DOES NOT WORK ON WINDOWS
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
});
|
package/test/versions.js
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
var test = require('tape'),
|
|
2
|
+
nock = require('nock'),
|
|
3
|
+
_ = require('lodash');
|
|
4
|
+
|
|
5
|
+
var versions = require('./../lib/versions');
|
|
6
|
+
|
|
7
|
+
var root = 'http://nwjs.io';
|
|
8
|
+
var dlUrl = 'http://dl.nwjs.io/';
|
|
9
|
+
var expectedLegacyVersions = ['0.10.2','0.10.0-rc1','0.9.3'];
|
|
10
|
+
|
|
11
|
+
test('getLatestVersion', function (t) {
|
|
12
|
+
t.plan(3);
|
|
13
|
+
|
|
14
|
+
nock(root).get('/versions.json').replyWithFile(200, './test/fixtures/manifest/versions.json');
|
|
15
|
+
nock(root).get('/versions.json').replyWithFile(200, './test/fixtures/manifest/versions.json');
|
|
16
|
+
|
|
17
|
+
versions.getLatestVersion('http://dl.nwjs.io/', root + '/versions.json').then(function(result){
|
|
18
|
+
t.equal(result.version, '0.15.2');
|
|
19
|
+
t.equal(result.name, 'nwjs');
|
|
20
|
+
t.deepEqual(result.platforms, {
|
|
21
|
+
'linux32-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-linux-ia32.tar.gz',
|
|
22
|
+
"linux32-sdk": 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-linux-ia32.tar.gz',
|
|
23
|
+
'linux64-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-linux-x64.tar.gz',
|
|
24
|
+
"linux64-sdk": 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-linux-x64.tar.gz',
|
|
25
|
+
'osx64-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-osx-x64.zip',
|
|
26
|
+
"osx64-sdk": 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-osx-x64.zip',
|
|
27
|
+
'win32-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-win-ia32.zip',
|
|
28
|
+
"win32-sdk": 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-win-ia32.zip',
|
|
29
|
+
'win64-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-win-x64.zip',
|
|
30
|
+
"win64-sdk": 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-win-x64.zip'
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('getVersions', function (t) {
|
|
36
|
+
t.plan(6);
|
|
37
|
+
|
|
38
|
+
nock(root).get('/versions.json').replyWithFile(200, './test/fixtures/manifest/versions.json');
|
|
39
|
+
nock(dlUrl).get('/').replyWithFile(200, './test/fixtures/testVersions.html');
|
|
40
|
+
expectedLegacyVersions.forEach(function(expectedVersion){
|
|
41
|
+
nock(dlUrl).head('/v' + expectedVersion + '/node-webkit-v' + expectedVersion + '-win-ia32.zip')
|
|
42
|
+
.replyWithFile(200, './test/fixtures/testVersions.html'); // needs to reply with *any* content
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
versions.getVersions(dlUrl, root + '/versions.json').then(function(result){
|
|
46
|
+
var expectedVersions = [
|
|
47
|
+
{
|
|
48
|
+
version: '0.15.2',
|
|
49
|
+
name: 'nwjs',
|
|
50
|
+
platforms: {
|
|
51
|
+
'linux32-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-linux-ia32.tar.gz',
|
|
52
|
+
'linux32-sdk': 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-linux-ia32.tar.gz',
|
|
53
|
+
'linux64-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-linux-x64.tar.gz',
|
|
54
|
+
'linux64-sdk': 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-linux-x64.tar.gz',
|
|
55
|
+
'osx64-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-osx-x64.zip',
|
|
56
|
+
'osx64-sdk': 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-osx-x64.zip',
|
|
57
|
+
'win32-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-win-ia32.zip',
|
|
58
|
+
'win32-sdk': 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-win-ia32.zip',
|
|
59
|
+
'win64-normal': 'http://dl.nwjs.io/v0.15.2/nwjs-v0.15.2-win-x64.zip',
|
|
60
|
+
'win64-sdk': 'http://dl.nwjs.io/v0.15.2/nwjs-sdk-v0.15.2-win-x64.zip'
|
|
61
|
+
},
|
|
62
|
+
isLegacy: false
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
version: '0.13.2',
|
|
66
|
+
name: 'nwjs',
|
|
67
|
+
platforms: {
|
|
68
|
+
'linux32-nacl': 'http://dl.nwjs.io/v0.13.2/nwjs-nacl-v0.13.2-linux-ia32.tar.gz',
|
|
69
|
+
'linux32-normal': 'http://dl.nwjs.io/v0.13.2/nwjs-v0.13.2-linux-ia32.tar.gz',
|
|
70
|
+
'linux32-sdk': 'http://dl.nwjs.io/v0.13.2/nwjs-sdk-v0.13.2-linux-ia32.tar.gz',
|
|
71
|
+
'osx64-nacl': 'http://dl.nwjs.io/v0.13.2/nwjs-nacl-v0.13.2-osx-x64.zip',
|
|
72
|
+
'osx64-normal': 'http://dl.nwjs.io/v0.13.2/nwjs-v0.13.2-osx-x64.zip',
|
|
73
|
+
'osx64-sdk': 'http://dl.nwjs.io/v0.13.2/nwjs-sdk-v0.13.2-osx-x64.zip',
|
|
74
|
+
'win64-nacl': 'http://dl.nwjs.io/v0.13.2/nwjs-nacl-v0.13.2-win-x64.zip',
|
|
75
|
+
'win64-normal': 'http://dl.nwjs.io/v0.13.2/nwjs-v0.13.2-win-x64.zip',
|
|
76
|
+
'win64-sdk': 'http://dl.nwjs.io/v0.13.2/nwjs-sdk-v0.13.2-win-x64.zip'
|
|
77
|
+
},
|
|
78
|
+
isLegacy: false
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
version: '0.12.3',
|
|
82
|
+
name: 'nwjs',
|
|
83
|
+
platforms: { 'linux32-macappstore': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-linux-ia32.tar.gz', 'linux32-normal': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-linux-ia32.tar.gz', 'linux64-macappstore': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-linux-x64.tar.gz', 'linux64-normal': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-linux-x64.tar.gz', 'osx32-macappstore': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-osx-ia32.zip', 'osx32-normal': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-osx-ia32.zip', 'osx64-macappstore': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-osx-x64.zip', 'osx64-normal': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-osx-x64.zip', 'win32-macappstore': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-ia32.zip', 'win32-normal': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-ia32.zip', 'win64-macappstore': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-x64.zip', 'win64-normal': 'http://dl.nwjs.io/v0.12.3/nwjs-v0.12.3-win-x64.zip' },
|
|
84
|
+
isLegacy: false
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
version: '0.10.2',
|
|
88
|
+
name: 'node-webkit',
|
|
89
|
+
platforms: {
|
|
90
|
+
'linux32-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-linux-ia32.tar.gz',
|
|
91
|
+
'linux64-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-linux-x64.tar.gz',
|
|
92
|
+
'osx32-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-osx-ia32.zip',
|
|
93
|
+
'osx64-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-osx-x64.zip',
|
|
94
|
+
'win32-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-win-ia32.zip',
|
|
95
|
+
'win64-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-win-x64.zip'
|
|
96
|
+
},
|
|
97
|
+
isLegacy: true
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
version: '0.10.0-rc1',
|
|
101
|
+
name: 'node-webkit',
|
|
102
|
+
platforms: {
|
|
103
|
+
'linux32-sdk': 'http://dl.nwjs.io/v0.10.0-rc1/node-webkit-v0.10.0-rc1-linux-ia32.tar.gz',
|
|
104
|
+
'linux64-sdk': 'http://dl.nwjs.io/v0.10.0-rc1/node-webkit-v0.10.0-rc1-linux-x64.tar.gz',
|
|
105
|
+
'osx32-sdk': 'http://dl.nwjs.io/v0.10.0-rc1/node-webkit-v0.10.0-rc1-osx-ia32.zip',
|
|
106
|
+
'osx64-sdk': 'http://dl.nwjs.io/v0.10.0-rc1/node-webkit-v0.10.0-rc1-osx-x64.zip',
|
|
107
|
+
'win32-sdk': 'http://dl.nwjs.io/v0.10.0-rc1/node-webkit-v0.10.0-rc1-win-ia32.zip',
|
|
108
|
+
'win64-sdk': 'http://dl.nwjs.io/v0.10.0-rc1/node-webkit-v0.10.0-rc1-win-x64.zip'
|
|
109
|
+
},
|
|
110
|
+
isLegacy: true
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
version: '0.9.3',
|
|
114
|
+
name: 'node-webkit',
|
|
115
|
+
platforms: { 'linux32-sdk': 'http://dl.nwjs.io/v0.9.3/node-webkit-v0.9.3-linux-ia32.tar.gz', 'linux64-sdk': 'http://dl.nwjs.io/v0.9.3/node-webkit-v0.9.3-linux-x64.tar.gz', 'osx32-sdk': 'http://dl.nwjs.io/v0.9.3/node-webkit-v0.9.3-osx-ia32.zip', 'osx64-sdk': 'http://dl.nwjs.io/v0.9.3/node-webkit-v0.9.3-osx-x64.zip', 'win32-sdk': 'http://dl.nwjs.io/v0.9.3/node-webkit-v0.9.3-win-ia32.zip', 'win64-sdk': 'http://dl.nwjs.io/v0.9.3/node-webkit-v0.9.3-win-x64.zip' },
|
|
116
|
+
isLegacy: true
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
for(var i = 0; i < expectedVersions.length; i++){
|
|
121
|
+
t.deepEqual(result[i], expectedVersions[i]);
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
.catch(function(err){
|
|
125
|
+
console.error(err.stack);
|
|
126
|
+
t.fail(err);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
test('getVersions (custom download URL)', function (t) {
|
|
132
|
+
t.plan(6);
|
|
133
|
+
|
|
134
|
+
nock(root).get('/versions.json').replyWithFile(200, './test/fixtures/manifest/versions.json');
|
|
135
|
+
nock('http://abc.xyz/').get('/').replyWithFile(200, './test/fixtures/testVersions.html');
|
|
136
|
+
expectedLegacyVersions.forEach(function(expectedVersion){
|
|
137
|
+
nock('http://abc.xyz/').head('/v' + expectedVersion + '/node-webkit-v' + expectedVersion + '-win-ia32.zip')
|
|
138
|
+
.replyWithFile(200, './test/fixtures/testVersions.html'); // needs to reply with *any* content
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
versions.getVersions('http://abc.xyz/', root + '/versions.json').then(function(result){
|
|
142
|
+
var expectedVersions = [
|
|
143
|
+
{
|
|
144
|
+
version: '0.15.2',
|
|
145
|
+
name: 'nwjs',
|
|
146
|
+
platforms: {
|
|
147
|
+
'linux32-normal': 'http://abc.xyz/v0.15.2/nwjs-v0.15.2-linux-ia32.tar.gz',
|
|
148
|
+
'linux32-sdk': 'http://abc.xyz/v0.15.2/nwjs-sdk-v0.15.2-linux-ia32.tar.gz',
|
|
149
|
+
'linux64-normal': 'http://abc.xyz/v0.15.2/nwjs-v0.15.2-linux-x64.tar.gz',
|
|
150
|
+
'linux64-sdk': 'http://abc.xyz/v0.15.2/nwjs-sdk-v0.15.2-linux-x64.tar.gz',
|
|
151
|
+
'osx64-normal': 'http://abc.xyz/v0.15.2/nwjs-v0.15.2-osx-x64.zip',
|
|
152
|
+
'osx64-sdk': 'http://abc.xyz/v0.15.2/nwjs-sdk-v0.15.2-osx-x64.zip',
|
|
153
|
+
'win32-normal': 'http://abc.xyz/v0.15.2/nwjs-v0.15.2-win-ia32.zip',
|
|
154
|
+
'win32-sdk': 'http://abc.xyz/v0.15.2/nwjs-sdk-v0.15.2-win-ia32.zip',
|
|
155
|
+
'win64-normal': 'http://abc.xyz/v0.15.2/nwjs-v0.15.2-win-x64.zip',
|
|
156
|
+
'win64-sdk': 'http://abc.xyz/v0.15.2/nwjs-sdk-v0.15.2-win-x64.zip'
|
|
157
|
+
},
|
|
158
|
+
isLegacy: false
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
version: '0.13.2',
|
|
162
|
+
name: 'nwjs',
|
|
163
|
+
platforms: {
|
|
164
|
+
'linux32-nacl': 'http://abc.xyz/v0.13.2/nwjs-nacl-v0.13.2-linux-ia32.tar.gz',
|
|
165
|
+
'linux32-normal': 'http://abc.xyz/v0.13.2/nwjs-v0.13.2-linux-ia32.tar.gz',
|
|
166
|
+
'linux32-sdk': 'http://abc.xyz/v0.13.2/nwjs-sdk-v0.13.2-linux-ia32.tar.gz',
|
|
167
|
+
'osx64-nacl': 'http://abc.xyz/v0.13.2/nwjs-nacl-v0.13.2-osx-x64.zip',
|
|
168
|
+
'osx64-normal': 'http://abc.xyz/v0.13.2/nwjs-v0.13.2-osx-x64.zip',
|
|
169
|
+
'osx64-sdk': 'http://abc.xyz/v0.13.2/nwjs-sdk-v0.13.2-osx-x64.zip',
|
|
170
|
+
'win64-nacl': 'http://abc.xyz/v0.13.2/nwjs-nacl-v0.13.2-win-x64.zip',
|
|
171
|
+
'win64-normal': 'http://abc.xyz/v0.13.2/nwjs-v0.13.2-win-x64.zip',
|
|
172
|
+
'win64-sdk': 'http://abc.xyz/v0.13.2/nwjs-sdk-v0.13.2-win-x64.zip'
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
isLegacy: false
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
version: '0.12.3',
|
|
179
|
+
name: 'nwjs',
|
|
180
|
+
platforms: {
|
|
181
|
+
'linux32-macappstore': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-linux-ia32.tar.gz',
|
|
182
|
+
'linux32-normal': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-linux-ia32.tar.gz',
|
|
183
|
+
'linux64-macappstore': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-linux-x64.tar.gz',
|
|
184
|
+
'linux64-normal': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-linux-x64.tar.gz',
|
|
185
|
+
'osx32-macappstore': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-osx-ia32.zip',
|
|
186
|
+
'osx32-normal': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-osx-ia32.zip',
|
|
187
|
+
'osx64-macappstore': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-osx-x64.zip',
|
|
188
|
+
'osx64-normal': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-osx-x64.zip',
|
|
189
|
+
'win32-macappstore': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-win-ia32.zip',
|
|
190
|
+
'win32-normal': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-win-ia32.zip',
|
|
191
|
+
'win64-macappstore': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-win-x64.zip',
|
|
192
|
+
'win64-normal': 'http://abc.xyz/v0.12.3/nwjs-v0.12.3-win-x64.zip'
|
|
193
|
+
},
|
|
194
|
+
isLegacy: false
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
version: '0.10.2',
|
|
198
|
+
name: 'node-webkit',
|
|
199
|
+
platforms: {
|
|
200
|
+
'linux32-sdk': 'http://abc.xyz/v0.10.2/node-webkit-v0.10.2-linux-ia32.tar.gz',
|
|
201
|
+
'linux64-sdk': 'http://abc.xyz/v0.10.2/node-webkit-v0.10.2-linux-x64.tar.gz',
|
|
202
|
+
'osx32-sdk': 'http://abc.xyz/v0.10.2/node-webkit-v0.10.2-osx-ia32.zip',
|
|
203
|
+
'osx64-sdk': 'http://abc.xyz/v0.10.2/node-webkit-v0.10.2-osx-x64.zip',
|
|
204
|
+
'win32-sdk': 'http://abc.xyz/v0.10.2/node-webkit-v0.10.2-win-ia32.zip',
|
|
205
|
+
'win64-sdk': 'http://abc.xyz/v0.10.2/node-webkit-v0.10.2-win-x64.zip'
|
|
206
|
+
},
|
|
207
|
+
isLegacy: true
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
version: '0.10.0-rc1',
|
|
211
|
+
name: 'node-webkit',
|
|
212
|
+
platforms: {
|
|
213
|
+
'linux32-sdk': 'http://abc.xyz/v0.10.0-rc1/node-webkit-v0.10.0-rc1-linux-ia32.tar.gz',
|
|
214
|
+
'linux64-sdk': 'http://abc.xyz/v0.10.0-rc1/node-webkit-v0.10.0-rc1-linux-x64.tar.gz',
|
|
215
|
+
'osx32-sdk': 'http://abc.xyz/v0.10.0-rc1/node-webkit-v0.10.0-rc1-osx-ia32.zip',
|
|
216
|
+
'osx64-sdk': 'http://abc.xyz/v0.10.0-rc1/node-webkit-v0.10.0-rc1-osx-x64.zip',
|
|
217
|
+
'win32-sdk': 'http://abc.xyz/v0.10.0-rc1/node-webkit-v0.10.0-rc1-win-ia32.zip',
|
|
218
|
+
'win64-sdk': 'http://abc.xyz/v0.10.0-rc1/node-webkit-v0.10.0-rc1-win-x64.zip'
|
|
219
|
+
},
|
|
220
|
+
isLegacy: true
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
version: '0.9.3',
|
|
224
|
+
name: 'node-webkit',
|
|
225
|
+
platforms: {
|
|
226
|
+
'linux32-sdk': 'http://abc.xyz/v0.9.3/node-webkit-v0.9.3-linux-ia32.tar.gz',
|
|
227
|
+
'linux64-sdk': 'http://abc.xyz/v0.9.3/node-webkit-v0.9.3-linux-x64.tar.gz',
|
|
228
|
+
'osx32-sdk': 'http://abc.xyz/v0.9.3/node-webkit-v0.9.3-osx-ia32.zip',
|
|
229
|
+
'osx64-sdk': 'http://abc.xyz/v0.9.3/node-webkit-v0.9.3-osx-x64.zip',
|
|
230
|
+
'win32-sdk': 'http://abc.xyz/v0.9.3/node-webkit-v0.9.3-win-ia32.zip',
|
|
231
|
+
'win64-sdk': 'http://abc.xyz/v0.9.3/node-webkit-v0.9.3-win-x64.zip'
|
|
232
|
+
},
|
|
233
|
+
isLegacy: true
|
|
234
|
+
},
|
|
235
|
+
];
|
|
236
|
+
|
|
237
|
+
for(var i = 0; i < expectedVersions.length; i++){
|
|
238
|
+
t.deepEqual(result[i], expectedVersions[i]);
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
.catch(function(err){
|
|
242
|
+
console.error(err.stack);
|
|
243
|
+
t.fail(err);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test('getVersion', function (t) {
|
|
248
|
+
t.plan(3);
|
|
249
|
+
|
|
250
|
+
nock(root).get('/versions.json').replyWithFile(200, './test/fixtures/manifest/versions.json');
|
|
251
|
+
versions.getVersion({
|
|
252
|
+
desiredVersion: '0.13.2',
|
|
253
|
+
downloadUrl: 'http://dl.nwjs.io/',
|
|
254
|
+
manifestUrl: root + '/versions.json'
|
|
255
|
+
}).then(function(result){
|
|
256
|
+
t.equal(result.version, '0.13.2');
|
|
257
|
+
t.equal(result.name, 'nwjs');
|
|
258
|
+
t.deepEqual(result.platforms, {
|
|
259
|
+
'linux32-nacl': 'http://dl.nwjs.io/v0.13.2/nwjs-nacl-v0.13.2-linux-ia32.tar.gz',
|
|
260
|
+
'linux32-normal': 'http://dl.nwjs.io/v0.13.2/nwjs-v0.13.2-linux-ia32.tar.gz',
|
|
261
|
+
'linux32-sdk': 'http://dl.nwjs.io/v0.13.2/nwjs-sdk-v0.13.2-linux-ia32.tar.gz',
|
|
262
|
+
'osx64-nacl': 'http://dl.nwjs.io/v0.13.2/nwjs-nacl-v0.13.2-osx-x64.zip',
|
|
263
|
+
'osx64-normal': 'http://dl.nwjs.io/v0.13.2/nwjs-v0.13.2-osx-x64.zip',
|
|
264
|
+
'osx64-sdk': 'http://dl.nwjs.io/v0.13.2/nwjs-sdk-v0.13.2-osx-x64.zip',
|
|
265
|
+
'win64-nacl': 'http://dl.nwjs.io/v0.13.2/nwjs-nacl-v0.13.2-win-x64.zip',
|
|
266
|
+
'win64-normal': 'http://dl.nwjs.io/v0.13.2/nwjs-v0.13.2-win-x64.zip',
|
|
267
|
+
'win64-sdk': 'http://dl.nwjs.io/v0.13.2/nwjs-sdk-v0.13.2-win-x64.zip'
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test('getVersion should fail for non-existent version', function (t) {
|
|
273
|
+
t.plan(1);
|
|
274
|
+
|
|
275
|
+
nock(root).get('/versions.json').replyWithFile(200, './test/fixtures/manifest/versions.json');
|
|
276
|
+
versions.getVersion({
|
|
277
|
+
desiredVersion:'0.13.3',
|
|
278
|
+
downloadUrl: 'http://dl.nwjs.io/',
|
|
279
|
+
manifestUrl: root + '/versions.json'
|
|
280
|
+
}).then(function(){
|
|
281
|
+
t.fail("Shouldn't go in here")
|
|
282
|
+
})
|
|
283
|
+
.catch(function(){
|
|
284
|
+
t.ok('Should fail');
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
test('getVersion (legacy)', function (t) {
|
|
289
|
+
t.plan(3);
|
|
290
|
+
|
|
291
|
+
nock(dlUrl).get('/').replyWithFile(200, './test/fixtures/testVersions.html');
|
|
292
|
+
nock(dlUrl).head('/v0.10.2/node-webkit-v0.10.2-win-ia32.zip')
|
|
293
|
+
.replyWithFile(200, './test/fixtures/testVersions.html'); // needs to reply with *any* content
|
|
294
|
+
|
|
295
|
+
versions.getVersion({
|
|
296
|
+
desiredVersion: '0.10.2',
|
|
297
|
+
downloadUrl:'http://dl.nwjs.io/',
|
|
298
|
+
flavor:'sdk'
|
|
299
|
+
}).then(function(result){
|
|
300
|
+
t.equal(result.version, '0.10.2');
|
|
301
|
+
t.equal(result.name, 'node-webkit');
|
|
302
|
+
t.deepEqual(result.platforms, {
|
|
303
|
+
'linux32-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-linux-ia32.tar.gz',
|
|
304
|
+
'linux64-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-linux-x64.tar.gz',
|
|
305
|
+
'osx32-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-osx-ia32.zip',
|
|
306
|
+
'osx64-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-osx-x64.zip',
|
|
307
|
+
'win32-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-win-ia32.zip',
|
|
308
|
+
'win64-sdk': 'http://dl.nwjs.io/v0.10.2/node-webkit-v0.10.2-win-x64.zip'
|
|
309
|
+
});
|
|
310
|
+
})
|
|
311
|
+
.catch(function(err){
|
|
312
|
+
t.end(err);
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
test('getVersion (legacy) should fail for non-existent version', function (t) {
|
|
317
|
+
t.plan(1);
|
|
318
|
+
|
|
319
|
+
nock(dlUrl).get('/').replyWithFile(200, './test/fixtures/testVersions.html');
|
|
320
|
+
versions.getVersion({
|
|
321
|
+
desiredVersion: '0.10.1',
|
|
322
|
+
downloadUrl: 'http://dl.nwjs.io/'
|
|
323
|
+
}).then(function(){
|
|
324
|
+
t.fail("shouldn't go in here");
|
|
325
|
+
})
|
|
326
|
+
.catch(function(){
|
|
327
|
+
t.ok('Should fail');
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
package/bin/README.md
DELETED