-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathforge.config.js
More file actions
85 lines (82 loc) · 2.63 KB
/
Copy pathforge.config.js
File metadata and controls
85 lines (82 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const fs = require("fs");
const jszip = require("jszip");
const crypto = require("crypto");
const path = require("path");
const date = new Date().toISOString();
const generateBuildFile = (platform, arch, maker) => {
const package = fs.readFileSync(path.join(__dirname, "package.json"), "utf8");
const hash = crypto.createHash("sha256").update(package);
const data = {
id: hash.digest("hex").slice(-6),
platform: platform,
arch: arch,
maker: maker,
date: date,
};
return JSON.stringify(data, null, 2);
};
module.exports = {
packagerConfig: {
ignore: [".github", ".gitignore", "install.sh", "forge.config.js"],
},
makers: [
{
name: "@electron-forge/maker-deb",
config: {
options: {
productName: "TouchKio",
productDescription: "Kiosk mode application for a Home Assistant dashboard",
categories: ["Network"],
icon: "img/icon.png",
},
},
},
{
name: "@electron-forge/maker-zip",
},
],
publishers: [
{
name: "@electron-forge/publisher-github",
config: {
repository: {
owner: "leukipp",
name: "touchkio",
},
draft: true,
},
},
],
hooks: {
postPackage: async (config, results) => {
for (const outputPath of results.outputPaths) {
const [name, platform, arch] = path.basename(outputPath).split("-");
const buildFile = path.join(outputPath, "resources", "app", "build.json");
fs.writeFileSync(buildFile, generateBuildFile(platform, arch, "deb"), { encoding: "utf8" });
}
},
postMake: async (config, results) => {
for (const result of results) {
const artifacts = [];
for (const artifact of result.artifacts) {
if (artifact.includes(".zip")) {
const [name, platform, arch] = path.basename(artifact).split("-");
const buildFile = path.join(`${name}-${platform}-${arch}`, "resources", "app", "build.json");
const options = { type: "nodebuffer", compression: "DEFLATE", compressionOptions: { level: 9 } };
const zip = await jszip.loadAsync(fs.readFileSync(artifact));
zip.file(buildFile, generateBuildFile(platform, arch, "zip"));
fs.writeFileSync(artifact, await zip.generateAsync(options));
}
if (artifact.includes("amd64")) {
const renamed = artifact.replace("amd64", "x64");
fs.renameSync(artifact, renamed);
artifacts.push(renamed);
} else {
artifacts.push(artifact);
}
}
result.artifacts = artifacts;
}
},
},
};