|
1 | 1 | #!/usr/bin/env node
|
2 | 2 |
|
3 |
| -'use strict' |
4 |
| - |
5 |
| -const CONFIG = require('./config') |
6 |
| - |
7 |
| -if (process.argv.includes('--no-bootstrap')) { |
8 |
| - console.log('Skipping bootstrap') |
9 |
| -} else { |
10 |
| - // Bootstrap first to ensure all the dependencies used later in this script |
11 |
| - // are installed. |
12 |
| - const path = require('path') |
13 |
| - const childProcess = require('child_process') |
14 |
| - childProcess.execFileSync(process.execPath, [path.join(CONFIG.scriptRootPath, 'bootstrap')], { env: process.env, cwd: CONFIG.repositoryRootPath, stdio: 'inherit' }); |
15 |
| -} |
16 |
| - |
17 |
| -// Required to load CS files in this build script, such as those in `donna` |
18 |
| -require('coffee-script/register') |
19 |
| -require('colors') |
20 |
| - |
21 |
| -const path = require('path') |
22 |
| -const yargs = require('yargs') |
23 |
| -const argv = yargs |
24 |
| - .usage('Usage: $0 [options]') |
25 |
| - .help('help') |
26 |
| - .describe('existing-binaries', 'Use existing Atom binaries (skip clean/transpile/cache)') |
27 |
| - .describe('code-sign', 'Code-sign executables (macOS and Windows only)') |
28 |
| - .describe('test-sign', 'Test-sign executables (macOS only)') |
29 |
| - .describe('create-windows-installer', 'Create installer (Windows only)') |
30 |
| - .describe('create-debian-package', 'Create .deb package (Linux only)') |
31 |
| - .describe('create-rpm-package', 'Create .rpm package (Linux only)') |
32 |
| - .describe('compress-artifacts', 'Compress Atom binaries (and symbols on macOS)') |
33 |
| - .describe('generate-api-docs', 'Only build the API documentation') |
34 |
| - .describe('install', 'Install Atom') |
35 |
| - .string('install') |
36 |
| - .describe('ci', 'Install dependencies quickly (package-lock.json files must be up to date)') |
37 |
| - .wrap(yargs.terminalWidth()) |
38 |
| - .argv |
39 |
| - |
40 |
| -const checkChromedriverVersion = require('./lib/check-chromedriver-version') |
41 |
| -const cleanOutputDirectory = require('./lib/clean-output-directory') |
42 |
| -const codeSignOnMac = require('./lib/code-sign-on-mac') |
43 |
| -const codeSignOnWindows = require('./lib/code-sign-on-windows') |
44 |
| -const compressArtifacts = require('./lib/compress-artifacts') |
45 |
| -const copyAssets = require('./lib/copy-assets') |
46 |
| -const createDebianPackage = require('./lib/create-debian-package') |
47 |
| -const createRpmPackage = require('./lib/create-rpm-package') |
48 |
| -const createWindowsInstaller = require('./lib/create-windows-installer') |
49 |
| -const dumpSymbols = require('./lib/dump-symbols') |
50 |
| -const generateAPIDocs = require('./lib/generate-api-docs') |
51 |
| -const generateMetadata = require('./lib/generate-metadata') |
52 |
| -const generateModuleCache = require('./lib/generate-module-cache') |
53 |
| -const generateStartupSnapshot = require('./lib/generate-startup-snapshot') |
54 |
| -const installApplication = require('./lib/install-application') |
55 |
| -const notarizeOnMac = require('./lib/notarize-on-mac') |
56 |
| -const packageApplication = require('./lib/package-application') |
57 |
| -const prebuildLessCache = require('./lib/prebuild-less-cache') |
58 |
| -const testSignOnMac = require('./lib/test-sign-on-mac') |
59 |
| - |
60 |
| -process.on('unhandledRejection', function (e) { |
61 |
| - console.error(e.stack || e) |
62 |
| - process.exit(1) |
63 |
| -}) |
64 |
| - |
65 |
| -process.env.ELECTRON_VERSION = CONFIG.appMetadata.electronVersion |
66 |
| - |
67 |
| -async function transpile() { |
68 |
| - const { spawn, Thread, Worker } = require(`${CONFIG.scriptRunnerModulesPath}/threads`) |
69 |
| - |
70 |
| - const transpilePackagesWithCustomTranspilerPaths = await spawn(new Worker('./lib/transpile-packages-with-custom-transpiler-paths')) |
71 |
| - const transpilePackagesWithCustomTranspilerPathsPromise = transpilePackagesWithCustomTranspilerPaths() |
72 |
| - |
73 |
| - const transpileBabelPaths = await spawn(new Worker('./lib/transpile-babel-paths')) |
74 |
| - const transpileBabelPathsPromise = transpileBabelPaths() |
75 |
| - |
76 |
| - const transpileCoffeeScriptPaths = await spawn(new Worker('./lib/transpile-coffee-script-paths')) |
77 |
| - const transpileCoffeeScriptPathsPromise = transpileCoffeeScriptPaths() |
78 |
| - |
79 |
| - const transpileCsonPaths = await spawn(new Worker('./lib/transpile-cson-paths')) |
80 |
| - const transpileCsonPathsPromise = transpileCsonPaths() |
81 |
| - |
82 |
| - const transpilePegJsPaths = await spawn(new Worker('./lib/transpile-peg-js-paths')) |
83 |
| - const transpilePegJsPathsPromise = transpilePegJsPaths() |
84 |
| - |
85 |
| - await transpilePackagesWithCustomTranspilerPathsPromise; |
86 |
| - await Thread.terminate(transpilePackagesWithCustomTranspilerPaths) |
87 |
| - |
88 |
| - await transpileBabelPathsPromise; |
89 |
| - await Thread.terminate(transpileBabelPaths) |
90 |
| - |
91 |
| - await transpileCoffeeScriptPathsPromise; |
92 |
| - await Thread.terminate(transpileCoffeeScriptPaths) |
93 |
| - |
94 |
| - await transpileCsonPathsPromise; |
95 |
| - await Thread.terminate(transpileCsonPaths) |
96 |
| - |
97 |
| - await transpilePegJsPathsPromise; |
98 |
| - await Thread.terminate(transpilePegJsPaths) |
99 |
| -} |
100 |
| - |
101 |
| -async function singAndCreateInstaller(packagedAppPath) { |
102 |
| - switch (process.platform) { |
103 |
| - case 'darwin': { |
104 |
| - if (argv.codeSign) { |
105 |
| - await codeSignOnMac(packagedAppPath) |
106 |
| - await notarizeOnMac(packagedAppPath) |
107 |
| - } else if (argv.testSign) { |
108 |
| - testSignOnMac(packagedAppPath) |
109 |
| - } else { |
110 |
| - console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray) |
111 |
| - } |
112 |
| - break |
113 |
| - } |
114 |
| - case 'win32': { |
115 |
| - if (argv.testSign) { |
116 |
| - console.log('Test signing is not supported on Windows, skipping.'.gray) |
117 |
| - } |
118 |
| - |
119 |
| - if (argv.codeSign) { |
120 |
| - const executablesToSign = [ path.join(packagedAppPath, CONFIG.executableName) ] |
121 |
| - if (argv.createWindowsInstaller) { |
122 |
| - executablesToSign.push(path.join(__dirname, 'node_modules', '@atom', 'electron-winstaller', 'vendor', 'Squirrel.exe')) |
123 |
| - } |
124 |
| - codeSignOnWindows(executablesToSign) |
125 |
| - } else { |
126 |
| - console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray) |
127 |
| - } |
128 |
| - if (argv.createWindowsInstaller) { |
129 |
| - return createWindowsInstaller(packagedAppPath) |
130 |
| - .then((installerPath) => { |
131 |
| - argv.codeSign && codeSignOnWindows([installerPath]) |
132 |
| - return packagedAppPath |
133 |
| - }) |
134 |
| - } else { |
135 |
| - console.log('Skipping creating installer. Specify the --create-windows-installer option to create a Squirrel-based Windows installer.'.gray) |
136 |
| - } |
137 |
| - break |
138 |
| - } |
139 |
| - case 'linux': { |
140 |
| - if (argv.createDebianPackage) { |
141 |
| - createDebianPackage(packagedAppPath) |
142 |
| - } else { |
143 |
| - console.log('Skipping creating debian package. Specify the --create-debian-package option to create it.'.gray) |
144 |
| - } |
145 |
| - |
146 |
| - if (argv.createRpmPackage) { |
147 |
| - createRpmPackage(packagedAppPath) |
148 |
| - } else { |
149 |
| - console.log('Skipping creating rpm package. Specify the --create-rpm-package option to create it.'.gray) |
150 |
| - } |
151 |
| - break |
152 |
| - } |
153 |
| - } |
154 |
| - |
155 |
| - return Promise.resolve(packagedAppPath) |
156 |
| -} |
157 |
| - |
158 |
| - |
159 |
| -async function build() { |
160 |
| - |
161 |
| - if (!argv.existingBinaries) { |
162 |
| - checkChromedriverVersion() |
163 |
| - await cleanOutputDirectory() |
164 |
| - await copyAssets() |
165 |
| - await transpile() |
166 |
| - generateModuleCache() |
167 |
| - prebuildLessCache() |
168 |
| - generateMetadata() |
169 |
| - generateAPIDocs() |
170 |
| - if (!argv.generateApiDocs) { |
171 |
| - await dumpSymbols() |
172 |
| - } |
173 |
| - } |
174 |
| - |
175 |
| - if (!argv.generateApiDocs) { |
176 |
| - const packagedAppPath = await packageApplication() |
177 |
| - await generateStartupSnapshot(packagedAppPath) |
178 |
| - await singAndCreateInstaller(packagedAppPath) |
179 |
| - if (argv.compressArtifacts) { |
180 |
| - compressArtifacts(packagedAppPath) |
181 |
| - } else { |
182 |
| - console.log('Skipping artifacts compression. Specify the --compress-artifacts option to compress Atom binaries (and symbols on macOS)'.gray) |
183 |
| - } |
184 |
| - |
185 |
| - if (argv.install != null) { |
186 |
| - installApplication(packagedAppPath, argv.install) |
187 |
| - } else { |
188 |
| - console.log('Skipping installation. Specify the --install option to install Atom'.gray) |
189 |
| - } |
190 |
| - } |
191 |
| - |
192 |
| -} |
193 |
| - |
194 |
| - |
195 |
| -build().then(() => {process.exit(0)}).catch((e) => {throw e;}) |
| 3 | +console.warn('`script/build` is deprecated. Use `node script/build.js` instead'); |
| 4 | +require('./build.js'); |
0 commit comments