forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdist-info.ts
130 lines (105 loc) · 3.33 KB
/
dist-info.ts
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
129
130
import * as Path from 'path'
import * as Fs from 'fs'
import { getProductName, getVersion } from '../app/package-info'
import { getReleaseBranchName } from './build-platforms'
const productName = getProductName()
const version = getVersion()
const projectRoot = Path.join(__dirname, '..')
export function getDistRoot() {
return Path.join(projectRoot, 'dist')
}
export function getDistPath() {
return Path.join(
getDistRoot(),
`${getExecutableName()}-${process.platform}-x64`
)
}
export function getExecutableName() {
const suffix = process.env.NODE_ENV === 'development' ? '-dev' : ''
if (process.platform === 'win32') {
return `${getWindowsIdentifierName()}${suffix}`
} else if (process.platform === 'linux') {
return 'desktop'
} else {
return productName
}
}
export function getOSXZipName() {
return `${productName}.zip`
}
export function getOSXZipPath() {
return Path.join(getDistPath(), '..', getOSXZipName())
}
export function getWindowsInstallerName() {
const productName = getExecutableName()
return `${productName}Setup.msi`
}
export function getWindowsInstallerPath() {
return Path.join(getDistPath(), '..', 'installer', getWindowsInstallerName())
}
export function getWindowsStandaloneName() {
const productName = getExecutableName()
return `${productName}Setup.exe`
}
export function getWindowsStandalonePath() {
return Path.join(getDistPath(), '..', 'installer', getWindowsStandaloneName())
}
export function getWindowsFullNugetPackageName() {
return `${getWindowsIdentifierName()}-${version}-full.nupkg`
}
export function getWindowsFullNugetPackagePath() {
return Path.join(
getDistPath(),
'..',
'installer',
getWindowsFullNugetPackageName()
)
}
export function getWindowsDeltaNugetPackageName() {
return `${getWindowsIdentifierName()}-${version}-delta.nupkg`
}
export function getWindowsDeltaNugetPackagePath() {
return Path.join(
getDistPath(),
'..',
'installer',
getWindowsDeltaNugetPackageName()
)
}
export function getWindowsIdentifierName() {
return 'GitHubDesktop'
}
export function getBundleSizes() {
// eslint-disable-next-line no-sync
const rendererStats = Fs.statSync(
Path.join(projectRoot, 'out', 'renderer.js')
)
// eslint-disable-next-line no-sync
const mainStats = Fs.statSync(Path.join(projectRoot, 'out', 'main.js'))
return { rendererSize: rendererStats.size, mainSize: mainStats.size }
}
export function getReleaseChannel() {
// Branch name format: __release-CHANNEL-DEPLOY_ID
const pieces = getReleaseBranchName().split('-')
if (pieces.length < 3 || pieces[0] !== '__release') {
return process.env.NODE_ENV || 'development'
}
return pieces[1]
}
export function getReleaseSHA() {
// Branch name format: __release-CHANNEL-DEPLOY_ID
const pieces = getReleaseBranchName().split('-')
if (pieces.length < 3 || pieces[0] !== '__release') {
return null
}
return pieces[2]
}
export function getUpdatesURL() {
return `https://central.github.com/api/deployments/desktop/desktop/latest?version=${version}&env=${getReleaseChannel()}`
}
export function shouldMakeDelta() {
// Only production and beta channels include deltas. Test releases aren't
// necessarily sequential so deltas wouldn't make sense.
const channelsWithDeltas = ['production', 'beta']
return channelsWithDeltas.indexOf(getReleaseChannel()) > -1
}