electron-mksnapshot 9.0.1 → 9.0.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/README.md +10 -0
- package/download-mksnapshot.js +33 -28
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,6 +41,16 @@ ELECTRON_MIRROR="https://npm.taobao.org/mirrors/electron/"
|
|
|
41
41
|
# Example of requested URL: http://localhost:8080/1.2.0/mksnapshot-v1.2.0-darwin-x64.zip
|
|
42
42
|
ELECTRON_MIRROR="http://localhost:8080/"
|
|
43
43
|
```
|
|
44
|
+
|
|
45
|
+
## Overriding the version downloaded
|
|
46
|
+
|
|
47
|
+
The version downloaded can be overriden by setting the `ELECTRON_CUSTOM_VERSION` environment variable.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
# Install mksnapshot for Electron v8.3.0
|
|
51
|
+
ELECTRON_CUSTOM_VERSION=8.3.0 npm install
|
|
52
|
+
```
|
|
53
|
+
|
|
44
54
|
## Generating snapshots for ARM hardware
|
|
45
55
|
|
|
46
56
|
If you need to generate snapshots for Linux on 32 bit ARM, Linux on ARM64, or Windows on ARM64 you will need to install a cross arch mksnapshot on an Intel x64 machine. To do so, set the npm config `arch` to the proper arch and then run `npm install --save-dev electron-mksnapshot`. For example:
|
package/download-mksnapshot.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
const { downloadArtifact } = require('@electron/get')
|
|
4
|
+
const extractZip = require('extract-zip')
|
|
5
|
+
const versionToDownload = require('./package').version
|
|
6
|
+
let archToDownload = process.env.npm_config_arch
|
|
7
7
|
|
|
8
8
|
if (process.arch.indexOf('arm') === 0) {
|
|
9
9
|
console.log(`WARNING: mksnapshot does not run on ${process.arch}. Download
|
|
@@ -23,38 +23,43 @@ if (archToDownload && archToDownload.indexOf('arm') === 0) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function download (version
|
|
27
|
-
|
|
26
|
+
function download (version) {
|
|
27
|
+
return downloadArtifact({
|
|
28
28
|
version: version,
|
|
29
|
-
|
|
29
|
+
artifactName: 'mksnapshot',
|
|
30
30
|
platform: process.env.npm_config_platform,
|
|
31
31
|
arch: archToDownload,
|
|
32
|
-
|
|
32
|
+
rejectUnauthorized: process.env.npm_config_strict_ssl === 'true',
|
|
33
33
|
quiet: ['info', 'verbose', 'silly', 'http'].indexOf(process.env.npm_config_loglevel) === -1
|
|
34
|
-
}
|
|
34
|
+
})
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
async function attemptDownload (version) {
|
|
38
|
+
try {
|
|
39
|
+
const targetFolder = path.join(__dirname, 'bin')
|
|
40
|
+
const zipPath = await download(version)
|
|
41
|
+
await extractZip(zipPath, { dir: targetFolder })
|
|
42
|
+
const platform = process.env.npm_config_platform || process.platform
|
|
43
|
+
if (platform !== 'win32') {
|
|
44
|
+
const mksnapshotPath = path.join(__dirname, 'bin', 'mksnapshot')
|
|
43
45
|
if (fs.existsSync(mksnapshotPath)) {
|
|
44
|
-
fs.chmod(
|
|
46
|
+
fs.chmod(mksnapshotPath, '755', function (error) {
|
|
45
47
|
if (error != null) throw error
|
|
46
48
|
})
|
|
47
49
|
}
|
|
48
50
|
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
+
} catch (err) {
|
|
52
|
+
// attempt to fall back to semver minor
|
|
53
|
+
const parts = version.split('.')
|
|
54
|
+
const baseVersion = `${parts[0]}.${parts[1]}.0`
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
processDownload(err, zipPath)
|
|
56
|
+
// don't recurse infinitely
|
|
57
|
+
if (baseVersion === version) {
|
|
58
|
+
throw err
|
|
59
|
+
} else {
|
|
60
|
+
await attemptDownload(baseVersion)
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
|
-
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
attemptDownload(versionToDownload)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "electron-mksnapshot",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.2",
|
|
4
4
|
"description": "Electron version of the mksnapshot binary",
|
|
5
5
|
"repository": "https://github.com/electron/mksnapshot",
|
|
6
6
|
"bin": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"electron
|
|
15
|
+
"@electron/get": "^1.12.2",
|
|
16
16
|
"extract-zip": "^2.0.0",
|
|
17
17
|
"fs-extra": "^7.0.1",
|
|
18
18
|
"temp": "^0.8.3"
|