[misc] bump the dev-env to 3.3.2

This commit is contained in:
Jakob Ackermann
2020-08-10 17:01:11 +01:00
parent 1ee48d0274
commit f4561c2fe2
66 changed files with 1371 additions and 1458 deletions

View File

@@ -47,9 +47,9 @@ module.exports = OutputCacheManager = {
generateBuildId(callback) {
// generate a secure build id from Date.now() and 8 random bytes in hex
if (callback == null) {
callback = function(error, buildId) {}
callback = function (error, buildId) {}
}
return crypto.randomBytes(8, function(err, buf) {
return crypto.randomBytes(8, function (err, buf) {
if (err != null) {
return callback(err)
}
@@ -61,9 +61,9 @@ module.exports = OutputCacheManager = {
saveOutputFiles(outputFiles, compileDir, callback) {
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
return OutputCacheManager.generateBuildId(function(err, buildId) {
return OutputCacheManager.generateBuildId(function (err, buildId) {
if (err != null) {
return callback(err)
}
@@ -80,7 +80,7 @@ module.exports = OutputCacheManager = {
// make a compileDir/CACHE_SUBDIR/build_id directory and
// copy all the output files into it
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
const cacheRoot = Path.join(compileDir, OutputCacheManager.CACHE_SUBDIR)
// Put the files into a new cache subdirectory
@@ -99,17 +99,20 @@ module.exports = OutputCacheManager = {
(Settings.clsi != null ? Settings.clsi.archive_logs : undefined) ||
(Settings.clsi != null ? Settings.clsi.strace : undefined)
) {
OutputCacheManager.archiveLogs(outputFiles, compileDir, buildId, function(
err
) {
if (err != null) {
return logger.warn({ err }, 'erroring archiving log files')
OutputCacheManager.archiveLogs(
outputFiles,
compileDir,
buildId,
function (err) {
if (err != null) {
return logger.warn({ err }, 'erroring archiving log files')
}
}
})
)
}
// make the new cache directory
return fse.ensureDir(cacheDir, function(err) {
return fse.ensureDir(cacheDir, function (err) {
if (err != null) {
logger.error(
{ err, directory: cacheDir },
@@ -121,7 +124,7 @@ module.exports = OutputCacheManager = {
const results = []
return async.mapSeries(
outputFiles,
function(file, cb) {
function (file, cb) {
// don't send dot files as output, express doesn't serve them
if (OutputCacheManager._fileIsHidden(file.path)) {
logger.debug(
@@ -136,7 +139,7 @@ module.exports = OutputCacheManager = {
Path.join(compileDir, file.path),
Path.join(cacheDir, file.path)
])
return OutputCacheManager._checkFileIsSafe(src, function(
return OutputCacheManager._checkFileIsSafe(src, function (
err,
isSafe
) {
@@ -146,7 +149,7 @@ module.exports = OutputCacheManager = {
if (!isSafe) {
return cb()
}
return OutputCacheManager._checkIfShouldCopy(src, function(
return OutputCacheManager._checkIfShouldCopy(src, function (
err,
shouldCopy
) {
@@ -156,7 +159,7 @@ module.exports = OutputCacheManager = {
if (!shouldCopy) {
return cb()
}
return OutputCacheManager._copyFile(src, dst, function(err) {
return OutputCacheManager._copyFile(src, dst, function (err) {
if (err != null) {
return cb(err)
}
@@ -167,12 +170,12 @@ module.exports = OutputCacheManager = {
})
})
},
function(err) {
function (err) {
if (err != null) {
// pass back the original files if we encountered *any* error
callback(err, outputFiles)
// clean up the directory we just created
return fse.remove(cacheDir, function(err) {
return fse.remove(cacheDir, function (err) {
if (err != null) {
return logger.error(
{ err, dir: cacheDir },
@@ -197,7 +200,7 @@ module.exports = OutputCacheManager = {
archiveLogs(outputFiles, compileDir, buildId, callback) {
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
const archiveDir = Path.join(
compileDir,
@@ -205,18 +208,18 @@ module.exports = OutputCacheManager = {
buildId
)
logger.log({ dir: archiveDir }, 'archiving log files for project')
return fse.ensureDir(archiveDir, function(err) {
return fse.ensureDir(archiveDir, function (err) {
if (err != null) {
return callback(err)
}
return async.mapSeries(
outputFiles,
function(file, cb) {
function (file, cb) {
const [src, dst] = Array.from([
Path.join(compileDir, file.path),
Path.join(archiveDir, file.path)
])
return OutputCacheManager._checkFileIsSafe(src, function(
return OutputCacheManager._checkFileIsSafe(src, function (
err,
isSafe
) {
@@ -226,7 +229,7 @@ module.exports = OutputCacheManager = {
if (!isSafe) {
return cb()
}
return OutputCacheManager._checkIfShouldArchive(src, function(
return OutputCacheManager._checkIfShouldArchive(src, function (
err,
shouldArchive
) {
@@ -248,9 +251,9 @@ module.exports = OutputCacheManager = {
expireOutputFiles(cacheRoot, options, callback) {
// look in compileDir for build dirs and delete if > N or age of mod time > T
if (callback == null) {
callback = function(error) {}
callback = function (error) {}
}
return fs.readdir(cacheRoot, function(err, results) {
return fs.readdir(cacheRoot, function (err, results) {
if (err != null) {
if (err.code === 'ENOENT') {
return callback(null)
@@ -262,7 +265,7 @@ module.exports = OutputCacheManager = {
const dirs = results.sort().reverse()
const currentTime = Date.now()
const isExpired = function(dir, index) {
const isExpired = function (dir, index) {
if ((options != null ? options.keep : undefined) === dir) {
return false
}
@@ -280,7 +283,7 @@ module.exports = OutputCacheManager = {
// we can get the build time from the first part of the directory name DDDD-RRRR
// DDDD is date and RRRR is random bytes
const dirTime = parseInt(
__guard__(dir.split('-'), x => x[0]),
__guard__(dir.split('-'), (x) => x[0]),
16
)
const age = currentTime - dirTime
@@ -290,7 +293,7 @@ module.exports = OutputCacheManager = {
const toRemove = _.filter(dirs, isExpired)
const removeDir = (dir, cb) =>
fse.remove(Path.join(cacheRoot, dir), function(err, result) {
fse.remove(Path.join(cacheRoot, dir), function (err, result) {
logger.log({ cache: cacheRoot, dir }, 'removed expired cache dir')
if (err != null) {
logger.error({ err, dir }, 'cache remove error')
@@ -312,9 +315,9 @@ module.exports = OutputCacheManager = {
_checkFileIsSafe(src, callback) {
// check if we have a valid file to copy into the cache
if (callback == null) {
callback = function(error, isSafe) {}
callback = function (error, isSafe) {}
}
return fs.stat(src, function(err, stats) {
return fs.stat(src, function (err, stats) {
if ((err != null ? err.code : undefined) === 'ENOENT') {
logger.warn(
{ err, file: src },
@@ -341,7 +344,7 @@ module.exports = OutputCacheManager = {
_copyFile(src, dst, callback) {
// copy output file into the cache
return fse.copy(src, dst, function(err) {
return fse.copy(src, dst, function (err) {
if ((err != null ? err.code : undefined) === 'ENOENT') {
logger.warn(
{ err, file: src },
@@ -368,7 +371,7 @@ module.exports = OutputCacheManager = {
_checkIfShouldCopy(src, callback) {
if (callback == null) {
callback = function(err, shouldCopy) {}
callback = function (err, shouldCopy) {}
}
return callback(null, !Path.basename(src).match(/^strace/))
},
@@ -376,7 +379,7 @@ module.exports = OutputCacheManager = {
_checkIfShouldArchive(src, callback) {
let needle
if (callback == null) {
callback = function(err, shouldCopy) {}
callback = function (err, shouldCopy) {}
}
if (Path.basename(src).match(/^strace/)) {
return callback(null, true)