Skip to content

Commit b2975cf

Browse files
authored
Merge pull request #445 from atom-community/file-extensions
build: add file extension for js files + deprecate shell and extension-less scripts
2 parents 727c15b + f8993f3 commit b2975cf

27 files changed

+1039
-922
lines changed

script/bootstrap

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,6 @@
11
#!/usr/bin/env node
22

3-
'use strict'
4-
5-
const CONFIG = require('./config')
6-
const childProcess = require('child_process')
7-
const cleanDependencies = require('./lib/clean-dependencies')
8-
const deleteMsbuildFromPath = require('./lib/delete-msbuild-from-path')
9-
const dependenciesFingerprint = require('./lib/dependencies-fingerprint')
10-
const installScriptRunnerDependencies = require('./lib/install-script-runner-dependencies')
11-
const verifyMachineRequirements = require('./lib/verify-machine-requirements')
12-
13-
process.on('unhandledRejection', function (e) {
14-
console.error(e.stack || e)
15-
process.exit(1)
16-
})
17-
18-
// We can't use yargs until installScriptDependencies() is executed, so...
19-
let ci = process.argv.indexOf('--ci') !== -1
20-
21-
if (!ci && process.env.CI === 'true' && process.argv.indexOf('--no-ci') === -1) {
22-
console.log('Automatically enabling --ci because CI is set in the environment')
23-
ci = true
24-
}
25-
26-
verifyMachineRequirements(ci)
27-
28-
async function bootstrap() {
29-
if (dependenciesFingerprint.isOutdated()) {
30-
await cleanDependencies()
31-
}
32-
33-
if (process.platform === 'win32') deleteMsbuildFromPath()
34-
35-
installScriptRunnerDependencies()
36-
37-
const { spawn, Thread, Worker } = require(`${CONFIG.scriptRunnerModulesPath}/threads`)
38-
39-
const installScriptDependencies = await spawn(new Worker('./lib/install-script-dependencies'))
40-
const installScriptDependenciesPromise = installScriptDependencies(ci)
41-
42-
const installApm = await spawn(new Worker('./lib/install-apm'))
43-
await installApm(ci);
44-
await Thread.terminate(installApm)
45-
46-
const runApmInstall = require('./lib/run-apm-install')
47-
runApmInstall(CONFIG.repositoryRootPath, ci)
48-
49-
await installScriptDependenciesPromise;
50-
await Thread.terminate(installScriptDependencies)
51-
52-
dependenciesFingerprint.write()
53-
}
54-
55-
bootstrap().then(() => {process.exit(0)}).catch((e) => {throw e;})
3+
console.warn(
4+
'`script/bootstrap` is deprecated. Use `node script/bootstrap.js` instead'
5+
);
6+
require('./bootstrap.js');

script/bootstrap.cmd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
@IF EXIST "%~dp0\node.exe" (
2-
"%~dp0\node.exe" "%~dp0\bootstrap" %*
3-
) ELSE (
4-
node "%~dp0\bootstrap" %*
5-
)
1+
@ECHO off
62

3+
echo `script\bootstrap.cmd` is deprecated. Use `node script/bootstrap.js` instead
4+
node "%~dp0\bootstrap.js" %*

script/bootstrap.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
const CONFIG = require('./config');
6+
const cleanDependencies = require('./lib/clean-dependencies');
7+
const deleteMsbuildFromPath = require('./lib/delete-msbuild-from-path');
8+
const dependenciesFingerprint = require('./lib/dependencies-fingerprint');
9+
const installScriptRunnerDependencies = require('./lib/install-script-runner-dependencies');
10+
const verifyMachineRequirements = require('./lib/verify-machine-requirements');
11+
12+
process.on('unhandledRejection', function(e) {
13+
console.error(e.stack || e);
14+
process.exit(1);
15+
});
16+
17+
// We can't use yargs until installScriptDependencies() is executed, so...
18+
let ci = process.argv.indexOf('--ci') !== -1;
19+
20+
if (
21+
!ci &&
22+
process.env.CI === 'true' &&
23+
process.argv.indexOf('--no-ci') === -1
24+
) {
25+
console.log(
26+
'Automatically enabling --ci because CI is set in the environment'
27+
);
28+
ci = true;
29+
}
30+
31+
verifyMachineRequirements(ci);
32+
33+
async function bootstrap() {
34+
if (dependenciesFingerprint.isOutdated()) {
35+
await cleanDependencies();
36+
}
37+
38+
if (process.platform === 'win32') deleteMsbuildFromPath();
39+
40+
installScriptRunnerDependencies();
41+
42+
const { spawn, Thread, Worker } = require(`${
43+
CONFIG.scriptRunnerModulesPath
44+
}/threads`);
45+
46+
const installScriptDependencies = await spawn(
47+
new Worker('./lib/install-script-dependencies')
48+
);
49+
const installScriptDependenciesPromise = installScriptDependencies(ci);
50+
51+
const installApm = await spawn(new Worker('./lib/install-apm'));
52+
await installApm(ci);
53+
await Thread.terminate(installApm);
54+
55+
const runApmInstall = require('./lib/run-apm-install');
56+
runApmInstall(CONFIG.repositoryRootPath, ci);
57+
58+
await installScriptDependenciesPromise;
59+
await Thread.terminate(installScriptDependencies);
60+
61+
dependenciesFingerprint.write();
62+
}
63+
64+
bootstrap()
65+
.then(() => {
66+
process.exit(0);
67+
})
68+
.catch(e => {
69+
throw e;
70+
});

script/build

Lines changed: 2 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -1,195 +1,4 @@
11
#!/usr/bin/env node
22

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');

script/build.cmd

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
@IF EXIST "%~dp0\node.exe" (
2-
"%~dp0\node.exe" "%~dp0\build" %*
3-
) ELSE (
4-
node "%~dp0\build" %*
5-
)
1+
@ECHO off
2+
3+
echo `script\build.cmd` is deprecated. Use `node script/build.js` instead
4+
node "%~dp0\build.js" %*

0 commit comments

Comments
 (0)