vue-cli-plugin-electron-haunv 1.0.6 → 1.0.7
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/bin/dev-runner.js +13 -2
- package/generator/index.js +12 -34
- package/generator/template/electron-builder.json +35 -0
- package/package.json +1 -1
package/bin/dev-runner.js
CHANGED
|
@@ -42,8 +42,8 @@ async function run() {
|
|
|
42
42
|
|
|
43
43
|
function startElectron() {
|
|
44
44
|
electronProcess = spawn(
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
electron,
|
|
46
|
+
["."],
|
|
47
47
|
{
|
|
48
48
|
stdio: "inherit",
|
|
49
49
|
env: {
|
|
@@ -52,6 +52,8 @@ function startElectron() {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
)
|
|
55
|
+
|
|
56
|
+
setupExitListener()
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
function restartElectron() {
|
|
@@ -61,4 +63,13 @@ function restartElectron() {
|
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
function setupExitListener() {
|
|
67
|
+
if (!electronProcess) return
|
|
68
|
+
|
|
69
|
+
electronProcess.on("exit", () => {
|
|
70
|
+
console.log("🛑 Electron closed → stopping dev server...")
|
|
71
|
+
process.exit()
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
64
75
|
run()
|
package/generator/index.js
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
const { execSync } = require("child_process")
|
|
2
2
|
|
|
3
|
+
const cache = {}
|
|
4
|
+
|
|
3
5
|
function getLatestVersion(pkg) {
|
|
6
|
+
if (cache[pkg]) return cache[pkg]
|
|
7
|
+
|
|
4
8
|
try {
|
|
5
|
-
|
|
9
|
+
const v = execSync(`npm view ${pkg} version`, {
|
|
6
10
|
stdio: ["pipe", "pipe", "ignore"]
|
|
7
11
|
})
|
|
8
12
|
.toString()
|
|
9
13
|
.trim()
|
|
14
|
+
|
|
15
|
+
cache[pkg] = v
|
|
16
|
+
return v
|
|
10
17
|
} catch (e) {
|
|
11
|
-
console.warn(`⚠️ Cannot fetch
|
|
18
|
+
console.warn(`⚠️ Cannot fetch ${pkg}, fallback to latest`)
|
|
12
19
|
return "latest"
|
|
13
20
|
}
|
|
14
21
|
}
|
|
@@ -24,49 +31,20 @@ module.exports = (api) => {
|
|
|
24
31
|
console.log(" electron:", electronVersion)
|
|
25
32
|
console.log(" electron-builder:", builderVersion)
|
|
26
33
|
|
|
34
|
+
console.log("⚡ Installing dependencies may take a moment...")
|
|
35
|
+
|
|
27
36
|
api.extendPackage({
|
|
28
37
|
|
|
29
38
|
main: "electron/main.js",
|
|
30
39
|
|
|
31
40
|
scripts: {
|
|
32
41
|
"electron:dev": "node node_modules/vue-cli-plugin-electron-haunv/bin/dev-runner.js",
|
|
33
|
-
"electron:build": "npm run build && electron-builder"
|
|
42
|
+
"electron:build": "npm run build && electron-builder --config electron-builder.json"
|
|
34
43
|
},
|
|
35
44
|
|
|
36
45
|
devDependencies: {
|
|
37
46
|
electron: `^${electronVersion}`,
|
|
38
47
|
"electron-builder": `^${builderVersion}`
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
build: {
|
|
42
|
-
appId: "com.haunv.app",
|
|
43
|
-
productName: "MyApp",
|
|
44
|
-
|
|
45
|
-
directories: {
|
|
46
|
-
output: "dist_electron"
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
files: [
|
|
50
|
-
"dist/**/*",
|
|
51
|
-
"electron/**/*",
|
|
52
|
-
"package.json"
|
|
53
|
-
],
|
|
54
|
-
|
|
55
|
-
extraMetadata: {
|
|
56
|
-
main: "electron/main.js"
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
win: {
|
|
60
|
-
target: [
|
|
61
|
-
{ target: "nsis", arch: ["x64"] },
|
|
62
|
-
{ target: "portable", arch: ["x64"] }
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
nsis: {
|
|
67
|
-
oneClick: false,
|
|
68
|
-
allowToChangeInstallationDirectory: true
|
|
69
|
-
}
|
|
70
48
|
}
|
|
71
49
|
|
|
72
50
|
})
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"appId": "com.haunv.app",
|
|
3
|
+
"productName": "MyApp",
|
|
4
|
+
"directories": {
|
|
5
|
+
"output": "dist_electron"
|
|
6
|
+
},
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"electron/**/*",
|
|
10
|
+
"package.json"
|
|
11
|
+
],
|
|
12
|
+
"extraMetadata": {
|
|
13
|
+
"main": "electron/main.js"
|
|
14
|
+
},
|
|
15
|
+
"win": {
|
|
16
|
+
"target": [
|
|
17
|
+
{
|
|
18
|
+
"target": "nsis",
|
|
19
|
+
"arch": [
|
|
20
|
+
"x64"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"target": "portable",
|
|
25
|
+
"arch": [
|
|
26
|
+
"x64"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
"nsis": {
|
|
32
|
+
"oneClick": false,
|
|
33
|
+
"allowToChangeInstallationDirectory": true
|
|
34
|
+
}
|
|
35
|
+
}
|