Skip to content

Commit 311858e

Browse files
committed
update minecraft-java-core
1 parent 81bd23d commit 311858e

9 files changed

Lines changed: 1519 additions & 1173 deletions

File tree

build.js

Lines changed: 79 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,84 @@
11
const builder = require('electron-builder')
2+
const nodeFetch = require('node-fetch')
3+
const fs = require("fs");
4+
const png2icons = require('png2icons');
5+
const Jimp = require('jimp');
26
const { preductname } = require('./package.json')
37

4-
builder.build({
5-
config: {
6-
generateUpdatesFilesForAllChannels: false,
7-
appId: preductname,
8-
productName: preductname,
9-
artifactName: "${productName}-${os}-${arch}.${ext}",
10-
files: ["src/**/*", "package.json", "LICENSE.md"],
11-
directories: { "output": "dist" },
12-
compression: 'maximum',
13-
asar: true,
14-
publish: [{
15-
provider: "github",
16-
releaseType: 'release',
17-
}],
18-
win: {
19-
icon: "./src/assets/images/icon.ico",
20-
target: [{
21-
target: "nsis",
22-
arch: ["x64"]
23-
}],
24-
},
25-
nsis: {
26-
oneClick: true,
27-
allowToChangeInstallationDirectory: false,
28-
createDesktopShortcut: true,
29-
runAfterFinish: true
30-
},
31-
mac: {
32-
icon: "./src/assets/images/icon.icns",
33-
category: "public.app-category.games",
34-
target: [{
35-
target: "dmg",
36-
arch: ["x64", "arm64"]
37-
}]
38-
},
39-
linux: {
40-
icon: "./src/assets/images/icon.png",
41-
target: [{
42-
target: "AppImage",
43-
arch: ["x64"]
44-
}, {
45-
target: "tar.gz",
46-
arch: ["x64"]
47-
}]
8+
class Index {
9+
async build() {
10+
builder.build({
11+
config: {
12+
generateUpdatesFilesForAllChannels: false,
13+
appId: preductname,
14+
productName: preductname,
15+
artifactName: "${productName}-${os}-${arch}.${ext}",
16+
files: ["src/**/*", "package.json", "LICENSE.md"],
17+
directories: { "output": "dist" },
18+
compression: 'maximum',
19+
asar: true,
20+
publish: [{
21+
provider: "github",
22+
releaseType: 'release',
23+
}],
24+
win: {
25+
icon: "./src/assets/images/icon.ico",
26+
target: [{
27+
target: "nsis",
28+
arch: ["x64"]
29+
}],
30+
},
31+
nsis: {
32+
oneClick: true,
33+
allowToChangeInstallationDirectory: false,
34+
createDesktopShortcut: true,
35+
runAfterFinish: true
36+
},
37+
mac: {
38+
icon: "./src/assets/images/icon.icns",
39+
category: "public.app-category.games",
40+
target: [{
41+
target: "dmg",
42+
arch: ["x64", "arm64"]
43+
}]
44+
},
45+
linux: {
46+
icon: "./src/assets/images/icon.png",
47+
target: [{
48+
target: "AppImage",
49+
arch: ["x64"]
50+
}, {
51+
target: "tar.gz",
52+
arch: ["x64"]
53+
}]
54+
}
55+
}
56+
}).then(() => {
57+
console.log('le build est terminé')
58+
}).catch(err => {
59+
console.error('Error during build!', err)
60+
})
61+
}
62+
63+
async iconSet(url) {
64+
let Buffer = await nodeFetch(url)
65+
if (Buffer.status == 200) {
66+
Buffer = await Buffer.buffer()
67+
const image = await Jimp.read(Buffer);
68+
Buffer = await image.resize(256, 256).getBufferAsync(Jimp.MIME_PNG)
69+
fs.writeFileSync("src/assets/images/icon.icns", png2icons.createICNS(Buffer, png2icons.BILINEAR, 0));
70+
fs.writeFileSync("src/assets/images/icon.ico", png2icons.createICO(Buffer, png2icons.HERMITE, 0, false));
71+
fs.writeFileSync("src/assets/images/icon.png", Buffer);
72+
} else {
73+
console.log('connection error')
4874
}
4975
}
50-
}).then(() => {
51-
console.log('le build est terminé')
52-
}).catch(err => {
53-
console.error('Error during build!', err)
54-
})
76+
}
77+
78+
process.argv.forEach(val => {
79+
if (val.startsWith('--icon')) {
80+
return new Index().iconSet(val.split('=')[1])
81+
} else if (val.startsWith('--build')) {
82+
new Index().build()
83+
}
84+
});

0 commit comments

Comments
 (0)