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/package.json
CHANGED
|
@@ -1,60 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nw-builder",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Build NW.js applications for Mac, Windows and Linux.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
|
|
3
|
+
"version": "3.7.2",
|
|
4
|
+
"description": "Build NW.js desktop applications for Mac, Windows and Linux.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"NW.js",
|
|
7
|
+
"Desktop",
|
|
8
|
+
"Application"
|
|
9
|
+
],
|
|
10
|
+
"author": "Steffen Müller <steffen@mllrsohn.com>",
|
|
7
11
|
"license": "MIT",
|
|
8
|
-
"main": "index.js",
|
|
9
|
-
"
|
|
12
|
+
"main": "lib/index.js",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"homepage": "https://github.com/nwutils/nw-builder",
|
|
10
15
|
"repository": {
|
|
11
16
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/
|
|
17
|
+
"url": "https://github.com/nwutils/nw-builder.git"
|
|
13
18
|
},
|
|
14
19
|
"scripts": {
|
|
15
|
-
"format": "prettier --write ./lib",
|
|
16
|
-
"lint": "eslint
|
|
17
|
-
"test": "tape test/*.
|
|
18
|
-
"
|
|
20
|
+
"format": "prettier --write ./bin ./lib ./src ./test",
|
|
21
|
+
"lint": "eslint ./bin/**.cjs ./lib/**.cjs ./src/**.js ./test/**.cjs ",
|
|
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"
|
|
19
26
|
},
|
|
20
27
|
"devDependencies": {
|
|
21
28
|
"decompress-zip": "0.3.3",
|
|
22
29
|
"eol": "0.9.1",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
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",
|
|
25
38
|
"prettier": "2.6.2",
|
|
26
39
|
"redtape": "1.0.0",
|
|
27
|
-
"
|
|
28
|
-
"tape": "4.9.0"
|
|
40
|
+
"tape": "5.5.3"
|
|
29
41
|
},
|
|
30
42
|
"dependencies": {
|
|
31
|
-
"archiver": "
|
|
32
|
-
"boxen": "1.1.0",
|
|
33
|
-
"chalk": "2.3.2",
|
|
43
|
+
"archiver": "5.3.1",
|
|
34
44
|
"deprecate": "1.1.1",
|
|
35
|
-
"extract-zip": "
|
|
45
|
+
"extract-zip": "2.0.1",
|
|
36
46
|
"graceful-fs-extra": "2.0.0",
|
|
37
47
|
"graceful-ncp": "3.0.0",
|
|
38
48
|
"inherits": "2.0.4",
|
|
39
|
-
"lazy-req": "2.0.0",
|
|
40
49
|
"lodash": "4.17.21",
|
|
41
|
-
"optimist": "0.6.1",
|
|
42
50
|
"plist": "3.0.5",
|
|
43
51
|
"progress": "2.0.3",
|
|
44
|
-
"rcedit": "
|
|
52
|
+
"rcedit": "3.0.1",
|
|
45
53
|
"recursive-readdir-sync": "1.0.6",
|
|
46
54
|
"request": "2.88.2",
|
|
47
|
-
"rimraf": "
|
|
48
|
-
"semver": "
|
|
55
|
+
"rimraf": "3.0.2",
|
|
56
|
+
"semver": "7.3.7",
|
|
49
57
|
"simple-glob": "0.2.0",
|
|
50
|
-
"tar-fs": "1.
|
|
58
|
+
"tar-fs": "2.1.1",
|
|
51
59
|
"temp": "github:adam-lynch/node-temp#remove_tmpdir_dep",
|
|
52
60
|
"thenify": "3.3.1",
|
|
53
|
-
"update-notifier": "
|
|
54
|
-
"winresourcer": "0.9.0"
|
|
61
|
+
"update-notifier": "5.1.0",
|
|
62
|
+
"winresourcer": "0.9.0",
|
|
63
|
+
"yargs": "17.5.1"
|
|
55
64
|
},
|
|
56
65
|
"bin": {
|
|
57
|
-
"nwbuild": "./bin/nwbuild"
|
|
66
|
+
"nwbuild": "./bin/nwbuild.cjs"
|
|
58
67
|
},
|
|
59
68
|
"prettier": {
|
|
60
69
|
"printWidth": 80,
|
|
@@ -73,6 +82,25 @@
|
|
|
73
82
|
"singleAttributePerLine": true
|
|
74
83
|
},
|
|
75
84
|
"eslintConfig": {
|
|
76
|
-
"extends": "eslint:recommended"
|
|
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"
|
|
77
105
|
}
|
|
78
106
|
}
|
|
@@ -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,143 @@
|
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
|
|
3
|
+
const Platforms = {
|
|
4
|
+
win32: {
|
|
5
|
+
needsZip: true,
|
|
6
|
+
getRunnable: function () {
|
|
7
|
+
return "nw.exe";
|
|
8
|
+
},
|
|
9
|
+
files: {
|
|
10
|
+
// First file must be the executable
|
|
11
|
+
"<=0.9.2": [
|
|
12
|
+
"nw.exe",
|
|
13
|
+
"ffmpegsumo.dll",
|
|
14
|
+
"icudt.dll",
|
|
15
|
+
"libEGL.dll",
|
|
16
|
+
"libGLESv2.dll",
|
|
17
|
+
"nw.pak",
|
|
18
|
+
],
|
|
19
|
+
">0.9.2 <0.12.0": [
|
|
20
|
+
"nw.exe",
|
|
21
|
+
"ffmpegsumo.dll",
|
|
22
|
+
"icudtl.dat",
|
|
23
|
+
"libEGL.dll",
|
|
24
|
+
"libGLESv2.dll",
|
|
25
|
+
"nw.pak",
|
|
26
|
+
"locales",
|
|
27
|
+
],
|
|
28
|
+
">=0.12.0": [
|
|
29
|
+
"nw.exe",
|
|
30
|
+
"ffmpegsumo.dll",
|
|
31
|
+
"icudtl.dat",
|
|
32
|
+
"libEGL.dll",
|
|
33
|
+
"libGLESv2.dll",
|
|
34
|
+
"nw.pak",
|
|
35
|
+
"locales",
|
|
36
|
+
"d3dcompiler_47.dll",
|
|
37
|
+
"pdf.dll",
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
versionNameTemplate: "v${ version }/${ name }-v${ version }-win-ia32.zip",
|
|
41
|
+
},
|
|
42
|
+
win64: {
|
|
43
|
+
needsZip: true,
|
|
44
|
+
getRunnable: function () {
|
|
45
|
+
return "nw.exe";
|
|
46
|
+
},
|
|
47
|
+
files: {
|
|
48
|
+
// First file must be the executable
|
|
49
|
+
"<=0.9.2": [
|
|
50
|
+
"nw.exe",
|
|
51
|
+
"ffmpegsumo.dll",
|
|
52
|
+
"icudt.dll",
|
|
53
|
+
"libEGL.dll",
|
|
54
|
+
"libGLESv2.dll",
|
|
55
|
+
"nw.pak",
|
|
56
|
+
"locales",
|
|
57
|
+
],
|
|
58
|
+
">0.9.2 <0.12.0": [
|
|
59
|
+
"nw.exe",
|
|
60
|
+
"ffmpegsumo.dll",
|
|
61
|
+
"icudtl.dat",
|
|
62
|
+
"libEGL.dll",
|
|
63
|
+
"libGLESv2.dll",
|
|
64
|
+
"nw.pak",
|
|
65
|
+
"locales",
|
|
66
|
+
],
|
|
67
|
+
">=0.12.0": [
|
|
68
|
+
"nw.exe",
|
|
69
|
+
"ffmpegsumo.dll",
|
|
70
|
+
"icudtl.dat",
|
|
71
|
+
"libEGL.dll",
|
|
72
|
+
"libGLESv2.dll",
|
|
73
|
+
"nw.pak",
|
|
74
|
+
"locales",
|
|
75
|
+
"d3dcompiler_47.dll",
|
|
76
|
+
"pdf.dll",
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
versionNameTemplate: "v${ version }/${ name }-v${ version }-win-x64.zip",
|
|
80
|
+
},
|
|
81
|
+
osx32: {
|
|
82
|
+
needsZip: false,
|
|
83
|
+
getRunnable: function (version) {
|
|
84
|
+
if (semver.satisfies(version, ">=0.12.0 || ~0.12.0-alpha")) {
|
|
85
|
+
return "nwjs.app/Contents/MacOS/nwjs";
|
|
86
|
+
} else {
|
|
87
|
+
return "node-webkit.app/Contents/MacOS/node-webkit";
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
files: {
|
|
91
|
+
"<0.12.0-alpha": ["node-webkit.app"],
|
|
92
|
+
">=0.12.0 || ~0.12.0-alpha": ["nwjs.app"],
|
|
93
|
+
},
|
|
94
|
+
versionNameTemplate: "v${ version }/${ name }-v${ version }-osx-ia32.zip",
|
|
95
|
+
},
|
|
96
|
+
osx64: {
|
|
97
|
+
needsZip: false,
|
|
98
|
+
getRunnable: function (version) {
|
|
99
|
+
if (semver.satisfies(version, ">=0.12.0 || ~0.12.0-alpha")) {
|
|
100
|
+
return "nwjs.app/Contents/MacOS/nwjs";
|
|
101
|
+
} else {
|
|
102
|
+
return "node-webkit.app/Contents/MacOS/node-webkit";
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
files: {
|
|
106
|
+
"<0.12.0-alpha": ["node-webkit.app"],
|
|
107
|
+
">=0.12.0 || ~0.12.0-alpha": ["nwjs.app"],
|
|
108
|
+
},
|
|
109
|
+
versionNameTemplate: "v${ version }/${ name }-v${ version }-osx-x64.zip",
|
|
110
|
+
},
|
|
111
|
+
linux32: {
|
|
112
|
+
needsZip: true,
|
|
113
|
+
chmod: "0755",
|
|
114
|
+
getRunnable: function () {
|
|
115
|
+
return "nw";
|
|
116
|
+
},
|
|
117
|
+
files: {
|
|
118
|
+
// First file must be the executable
|
|
119
|
+
"<=0.9.2": ["nw", "nw.pak", "libffmpegsumo.so"],
|
|
120
|
+
">0.9.2 <=0.10.1": ["nw", "nw.pak", "libffmpegsumo.so", "icudtl.dat"],
|
|
121
|
+
">0.10.1": ["nw", "nw.pak", "libffmpegsumo.so", "icudtl.dat", "locales"],
|
|
122
|
+
},
|
|
123
|
+
versionNameTemplate:
|
|
124
|
+
"v${ version }/${ name }-v${ version }-linux-ia32.tar.gz",
|
|
125
|
+
},
|
|
126
|
+
linux64: {
|
|
127
|
+
needsZip: true,
|
|
128
|
+
chmod: "0755", // chmod file file to be executable
|
|
129
|
+
getRunnable: function () {
|
|
130
|
+
return "nw";
|
|
131
|
+
},
|
|
132
|
+
files: {
|
|
133
|
+
// First file must be the executable
|
|
134
|
+
"<=0.9.2": ["nw", "nw.pak", "libffmpegsumo.so"],
|
|
135
|
+
">0.9.2 <=0.10.1": ["nw", "nw.pak", "libffmpegsumo.so", "icudtl.dat"],
|
|
136
|
+
">0.10.1": ["nw", "nw.pak", "libffmpegsumo.so", "icudtl.dat", "locales"],
|
|
137
|
+
},
|
|
138
|
+
versionNameTemplate:
|
|
139
|
+
"v${ version }/${ name }-v${ version }-linux-x64.tar.gz",
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default Platforms;
|
package/src/index.js
ADDED
|
@@ -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 "../constants";
|
|
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;
|
|
File without changes
|
|
File without changes
|
|
@@ -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));
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
"main": "index.html",
|
|
3
2
|
"name": "nw-demo",
|
|
4
|
-
"description": "demo app of NW.js",
|
|
5
3
|
"version": "0.1.0",
|
|
6
|
-
"
|
|
4
|
+
"description": "NW.js demo",
|
|
5
|
+
"main": "./index.html",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node ./index.cjs"
|
|
8
|
+
},
|
|
7
9
|
"window": {
|
|
8
|
-
"title": "NW.js
|
|
9
|
-
"icon": "link.png",
|
|
10
|
+
"title": "NW.js Demo",
|
|
10
11
|
"toolbar": false,
|
|
11
12
|
"frame": true,
|
|
12
13
|
"width": 800,
|
|
@@ -20,4 +21,4 @@
|
|
|
20
21
|
"webkit": {
|
|
21
22
|
"plugin": true
|
|
22
23
|
}
|
|
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
|
+
});
|
package/test/expected/README.md
CHANGED
package/test/expected/merged
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
imagefilejsfile
|
|
1
|
+
imagefilejsfile
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
2
|
+
"name": "nw-demo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "another.html",
|
|
5
|
+
"window": {
|
|
6
|
+
"frame": true,
|
|
7
|
+
"toolbar": false
|
|
8
|
+
},
|
|
9
|
+
"frame": false,
|
|
10
|
+
"x": {},
|
|
11
|
+
"abc": [],
|
|
12
|
+
"def": {}
|
|
13
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
2
|
+
"name": "nw-demo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "index.html",
|
|
5
|
+
"window": {},
|
|
6
|
+
"x": [],
|
|
7
|
+
"abc": [],
|
|
8
|
+
"def": {}
|
|
9
|
+
}
|