nw-builder 3.5.6 → 3.7.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/.github/CHANGELOG.md +128 -0
- package/.github/CODE_OF_CONDUCT.md +55 -0
- package/.github/ISSUE_TEMPLATE.md +17 -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 +30 -0
- package/README.md +169 -113
- package/bin/nwbuild.cjs +97 -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.cjs +147 -0
- package/lib/platforms.cjs +141 -0
- package/lib/utils.cjs +293 -0
- package/lib/versions.cjs +206 -0
- package/package.json +94 -62
- package/src/index.js +2 -0
- package/src/schema/Platform.js +16 -0
- package/src/schema/index.js +3 -0
- package/src/utilities/checkCache.js +30 -0
- package/src/utilities/detectCurrentPlatform.js +24 -0
- package/src/utilities/index.js +4 -0
- package/test/demo/icon.icns +0 -0
- package/test/demo/icon.ico +0 -0
- package/test/demo/index.cjs +14 -0
- package/test/demo/index.html +10 -0
- package/test/demo/package.json +24 -0
- package/test/downloader.cjs +131 -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 +29 -0
- package/test/fixtures/nwapp/README.md +7 -0
- package/test/fixtures/nwapp/images/imagefile.img +1 -0
- package/test/fixtures/nwapp/index.html +13 -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 +72 -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 +74 -0
- 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 +486 -0
- package/CHANGELOG.md +0 -83
- package/bin/README.md +0 -7
- package/bin/nwbuild +0 -101
- package/index.js +0 -1
- package/lib/README.md +0 -7
- package/lib/Version.js +0 -60
- package/lib/detectCurrentPlatform.js +0 -17
- package/lib/downloader.js +0 -192
- package/lib/index.js +0 -863
- package/lib/platforms.js +0 -76
- package/lib/utils.js +0 -249
- package/lib/versions.js +0 -198
package/lib/versions.cjs
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
var platforms = require("./platforms.cjs");
|
|
2
|
+
var semver = require("semver");
|
|
3
|
+
var request = require("request");
|
|
4
|
+
var _ = require("lodash");
|
|
5
|
+
var Version = require("./Version.cjs");
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} url
|
|
9
|
+
* @param {object} options - Passed to request
|
|
10
|
+
* @returns {promise} which resolves to response body
|
|
11
|
+
*/
|
|
12
|
+
function get(url, options) {
|
|
13
|
+
return new Promise(function (resolve, reject) {
|
|
14
|
+
request(url, options, function (err, res, body) {
|
|
15
|
+
if (err) {
|
|
16
|
+
reject(err);
|
|
17
|
+
} else if (res.statusCode !== 200) {
|
|
18
|
+
reject("Received status code " + res.statusCode + ": " + url);
|
|
19
|
+
} else {
|
|
20
|
+
resolve(body);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @param {string} downloadUrl
|
|
28
|
+
* @returns {promise} which resolves to an array of {Version}s
|
|
29
|
+
*/
|
|
30
|
+
function getLegacyVersions(downloadUrl) {
|
|
31
|
+
var scrapePtrn = /href="v?([0-9]+\.[0-9]+\.[0-9]+[^"]*)\/"/gi,
|
|
32
|
+
searchRes,
|
|
33
|
+
versions = [];
|
|
34
|
+
|
|
35
|
+
return get(downloadUrl).then(function (body) {
|
|
36
|
+
// scrapes valid semver versions from apache directory listing
|
|
37
|
+
while ((searchRes = scrapePtrn.exec(body)) !== null) {
|
|
38
|
+
searchRes = searchRes[1];
|
|
39
|
+
if (semver.valid(searchRes) && !_.includes(versions, searchRes)) {
|
|
40
|
+
versions.push(searchRes);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// order with newest version at front of array
|
|
44
|
+
versions = versions.sort(function (a, b) {
|
|
45
|
+
return semver.compare(b, a);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// filter out invalid / alpha versions
|
|
49
|
+
var validationPromises = [];
|
|
50
|
+
versions.forEach(function (version) {
|
|
51
|
+
if (!isLegacyVersion(version)) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
validationPromises.push(
|
|
55
|
+
new Promise(function (resolve) {
|
|
56
|
+
// check if windows 64-bit ZIP exists
|
|
57
|
+
var win32Url = new Version({
|
|
58
|
+
version: version,
|
|
59
|
+
flavors: ["sdk"],
|
|
60
|
+
supportedPlatforms: ["win32"],
|
|
61
|
+
downloadUrl: downloadUrl,
|
|
62
|
+
}).platforms["win32-sdk"];
|
|
63
|
+
request.head(win32Url, function (err, res) {
|
|
64
|
+
// note: this takes a version string and replaces it with an object (will be converted back later)
|
|
65
|
+
resolve({
|
|
66
|
+
version: version,
|
|
67
|
+
flavors: ["sdk"],
|
|
68
|
+
valid: !err && res.statusCode === 200,
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
var allPlatforms = Object.keys(platforms);
|
|
76
|
+
|
|
77
|
+
return Promise.all(validationPromises).then(function (versions) {
|
|
78
|
+
// convert back to array of version strings (filtered)
|
|
79
|
+
return versions
|
|
80
|
+
.filter(function (versionObj) {
|
|
81
|
+
return versionObj.valid;
|
|
82
|
+
})
|
|
83
|
+
.map(function (versionObj) {
|
|
84
|
+
return new Version({
|
|
85
|
+
version: versionObj.version,
|
|
86
|
+
flavors: versionObj.flavors,
|
|
87
|
+
supportedPlatforms: allPlatforms,
|
|
88
|
+
downloadUrl: downloadUrl,
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @param {string?} manifestUrl
|
|
97
|
+
* @returns {promise} which resolves to response body
|
|
98
|
+
*/
|
|
99
|
+
function getManifest(manifestUrl) {
|
|
100
|
+
if (!manifestUrl) {
|
|
101
|
+
manifestUrl = "https://nwjs.io/versions.json";
|
|
102
|
+
}
|
|
103
|
+
return get(manifestUrl, { json: true }).then(function (body) {
|
|
104
|
+
return body;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {string} downloadUrl
|
|
110
|
+
* @param {string} manifestUrl
|
|
111
|
+
* @returns {promise} which resolves to an array of {Version}s
|
|
112
|
+
*/
|
|
113
|
+
function getVersionsFromManifest(downloadUrl, manifestUrl) {
|
|
114
|
+
var mapFilesToPlatforms = function (files) {
|
|
115
|
+
return files.map(function (file) {
|
|
116
|
+
// convert win-x64 to win64, linux-ia32 to linux 32, etc.
|
|
117
|
+
return file.replace(/-(x|ia)/, "");
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
return getManifest(manifestUrl).then(function (manifest) {
|
|
122
|
+
return manifest.versions
|
|
123
|
+
.filter(function (versionFromManifest) {
|
|
124
|
+
// 0.12.3 is an exception that is in the manifest but is kind of a legacy version
|
|
125
|
+
return (
|
|
126
|
+
versionFromManifest.flavors !== undefined &&
|
|
127
|
+
(versionFromManifest.flavors.indexOf("sdk") !== -1 ||
|
|
128
|
+
versionFromManifest.version === "v0.12.3")
|
|
129
|
+
);
|
|
130
|
+
})
|
|
131
|
+
.map(function (versionFromManifest) {
|
|
132
|
+
return new Version({
|
|
133
|
+
version: versionFromManifest.version.replace("v", ""),
|
|
134
|
+
flavors: versionFromManifest.flavors,
|
|
135
|
+
supportedPlatforms: mapFilesToPlatforms(versionFromManifest.files),
|
|
136
|
+
downloadUrl: downloadUrl,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} version
|
|
144
|
+
* @returns {boolean}
|
|
145
|
+
*/
|
|
146
|
+
function isLegacyVersion(version) {
|
|
147
|
+
return semver.lte(version, "0.12.3");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
module.exports = {
|
|
151
|
+
/**
|
|
152
|
+
* Gets the latest stable version
|
|
153
|
+
* @param {string} downloadUrl
|
|
154
|
+
* @param {string} manifestUrl
|
|
155
|
+
* @param {string} flavor
|
|
156
|
+
* @returns {promise} which resolves to a {Version}
|
|
157
|
+
*/
|
|
158
|
+
getLatestVersion: function (downloadUrl, manifestUrl, flavor) {
|
|
159
|
+
return getManifest(manifestUrl)
|
|
160
|
+
.then(function (manifest) {
|
|
161
|
+
return {
|
|
162
|
+
desiredVersion: manifest.stable.replace("v", ""),
|
|
163
|
+
downloadUrl: downloadUrl,
|
|
164
|
+
manifestUrl: manifestUrl,
|
|
165
|
+
flavor: flavor,
|
|
166
|
+
};
|
|
167
|
+
})
|
|
168
|
+
.then(this.getVersion);
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* @param {string} args.desiredVersion
|
|
172
|
+
* @param {string} args.downloadUrl
|
|
173
|
+
* @param {string} args.manifestUrl
|
|
174
|
+
* @param {string} args.flavor
|
|
175
|
+
* @returns {promise} which resolves to a {Version}
|
|
176
|
+
*/
|
|
177
|
+
getVersion: function (args) {
|
|
178
|
+
return (
|
|
179
|
+
isLegacyVersion(args.desiredVersion)
|
|
180
|
+
? getLegacyVersions
|
|
181
|
+
: getVersionsFromManifest
|
|
182
|
+
)(args.downloadUrl, args.manifestUrl).then(function (versions) {
|
|
183
|
+
var version = versions.findIndex(function (version) {
|
|
184
|
+
return version.version === args.desiredVersion;
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return version >= 0
|
|
188
|
+
? Promise.resolve(versions[version])
|
|
189
|
+
: Promise.reject("Version " + args.desiredVersion + " not found.");
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* @param {string} downloadUrl
|
|
194
|
+
* @param {string} manifestUrl
|
|
195
|
+
* @param {string} flavor
|
|
196
|
+
* @returns {promise} which resolves to an array of {Version}s
|
|
197
|
+
*/
|
|
198
|
+
getVersions: function (downloadUrl, manifestUrl, flavor) {
|
|
199
|
+
return Promise.all([
|
|
200
|
+
getVersionsFromManifest(downloadUrl, manifestUrl, flavor),
|
|
201
|
+
getLegacyVersions(downloadUrl, flavor),
|
|
202
|
+
]).then(function (versionLists) {
|
|
203
|
+
return versionLists[0].concat(versionLists[1]);
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
};
|
package/package.json
CHANGED
|
@@ -1,74 +1,106 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
3
|
+
"version": "3.7.0",
|
|
4
|
+
"description": "Build NW.js applications for Mac, Windows and Linux.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"NW.js",
|
|
7
|
+
"Desktop",
|
|
8
|
+
"Application"
|
|
9
|
+
],
|
|
10
|
+
"author": "Steffen Müller <steffen@mllrsohn.com>",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"homepage": "https://github.com/nwutils/nw-builder",
|
|
9
15
|
"repository": {
|
|
10
16
|
"type": "git",
|
|
11
|
-
"url": "
|
|
12
|
-
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"nwbuild": "./bin/nwbuild"
|
|
15
|
-
},
|
|
16
|
-
"author": {
|
|
17
|
-
"name": "Steffen Müller"
|
|
18
|
-
},
|
|
19
|
-
"contributors": [
|
|
20
|
-
{
|
|
21
|
-
"name": "Adam Lynch",
|
|
22
|
-
"email": "contact@adamlynch.com"
|
|
23
|
-
}
|
|
24
|
-
],
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">= 4.0.0"
|
|
17
|
+
"url": "https://github.com/nwutils/nw-builder.git"
|
|
27
18
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
"
|
|
19
|
+
"scripts": {
|
|
20
|
+
"format": "prettier --write ./bin ./lib ./src ./test",
|
|
21
|
+
"lint": "eslint ./src",
|
|
22
|
+
"test": "pnpm test:unit && tape test/*.cjs",
|
|
23
|
+
"test:unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
24
|
+
"demo": "cd ./test/demo && pnpm start",
|
|
25
|
+
"build": "esbuild src/index.js --bundle --minify --platform=node --outfile=./dist/index.cjs"
|
|
31
26
|
},
|
|
32
|
-
"homepage": "https://github.com/mllrsohn/nw-builder",
|
|
33
|
-
"keywords": [
|
|
34
|
-
"NW.js",
|
|
35
|
-
"node-webkit",
|
|
36
|
-
"desktop",
|
|
37
|
-
"application"
|
|
38
|
-
],
|
|
39
27
|
"devDependencies": {
|
|
40
|
-
"decompress-zip": "0.3.
|
|
41
|
-
"eol": "
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
28
|
+
"decompress-zip": "0.3.3",
|
|
29
|
+
"eol": "0.9.1",
|
|
30
|
+
"esbuild": "0.14.42",
|
|
31
|
+
"eslint": "8.16.0",
|
|
32
|
+
"eslint-plugin-jsdoc": "^39.3.2",
|
|
33
|
+
"jest": "28.1.0",
|
|
34
|
+
"jest-environment-jsdom": "28.1.0",
|
|
35
|
+
"jsdom": "19.0.0",
|
|
36
|
+
"nock": "13.2.4",
|
|
37
|
+
"pnpm": "7.1.7",
|
|
38
|
+
"prettier": "2.6.2",
|
|
39
|
+
"redtape": "1.0.0",
|
|
40
|
+
"tape": "5.5.3"
|
|
46
41
|
},
|
|
47
42
|
"dependencies": {
|
|
48
|
-
"archiver": "
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"request": "^2.88.0",
|
|
65
|
-
"rimraf": "^2.5.2",
|
|
66
|
-
"semver": "^5.5.0",
|
|
67
|
-
"simple-glob": "~0.2.0",
|
|
68
|
-
"tar-fs": "^1.13.0",
|
|
43
|
+
"archiver": "5.3.1",
|
|
44
|
+
"deprecate": "1.1.1",
|
|
45
|
+
"extract-zip": "2.0.1",
|
|
46
|
+
"graceful-fs-extra": "2.0.0",
|
|
47
|
+
"graceful-ncp": "3.0.0",
|
|
48
|
+
"inherits": "2.0.4",
|
|
49
|
+
"lodash": "4.17.21",
|
|
50
|
+
"plist": "3.0.5",
|
|
51
|
+
"progress": "2.0.3",
|
|
52
|
+
"rcedit": "3.0.1",
|
|
53
|
+
"recursive-readdir-sync": "1.0.6",
|
|
54
|
+
"request": "2.88.2",
|
|
55
|
+
"rimraf": "3.0.2",
|
|
56
|
+
"semver": "7.3.7",
|
|
57
|
+
"simple-glob": "0.2.0",
|
|
58
|
+
"tar-fs": "2.1.1",
|
|
69
59
|
"temp": "github:adam-lynch/node-temp#remove_tmpdir_dep",
|
|
70
|
-
"thenify": "
|
|
71
|
-
"update-notifier": "
|
|
72
|
-
"winresourcer": "
|
|
60
|
+
"thenify": "3.3.1",
|
|
61
|
+
"update-notifier": "5.1.0",
|
|
62
|
+
"winresourcer": "0.9.0",
|
|
63
|
+
"yargs": "17.5.1"
|
|
64
|
+
},
|
|
65
|
+
"bin": {
|
|
66
|
+
"nwbuild": "./bin/nwbuild.cjs"
|
|
67
|
+
},
|
|
68
|
+
"prettier": {
|
|
69
|
+
"printWidth": 80,
|
|
70
|
+
"tabWidth": 2,
|
|
71
|
+
"useTabs": false,
|
|
72
|
+
"semi": true,
|
|
73
|
+
"singleQuote": false,
|
|
74
|
+
"quoteProps": "consistent",
|
|
75
|
+
"trailingComma": "all",
|
|
76
|
+
"bracketSpacing": true,
|
|
77
|
+
"bracketSameLine": false,
|
|
78
|
+
"arrowParens": "always",
|
|
79
|
+
"proseWrap": "preserve",
|
|
80
|
+
"htmlWhitespaceSensitivity": "strict",
|
|
81
|
+
"endOfLine": "lf",
|
|
82
|
+
"singleAttributePerLine": true
|
|
83
|
+
},
|
|
84
|
+
"eslintConfig": {
|
|
85
|
+
"extends": "eslint:recommended",
|
|
86
|
+
"parserOptions": {
|
|
87
|
+
"ecmaVersion": 2021,
|
|
88
|
+
"sourceType": "module"
|
|
89
|
+
},
|
|
90
|
+
"env": {
|
|
91
|
+
"es6": true,
|
|
92
|
+
"node": true
|
|
93
|
+
},
|
|
94
|
+
"overrides": [
|
|
95
|
+
{
|
|
96
|
+
"files": "./src/**/*.js"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"plugins": [
|
|
100
|
+
"jsdoc"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"jest": {
|
|
104
|
+
"testEnvironment": "jsdom"
|
|
73
105
|
}
|
|
74
106
|
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @readonly
|
|
3
|
+
* @enum {string}
|
|
4
|
+
*/
|
|
5
|
+
const Platform = {
|
|
6
|
+
NIX_32: "linux32",
|
|
7
|
+
NIX_64: "linux64",
|
|
8
|
+
OSX_32: "osx32",
|
|
9
|
+
OSX_64: "osx64",
|
|
10
|
+
WIN_32: "win32",
|
|
11
|
+
WIN_64: "win64",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
Object.freeze(Platform);
|
|
15
|
+
|
|
16
|
+
export default Platform;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {string} filePath
|
|
7
|
+
* @param {string[]} files
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
const checkCache = (filePath, files) => {
|
|
11
|
+
let missing = false;
|
|
12
|
+
|
|
13
|
+
// If NW.js is above v0.12.3, then we don't know which files we want from the archives. So just check that the folder exists and has at least 3 files in it.
|
|
14
|
+
if (files.length === 1 && files[0] === "*") {
|
|
15
|
+
return fs.existsSync(filePath) && fs.readdirSync(filePath).length >= 2;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
for (let file of files) {
|
|
19
|
+
if (missing) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (!fs.existsSync(path.join(filePath, file))) {
|
|
23
|
+
missing = true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return !missing;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default checkCache;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Platform } from "../schema";
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {NodeJS.Process} process
|
|
5
|
+
* @returns {Platform | undefined}
|
|
6
|
+
*/
|
|
7
|
+
const detectCurrentPlatform = (process) => {
|
|
8
|
+
switch (process.platform) {
|
|
9
|
+
case "darwin":
|
|
10
|
+
return process.arch === "x64" ? Platform.OSX_64 : Platform.OSX_32;
|
|
11
|
+
|
|
12
|
+
case "win32":
|
|
13
|
+
return process.arch === "x64" || process.env.PROCESSOR_ARCHITEW6432
|
|
14
|
+
? Platform.WIN_64
|
|
15
|
+
: Platform.WIN_32;
|
|
16
|
+
|
|
17
|
+
case "linux":
|
|
18
|
+
return process.arch === "x64" ? Platform.NIX_64 : Platform.NIX_32;
|
|
19
|
+
default:
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default detectCurrentPlatform;
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const NwBuilder = require("../../lib/index.cjs");
|
|
2
|
+
|
|
3
|
+
const nw = new NwBuilder({
|
|
4
|
+
version: "0.64.1",
|
|
5
|
+
files: "./**",
|
|
6
|
+
macIcns: "./icon.icns",
|
|
7
|
+
macPlist: { mac_bundle_id: "myPkg" },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
nw.on("log", (msg) => console.log("nw-builder", msg));
|
|
11
|
+
|
|
12
|
+
nw.run()
|
|
13
|
+
.then(() => process.exit(0))
|
|
14
|
+
.catch((error) => console.log(error));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nw-demo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "NW.js demo",
|
|
5
|
+
"main": "./index.html",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node ./index.cjs"
|
|
8
|
+
},
|
|
9
|
+
"window": {
|
|
10
|
+
"title": "NW.js Demo",
|
|
11
|
+
"toolbar": false,
|
|
12
|
+
"frame": true,
|
|
13
|
+
"width": 800,
|
|
14
|
+
"height": 500,
|
|
15
|
+
"position": "center",
|
|
16
|
+
"min_width": 400,
|
|
17
|
+
"min_height": 200,
|
|
18
|
+
"max_width": 800,
|
|
19
|
+
"max_height": 600
|
|
20
|
+
},
|
|
21
|
+
"webkit": {
|
|
22
|
+
"plugin": true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var test = require("tape"),
|
|
2
|
+
nock = require("nock"),
|
|
3
|
+
temp = require("temp"),
|
|
4
|
+
path = require("path"),
|
|
5
|
+
fs = require("fs");
|
|
6
|
+
|
|
7
|
+
temp.track();
|
|
8
|
+
|
|
9
|
+
var downloader = require("../lib/downloader.cjs");
|
|
10
|
+
var fixturesZip = "./test/fixtures/test.zip";
|
|
11
|
+
var fixturesZipStrip = "./test/fixtures/test-strip.zip";
|
|
12
|
+
var fixturesTar = "./test/fixtures/test.tar.gz";
|
|
13
|
+
var isWindows = process.platform === "win32";
|
|
14
|
+
|
|
15
|
+
test("downloadAndUnpack: zip", function (t) {
|
|
16
|
+
t.plan(isWindows ? 3 : 6);
|
|
17
|
+
nock("https://amazon.s3.nw.com")
|
|
18
|
+
.get("/test.zip")
|
|
19
|
+
.replyWithFile(200, fixturesZip);
|
|
20
|
+
temp.mkdir("tmpcache", function (err, dirPath) {
|
|
21
|
+
downloader
|
|
22
|
+
.downloadAndUnpack(dirPath, "https://amazon.s3.nw.com/test.zip")
|
|
23
|
+
.then(function (files) {
|
|
24
|
+
files.forEach(function (file) {
|
|
25
|
+
t.ok(
|
|
26
|
+
fs.existsSync(path.join(dirPath, file.path)),
|
|
27
|
+
file.path + " unpacked",
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!isWindows) {
|
|
32
|
+
t.ok(
|
|
33
|
+
fs.statSync(path.join(dirPath, "file1")).mode.toString(8) == 100444,
|
|
34
|
+
"444 file permission",
|
|
35
|
+
);
|
|
36
|
+
t.ok(
|
|
37
|
+
fs.statSync(path.join(dirPath, "file2")).mode.toString(8) == 100666,
|
|
38
|
+
"666 file permission",
|
|
39
|
+
);
|
|
40
|
+
t.ok(
|
|
41
|
+
fs.statSync(path.join(dirPath, "file3")).mode.toString(8) == 100644,
|
|
42
|
+
"644 file permission",
|
|
43
|
+
); // DOES NOT WORK ON WINDOWS
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("downloadAndUnpack: zip+strip", function (t) {
|
|
50
|
+
t.plan(isWindows ? 3 : 6);
|
|
51
|
+
nock("https://amazon.s3.nw.com")
|
|
52
|
+
.get("/test-strip.zip")
|
|
53
|
+
.replyWithFile(200, fixturesZipStrip);
|
|
54
|
+
temp.mkdir("tmpcache", function (err, dirPath) {
|
|
55
|
+
downloader
|
|
56
|
+
.downloadAndUnpack(dirPath, "https://amazon.s3.nw.com/test-strip.zip")
|
|
57
|
+
.then(function (files) {
|
|
58
|
+
files.forEach(function (file) {
|
|
59
|
+
t.ok(
|
|
60
|
+
fs.existsSync(path.join(dirPath, file.path)),
|
|
61
|
+
file.path + " unpacked",
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
if (!isWindows) {
|
|
66
|
+
t.ok(
|
|
67
|
+
fs.statSync(path.join(dirPath, "file1")).mode.toString(8) == 100444,
|
|
68
|
+
"444 file permission",
|
|
69
|
+
);
|
|
70
|
+
t.ok(
|
|
71
|
+
fs.statSync(path.join(dirPath, "file2")).mode.toString(8) == 100666,
|
|
72
|
+
"666 file permission",
|
|
73
|
+
);
|
|
74
|
+
t.ok(
|
|
75
|
+
fs.statSync(path.join(dirPath, "file3")).mode.toString(8) == 100644,
|
|
76
|
+
"644 file permission",
|
|
77
|
+
); // DOES NOT WORK ON WINDOWS
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("downloadAndUnpack: tar", function (t) {
|
|
84
|
+
t.plan(isWindows ? 3 : 6);
|
|
85
|
+
nock("https://amazon.s3.nw.com")
|
|
86
|
+
.get("/test.tar.gz")
|
|
87
|
+
.replyWithFile(200, fixturesTar);
|
|
88
|
+
temp.mkdir("tmpcache", function (err, dirPath) {
|
|
89
|
+
downloader
|
|
90
|
+
.downloadAndUnpack(dirPath, "https://amazon.s3.nw.com/test.tar.gz")
|
|
91
|
+
.then(function (files) {
|
|
92
|
+
files.forEach(function (file) {
|
|
93
|
+
t.ok(
|
|
94
|
+
fs.existsSync(path.join(dirPath, file.path)),
|
|
95
|
+
file.path + " unpacked",
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (!isWindows) {
|
|
100
|
+
t.ok(
|
|
101
|
+
fs.statSync(path.join(dirPath, "file1")).mode.toString(8) == 100444,
|
|
102
|
+
"444 file permission",
|
|
103
|
+
); // DOES NOT WORK ON WINDOWS
|
|
104
|
+
t.ok(
|
|
105
|
+
fs.statSync(path.join(dirPath, "file2")).mode.toString(8) == 100666,
|
|
106
|
+
"666 file permission",
|
|
107
|
+
);
|
|
108
|
+
t.ok(
|
|
109
|
+
fs.statSync(path.join(dirPath, "file3")).mode.toString(8) == 100644,
|
|
110
|
+
"644 file permission",
|
|
111
|
+
); // DOES NOT WORK ON WINDOWS
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test("Should throw an error if you try to download a file that is not available", function (t) {
|
|
118
|
+
t.plan(2);
|
|
119
|
+
nock("https://doesnot.com").get("/exist.zip").reply(404);
|
|
120
|
+
downloader
|
|
121
|
+
.downloadAndUnpack("/", "https://doesnot.com/exist.zip")
|
|
122
|
+
.catch(function (err) {
|
|
123
|
+
t.equal(err.statusCode, 404, err.msg);
|
|
124
|
+
});
|
|
125
|
+
nock("https://doesnot.com").get("/exist.tar").reply(404);
|
|
126
|
+
downloader
|
|
127
|
+
.downloadAndUnpack("/", "https://doesnot.com/exist.tar")
|
|
128
|
+
.catch(function (err) {
|
|
129
|
+
t.equal(err.statusCode, 404, err.msg);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
imagefilejsfile
|