Merge branch 'master' into bring-back-asar

This commit is contained in:
Antonio Scandurra
2017-08-15 10:03:27 +02:00
committed by GitHub
82 changed files with 3372 additions and 717 deletions

View File

@@ -2,6 +2,7 @@
'use strict'
const childProcess = require('child_process')
const CONFIG = require('./config')
const cleanDependencies = require('./lib/clean-dependencies')
const deleteMsbuildFromPath = require('./lib/delete-msbuild-from-path')
@@ -26,6 +27,11 @@ if (process.platform === 'win32') deleteMsbuildFromPath()
installScriptDependencies()
installApm()
childProcess.execFileSync(
CONFIG.getApmBinPath(),
['--version'],
{stdio: 'inherit'}
)
runApmInstall(CONFIG.repositoryRootPath)
dependenciesFingerprint.write()

View File

@@ -10,10 +10,12 @@ require('./bootstrap')
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('create-windows-installer', 'Create installer (Windows only)')
.describe('create-debian-package', 'Create .deb package (Linux only)')
@@ -52,50 +54,67 @@ process.on('unhandledRejection', function (e) {
process.exit(1)
})
checkChromedriverVersion()
cleanOutputDirectory()
copyAssets()
transpilePackagesWithCustomTranspilerPaths()
transpileBabelPaths()
transpileCoffeeScriptPaths()
transpileCsonPaths()
transpilePegJsPaths()
generateModuleCache()
prebuildLessCache()
generateMetadata()
generateAPIDocs()
dumpSymbols()
const CONFIG = require('./config')
let binariesPromise = Promise.resolve()
if (!argv.existingBinaries) {
checkChromedriverVersion()
cleanOutputDirectory()
copyAssets()
transpilePackagesWithCustomTranspilerPaths()
transpileBabelPaths()
transpileCoffeeScriptPaths()
transpileCsonPaths()
transpilePegJsPaths()
generateModuleCache()
prebuildLessCache()
generateMetadata()
generateAPIDocs()
binariesPromise = dumpSymbols()
}
binariesPromise
.then(packageApplication)
.then(packagedAppPath => generateStartupSnapshot(packagedAppPath).then(() => packagedAppPath))
.then(packagedAppPath => {
if (process.platform === 'darwin') {
if (argv.codeSign) {
codeSignOnMac(packagedAppPath)
} else {
console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray)
}
} else if (process.platform === 'win32') {
if (argv.createWindowsInstaller) {
return createWindowsInstaller(packagedAppPath, argv.codeSign).then(() => packagedAppPath)
} else {
console.log('Skipping creating installer. Specify the --create-windows-installer option to create a Squirrel-based Windows installer.'.gray)
switch (process.platform) {
case 'darwin': {
if (argv.codeSign) {
codeSignOnWindows(packagedAppPath)
codeSignOnMac(packagedAppPath)
} else {
console.log('Skipping code-signing. Specify the --code-sign option to perform code-signing'.gray)
}
}
} else if (process.platform === 'linux') {
if (argv.createDebianPackage) {
createDebianPackage(packagedAppPath)
} else {
console.log('Skipping creating debian package. Specify the --create-debian-package option to create it.'.gray)
case 'win32': {
if (argv.codeSign) {
const executablesToSign = [ path.join(packagedAppPath, 'Atom.exe') ]
if (argv.createWindowsInstaller) {
executablesToSign.push(path.join(__dirname, 'node_modules', 'electron-winstaller', 'vendor', 'Update.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(() => argv.codeSign && codeSignOnWindows([ path.join(CONFIG.buildOutputPath, 'AtomSetup.exe') ]))
.then(() => packagedAppPath)
} else {
console.log('Skipping creating installer. Specify the --create-windows-installer option to create a Squirrel-based Windows installer.'.gray)
}
}
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)
if (argv.createRpmPackage) {
createRpmPackage(packagedAppPath)
} else {
console.log('Skipping creating rpm package. Specify the --create-rpm-package option to create it.'.gray)
}
}
}

View File

@@ -0,0 +1,6 @@
@ECHO OFF
IF NOT EXIST C:\sqtemp MKDIR C:\sqtemp
SET SQUIRREL_TEMP=C:\sqtemp
del script\package-lock.json /q
del apm\package-lock.json /q
script\build.cmd --existing-binaries --code-sign --create-windows-installer

View File

@@ -875,10 +875,6 @@
"hasDeprecations": true,
"latestHasDeprecations": false
},
"language-typescript": {
"hasAlternative": true,
"alternative": "atom-typescript"
},
"laravel-facades": {
"version": "<=1.0.0",
"hasDeprecations": true,

View File

@@ -4,10 +4,7 @@ const os = require('os')
const path = require('path')
const {spawnSync} = require('child_process')
// This is only used when specifying --code-sign WITHOUT --create-windows-installer
// as Squirrel has to take care of code-signing in order to correctly wrap during the building of setup
module.exports = function (packagedAppPath) {
module.exports = function (filesToSign) {
if (!process.env.ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL && !process.env.ATOM_WIN_CODE_SIGNING_CERT_PATH) {
console.log('Skipping code signing because the ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL environment variable is not defined'.gray)
return
@@ -19,25 +16,26 @@ module.exports = function (packagedAppPath) {
downloadFileFromGithub(process.env.ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL, certPath)
}
try {
console.log(`Code-signing application at ${packagedAppPath}`)
signFile(path.join(packagedAppPath, 'atom.exe'))
for (const fileToSign of filesToSign) {
console.log(`Code-signing executable at ${fileToSign}`)
signFile(fileToSign)
}
} finally {
if (!process.env.ATOM_WIN_CODE_SIGNING_CERT_PATH) {
console.log(`Deleting certificate at ${certPath}`)
fs.removeSync(certPath)
}
}
function signFile (filePath) {
function signFile (fileToSign) {
const signCommand = path.resolve(__dirname, '..', 'node_modules', 'electron-winstaller', 'vendor', 'signtool.exe')
const args = [ // Changing any of these should also be done in create-windows-installer.js
const args = [
'sign',
`/f ${certPath}`, // Signing cert file
`/p ${process.env.ATOM_WIN_CODE_SIGNING_CERT_PASSWORD}`, // Signing cert password
'/fd sha256', // File digest algorithm
'/tr http://timestamp.digicert.com', // Time stamp server
'/td sha256', // Times stamp algorithm
`"${filePath}"`
`"${fileToSign}"`
]
const result = spawnSync(signCommand, args, {stdio: 'inherit', shell: true})
if (result.status !== 0) {

View File

@@ -1,16 +1,13 @@
'use strict'
const downloadFileFromGithub = require('./download-file-from-github')
const electronInstaller = require('electron-winstaller')
const fs = require('fs-extra')
const glob = require('glob')
const os = require('os')
const path = require('path')
const spawnSync = require('./spawn-sync')
const CONFIG = require('../config')
module.exports = (packagedAppPath, codeSign) => {
module.exports = (packagedAppPath) => {
const archSuffix = process.arch === 'ia32' ? '' : '-' + process.arch
const options = {
appDirectory: packagedAppPath,
@@ -23,32 +20,7 @@ module.exports = (packagedAppPath, codeSign) => {
setupIcon: path.join(CONFIG.repositoryRootPath, 'resources', 'app-icons', CONFIG.channel, 'atom.ico')
}
const signing = codeSign && (process.env.ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL || process.env.ATOM_WIN_CODE_SIGNING_CERT_PATH)
let certPath = process.env.ATOM_WIN_CODE_SIGNING_CERT_PATH
if (signing) {
if (!certPath) {
certPath = path.join(os.tmpdir(), 'win.p12')
downloadFileFromGithub(process.env.ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL, certPath)
}
var signParams = [] // Changing any of these should also be done in code-sign-on-windows.js
signParams.push(`/f ${certPath}`) // Signing cert file
signParams.push(`/p ${process.env.ATOM_WIN_CODE_SIGNING_CERT_PASSWORD}`) // Signing cert password
signParams.push('/fd sha256') // File digest algorithm
signParams.push('/tr http://timestamp.digicert.com') // Time stamp server
signParams.push('/td sha256') // Times stamp algorithm
options.signWithParams = signParams.join(' ')
} else {
console.log('Skipping code-signing. Specify the --code-sign option and provide a ATOM_WIN_CODE_SIGNING_CERT_DOWNLOAD_URL environment variable to perform code-signing'.gray)
}
const cleanUp = () => {
if (fs.existsSync(certPath) && !process.env.ATOM_WIN_CODE_SIGNING_CERT_PATH) {
console.log(`Deleting certificate at ${certPath}`)
fs.removeSync(certPath)
}
for (let nupkgPath of glob.sync(`${CONFIG.buildOutputPath}/*.nupkg`)) {
if (!nupkgPath.includes(CONFIG.appMetadata.version)) {
console.log(`Deleting downloaded nupkg for previous version at ${nupkgPath} to prevent it from being stored as an artifact`)
@@ -57,24 +29,8 @@ module.exports = (packagedAppPath, codeSign) => {
}
}
// Squirrel signs its own copy of the executables but we need them for the portable ZIP
const extractSignedExes = () => {
if (signing) {
for (let nupkgPath of glob.sync(`${CONFIG.buildOutputPath}/*-full.nupkg`)) {
if (nupkgPath.includes(CONFIG.appMetadata.version)) {
nupkgPath = path.resolve(nupkgPath) // Switch from forward-slash notation
console.log(`Extracting signed executables from ${nupkgPath} for use in portable zip`)
spawnSync('7z.exe', ['e', nupkgPath, 'lib\\net45\\*.exe', '-aoa', `-o${packagedAppPath}`])
spawnSync(process.env.COMSPEC, ['/c', 'move', '/y', path.join(packagedAppPath, 'squirrel.exe'), path.join(packagedAppPath, 'update.exe')])
return
}
}
}
}
console.log(`Creating Windows Installer for ${packagedAppPath}`)
return electronInstaller.createWindowsInstaller(options)
.then(extractSignedExes)
.then(cleanUp, error => {
cleanUp()
return Promise.reject(error)

View File

@@ -39,6 +39,7 @@ module.exports = function (packagedAppPath) {
relativePath === path.join('..', 'node_modules', 'decompress-zip', 'lib', 'decompress-zip.js') ||
relativePath === path.join('..', 'node_modules', 'debug', 'node.js') ||
relativePath === path.join('..', 'node_modules', 'fs-extra', 'lib', 'index.js') ||
relativePath === path.join('..', 'node_modules', 'github', 'node_modules', 'fs-extra', 'lib', 'index.js') ||
relativePath === path.join('..', 'node_modules', 'git-utils', 'lib', 'git.js') ||
relativePath === path.join('..', 'node_modules', 'glob', 'glob.js') ||
relativePath === path.join('..', 'node_modules', 'graceful-fs', 'graceful-fs.js') ||

View File

@@ -9,20 +9,20 @@
"csslint": "1.0.2",
"donna": "1.0.16",
"electron-chromedriver": "~1.6",
"electron-link": "0.1.0",
"electron-link": "0.1.1",
"electron-mksnapshot": "~1.6",
"electron-packager": "7.3.0",
"electron-winstaller": "2.6.2",
"fs-extra": "0.30.0",
"glob": "7.0.3",
"joanna": "0.0.8",
"joanna": "0.0.9",
"klaw-sync": "^1.1.2",
"legal-eagle": "0.14.0",
"lodash.template": "4.4.0",
"minidump": "0.9.0",
"mkdirp": "0.5.1",
"normalize-package-data": "2.3.5",
"npm": "3.10.5",
"npm": "5.3.0",
"passwd-user": "2.1.0",
"pegjs": "0.9.0",
"runas": "3.1.1",

View File

@@ -32,18 +32,29 @@ if (process.platform === 'darwin') {
throw new Error('Running tests on this platform is not supported.')
}
function prepareEnv (suiteName) {
const env = Object.assign({}, process.env)
if (process.env.TEST_JUNIT_XML_ROOT) {
// Tell Jasmine to output this suite's results as a JUnit XML file to a subdirectory of the root, so that a
// CI system can interpret it.
const outputPath = path.join(process.env.TEST_JUNIT_XML_ROOT, suiteName, 'test-results.xml')
env.TEST_JUNIT_XML_PATH = outputPath
}
return env
}
function runCoreMainProcessTests (callback) {
const testPath = path.join(CONFIG.repositoryRootPath, 'spec', 'main-process')
const testArguments = [
'--resource-path', resourcePath,
'--test', '--main-process', testPath
]
const testEnv = Object.assign({}, prepareEnv('core-main-process'), {ATOM_GITHUB_INLINE_GIT_EXEC: 'true'})
console.log('Executing core main process tests'.bold.green)
const cp = childProcess.spawn(executablePath, testArguments, {
stdio: 'inherit',
env: Object.assign({}, process.env, {ATOM_GITHUB_INLINE_GIT_EXEC: 'true'})
})
const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv})
cp.on('error', error => { callback(error) })
cp.on('close', exitCode => { callback(null, exitCode) })
}
@@ -54,9 +65,10 @@ function runCoreRenderProcessTests (callback) {
'--resource-path', resourcePath,
'--test', testPath
]
const testEnv = prepareEnv('core-render-process')
console.log('Executing core render process tests'.bold.green)
const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit'})
const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv})
cp.on('error', error => { callback(error) })
cp.on('close', exitCode => { callback(null, exitCode) })
}
@@ -87,10 +99,10 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) {
'--resource-path', resourcePath,
'--test', testFolder
]
const testEnv = prepareEnv(`bundled-package-${packageName}`)
const pkgJsonPath = path.join(repositoryPackagePath, 'package.json')
const nodeModulesPath = path.join(repositoryPackagePath, 'node_modules')
const nodeModulesBackupPath = path.join(repositoryPackagePath, 'node_modules.bak')
let finalize = () => null
if (require(pkgJsonPath).atomTestRunner) {
console.log(`Installing test runner dependencies for ${packageName}`.bold.green)
@@ -105,7 +117,7 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) {
} else {
console.log(`Executing ${packageName} tests`.bold.green)
}
const cp = childProcess.spawn(executablePath, testArguments)
const cp = childProcess.spawn(executablePath, testArguments, {env: testEnv})
let stderrOutput = ''
cp.stderr.on('data', data => { stderrOutput += data })
cp.stdout.on('data', data => { stderrOutput += data })
@@ -127,21 +139,27 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) {
function runBenchmarkTests (callback) {
const benchmarksPath = path.join(CONFIG.repositoryRootPath, 'benchmarks')
const testArguments = ['--benchmark-test', benchmarksPath]
const testEnv = prepareEnv('benchmark')
console.log('Executing benchmark tests'.bold.green)
const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit'})
const cp = childProcess.spawn(executablePath, testArguments, {stdio: 'inherit', env: testEnv})
cp.on('error', error => { callback(error) })
cp.on('close', exitCode => { callback(null, exitCode) })
}
let testSuitesToRun = testSuitesForPlatform(process.platform)
function testSuitesForPlatform(platform) {
switch(platform) {
case 'darwin': return [runCoreMainProcessTests, runCoreRenderProcessTests, runBenchmarkTests].concat(packageTestSuites)
case 'win32': return (process.arch === 'x64') ? [runCoreMainProcessTests, runCoreRenderProcessTests] : [runCoreMainProcessTests]
case 'linux': return [runCoreMainProcessTests]
default: return []
function testSuitesForPlatform (platform) {
switch (platform) {
case 'darwin':
return [runCoreMainProcessTests, runCoreRenderProcessTests, runBenchmarkTests].concat(packageTestSuites)
case 'win32':
return (process.arch === 'x64') ? [runCoreMainProcessTests, runCoreRenderProcessTests] : [runCoreMainProcessTests]
case 'linux':
return [runCoreMainProcessTests]
default:
console.log(`Unrecognized platform: ${platform}`)
return []
}
}