build: ensure consistent lock files across multiple machines (#17955)
* build: ensure consistent package-lock across multiple machines * build: fix linting errors and use npm ci instead of npm install * build: use a yarn.lock and yarn instead of package-lock and npm * chore: replace package-lock.json files with yarn.lock * chore: replace last instance of `npm install`
This commit is contained in:
parent
8d83518f9a
commit
98c51dd660
18 changed files with 9970 additions and 15506 deletions
|
@ -111,7 +111,7 @@ async function updateVersion (version) {
|
|||
|
||||
// update package metadata files with new version
|
||||
async function updatePackageJSON (version) {
|
||||
['package.json', 'package-lock.json'].forEach(async fileName => {
|
||||
['package.json'].forEach(async fileName => {
|
||||
const filePath = path.resolve(__dirname, '..', fileName)
|
||||
const file = require(filePath)
|
||||
file.version = version
|
||||
|
|
|
@ -8,7 +8,7 @@ const HASH_VERSION = 1
|
|||
// Base files to hash
|
||||
const filesToHash = [
|
||||
path.resolve(__dirname, '../DEPS'),
|
||||
path.resolve(__dirname, '../package-lock.json')
|
||||
path.resolve(__dirname, '../yarn.lock')
|
||||
]
|
||||
|
||||
const addAllFiles = (dir) => {
|
||||
|
|
18
script/lib/npx.py
Normal file
18
script/lib/npx.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def npx(*npx_args):
|
||||
call_args = [__get_executable_name()] + list(npx_args)
|
||||
subprocess.check_call(call_args)
|
||||
|
||||
|
||||
def __get_executable_name():
|
||||
executable = 'npx'
|
||||
if sys.platform == 'win32':
|
||||
executable += '.cmd'
|
||||
return executable
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
npx(*sys.argv[1:])
|
|
@ -144,7 +144,9 @@ async function findChangedFiles (top) {
|
|||
async function findMatchingFiles (top, test) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const matches = []
|
||||
klaw(top)
|
||||
klaw(top, {
|
||||
filter: f => path.basename(f) !== '.bin'
|
||||
})
|
||||
.on('end', () => resolve(matches))
|
||||
.on('data', item => {
|
||||
if (test(item.path)) {
|
||||
|
|
|
@ -25,6 +25,9 @@ const utils = require('./lib/utils')
|
|||
|
||||
const BASE = path.resolve(__dirname, '../..')
|
||||
const NPM_CMD = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
||||
const NPX_CMD = process.platform === 'win32' ? 'npx.cmd' : 'npx'
|
||||
// KEEP IN SYNC WITH DEPS FILE
|
||||
const YARN_VERSION = '1.15.2'
|
||||
|
||||
const specHashPath = path.resolve(__dirname, '../spec/.hash')
|
||||
|
||||
|
@ -143,7 +146,7 @@ async function installSpecModules () {
|
|||
npm_config_nodedir: nodeDir,
|
||||
npm_config_msvs_version: '2017'
|
||||
})
|
||||
const { status } = childProcess.spawnSync(NPM_CMD, ['install'], {
|
||||
const { status } = childProcess.spawnSync(NPX_CMD, [`yarn@${YARN_VERSION}`, 'install', '--frozen-lockfile'], {
|
||||
env,
|
||||
cwd: path.resolve(__dirname, '../spec'),
|
||||
stdio: 'inherit'
|
||||
|
@ -158,7 +161,7 @@ function getSpecHash () {
|
|||
(async () => {
|
||||
const hasher = crypto.createHash('SHA256')
|
||||
hasher.update(fs.readFileSync(path.resolve(__dirname, '../spec/package.json')))
|
||||
hasher.update(fs.readFileSync(path.resolve(__dirname, '../spec/package-lock.json')))
|
||||
hasher.update(fs.readFileSync(path.resolve(__dirname, '../spec/yarn.lock')))
|
||||
return hasher.digest('hex')
|
||||
})(),
|
||||
(async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue