chore: update package.json scripts for gn build and automated releases (#14612)

* Removes un-used and non-functional code coverage helpers
* Removes un-used release script aliases
* Moves TLS to a lib folder for cleaner directory structure
* Implements start.py as start.js for the GN build
* Adds a re-usable getElectronExec helper for future scripts
* Refactors spec runner to use the helper
This commit is contained in:
Samuel Attard 2018-09-14 02:57:39 +10:00 committed by GitHub
parent 774395d910
commit 238ea29fa8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 26 deletions

View file

@ -51,8 +51,6 @@
"bump-version": "./script/bump-version.py",
"check-tls": "python ./script/tls.py",
"clang-format": "find atom/ brightray/ chromium_src/ -iname *.h -o -iname *.cc -o -iname *.mm | xargs clang-format -i",
"coverage": "npm run instrument-code-coverage && npm test -- --use_instrumented_asar",
"instrument-code-coverage": "electabul instrument --input-path ./lib --output-path ./out/coverage/electron.asar",
"lint": "npm run lint:js && npm run lint:cpp && npm run lint:clang-format && npm run lint:py && npm run lint:docs",
"lint:js": "standard && cd spec && standard",
"lint:clang-format": "python script/run-clang-format.py -r -c atom/ chromium_src/ brightray/ || (echo \"\\nCode not formatted correctly.\" && exit 1)",
@ -61,18 +59,14 @@
"lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links",
"lint:docs-relative-links": "python ./script/check-relative-doc-links.py",
"lint:js-in-markdown": "standard-markdown docs",
"create-api-json": "electron-docs-linter docs --outfile=electron-api.json --version=4.0.0-nightly.20180823",
"create-api-json": "electron-docs-linter docs --outfile=electron-api.json --version=$npm_package_version",
"create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --in=electron-api.json --out=electron.d.ts",
"mock-release": "node ./script/ci-release-build.js",
"preinstall": "node -e 'process.exit(0)'",
"publish-to-npm": "node ./script/publish-to-npm.js",
"precommit": "python script/run-clang-format.py -r -c atom/ chromium_src/ brightray/ && node ./script/cpplint.js -c && npm run lint:js && remark docs -qf || (echo \"Code not formatted correctly.\" && exit 1)",
"prepack": "check-for-leaks",
"prepush": "check-for-leaks",
"prepare-release": "node ./script/prepare-release.js",
"release": "node ./script/release.js",
"repl": "python ./script/start.py --interactive",
"start": "python ./script/start.py",
"repl": "node ./script/start.js --interactive",
"start": "node ./script/start.js",
"test": "node ./script/spec-runner.js electron/spec"
},
"license": "MIT",

26
script/lib/utils.js Normal file
View file

@ -0,0 +1,26 @@
const OUT_DIR = process.env.ELECTRON_OUT_DIR || 'Default'
const path = require('path')
function getElectronExec () {
switch (process.platform) {
case 'darwin':
return `out/${OUT_DIR}/Electron.app/Contents/MacOS/Electron`
case 'win32':
return `out/${OUT_DIR}/electron.exe`
case 'linux':
return `out/${OUT_DIR}/electron`
default:
throw new Error('Unknown platform')
}
}
function getAbsoluteElectronExec () {
return path.resolve(__dirname, '../../..', getElectronExec())
}
module.exports = {
getElectronExec,
getAbsoluteElectronExec,
OUT_DIR
}

View file

@ -4,9 +4,10 @@ const fs = require('fs')
const { hashElement } = require('folder-hash')
const path = require('path')
const utils = require('./lib/utils')
const BASE = path.resolve(__dirname, '../..')
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
const OUT_DIR = process.env.ELECTRON_SPEC_OUT_DIR || 'Default'
const specHashPath = path.resolve(__dirname, '../spec/.hash')
@ -20,7 +21,7 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
if (specChanged || installChanged) {
const out = cp.spawnSync(NPM_CMD, ['install'], {
env: Object.assign({}, process.env, {
npm_config_nodedir: path.resolve(BASE, `out/${OUT_DIR}/gen/node_headers`),
npm_config_nodedir: path.resolve(BASE, `out/${utils.OUT_DIR}/gen/node_headers`),
npm_config_msvs_version: '2017'
}),
cwd: path.resolve(__dirname, '../spec')
@ -35,7 +36,7 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
})
}
}).then(() => {
let exe = path.resolve(BASE, getElectronExec())
let exe = path.resolve(BASE, utils.getElectronExec())
const args = process.argv.slice(2)
if (process.platform === 'linux') {
args.unshift(path.resolve(__dirname, 'lib/dbus_mock.py'), exe)
@ -50,19 +51,6 @@ getSpecHash().then(([currentSpecHash, currentSpecInstallHash]) => {
})
})
function getElectronExec () {
switch (process.platform) {
case 'darwin':
return 'out/Default/Electron.app/Contents/MacOS/Electron'
case 'win32':
return 'out/Default/electron.exe'
case 'linux':
return 'out/Default/electron'
default:
throw new Error('Unknown path')
}
}
function getSpecHash () {
return Promise.all([
new Promise((resolve) => {

18
script/start.js Normal file
View file

@ -0,0 +1,18 @@
const cp = require('child_process')
const utils = require('./lib/utils')
const electronPath = utils.getAbsoluteElectronExec()
var child = cp.spawn(electronPath, process.argv.slice(2), { stdio: 'inherit' })
child.on('close', (code) => process.exit(code))
const handleTerminationSignal = (signal) =>
process.on(signal, () => {
if (!child.killed) {
child.kill(signal)
}
})
handleTerminationSignal('SIGINT')
handleTerminationSignal('SIGTERM')

View file

@ -13,7 +13,7 @@ ctx.verify_mode = ssl.CERT_NONE
def check_tls(verbose):
process = subprocess.Popen(
'node tls.js',
'node lib/tls',
cwd=os.path.dirname(os.path.realpath(__file__)),
shell=True,
stdout=subprocess.PIPE,