@overwolf/ow-electron 12.2.3
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/LICENSE +22 -0
- package/README.md +121 -0
- package/checksums.json +8 -0
- package/cli.js +25 -0
- package/electron.d.ts +16176 -0
- package/index.js +21 -0
- package/install.js +107 -0
- package/package.json +29 -0
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const pathFile = path.join(__dirname, 'path.txt');
|
|
5
|
+
|
|
6
|
+
function getElectronPath () {
|
|
7
|
+
let executablePath;
|
|
8
|
+
if (fs.existsSync(pathFile)) {
|
|
9
|
+
executablePath = fs.readFileSync(pathFile, 'utf-8');
|
|
10
|
+
}
|
|
11
|
+
if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
|
|
12
|
+
return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath || 'electron');
|
|
13
|
+
}
|
|
14
|
+
if (executablePath) {
|
|
15
|
+
return path.join(__dirname, 'dist', executablePath);
|
|
16
|
+
} else {
|
|
17
|
+
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = getElectronPath();
|
package/install.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
//const { version } = require('./package');
|
|
4
|
+
const { owElectronVersion } = require('./package');
|
|
5
|
+
|
|
6
|
+
const childProcess = require('child_process');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const extract = require('extract-zip');
|
|
11
|
+
const { downloadArtifact } = require('@electron/get');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) {
|
|
15
|
+
process.exit(0);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const platformPath = getPlatformPath();
|
|
19
|
+
|
|
20
|
+
if (isInstalled()) {
|
|
21
|
+
process.exit(0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const platform = process.env.npm_config_platform || process.platform;
|
|
25
|
+
let arch = process.env.npm_config_arch || process.arch;
|
|
26
|
+
|
|
27
|
+
if (platform === 'darwin' && process.platform === 'darwin' && arch === 'x64' &&
|
|
28
|
+
process.env.npm_config_arch === undefined) {
|
|
29
|
+
// When downloading for macOS ON macOS and we think we need x64 we should
|
|
30
|
+
// check if we're running under rosetta and download the arm64 version if appropriate
|
|
31
|
+
try {
|
|
32
|
+
const output = childProcess.execSync('sysctl -in sysctl.proc_translated');
|
|
33
|
+
if (output.toString().trim() === '1') {
|
|
34
|
+
arch = 'arm64';
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
// Ignore failure
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// downloads if not cached
|
|
42
|
+
downloadArtifact({
|
|
43
|
+
mirrorOptions: {
|
|
44
|
+
mirror: 'https://content.overwolf.com/ow-electron/releases/download/',
|
|
45
|
+
},
|
|
46
|
+
version: owElectronVersion,
|
|
47
|
+
artifactName: 'ow-electron',
|
|
48
|
+
force: process.env.force_no_cache === 'true',
|
|
49
|
+
cacheRoot: process.env.electron_config_cache,
|
|
50
|
+
checksums: process.env.electron_use_remote_checksums ? undefined : require('./checksums.json'),
|
|
51
|
+
platform,
|
|
52
|
+
arch
|
|
53
|
+
}).then(extractFile).catch(err => {
|
|
54
|
+
console.error(err.stack);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
function isInstalled () {
|
|
59
|
+
try {
|
|
60
|
+
if (fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '') !== owElectronVersion) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (fs.readFileSync(path.join(__dirname, 'path.txt'), 'utf-8') !== platformPath) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
} catch (ignored) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const electronPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist', platformPath);
|
|
72
|
+
|
|
73
|
+
return fs.existsSync(electronPath);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// unzips and makes path.txt point at the correct executable
|
|
77
|
+
function extractFile (zipPath) {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
extract(zipPath, { dir: path.join(__dirname, 'dist') }, err => {
|
|
80
|
+
if (err) return reject(err);
|
|
81
|
+
|
|
82
|
+
fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, err => {
|
|
83
|
+
if (err) return reject(err);
|
|
84
|
+
|
|
85
|
+
resolve();
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function getPlatformPath () {
|
|
92
|
+
const platform = process.env.npm_config_platform || os.platform();
|
|
93
|
+
|
|
94
|
+
switch (platform) {
|
|
95
|
+
case 'mas':
|
|
96
|
+
case 'darwin':
|
|
97
|
+
return 'Electron.app/Contents/MacOS/Electron';
|
|
98
|
+
case 'freebsd':
|
|
99
|
+
case 'openbsd':
|
|
100
|
+
case 'linux':
|
|
101
|
+
return 'electron';
|
|
102
|
+
case 'win32':
|
|
103
|
+
return 'electron.exe';
|
|
104
|
+
default:
|
|
105
|
+
throw new Error('Electron builds are not available on platform: ' + platform);
|
|
106
|
+
}
|
|
107
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@overwolf/ow-electron",
|
|
3
|
+
"version": "12.2.3",
|
|
4
|
+
"owElectronVersion": "12.2.3",
|
|
5
|
+
"repository": "https://github.com/electron/electron",
|
|
6
|
+
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Overwolf",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"ow-electron",
|
|
11
|
+
"overwolf electron"
|
|
12
|
+
],
|
|
13
|
+
"main": "index.js",
|
|
14
|
+
"types": "electron.d.ts",
|
|
15
|
+
"bin": {
|
|
16
|
+
"ow-electron": "cli.js"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"postinstall": "node install.js"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@electron/get": "^1.14.1",
|
|
23
|
+
"@types/node": "^16.11.26",
|
|
24
|
+
"extract-zip": "^1.0.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">= 10.17.0"
|
|
28
|
+
}
|
|
29
|
+
}
|