-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
128 lines (122 loc) · 4.24 KB
/
Copy pathbuild.js
File metadata and controls
128 lines (122 loc) · 4.24 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
* _ _
* | | __ _ _ __ | |__ ___
* _ | |/ _` | '_ \| '_ \ / _ \
* | |_| | (_| | | | | | | | (_) |
* \___/ \__,_|_| |_|_| |_|\___/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* @author Saisana299
* @link https://github.com/Janho-Dev/Janho-Server
*
*/
const nexe = require('nexe');
const rcedit = require('rcedit');
const fs = require('fs');
const {execSync} = require('child_process');
const {resolve} = require('path');
const platform = process.argv[2];
let version = 0;
try{
const stdout = execSync("git log --oneline --no-merges");
const log = stdout.toString();
version = log.split("\n").length + 63;
fs.writeFile('CURRENT_VERSION', version.toString(), function (err) {
if (err) { throw err; }
});
}catch(error){
console.error(error);
};
const assets =
{
windows: "./build/asset/windows-x64-14.15.3",
linux: './build/asset/linux-x64-14.15.3',
mac: './build/asset/mac-x64-14.15.3'
};
const __version = `dev-${version}`
const __number_ver = version / 10**version.toString().length
const rc = {
'CompanyName': "Janho",
'ProductName': "Janho Server",
'FileDescription': "Janho Server Software",
'FileVersion': __number_ver,
'ProductVersion': __number_ver,
'OriginalFilename': "JanhoServer_"+ __version +".exe",
'InternalName': "JanhoServer_" + __version,
'LegalCopyright': "Copyright (c) Saisana299. Licensed under the AGPL-3.0"
};
async function exists(filename) {
try {
return (await fs.promises.stat(filename)).size > 0
} catch{ }
return false;
}
(async function () {
if(platform === "windows"){
await nexe.compile({
input: './build/janho/Janho.js',
output: "./build/JanhoServer_" + __version + "_win-x64",
resources: ["./build/janho/resource/**/*"],
asset: assets.windows,
temp: "../node/.nexe",
flags: ["--experimental-modules"],
target: "win-x64",
rc: Object.assign({
'PRODUCTVERSION': __number_ver,
'FILEVERSION': __number_ver
}, rc),
patches: [
async(compiler, next) => {
const exePath = compiler.getNodeExecutableLocation();
if(await exists(exePath)){
await rcedit(exePath, {
'version-string': rc,
'file-version': __number_ver,
'product-version': __number_ver,
icon: resolve(__dirname, "./build/asset/janho.ico")
});
}
return next()
}
]
}, function(err){
if(err) console.error(err);
});
}else if(platform === "linux"){
await nexe.compile({
input: './build/janho/Janho.js',
output: "./build/JanhoServer_" + __version + "_linux-x64",
resources: ["./build/janho/resource/**/*"],
asset: assets.linux,
temp: "../node/.nexe",
flags: ["--experimental-modules"],
target: "linux-x64"
}, function (err) {
if (err) console.log(err);
});
}else if(platform === "mac"){
await nexe.compile({
input: './build/janho/Janho.js',
output: "./build/JanhoServer_" + __version + "_mac-x64",
resources: ["./build/janho/resource/**/*"],
asset: assets.mac,
temp: "../node/.nexe",
flags: ["--experimental-modules"],
target: "mac-x64"
}, function (err) {
if (err) console.log(err);
});
}
})().catch(console.error);