-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·161 lines (147 loc) · 6.27 KB
/
build
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
#!/usr/bin/env node
'use strict'
if (process.argv.includes('--no-bootstrap')) {
console.log('Skipping bootstrap')
} else {
// Bootstrap first to ensure all the dependencies used later in this script
// are installed.
require('./bootstrap')
}
// Required to load CS files in this build script, such as those in `donna`
require('coffee-script/register')
require('colors')
const path = require('path')
const yargs = require('yargs')
const argv = yargs
.usage('Usage: $0 [options]')
.help('help')
.describe('existing-binaries', 'Use existing Atom binaries (skip clean/transpile/cache)')
.describe('code-sign', 'Code-sign executables (macOS and Windows only)')
.describe('test-sign', 'Test-sign executables (macOS only)')
.describe('create-windows-installer', 'Create installer (Windows only)')
.describe('create-debian-package', 'Create .deb package (Linux only)')
.describe('create-rpm-package', 'Create .rpm package (Linux only)')
.describe('compress-artifacts', 'Compress Atom binaries (and symbols on macOS)')
.describe('generate-api-docs', 'Only build the API documentation')
.describe('install', 'Install Atom')
.string('install')
.describe('ci', 'Install dependencies quickly (package-lock.json files must be up to date)')
.wrap(yargs.terminalWidth())
.argv
const checkChromedriverVersion = require('./lib/check-chromedriver-version')
const cleanOutputDirectory = require('./lib/clean-output-directory')
const codeSignOnMac = require('./lib/code-sign-on-mac')
const codeSignOnWindows = require('./lib/code-sign-on-windows')
const compressArtifacts = require('./lib/compress-artifacts')
const copyAssets = require('./lib/copy-assets')
const createDebianPackage = require('./lib/create-debian-package')
const createRpmPackage = require('./lib/create-rpm-package')
const createWindowsInstaller = require('./lib/create-windows-installer')
const dumpSymbols = require('./lib/dump-symbols')
const generateAPIDocs = require('./lib/generate-api-docs')
const generateMetadata = require('./lib/generate-metadata')
const generateModuleCache = require('./lib/generate-module-cache')
const generateStartupSnapshot = require('./lib/generate-startup-snapshot')
const installApplication = require('./lib/install-application')
const notarizeOnMac = require('./lib/notarize-on-mac')
const packageApplication = require('./lib/package-application')
const prebuildLessCache = require('./lib/prebuild-less-cache')
const testSignOnMac = require('./lib/test-sign-on-mac')
const transpileBabelPaths = require('./lib/transpile-babel-paths')
const transpileCoffeeScriptPaths = require('./lib/transpile-coffee-script-paths')
const transpileCsonPaths = require('./lib/transpile-cson-paths')
const transpilePegJsPaths = require('./lib/transpile-peg-js-paths')
const transpilePackagesWithCustomTranspilerPaths = require('./lib/transpile-packages-with-custom-transpiler-paths.js')
process.on('unhandledRejection', function (e) {
console.error(e.stack || e)
process.exit(1)
})
const CONFIG = require('./config')
process.env.ELECTRON_VERSION = CONFIG.appMetadata.electronVersion
let binariesPromise = Promise.resolve()
if (!argv.existingBinaries) {
checkChromedriverVersion()
cleanOutputDirectory()
copyAssets()
transpilePackagesWithCustomTranspilerPaths()
transpileBabelPaths()
transpileCoffeeScriptPaths()
transpileCsonPaths()
transpilePegJsPaths()
generateModuleCache()
prebuildLessCache()
generateMetadata()
generateAPIDocs()
if (!argv.generateApiDocs) {
binariesPromise = dumpSymbols()
}
}
if (!argv.generateApiDocs) {
binariesPromise
.then(packageApplication)
.then(packagedAppPath => generateStartupSnapshot(packagedAppPath).then(() => packagedAppPath))
.then(async packagedAppPath => {
switch (process.platform) {
case 'darwin': {
if (argv.codeSign) {
await codeSignOnMac(packagedAppPath)
await notarizeOnMac(packagedAppPath)
} else if (argv.testSign) {
testSignOnMac(packagedAppPath)
} else {
console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray)
}
break
}
case 'win32': {
if (argv.testSign) {
console.log('Test signing is not supported on Windows, skipping.'.gray)
}
if (argv.codeSign) {
const executablesToSign = [ path.join(packagedAppPath, CONFIG.executableName) ]
if (argv.createWindowsInstaller) {
executablesToSign.push(path.join(__dirname, 'node_modules', '@atom', 'electron-winstaller', 'vendor', 'Squirrel.exe'))
}
codeSignOnWindows(executablesToSign)
} else {
console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray)
}
if (argv.createWindowsInstaller) {
return createWindowsInstaller(packagedAppPath)
.then((installerPath) => {
argv.codeSign && codeSignOnWindows([installerPath])
return packagedAppPath
})
} else {
console.log('Skipping creating installer. Specify the --create-windows-installer option to create a Squirrel-based Windows installer.'.gray)
}
break
}
case 'linux': {
if (argv.createDebianPackage) {
createDebianPackage(packagedAppPath)
} else {
console.log('Skipping creating debian package. Specify the --create-debian-package option to create it.'.gray)
}
if (argv.createRpmPackage) {
createRpmPackage(packagedAppPath)
} else {
console.log('Skipping creating rpm package. Specify the --create-rpm-package option to create it.'.gray)
}
break
}
}
return Promise.resolve(packagedAppPath)
}).then(packagedAppPath => {
if (argv.compressArtifacts) {
compressArtifacts(packagedAppPath)
} else {
console.log('Skipping artifacts compression. Specify the --compress-artifacts option to compress Atom binaries (and symbols on macOS)'.gray)
}
if (argv.install != null) {
installApplication(packagedAppPath, argv.install)
} else {
console.log('Skipping installation. Specify the --install option to install Atom'.gray)
}
})
}