forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdist-info.js
163 lines (135 loc) · 3.87 KB
/
dist-info.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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
'use strict'
const path = require('path')
const fs = require('fs')
const os = require('os')
const packageInfo = require('../app/package-info')
const productName = packageInfo.getProductName()
const version = packageInfo.getVersion()
const projectRoot = path.join(__dirname, '..')
function getDistRoot() {
return path.join(projectRoot, 'dist')
}
function getDistPath() {
return path.join(
getDistRoot(),
`${getExecutableName()}-${process.platform}-${os.arch()}`
)
}
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
}
}
function getOSXZipName() {
return `${productName}.zip`
}
function getOSXZipPath() {
return path.join(getDistPath(), '..', getOSXZipName())
}
function getWindowsInstallerName() {
const productName = getExecutableName()
return `${productName}Setup.msi`
}
function getWindowsInstallerPath() {
return path.join(getDistPath(), '..', 'installer', getWindowsInstallerName())
}
function getWindowsStandaloneName() {
const productName = getExecutableName()
return `${productName}Setup.exe`
}
function getWindowsStandalonePath() {
return path.join(getDistPath(), '..', 'installer', getWindowsStandaloneName())
}
function getWindowsFullNugetPackageName() {
return `${getWindowsIdentifierName()}-${version}-full.nupkg`
}
function getWindowsFullNugetPackagePath() {
return path.join(
getDistPath(),
'..',
'installer',
getWindowsFullNugetPackageName()
)
}
function getWindowsDeltaNugetPackageName() {
return `${getWindowsIdentifierName()}-${version}-delta.nupkg`
}
function getWindowsDeltaNugetPackagePath() {
return path.join(
getDistPath(),
'..',
'installer',
getWindowsDeltaNugetPackageName()
)
}
function getWindowsIdentifierName() {
return 'GitHubDesktop'
}
function getBundleSizes() {
const rendererStats = fs.statSync(
path.join(projectRoot, 'out', 'renderer.js')
)
const mainStats = fs.statSync(path.join(projectRoot, 'out', 'main.js'))
return { rendererSize: rendererStats.size, mainSize: mainStats.size }
}
function getReleaseBranchName() {
let branchName
if (process.platform === 'darwin') {
branchName = process.env.CIRCLE_BRANCH
} else if (process.platform === 'win32') {
branchName = process.env.APPVEYOR_REPO_BRANCH
}
return branchName || ''
}
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]
}
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]
}
function getUpdatesURL() {
return `https://central.github.com/api/deployments/desktop/desktop/latest?version=${version}&env=${getReleaseChannel()}`
}
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
}
module.exports = {
getDistRoot,
getDistPath,
getOSXZipName,
getOSXZipPath,
getWindowsInstallerName,
getWindowsInstallerPath,
getWindowsStandaloneName,
getWindowsStandalonePath,
getWindowsFullNugetPackageName,
getWindowsFullNugetPackagePath,
getWindowsIdentifierName,
getBundleSizes,
getReleaseChannel,
getReleaseSHA,
getUpdatesURL,
getWindowsDeltaNugetPackageName,
getWindowsDeltaNugetPackagePath,
shouldMakeDelta,
getReleaseBranchName,
getExecutableName,
}