nw-builder 3.6.0 → 3.7.2
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/.editorconfig +17 -0
- package/.github/CHANGELOG.md +77 -35
- package/.github/CODE_OF_CONDUCT.md +55 -0
- package/.github/{ISSUE_REQUEST_TEMPLATE.md → ISSUE_TEMPLATE.md} +1 -0
- package/.github/workflows/cd.yml +3 -3
- package/.github/workflows/ci.yml +9 -5
- package/README.md +81 -23
- package/bin/nwbuild.cjs +102 -0
- package/dist/index.cjs +1 -0
- package/lib/Version.cjs +81 -0
- package/lib/downloader.cjs +177 -0
- package/lib/index.cjs +1078 -0
- package/lib/{platformOverrides.js → platformOverrides.cjs} +61 -36
- package/lib/utils.cjs +293 -0
- package/lib/versions.cjs +206 -0
- package/package.json +57 -29
- package/src/constants/Platform.js +16 -0
- package/src/constants/Platforms.js +143 -0
- package/src/constants/index.js +7 -0
- package/src/index.js +2 -0
- package/src/utilities/checkCache.js +30 -0
- package/src/utilities/detectCurrentPlatform.js +24 -0
- package/src/utilities/index.js +4 -0
- package/{example/icons → test/demo}/icon.icns +0 -0
- package/{example/icons → test/demo}/icon.ico +0 -0
- package/test/demo/index.cjs +14 -0
- package/test/demo/index.html +10 -0
- package/{example/nwapp → test/demo}/package.json +7 -6
- package/test/downloader.cjs +131 -0
- package/test/expected/README.md +1 -1
- package/test/expected/merged +1 -1
- package/test/expected/oneOveriddenRestNot/README.md +1 -1
- package/test/expected/oneOveriddenRestNot/osx32.json +7 -7
- package/test/expected/oneOveriddenRestNot/osx64.json +7 -7
- package/test/expected/osx-plist/README.md +1 -1
- package/test/expected/platformOverrides/README.md +1 -1
- package/test/expected/platformOverrides/linux32.json +12 -12
- package/test/expected/platformOverrides/linux64.json +8 -8
- package/test/expected/platformOverrides/osx32.json +10 -10
- package/test/expected/platformOverrides/osx64.json +10 -10
- package/test/expected/platformOverrides/win32.json +10 -10
- package/test/expected/platformOverrides/win64.json +10 -10
- package/test/fixtures/README.md +1 -1
- package/test/fixtures/invalid.json +1 -1
- package/test/fixtures/manifest/README.md +1 -1
- package/test/fixtures/manifest/versions.json +9 -3
- package/test/fixtures/nwapp/README.md +1 -1
- package/test/fixtures/nwapp/images/imagefile.img +1 -1
- package/test/fixtures/nwapp/index.html +5 -2
- package/test/fixtures/nwapp/javascript/bower_packages/simple/package.json +1 -1
- package/test/fixtures/nwapp/javascript/jsfile.js +1 -1
- package/test/fixtures/nwapp/package.json +1 -1
- package/test/fixtures/oneOveriddenRestNot/README.md +1 -1
- package/test/fixtures/oneOveriddenRestNot/package.json +13 -13
- package/test/fixtures/osx-plist/README.md +1 -1
- package/test/fixtures/platformOverrides/README.md +1 -1
- package/test/fixtures/platformOverrides/package.json +68 -48
- package/test/fixtures/testVersions.html +73 -16
- package/test/nwBuilder.cjs +339 -0
- package/test/unit/checkCache.test.js +19 -0
- package/test/unit/checkCacheDir/v0.64.1/linux64/nw1.app +0 -0
- package/test/unit/checkCacheDir/v0.64.1/linux64/nw2.app +0 -0
- package/test/unit/detectCurrentPlatform.test.js +58 -0
- package/test/utils.cjs +310 -0
- package/test/versions.cjs +485 -0
- package/bin/nwbuild +0 -98
- package/demo.js +0 -22
- package/example/icons/README.md +0 -7
- package/example/nwapp/Credits.html +0 -9
- package/example/nwapp/README.md +0 -7
- package/example/nwapp/images/README.md +0 -7
- package/example/nwapp/images/kitten.jpg +0 -0
- package/example/nwapp/index.html +0 -22
- package/example/package.json +0 -7
- package/index.js +0 -1
- package/lib/Version.js +0 -60
- package/lib/detectCurrentPlatform.js +0 -17
- package/lib/downloader.js +0 -192
- package/lib/index.js +0 -873
- package/lib/platforms.js +0 -76
- package/lib/utils.js +0 -249
- package/lib/versions.js +0 -198
- package/test/downloader.js +0 -87
- package/test/nwBuilder.js +0 -237
- package/test/utils.js +0 -232
- package/test/versions.js +0 -330
package/lib/Version.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
var platforms = require('./platforms');
|
|
2
|
-
var _ = require('lodash');
|
|
3
|
-
var semver = require('semver');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Represents a version.
|
|
7
|
-
* @constructor
|
|
8
|
-
* @param {string} args.version.
|
|
9
|
-
* @param {string} args.flavors.
|
|
10
|
-
* @param {array} args.supportedPlatforms - array of strings like `osx64`.
|
|
11
|
-
* @param {string} args.downloadUrl.
|
|
12
|
-
*/
|
|
13
|
-
module.exports = function Version(args){
|
|
14
|
-
var generatePlatformUrls,
|
|
15
|
-
result = {
|
|
16
|
-
isLegacy: semver.lt(args.version, '0.12.3'),
|
|
17
|
-
name: semver.gte(args.version, '0.12.0') || semver.satisfies(args.version, '~0.12.0-alpha') ? 'nwjs' : 'node-webkit',
|
|
18
|
-
version: args.version
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
// 0.12.3 is an exception that is in the manifest but is pretty much a legacy version
|
|
22
|
-
if(result.isLegacy || args.version === '0.12.3'){
|
|
23
|
-
generatePlatformUrls = function(version,flavors, supportedPlatforms){
|
|
24
|
-
var platformUrls = {};
|
|
25
|
-
supportedPlatforms.forEach(function (supportedPlatform) {
|
|
26
|
-
flavors.forEach(function(flavor) {
|
|
27
|
-
platformUrls[supportedPlatform + '-' + flavor] = args.downloadUrl + _.template(platforms[supportedPlatform].versionNameTemplate)(result);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
return platformUrls;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
var fixPlatformName = function(platform){
|
|
35
|
-
return platform.replace('32', '-ia32').replace('64', '-x64');
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
var mapPlatformToExtension = function(platform){
|
|
39
|
-
if(platform.indexOf('linux') === 0){
|
|
40
|
-
return 'tar.gz'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return 'zip'
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
generatePlatformUrls = function(version, flavors, supportedPlatforms){
|
|
47
|
-
var platformUrls = {};
|
|
48
|
-
supportedPlatforms.forEach(function(platform){
|
|
49
|
-
flavors.forEach(function(flavor) {
|
|
50
|
-
platformUrls[platform + '-' + flavor] = args.downloadUrl + 'v' + version + '/nwjs' + (flavor === 'normal' ? '' : '-' + flavor) + '-v' + version + '-' + fixPlatformName(platform)
|
|
51
|
-
+ '.' + mapPlatformToExtension(platform);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
return platformUrls;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
result.platforms = generatePlatformUrls(args.version, args.flavors, args.supportedPlatforms);
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
detect the current platform according to expected constants
|
|
3
|
-
|
|
4
|
-
return undefined if platform is unrecognized
|
|
5
|
-
*/
|
|
6
|
-
module.exports = function () {
|
|
7
|
-
switch(process.platform) {
|
|
8
|
-
case 'darwin':
|
|
9
|
-
return process.arch === 'x64' ? 'osx64' : 'osx32';
|
|
10
|
-
|
|
11
|
-
case 'win32':
|
|
12
|
-
return (process.arch === 'x64' || process.env.hasOwnProperty('PROCESSOR_ARCHITEW6432')) ? 'win64' : 'win32';
|
|
13
|
-
|
|
14
|
-
case 'linux':
|
|
15
|
-
return process.arch === 'x64' ? 'linux64' : 'linux32';
|
|
16
|
-
}
|
|
17
|
-
};
|
package/lib/downloader.js
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
var request = require('request');
|
|
2
|
-
var progress = require('progress');
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var path = require('path');
|
|
5
|
-
var zlib = require('zlib');
|
|
6
|
-
var tar = require('tar-fs');
|
|
7
|
-
var temp = require('temp');
|
|
8
|
-
var ncp = require('graceful-ncp').ncp;
|
|
9
|
-
var rimraf = require('rimraf');
|
|
10
|
-
var extract = require('extract-zip');
|
|
11
|
-
|
|
12
|
-
// Automatically track and cleanup files at exit
|
|
13
|
-
temp.track();
|
|
14
|
-
var isWin = /^win/.test(process.platform);
|
|
15
|
-
|
|
16
|
-
// one progressbar for all downloads
|
|
17
|
-
var bar;
|
|
18
|
-
|
|
19
|
-
module.exports = {
|
|
20
|
-
checkCache: function(cachepath, files) {
|
|
21
|
-
var missing;
|
|
22
|
-
|
|
23
|
-
// if the version is >=0.12.3, then we don't know which files we want from the archives, so just check that the
|
|
24
|
-
// folder exists and has at least 3 files in it.
|
|
25
|
-
if(files.length === 1 && files[0] === '*'){
|
|
26
|
-
return fs.existsSync(cachepath) && fs.readdirSync(cachepath).length >= 2;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
files.forEach(function(file) {
|
|
30
|
-
if (missing) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (!fs.existsSync(path.join(cachepath, file))) {
|
|
34
|
-
missing = true;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return !missing;
|
|
39
|
-
},
|
|
40
|
-
clearProgressbar: function() {
|
|
41
|
-
bar && bar.terminate();
|
|
42
|
-
bar = null;
|
|
43
|
-
},
|
|
44
|
-
downloadAndUnpack: function(cachepath, url) {
|
|
45
|
-
var extention = path.extname(url),
|
|
46
|
-
self = this,
|
|
47
|
-
rq = request(url),
|
|
48
|
-
len,
|
|
49
|
-
stream;
|
|
50
|
-
|
|
51
|
-
function format(statusCode) {
|
|
52
|
-
return statusCode + ': ' + require('http').STATUS_CODES[statusCode];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return new Promise(function(resolve, reject){
|
|
56
|
-
rq.proxy = true;
|
|
57
|
-
rq.on('error', function(err) {
|
|
58
|
-
bar && bar.terminate();
|
|
59
|
-
reject(err);
|
|
60
|
-
});
|
|
61
|
-
rq.on('response', function (res) {
|
|
62
|
-
len = parseInt(res.headers['content-length'], 10);
|
|
63
|
-
if (res.statusCode !== 200) {
|
|
64
|
-
reject({
|
|
65
|
-
statusCode: res.statusCode,
|
|
66
|
-
msg: 'Recieved status code ' + format(res.statusCode)
|
|
67
|
-
});
|
|
68
|
-
} else if (len) {
|
|
69
|
-
if (!bar) {
|
|
70
|
-
bar = new progress(' downloading [:bar] :percent :etas', {
|
|
71
|
-
complete: '=',
|
|
72
|
-
incomplete: '-',
|
|
73
|
-
width: 20,
|
|
74
|
-
total: len
|
|
75
|
-
});
|
|
76
|
-
} else {
|
|
77
|
-
bar.total += len;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
rq.on('data', function(chunk) {
|
|
82
|
-
len && bar && bar.tick(chunk.length);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
if (extention === '.zip') {
|
|
86
|
-
rq.on('response', function(res) {
|
|
87
|
-
if(res.statusCode !== 200) return;
|
|
88
|
-
stream = temp.createWriteStream();
|
|
89
|
-
|
|
90
|
-
stream.on('finish', function() {
|
|
91
|
-
self.extractZip(stream.path, cachepath).then(self.stripRootFolder).then(function(files) {
|
|
92
|
-
resolve(files);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
rq.pipe(stream);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
else if (extention === '.gz') {
|
|
101
|
-
rq.on('response', function(res) {
|
|
102
|
-
if(res.statusCode !== 200) return;
|
|
103
|
-
self.extractTar(res, cachepath).then(self.stripRootFolder).then(function(files) {
|
|
104
|
-
resolve(files);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
extractTar: function(tarstream, destination) {
|
|
111
|
-
var gunzip = zlib.createGunzip(),
|
|
112
|
-
files = [];
|
|
113
|
-
|
|
114
|
-
return new Promise(function(resolve, reject){
|
|
115
|
-
tarstream
|
|
116
|
-
.pipe(gunzip)
|
|
117
|
-
.on('error', function(err){
|
|
118
|
-
reject(err);
|
|
119
|
-
})
|
|
120
|
-
.pipe(tar.extract(destination, {
|
|
121
|
-
umask: (isWin ? false : 0),
|
|
122
|
-
map: function(header) {
|
|
123
|
-
files.push({path: path.basename(header.name)});
|
|
124
|
-
return header;
|
|
125
|
-
}
|
|
126
|
-
}))
|
|
127
|
-
.on('finish', function() {
|
|
128
|
-
resolve({files:files, destination:destination});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
extractZip: function(zipfile, destination) {
|
|
134
|
-
var files = [];
|
|
135
|
-
|
|
136
|
-
var onEntry = function(entry){
|
|
137
|
-
files.push({
|
|
138
|
-
mode: entry.externalFileAttributes >>> 16,
|
|
139
|
-
path: entry.fileName
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
return new Promise(function(resolve, reject){
|
|
144
|
-
extract(zipfile, { dir: destination, onEntry: onEntry }, function(err){
|
|
145
|
-
if(err){
|
|
146
|
-
return reject(err);
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Setup chmodSync to fix permissions
|
|
150
|
-
files.forEach(function(file) {
|
|
151
|
-
fs.chmodSync(path.join(destination, file.path), file.mode);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
resolve({ files: files, destination: destination });
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
});
|
|
158
|
-
},
|
|
159
|
-
stripRootFolder: function(extracted){
|
|
160
|
-
var files = extracted.files,
|
|
161
|
-
destination = extracted.destination,
|
|
162
|
-
rootFiles = fs.readdirSync(destination),
|
|
163
|
-
fromDir = path.join(destination, rootFiles.length === 1 ? rootFiles[0] : '');
|
|
164
|
-
|
|
165
|
-
// strip out root folder if it exists
|
|
166
|
-
if(rootFiles.length === 1 && fs.statSync(fromDir).isDirectory() ){
|
|
167
|
-
// strip folder from files
|
|
168
|
-
for (var i = 0; i < files.length; i++) {
|
|
169
|
-
var file = files[i];
|
|
170
|
-
file.path = path.relative(rootFiles[0], file.path);
|
|
171
|
-
if(file.path === '') {
|
|
172
|
-
files.splice(i, 1);
|
|
173
|
-
i--;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return new Promise(function(resolve, reject){
|
|
178
|
-
// move stripped folder to destination
|
|
179
|
-
ncp(fromDir, destination, function (err) {
|
|
180
|
-
if (err) {
|
|
181
|
-
return reject();
|
|
182
|
-
}
|
|
183
|
-
else rimraf(fromDir, function(){
|
|
184
|
-
resolve(files);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
} else {
|
|
189
|
-
return Promise.resolve(files);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|