-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathdist-utils.js
94 lines (81 loc) · 2.55 KB
/
dist-utils.js
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
const path = require('path')
const chromeManifest = require('./src/web/vendor/chrome/manifest.json')
const firefoxManifest = require('./src/web/vendor/firefox/manifest.json')
const edgeManifest = require('./src/web/vendor/edge/manifest.json')
const pcPackageJSON = require('./src/pc/package.json')
const getVersion = (platform) => {
switch (platform) {
case 'CHROME':
return chromeManifest.version
case 'FIREFOX':
return firefoxManifest.version
case 'EDGE':
return edgeManifest.version
case 'MACOS':
return pcPackageJSON.version
case 'WINDOWS':
return pcPackageJSON.version
default:
return ''
}
}
const FILE_DIR = {
CHROME: './dist/chrome',
FIREFOX: './dist/firefox',
EDGE: './dist/edge',
MACOS: './dist/macos',
MACOS_X64: './dist/macos',
MACOS_ARM64: './dist/macos',
WINDOWS: './dist/windows'
}
const FILE_NAME_ORIGINAL = {
CHROME: `ZaDark Chrome ${getVersion('CHROME')}.zip`,
FIREFOX: `ZaDark Firefox ${getVersion('FIREFOX')}.zip`,
OPERA: `ZaDark Opera ${getVersion('OPERA')}.zip`,
EDGE: `ZaDark Edge ${getVersion('EDGE')}.zip`,
MACOS: `ZaDark ${getVersion('MACOS')}`,
MACOS_X64: `ZaDark ${getVersion('MACOS')}-x64`,
MACOS_ARM64: `ZaDark ${getVersion('MACOS')}-arm64`,
MACOS_X64_FRIENDLY: `ZaDark ${getVersion('MACOS')} - Intel Chip`,
MACOS_ARM64_FRIENDLY: `ZaDark ${getVersion('MACOS')} - Apple Chip`,
WINDOWS: `ZaDark ${getVersion('WINDOWS')}.exe`
}
const FILE_NAME_ZIP = {
CHROME: `ZaDark Chrome ${getVersion('CHROME')}.zip`,
FIREFOX: `ZaDark Firefox ${getVersion('FIREFOX')}.zip`,
OPERA: `ZaDark Opera ${getVersion('OPERA')}.zip`,
EDGE: `ZaDark Edge ${getVersion('EDGE')}.zip`,
MACOS: `ZaDark ${getVersion('MACOS')}.zip`,
MACOS_X64: `ZaDark ${getVersion('MACOS')} - Intel Chip.zip`,
MACOS_ARM64: `ZaDark ${getVersion('MACOS')} - Apple Chip.zip`,
WINDOWS: `ZaDark ${getVersion('WINDOWS')}.zip`
}
const getFileNameOriginal = (plat) => {
return FILE_NAME_ORIGINAL[plat]
}
const getFileNameZip = (plat) => {
return FILE_NAME_ZIP[plat]
}
const getFileNameMacOSTar = (arch = 'x64') => {
return `zadark-macos-${pcPackageJSON.version}-${arch}.tar`
}
const getFileDir = (platform) => {
return path.join(__dirname, FILE_DIR[platform])
}
const getFilePath = (platform, isOriginalFile = false) => {
return path.join(
__dirname,
FILE_DIR[platform],
isOriginalFile
? getFileNameOriginal(platform)
: getFileNameZip(platform)
)
}
module.exports = {
getVersion,
getFileNameOriginal,
getFileNameZip,
getFileNameMacOSTar,
getFileDir,
getFilePath
}