|
|
|
@@ -81,6 +81,373 @@ function wrappy (fn, cb) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 13:
|
|
|
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
const assert = __webpack_require__(357)
|
|
|
|
|
const path = __webpack_require__(622)
|
|
|
|
|
const fs = __webpack_require__(747)
|
|
|
|
|
let glob = undefined
|
|
|
|
|
try {
|
|
|
|
|
glob = __webpack_require__(402)
|
|
|
|
|
} catch (_err) {
|
|
|
|
|
// treat glob as optional.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const defaultGlobOpts = {
|
|
|
|
|
nosort: true,
|
|
|
|
|
silent: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// for EMFILE handling
|
|
|
|
|
let timeout = 0
|
|
|
|
|
|
|
|
|
|
const isWindows = (process.platform === "win32")
|
|
|
|
|
|
|
|
|
|
const defaults = options => {
|
|
|
|
|
const methods = [
|
|
|
|
|
'unlink',
|
|
|
|
|
'chmod',
|
|
|
|
|
'stat',
|
|
|
|
|
'lstat',
|
|
|
|
|
'rmdir',
|
|
|
|
|
'readdir'
|
|
|
|
|
]
|
|
|
|
|
methods.forEach(m => {
|
|
|
|
|
options[m] = options[m] || fs[m]
|
|
|
|
|
m = m + 'Sync'
|
|
|
|
|
options[m] = options[m] || fs[m]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
options.maxBusyTries = options.maxBusyTries || 3
|
|
|
|
|
options.emfileWait = options.emfileWait || 1000
|
|
|
|
|
if (options.glob === false) {
|
|
|
|
|
options.disableGlob = true
|
|
|
|
|
}
|
|
|
|
|
if (options.disableGlob !== true && glob === undefined) {
|
|
|
|
|
throw Error('glob dependency not found, set `options.disableGlob = true` if intentional')
|
|
|
|
|
}
|
|
|
|
|
options.disableGlob = options.disableGlob || false
|
|
|
|
|
options.glob = options.glob || defaultGlobOpts
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rimraf = (p, options, cb) => {
|
|
|
|
|
if (typeof options === 'function') {
|
|
|
|
|
cb = options
|
|
|
|
|
options = {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(p, 'rimraf: missing path')
|
|
|
|
|
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
|
|
|
|
|
assert.equal(typeof cb, 'function', 'rimraf: callback function required')
|
|
|
|
|
assert(options, 'rimraf: invalid options argument provided')
|
|
|
|
|
assert.equal(typeof options, 'object', 'rimraf: options should be object')
|
|
|
|
|
|
|
|
|
|
defaults(options)
|
|
|
|
|
|
|
|
|
|
let busyTries = 0
|
|
|
|
|
let errState = null
|
|
|
|
|
let n = 0
|
|
|
|
|
|
|
|
|
|
const next = (er) => {
|
|
|
|
|
errState = errState || er
|
|
|
|
|
if (--n === 0)
|
|
|
|
|
cb(errState)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const afterGlob = (er, results) => {
|
|
|
|
|
if (er)
|
|
|
|
|
return cb(er)
|
|
|
|
|
|
|
|
|
|
n = results.length
|
|
|
|
|
if (n === 0)
|
|
|
|
|
return cb()
|
|
|
|
|
|
|
|
|
|
results.forEach(p => {
|
|
|
|
|
const CB = (er) => {
|
|
|
|
|
if (er) {
|
|
|
|
|
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
|
|
|
|
|
busyTries < options.maxBusyTries) {
|
|
|
|
|
busyTries ++
|
|
|
|
|
// try again, with the same exact callback as this one.
|
|
|
|
|
return setTimeout(() => rimraf_(p, options, CB), busyTries * 100)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this one won't happen if graceful-fs is used.
|
|
|
|
|
if (er.code === "EMFILE" && timeout < options.emfileWait) {
|
|
|
|
|
return setTimeout(() => rimraf_(p, options, CB), timeout ++)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// already gone
|
|
|
|
|
if (er.code === "ENOENT") er = null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
timeout = 0
|
|
|
|
|
next(er)
|
|
|
|
|
}
|
|
|
|
|
rimraf_(p, options, CB)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.disableGlob || !glob.hasMagic(p))
|
|
|
|
|
return afterGlob(null, [p])
|
|
|
|
|
|
|
|
|
|
options.lstat(p, (er, stat) => {
|
|
|
|
|
if (!er)
|
|
|
|
|
return afterGlob(null, [p])
|
|
|
|
|
|
|
|
|
|
glob(p, options.glob, afterGlob)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Two possible strategies.
|
|
|
|
|
// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
|
|
|
|
|
// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
|
|
|
|
|
//
|
|
|
|
|
// Both result in an extra syscall when you guess wrong. However, there
|
|
|
|
|
// are likely far more normal files in the world than directories. This
|
|
|
|
|
// is based on the assumption that a the average number of files per
|
|
|
|
|
// directory is >= 1.
|
|
|
|
|
//
|
|
|
|
|
// If anyone ever complains about this, then I guess the strategy could
|
|
|
|
|
// be made configurable somehow. But until then, YAGNI.
|
|
|
|
|
const rimraf_ = (p, options, cb) => {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
|
|
|
|
|
// sunos lets the root user unlink directories, which is... weird.
|
|
|
|
|
// so we have to lstat here and make sure it's not a dir.
|
|
|
|
|
options.lstat(p, (er, st) => {
|
|
|
|
|
if (er && er.code === "ENOENT")
|
|
|
|
|
return cb(null)
|
|
|
|
|
|
|
|
|
|
// Windows can EPERM on stat. Life is suffering.
|
|
|
|
|
if (er && er.code === "EPERM" && isWindows)
|
|
|
|
|
fixWinEPERM(p, options, er, cb)
|
|
|
|
|
|
|
|
|
|
if (st && st.isDirectory())
|
|
|
|
|
return rmdir(p, options, er, cb)
|
|
|
|
|
|
|
|
|
|
options.unlink(p, er => {
|
|
|
|
|
if (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return cb(null)
|
|
|
|
|
if (er.code === "EPERM")
|
|
|
|
|
return (isWindows)
|
|
|
|
|
? fixWinEPERM(p, options, er, cb)
|
|
|
|
|
: rmdir(p, options, er, cb)
|
|
|
|
|
if (er.code === "EISDIR")
|
|
|
|
|
return rmdir(p, options, er, cb)
|
|
|
|
|
}
|
|
|
|
|
return cb(er)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fixWinEPERM = (p, options, er, cb) => {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
|
|
|
|
|
options.chmod(p, 0o666, er2 => {
|
|
|
|
|
if (er2)
|
|
|
|
|
cb(er2.code === "ENOENT" ? null : er)
|
|
|
|
|
else
|
|
|
|
|
options.stat(p, (er3, stats) => {
|
|
|
|
|
if (er3)
|
|
|
|
|
cb(er3.code === "ENOENT" ? null : er)
|
|
|
|
|
else if (stats.isDirectory())
|
|
|
|
|
rmdir(p, options, er, cb)
|
|
|
|
|
else
|
|
|
|
|
options.unlink(p, cb)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fixWinEPERMSync = (p, options, er) => {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
options.chmodSync(p, 0o666)
|
|
|
|
|
} catch (er2) {
|
|
|
|
|
if (er2.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
throw er
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let stats
|
|
|
|
|
try {
|
|
|
|
|
stats = options.statSync(p)
|
|
|
|
|
} catch (er3) {
|
|
|
|
|
if (er3.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
throw er
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stats.isDirectory())
|
|
|
|
|
rmdirSync(p, options, er)
|
|
|
|
|
else
|
|
|
|
|
options.unlinkSync(p)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rmdir = (p, options, originalEr, cb) => {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
|
|
|
|
|
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
|
|
|
|
|
// if we guessed wrong, and it's not a directory, then
|
|
|
|
|
// raise the original error.
|
|
|
|
|
options.rmdir(p, er => {
|
|
|
|
|
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
|
|
|
|
|
rmkids(p, options, cb)
|
|
|
|
|
else if (er && er.code === "ENOTDIR")
|
|
|
|
|
cb(originalEr)
|
|
|
|
|
else
|
|
|
|
|
cb(er)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rmkids = (p, options, cb) => {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
|
|
|
|
|
options.readdir(p, (er, files) => {
|
|
|
|
|
if (er)
|
|
|
|
|
return cb(er)
|
|
|
|
|
let n = files.length
|
|
|
|
|
if (n === 0)
|
|
|
|
|
return options.rmdir(p, cb)
|
|
|
|
|
let errState
|
|
|
|
|
files.forEach(f => {
|
|
|
|
|
rimraf(path.join(p, f), options, er => {
|
|
|
|
|
if (errState)
|
|
|
|
|
return
|
|
|
|
|
if (er)
|
|
|
|
|
return cb(errState = er)
|
|
|
|
|
if (--n === 0)
|
|
|
|
|
options.rmdir(p, cb)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this looks simpler, and is strictly *faster*, but will
|
|
|
|
|
// tie up the JavaScript thread and fail on excessively
|
|
|
|
|
// deep directory trees.
|
|
|
|
|
const rimrafSync = (p, options) => {
|
|
|
|
|
options = options || {}
|
|
|
|
|
defaults(options)
|
|
|
|
|
|
|
|
|
|
assert(p, 'rimraf: missing path')
|
|
|
|
|
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
|
|
|
|
|
assert(options, 'rimraf: missing options')
|
|
|
|
|
assert.equal(typeof options, 'object', 'rimraf: options should be object')
|
|
|
|
|
|
|
|
|
|
let results
|
|
|
|
|
|
|
|
|
|
if (options.disableGlob || !glob.hasMagic(p)) {
|
|
|
|
|
results = [p]
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
options.lstatSync(p)
|
|
|
|
|
results = [p]
|
|
|
|
|
} catch (er) {
|
|
|
|
|
results = glob.sync(p, options.glob)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!results.length)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < results.length; i++) {
|
|
|
|
|
const p = results[i]
|
|
|
|
|
|
|
|
|
|
let st
|
|
|
|
|
try {
|
|
|
|
|
st = options.lstatSync(p)
|
|
|
|
|
} catch (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
// Windows can EPERM on stat. Life is suffering.
|
|
|
|
|
if (er.code === "EPERM" && isWindows)
|
|
|
|
|
fixWinEPERMSync(p, options, er)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// sunos lets the root user unlink directories, which is... weird.
|
|
|
|
|
if (st && st.isDirectory())
|
|
|
|
|
rmdirSync(p, options, null)
|
|
|
|
|
else
|
|
|
|
|
options.unlinkSync(p)
|
|
|
|
|
} catch (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
if (er.code === "EPERM")
|
|
|
|
|
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
|
|
|
|
|
if (er.code !== "EISDIR")
|
|
|
|
|
throw er
|
|
|
|
|
|
|
|
|
|
rmdirSync(p, options, er)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rmdirSync = (p, options, originalEr) => {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
options.rmdirSync(p)
|
|
|
|
|
} catch (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
if (er.code === "ENOTDIR")
|
|
|
|
|
throw originalEr
|
|
|
|
|
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
|
|
|
|
|
rmkidsSync(p, options)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rmkidsSync = (p, options) => {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
options.readdirSync(p).forEach(f => rimrafSync(path.join(p, f), options))
|
|
|
|
|
|
|
|
|
|
// We only end up here once we got ENOTEMPTY at least once, and
|
|
|
|
|
// at this point, we are guaranteed to have removed all the kids.
|
|
|
|
|
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
|
|
|
|
|
// try really hard to delete stuff on windows, because it has a
|
|
|
|
|
// PROFOUNDLY annoying habit of not closing handles promptly when
|
|
|
|
|
// files are deleted, resulting in spurious ENOTEMPTY errors.
|
|
|
|
|
const retries = isWindows ? 100 : 1
|
|
|
|
|
let i = 0
|
|
|
|
|
do {
|
|
|
|
|
let threw = true
|
|
|
|
|
try {
|
|
|
|
|
const ret = options.rmdirSync(p, options)
|
|
|
|
|
threw = false
|
|
|
|
|
return ret
|
|
|
|
|
} finally {
|
|
|
|
|
if (++i < retries && threw)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
} while (true)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = rimraf
|
|
|
|
|
rimraf.sync = rimrafSync
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 16:
|
|
|
|
@@ -90,6 +457,58 @@ module.exports = require("tls");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 22:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _validate = _interopRequireDefault(__webpack_require__(78));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
function parse(uuid) {
|
|
|
|
|
if (!(0, _validate.default)(uuid)) {
|
|
|
|
|
throw TypeError('Invalid UUID');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let v;
|
|
|
|
|
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
|
|
|
|
|
|
|
|
|
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
|
|
|
arr[1] = v >>> 16 & 0xff;
|
|
|
|
|
arr[2] = v >>> 8 & 0xff;
|
|
|
|
|
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
|
|
|
|
|
|
|
|
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
|
|
|
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
|
|
|
|
|
|
|
|
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
|
|
|
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
|
|
|
|
|
|
|
|
|
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
|
|
|
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
|
|
|
|
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
|
|
|
|
|
|
|
|
|
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
|
|
|
|
arr[11] = v / 0x100000000 & 0xff;
|
|
|
|
|
arr[12] = v >>> 24 & 0xff;
|
|
|
|
|
arr[13] = v >>> 16 & 0xff;
|
|
|
|
|
arr[14] = v >>> 8 & 0xff;
|
|
|
|
|
arr[15] = v & 0xff;
|
|
|
|
|
return arr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = parse;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 49:
|
|
|
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
@@ -137,6 +556,116 @@ function onceStrict (fn) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 62:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "v1", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _v.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "v3", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _v2.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "v4", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _v3.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "v5", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _v4.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "NIL", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _nil.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "version", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _version.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "validate", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _validate.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "stringify", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _stringify.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
Object.defineProperty(exports, "parse", {
|
|
|
|
|
enumerable: true,
|
|
|
|
|
get: function () {
|
|
|
|
|
return _parse.default;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var _v = _interopRequireDefault(__webpack_require__(893));
|
|
|
|
|
|
|
|
|
|
var _v2 = _interopRequireDefault(__webpack_require__(209));
|
|
|
|
|
|
|
|
|
|
var _v3 = _interopRequireDefault(__webpack_require__(733));
|
|
|
|
|
|
|
|
|
|
var _v4 = _interopRequireDefault(__webpack_require__(384));
|
|
|
|
|
|
|
|
|
|
var _nil = _interopRequireDefault(__webpack_require__(327));
|
|
|
|
|
|
|
|
|
|
var _version = _interopRequireDefault(__webpack_require__(695));
|
|
|
|
|
|
|
|
|
|
var _validate = _interopRequireDefault(__webpack_require__(78));
|
|
|
|
|
|
|
|
|
|
var _stringify = _interopRequireDefault(__webpack_require__(411));
|
|
|
|
|
|
|
|
|
|
var _parse = _interopRequireDefault(__webpack_require__(22));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 78:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _regex = _interopRequireDefault(__webpack_require__(456));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
function validate(uuid) {
|
|
|
|
|
return typeof uuid === 'string' && _regex.default.test(uuid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = validate;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 82:
|
|
|
|
@@ -147,6 +676,7 @@ function onceStrict (fn) {
|
|
|
|
|
// We use any as a valid input type
|
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.toCommandProperties = exports.toCommandValue = void 0;
|
|
|
|
|
/**
|
|
|
|
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
|
|
|
|
* @param input input to sanitize into a string
|
|
|
|
@@ -161,6 +691,26 @@ function toCommandValue(input) {
|
|
|
|
|
return JSON.stringify(input);
|
|
|
|
|
}
|
|
|
|
|
exports.toCommandValue = toCommandValue;
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param annotationProperties
|
|
|
|
|
* @returns The command properties to send with the actual annotation command
|
|
|
|
|
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
|
|
|
|
*/
|
|
|
|
|
function toCommandProperties(annotationProperties) {
|
|
|
|
|
if (!Object.keys(annotationProperties).length) {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
title: annotationProperties.title,
|
|
|
|
|
file: annotationProperties.file,
|
|
|
|
|
line: annotationProperties.startLine,
|
|
|
|
|
endLine: annotationProperties.endLine,
|
|
|
|
|
col: annotationProperties.startColumn,
|
|
|
|
|
endColumn: annotationProperties.endColumn
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
exports.toCommandProperties = toCommandProperties;
|
|
|
|
|
//# sourceMappingURL=utils.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
@@ -1100,6 +1650,89 @@ function regExpEscape (s) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 95:
|
|
|
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.checkBypass = exports.getProxyUrl = void 0;
|
|
|
|
|
function getProxyUrl(reqUrl) {
|
|
|
|
|
const usingSsl = reqUrl.protocol === 'https:';
|
|
|
|
|
if (checkBypass(reqUrl)) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
const proxyVar = (() => {
|
|
|
|
|
if (usingSsl) {
|
|
|
|
|
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
|
|
|
|
}
|
|
|
|
|
})();
|
|
|
|
|
if (proxyVar) {
|
|
|
|
|
return new URL(proxyVar);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.getProxyUrl = getProxyUrl;
|
|
|
|
|
function checkBypass(reqUrl) {
|
|
|
|
|
if (!reqUrl.hostname) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
const reqHost = reqUrl.hostname;
|
|
|
|
|
if (isLoopbackAddress(reqHost)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
|
|
|
|
if (!noProxy) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// Determine the request port
|
|
|
|
|
let reqPort;
|
|
|
|
|
if (reqUrl.port) {
|
|
|
|
|
reqPort = Number(reqUrl.port);
|
|
|
|
|
}
|
|
|
|
|
else if (reqUrl.protocol === 'http:') {
|
|
|
|
|
reqPort = 80;
|
|
|
|
|
}
|
|
|
|
|
else if (reqUrl.protocol === 'https:') {
|
|
|
|
|
reqPort = 443;
|
|
|
|
|
}
|
|
|
|
|
// Format the request hostname and hostname with port
|
|
|
|
|
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
|
|
|
|
if (typeof reqPort === 'number') {
|
|
|
|
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
|
|
|
|
}
|
|
|
|
|
// Compare request host against noproxy
|
|
|
|
|
for (const upperNoProxyItem of noProxy
|
|
|
|
|
.split(',')
|
|
|
|
|
.map(x => x.trim().toUpperCase())
|
|
|
|
|
.filter(x => x)) {
|
|
|
|
|
if (upperNoProxyItem === '*' ||
|
|
|
|
|
upperReqHosts.some(x => x === upperNoProxyItem ||
|
|
|
|
|
x.endsWith(`.${upperNoProxyItem}`) ||
|
|
|
|
|
(upperNoProxyItem.startsWith('.') &&
|
|
|
|
|
x.endsWith(`${upperNoProxyItem}`)))) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
exports.checkBypass = checkBypass;
|
|
|
|
|
function isLoopbackAddress(host) {
|
|
|
|
|
const hostLower = host.toLowerCase();
|
|
|
|
|
return (hostLower === 'localhost' ||
|
|
|
|
|
hostLower.startsWith('127.') ||
|
|
|
|
|
hostLower.startsWith('[::1]') ||
|
|
|
|
|
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
|
|
|
|
|
}
|
|
|
|
|
//# sourceMappingURL=proxy.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 102:
|
|
|
|
@@ -1108,20 +1741,34 @@ function regExpEscape (s) {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
// For internal use, subject to change.
|
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
o[k2] = m[k];
|
|
|
|
|
}));
|
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
|
}) : function(o, v) {
|
|
|
|
|
o["default"] = v;
|
|
|
|
|
});
|
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
|
var result = {};
|
|
|
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
|
|
|
result["default"] = mod;
|
|
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
|
|
|
|
|
// We use any as a valid input type
|
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
const fs = __importStar(__webpack_require__(747));
|
|
|
|
|
const os = __importStar(__webpack_require__(87));
|
|
|
|
|
const uuid_1 = __webpack_require__(62);
|
|
|
|
|
const utils_1 = __webpack_require__(82);
|
|
|
|
|
function issueCommand(command, message) {
|
|
|
|
|
function issueFileCommand(command, message) {
|
|
|
|
|
const filePath = process.env[`GITHUB_${command}`];
|
|
|
|
|
if (!filePath) {
|
|
|
|
|
throw new Error(`Unable to find environment variable for file command ${command}`);
|
|
|
|
@@ -1133,7 +1780,22 @@ function issueCommand(command, message) {
|
|
|
|
|
encoding: 'utf8'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
exports.issueCommand = issueCommand;
|
|
|
|
|
exports.issueFileCommand = issueFileCommand;
|
|
|
|
|
function prepareKeyValueMessage(key, value) {
|
|
|
|
|
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
|
|
|
|
const convertedValue = utils_1.toCommandValue(value);
|
|
|
|
|
// These should realistically never happen, but just in case someone finds a
|
|
|
|
|
// way to exploit uuid generation let's not allow keys or values that contain
|
|
|
|
|
// the delimiter.
|
|
|
|
|
if (key.includes(delimiter)) {
|
|
|
|
|
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
|
|
|
|
}
|
|
|
|
|
if (convertedValue.includes(delimiter)) {
|
|
|
|
|
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
|
|
|
|
}
|
|
|
|
|
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
|
|
|
|
|
}
|
|
|
|
|
exports.prepareKeyValueMessage = prepareKeyValueMessage;
|
|
|
|
|
//# sourceMappingURL=file-command.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
@@ -1738,10 +2400,8 @@ const fs = __webpack_require__(747);
|
|
|
|
|
const os = __webpack_require__(87);
|
|
|
|
|
const path = __webpack_require__(622);
|
|
|
|
|
const crypto = __webpack_require__(417);
|
|
|
|
|
const _c = fs.constants && os.constants ?
|
|
|
|
|
{ fs: fs.constants, os: os.constants } :
|
|
|
|
|
process.binding('constants');
|
|
|
|
|
const rimraf = __webpack_require__(569);
|
|
|
|
|
const _c = { fs: fs.constants, os: os.constants };
|
|
|
|
|
const rimraf = __webpack_require__(13);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The working inner variables.
|
|
|
|
@@ -1756,128 +2416,26 @@ const
|
|
|
|
|
|
|
|
|
|
CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR),
|
|
|
|
|
|
|
|
|
|
// constants are off on the windows platform and will not match the actual errno codes
|
|
|
|
|
IS_WIN32 = os.platform() === 'win32',
|
|
|
|
|
EBADF = _c.EBADF || _c.os.errno.EBADF,
|
|
|
|
|
ENOENT = _c.ENOENT || _c.os.errno.ENOENT,
|
|
|
|
|
|
|
|
|
|
DIR_MODE = 448 /* 0o700 */,
|
|
|
|
|
FILE_MODE = 384 /* 0o600 */,
|
|
|
|
|
DIR_MODE = 0o700 /* 448 */,
|
|
|
|
|
FILE_MODE = 0o600 /* 384 */,
|
|
|
|
|
|
|
|
|
|
EXIT = 'exit',
|
|
|
|
|
|
|
|
|
|
SIGINT = 'SIGINT',
|
|
|
|
|
|
|
|
|
|
// this will hold the objects need to be removed on exit
|
|
|
|
|
_removeObjects = [];
|
|
|
|
|
_removeObjects = [],
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
// API change in fs.rmdirSync leads to error when passing in a second parameter, e.g. the callback
|
|
|
|
|
FN_RMDIR_SYNC = fs.rmdirSync.bind(fs),
|
|
|
|
|
FN_RIMRAF_SYNC = rimraf.sync;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
_gracefulCleanup = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Random name generator based on crypto.
|
|
|
|
|
* Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript
|
|
|
|
|
*
|
|
|
|
|
* @param {number} howMany
|
|
|
|
|
* @returns {string} the generated random name
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _randomChars(howMany) {
|
|
|
|
|
var
|
|
|
|
|
value = [],
|
|
|
|
|
rnd = null;
|
|
|
|
|
|
|
|
|
|
// make sure that we do not fail because we ran out of entropy
|
|
|
|
|
try {
|
|
|
|
|
rnd = crypto.randomBytes(howMany);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
rnd = crypto.pseudoRandomBytes(howMany);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < howMany; i++) {
|
|
|
|
|
value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value.join('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks whether the `obj` parameter is defined or not.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} obj
|
|
|
|
|
* @returns {boolean} true if the object is undefined
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _isUndefined(obj) {
|
|
|
|
|
return typeof obj === 'undefined';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parses the function arguments.
|
|
|
|
|
*
|
|
|
|
|
* This function helps to have optional arguments.
|
|
|
|
|
*
|
|
|
|
|
* @param {(Options|Function)} options
|
|
|
|
|
* @param {Function} callback
|
|
|
|
|
* @returns {Array} parsed arguments
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _parseArguments(options, callback) {
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (typeof options === 'function') {
|
|
|
|
|
return [{}, options];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (_isUndefined(options)) {
|
|
|
|
|
return [{}, callback];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [options, callback];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates a new temporary name.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} opts
|
|
|
|
|
* @returns {string} the new random name according to opts
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _generateTmpName(opts) {
|
|
|
|
|
|
|
|
|
|
const tmpDir = _getTmpDir();
|
|
|
|
|
|
|
|
|
|
// fail early on missing tmp dir
|
|
|
|
|
if (isBlank(opts.dir) && isBlank(tmpDir)) {
|
|
|
|
|
throw new Error('No tmp dir specified');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!isBlank(opts.name)) {
|
|
|
|
|
return path.join(opts.dir || tmpDir, opts.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mkstemps like template
|
|
|
|
|
// opts.template has already been guarded in tmpName() below
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (opts.template) {
|
|
|
|
|
var template = opts.template;
|
|
|
|
|
// make sure that we prepend the tmp path if none was given
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (path.basename(template) === template)
|
|
|
|
|
template = path.join(opts.dir || tmpDir, template);
|
|
|
|
|
return template.replace(TEMPLATE_PATTERN, _randomChars(6));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// prefix and postfix
|
|
|
|
|
const name = [
|
|
|
|
|
(isBlank(opts.prefix) ? 'tmp-' : opts.prefix),
|
|
|
|
|
process.pid,
|
|
|
|
|
_randomChars(12),
|
|
|
|
|
(opts.postfix ? opts.postfix : '')
|
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
|
|
return path.join(opts.dir || tmpDir, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets a temporary file name.
|
|
|
|
|
*
|
|
|
|
@@ -1885,20 +2443,18 @@ function _generateTmpName(opts) {
|
|
|
|
|
* @param {?tmpNameCallback} callback the callback function
|
|
|
|
|
*/
|
|
|
|
|
function tmpName(options, callback) {
|
|
|
|
|
var
|
|
|
|
|
const
|
|
|
|
|
args = _parseArguments(options, callback),
|
|
|
|
|
opts = args[0],
|
|
|
|
|
cb = args[1],
|
|
|
|
|
tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES;
|
|
|
|
|
cb = args[1];
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (isNaN(tries) || tries < 0)
|
|
|
|
|
return cb(new Error('Invalid tries'));
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
|
|
|
|
|
return cb(new Error('Invalid template provided'));
|
|
|
|
|
try {
|
|
|
|
|
_assertAndSanitizeOptions(opts);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
return cb(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let tries = opts.tries;
|
|
|
|
|
(function _getUniqueName() {
|
|
|
|
|
try {
|
|
|
|
|
const name = _generateTmpName(opts);
|
|
|
|
@@ -1929,19 +2485,13 @@ function tmpName(options, callback) {
|
|
|
|
|
* @throws {Error} if the options are invalid or could not generate a filename
|
|
|
|
|
*/
|
|
|
|
|
function tmpNameSync(options) {
|
|
|
|
|
var
|
|
|
|
|
const
|
|
|
|
|
args = _parseArguments(options),
|
|
|
|
|
opts = args[0],
|
|
|
|
|
tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES;
|
|
|
|
|
opts = args[0];
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (isNaN(tries) || tries < 0)
|
|
|
|
|
throw new Error('Invalid tries');
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
|
|
|
|
|
throw new Error('Invalid template provided');
|
|
|
|
|
_assertAndSanitizeOptions(opts);
|
|
|
|
|
|
|
|
|
|
let tries = opts.tries;
|
|
|
|
|
do {
|
|
|
|
|
const name = _generateTmpName(opts);
|
|
|
|
|
try {
|
|
|
|
@@ -1957,11 +2507,11 @@ function tmpNameSync(options) {
|
|
|
|
|
/**
|
|
|
|
|
* Creates and opens a temporary file.
|
|
|
|
|
*
|
|
|
|
|
* @param {(Options|fileCallback)} options the config options or the callback function
|
|
|
|
|
* @param {(Options|null|undefined|fileCallback)} options the config options or the callback function or null or undefined
|
|
|
|
|
* @param {?fileCallback} callback
|
|
|
|
|
*/
|
|
|
|
|
function file(options, callback) {
|
|
|
|
|
var
|
|
|
|
|
const
|
|
|
|
|
args = _parseArguments(options, callback),
|
|
|
|
|
opts = args[0],
|
|
|
|
|
cb = args[1];
|
|
|
|
@@ -1973,34 +2523,20 @@ function file(options, callback) {
|
|
|
|
|
|
|
|
|
|
// create and open the file
|
|
|
|
|
fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) {
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
/* istanbu ignore else */
|
|
|
|
|
if (err) return cb(err);
|
|
|
|
|
|
|
|
|
|
if (opts.discardDescriptor) {
|
|
|
|
|
return fs.close(fd, function _discardCallback(err) {
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (err) {
|
|
|
|
|
// Low probability, and the file exists, so this could be
|
|
|
|
|
// ignored. If it isn't we certainly need to unlink the
|
|
|
|
|
// file, and if that fails too its error is more
|
|
|
|
|
// important.
|
|
|
|
|
try {
|
|
|
|
|
fs.unlinkSync(name);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
if (!isENOENT(e)) {
|
|
|
|
|
err = e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return cb(err);
|
|
|
|
|
}
|
|
|
|
|
cb(null, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts));
|
|
|
|
|
return fs.close(fd, function _discardCallback(possibleErr) {
|
|
|
|
|
// the chance of getting an error on close here is rather low and might occur in the most edgiest cases only
|
|
|
|
|
return cb(possibleErr, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts, false));
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// detachDescriptor passes the descriptor whereas discardDescriptor closes it, either way, we no longer care
|
|
|
|
|
// about the descriptor
|
|
|
|
|
const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor;
|
|
|
|
|
cb(null, name, fd, _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, false));
|
|
|
|
|
}
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (opts.detachDescriptor) {
|
|
|
|
|
return cb(null, name, fd, _prepareTmpFileRemoveCallback(name, -1, opts));
|
|
|
|
|
}
|
|
|
|
|
cb(null, name, fd, _prepareTmpFileRemoveCallback(name, fd, opts));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@@ -2013,7 +2549,7 @@ function file(options, callback) {
|
|
|
|
|
* @throws {Error} if cannot create a file
|
|
|
|
|
*/
|
|
|
|
|
function fileSync(options) {
|
|
|
|
|
var
|
|
|
|
|
const
|
|
|
|
|
args = _parseArguments(options),
|
|
|
|
|
opts = args[0];
|
|
|
|
|
|
|
|
|
@@ -2029,7 +2565,7 @@ function fileSync(options) {
|
|
|
|
|
return {
|
|
|
|
|
name: name,
|
|
|
|
|
fd: fd,
|
|
|
|
|
removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts)
|
|
|
|
|
removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts, true)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2040,7 +2576,7 @@ function fileSync(options) {
|
|
|
|
|
* @param {?dirCallback} callback
|
|
|
|
|
*/
|
|
|
|
|
function dir(options, callback) {
|
|
|
|
|
var
|
|
|
|
|
const
|
|
|
|
|
args = _parseArguments(options, callback),
|
|
|
|
|
opts = args[0],
|
|
|
|
|
cb = args[1];
|
|
|
|
@@ -2055,7 +2591,7 @@ function dir(options, callback) {
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (err) return cb(err);
|
|
|
|
|
|
|
|
|
|
cb(null, name, _prepareTmpDirRemoveCallback(name, opts));
|
|
|
|
|
cb(null, name, _prepareTmpDirRemoveCallback(name, opts, false));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@@ -2068,7 +2604,7 @@ function dir(options, callback) {
|
|
|
|
|
* @throws {Error} if it cannot create a directory
|
|
|
|
|
*/
|
|
|
|
|
function dirSync(options) {
|
|
|
|
|
var
|
|
|
|
|
const
|
|
|
|
|
args = _parseArguments(options),
|
|
|
|
|
opts = args[0];
|
|
|
|
|
|
|
|
|
@@ -2077,7 +2613,7 @@ function dirSync(options) {
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
name: name,
|
|
|
|
|
removeCallback: _prepareTmpDirRemoveCallback(name, opts)
|
|
|
|
|
removeCallback: _prepareTmpDirRemoveCallback(name, opts, true)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2090,15 +2626,15 @@ function dirSync(options) {
|
|
|
|
|
*/
|
|
|
|
|
function _removeFileAsync(fdPath, next) {
|
|
|
|
|
const _handler = function (err) {
|
|
|
|
|
if (err && !isENOENT(err)) {
|
|
|
|
|
if (err && !_isENOENT(err)) {
|
|
|
|
|
// reraise any unanticipated error
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (0 <= fdPath[0])
|
|
|
|
|
fs.close(fdPath[0], function (err) {
|
|
|
|
|
fs.close(fdPath[0], function () {
|
|
|
|
|
fs.unlink(fdPath[1], _handler);
|
|
|
|
|
});
|
|
|
|
|
else fs.unlink(fdPath[1], _handler);
|
|
|
|
@@ -2111,117 +2647,104 @@ function _removeFileAsync(fdPath, next) {
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _removeFileSync(fdPath) {
|
|
|
|
|
let rethrownException = null;
|
|
|
|
|
try {
|
|
|
|
|
if (0 <= fdPath[0]) fs.closeSync(fdPath[0]);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// reraise any unanticipated error
|
|
|
|
|
if (!isEBADF(e) && !isENOENT(e)) throw e;
|
|
|
|
|
if (!_isEBADF(e) && !_isENOENT(e)) throw e;
|
|
|
|
|
} finally {
|
|
|
|
|
try {
|
|
|
|
|
fs.unlinkSync(fdPath[1]);
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
|
|
|
|
// reraise any unanticipated error
|
|
|
|
|
if (!isENOENT(e)) throw e;
|
|
|
|
|
if (!_isENOENT(e)) rethrownException = e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (rethrownException !== null) {
|
|
|
|
|
throw rethrownException;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepares the callback for removal of the temporary file.
|
|
|
|
|
*
|
|
|
|
|
* Returns either a sync callback or a async callback depending on whether
|
|
|
|
|
* fileSync or file was called, which is expressed by the sync parameter.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} name the path of the file
|
|
|
|
|
* @param {number} fd file descriptor
|
|
|
|
|
* @param {Object} opts
|
|
|
|
|
* @returns {fileCallback}
|
|
|
|
|
* @param {boolean} sync
|
|
|
|
|
* @returns {fileCallback | fileCallbackSync}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _prepareTmpFileRemoveCallback(name, fd, opts) {
|
|
|
|
|
const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name]);
|
|
|
|
|
const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], removeCallbackSync);
|
|
|
|
|
function _prepareTmpFileRemoveCallback(name, fd, opts, sync) {
|
|
|
|
|
const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name], sync);
|
|
|
|
|
const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], sync, removeCallbackSync);
|
|
|
|
|
|
|
|
|
|
if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
|
|
|
|
|
|
|
|
|
|
return removeCallback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Simple wrapper for rimraf.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} dirPath
|
|
|
|
|
* @param {Function} next
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _rimrafRemoveDirWrapper(dirPath, next) {
|
|
|
|
|
rimraf(dirPath, next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Simple wrapper for rimraf.sync.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} dirPath
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _rimrafRemoveDirSyncWrapper(dirPath, next) {
|
|
|
|
|
try {
|
|
|
|
|
return next(null, rimraf.sync(dirPath));
|
|
|
|
|
} catch (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
return sync ? removeCallbackSync : removeCallback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepares the callback for removal of the temporary directory.
|
|
|
|
|
*
|
|
|
|
|
* Returns either a sync callback or a async callback depending on whether
|
|
|
|
|
* tmpFileSync or tmpFile was called, which is expressed by the sync parameter.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} name
|
|
|
|
|
* @param {Object} opts
|
|
|
|
|
* @param {boolean} sync
|
|
|
|
|
* @returns {Function} the callback
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _prepareTmpDirRemoveCallback(name, opts) {
|
|
|
|
|
const removeFunction = opts.unsafeCleanup ? _rimrafRemoveDirWrapper : fs.rmdir.bind(fs);
|
|
|
|
|
const removeFunctionSync = opts.unsafeCleanup ? _rimrafRemoveDirSyncWrapper : fs.rmdirSync.bind(fs);
|
|
|
|
|
const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name);
|
|
|
|
|
const removeCallback = _prepareRemoveCallback(removeFunction, name, removeCallbackSync);
|
|
|
|
|
function _prepareTmpDirRemoveCallback(name, opts, sync) {
|
|
|
|
|
const removeFunction = opts.unsafeCleanup ? rimraf : fs.rmdir.bind(fs);
|
|
|
|
|
const removeFunctionSync = opts.unsafeCleanup ? FN_RIMRAF_SYNC : FN_RMDIR_SYNC;
|
|
|
|
|
const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name, sync);
|
|
|
|
|
const removeCallback = _prepareRemoveCallback(removeFunction, name, sync, removeCallbackSync);
|
|
|
|
|
if (!opts.keep) _removeObjects.unshift(removeCallbackSync);
|
|
|
|
|
|
|
|
|
|
return removeCallback;
|
|
|
|
|
return sync ? removeCallbackSync : removeCallback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a guarded function wrapping the removeFunction call.
|
|
|
|
|
*
|
|
|
|
|
* The cleanup callback is save to be called multiple times.
|
|
|
|
|
* Subsequent invocations will be ignored.
|
|
|
|
|
*
|
|
|
|
|
* @param {Function} removeFunction
|
|
|
|
|
* @param {Object} arg
|
|
|
|
|
* @returns {Function}
|
|
|
|
|
* @param {string} fileOrDirName
|
|
|
|
|
* @param {boolean} sync
|
|
|
|
|
* @param {cleanupCallbackSync?} cleanupCallbackSync
|
|
|
|
|
* @returns {cleanupCallback | cleanupCallbackSync}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _prepareRemoveCallback(removeFunction, arg, cleanupCallbackSync) {
|
|
|
|
|
var called = false;
|
|
|
|
|
function _prepareRemoveCallback(removeFunction, fileOrDirName, sync, cleanupCallbackSync) {
|
|
|
|
|
let called = false;
|
|
|
|
|
|
|
|
|
|
// if sync is true, the next parameter will be ignored
|
|
|
|
|
return function _cleanupCallback(next) {
|
|
|
|
|
next = next || function () {};
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!called) {
|
|
|
|
|
// remove cleanupCallback from cache
|
|
|
|
|
const toRemove = cleanupCallbackSync || _cleanupCallback;
|
|
|
|
|
const index = _removeObjects.indexOf(toRemove);
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (index >= 0) _removeObjects.splice(index, 1);
|
|
|
|
|
|
|
|
|
|
called = true;
|
|
|
|
|
// sync?
|
|
|
|
|
if (removeFunction.length === 1) {
|
|
|
|
|
try {
|
|
|
|
|
removeFunction(arg);
|
|
|
|
|
return next(null);
|
|
|
|
|
}
|
|
|
|
|
catch (err) {
|
|
|
|
|
// if no next is provided and since we are
|
|
|
|
|
// in silent cleanup mode on process exit,
|
|
|
|
|
// we will ignore the error
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
} else return removeFunction(arg, next);
|
|
|
|
|
} else return next(new Error('cleanup callback has already been called'));
|
|
|
|
|
if (sync || removeFunction === FN_RMDIR_SYNC || removeFunction === FN_RIMRAF_SYNC) {
|
|
|
|
|
return removeFunction(fileOrDirName);
|
|
|
|
|
} else {
|
|
|
|
|
return removeFunction(fileOrDirName, next || function() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2246,41 +2769,30 @@ function _garbageCollector() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper for testing against EBADF to compensate changes made to Node 7.x under Windows.
|
|
|
|
|
* Random name generator based on crypto.
|
|
|
|
|
* Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript
|
|
|
|
|
*
|
|
|
|
|
* @param {number} howMany
|
|
|
|
|
* @returns {string} the generated random name
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function isEBADF(error) {
|
|
|
|
|
return isExpectedError(error, -EBADF, 'EBADF');
|
|
|
|
|
}
|
|
|
|
|
function _randomChars(howMany) {
|
|
|
|
|
let
|
|
|
|
|
value = [],
|
|
|
|
|
rnd = null;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows.
|
|
|
|
|
*/
|
|
|
|
|
function isENOENT(error) {
|
|
|
|
|
return isExpectedError(error, -ENOENT, 'ENOENT');
|
|
|
|
|
}
|
|
|
|
|
// make sure that we do not fail because we ran out of entropy
|
|
|
|
|
try {
|
|
|
|
|
rnd = crypto.randomBytes(howMany);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
rnd = crypto.pseudoRandomBytes(howMany);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper to determine whether the expected error code matches the actual code and errno,
|
|
|
|
|
* which will differ between the supported node versions.
|
|
|
|
|
*
|
|
|
|
|
* - Node >= 7.0:
|
|
|
|
|
* error.code {string}
|
|
|
|
|
* error.errno {string|number} any numerical value will be negated
|
|
|
|
|
*
|
|
|
|
|
* - Node >= 6.0 < 7.0:
|
|
|
|
|
* error.code {string}
|
|
|
|
|
* error.errno {number} negated
|
|
|
|
|
*
|
|
|
|
|
* - Node >= 4.0 < 6.0: introduces SystemError
|
|
|
|
|
* error.code {string}
|
|
|
|
|
* error.errno {number} negated
|
|
|
|
|
*
|
|
|
|
|
* - Node >= 0.10 < 4.0:
|
|
|
|
|
* error.code {number} negated
|
|
|
|
|
* error.errno n/a
|
|
|
|
|
*/
|
|
|
|
|
function isExpectedError(error, code, errno) {
|
|
|
|
|
return error.code === code || error.code === errno;
|
|
|
|
|
for (var i = 0; i < howMany; i++) {
|
|
|
|
|
value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value.join('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -2290,12 +2802,241 @@ function isExpectedError(error, code, errno) {
|
|
|
|
|
* @param {string} s
|
|
|
|
|
* @returns {Boolean} true whether the string s is blank, false otherwise
|
|
|
|
|
*/
|
|
|
|
|
function isBlank(s) {
|
|
|
|
|
return s === null || s === undefined || !s.trim();
|
|
|
|
|
function _isBlank(s) {
|
|
|
|
|
return s === null || _isUndefined(s) || !s.trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks whether the `obj` parameter is defined or not.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} obj
|
|
|
|
|
* @returns {boolean} true if the object is undefined
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _isUndefined(obj) {
|
|
|
|
|
return typeof obj === 'undefined';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parses the function arguments.
|
|
|
|
|
*
|
|
|
|
|
* This function helps to have optional arguments.
|
|
|
|
|
*
|
|
|
|
|
* @param {(Options|null|undefined|Function)} options
|
|
|
|
|
* @param {?Function} callback
|
|
|
|
|
* @returns {Array} parsed arguments
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _parseArguments(options, callback) {
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (typeof options === 'function') {
|
|
|
|
|
return [{}, options];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (_isUndefined(options)) {
|
|
|
|
|
return [{}, callback];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// copy options so we do not leak the changes we make internally
|
|
|
|
|
const actualOptions = {};
|
|
|
|
|
for (const key of Object.getOwnPropertyNames(options)) {
|
|
|
|
|
actualOptions[key] = options[key];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return [actualOptions, callback];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates a new temporary name.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} opts
|
|
|
|
|
* @returns {string} the new random name according to opts
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _generateTmpName(opts) {
|
|
|
|
|
|
|
|
|
|
const tmpDir = opts.tmpdir;
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!_isUndefined(opts.name))
|
|
|
|
|
return path.join(tmpDir, opts.dir, opts.name);
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!_isUndefined(opts.template))
|
|
|
|
|
return path.join(tmpDir, opts.dir, opts.template).replace(TEMPLATE_PATTERN, _randomChars(6));
|
|
|
|
|
|
|
|
|
|
// prefix and postfix
|
|
|
|
|
const name = [
|
|
|
|
|
opts.prefix ? opts.prefix : 'tmp',
|
|
|
|
|
'-',
|
|
|
|
|
process.pid,
|
|
|
|
|
'-',
|
|
|
|
|
_randomChars(12),
|
|
|
|
|
opts.postfix ? '-' + opts.postfix : ''
|
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
|
|
return path.join(tmpDir, opts.dir, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Asserts whether the specified options are valid, also sanitizes options and provides sane defaults for missing
|
|
|
|
|
* options.
|
|
|
|
|
*
|
|
|
|
|
* @param {Options} options
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _assertAndSanitizeOptions(options) {
|
|
|
|
|
|
|
|
|
|
options.tmpdir = _getTmpDir(options);
|
|
|
|
|
|
|
|
|
|
const tmpDir = options.tmpdir;
|
|
|
|
|
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!_isUndefined(options.name))
|
|
|
|
|
_assertIsRelative(options.name, 'name', tmpDir);
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!_isUndefined(options.dir))
|
|
|
|
|
_assertIsRelative(options.dir, 'dir', tmpDir);
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!_isUndefined(options.template)) {
|
|
|
|
|
_assertIsRelative(options.template, 'template', tmpDir);
|
|
|
|
|
if (!options.template.match(TEMPLATE_PATTERN))
|
|
|
|
|
throw new Error(`Invalid template, found "${options.template}".`);
|
|
|
|
|
}
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (!_isUndefined(options.tries) && isNaN(options.tries) || options.tries < 0)
|
|
|
|
|
throw new Error(`Invalid tries, found "${options.tries}".`);
|
|
|
|
|
|
|
|
|
|
// if a name was specified we will try once
|
|
|
|
|
options.tries = _isUndefined(options.name) ? options.tries || DEFAULT_TRIES : 1;
|
|
|
|
|
options.keep = !!options.keep;
|
|
|
|
|
options.detachDescriptor = !!options.detachDescriptor;
|
|
|
|
|
options.discardDescriptor = !!options.discardDescriptor;
|
|
|
|
|
options.unsafeCleanup = !!options.unsafeCleanup;
|
|
|
|
|
|
|
|
|
|
// sanitize dir, also keep (multiple) blanks if the user, purportedly sane, requests us to
|
|
|
|
|
options.dir = _isUndefined(options.dir) ? '' : path.relative(tmpDir, _resolvePath(options.dir, tmpDir));
|
|
|
|
|
options.template = _isUndefined(options.template) ? undefined : path.relative(tmpDir, _resolvePath(options.template, tmpDir));
|
|
|
|
|
// sanitize further if template is relative to options.dir
|
|
|
|
|
options.template = _isBlank(options.template) ? undefined : path.relative(options.dir, options.template);
|
|
|
|
|
|
|
|
|
|
// for completeness' sake only, also keep (multiple) blanks if the user, purportedly sane, requests us to
|
|
|
|
|
options.name = _isUndefined(options.name) ? undefined : _sanitizeName(options.name);
|
|
|
|
|
options.prefix = _isUndefined(options.prefix) ? '' : options.prefix;
|
|
|
|
|
options.postfix = _isUndefined(options.postfix) ? '' : options.postfix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resolve the specified path name in respect to tmpDir.
|
|
|
|
|
*
|
|
|
|
|
* The specified name might include relative path components, e.g. ../
|
|
|
|
|
* so we need to resolve in order to be sure that is is located inside tmpDir
|
|
|
|
|
*
|
|
|
|
|
* @param name
|
|
|
|
|
* @param tmpDir
|
|
|
|
|
* @returns {string}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _resolvePath(name, tmpDir) {
|
|
|
|
|
const sanitizedName = _sanitizeName(name);
|
|
|
|
|
if (sanitizedName.startsWith(tmpDir)) {
|
|
|
|
|
return path.resolve(sanitizedName);
|
|
|
|
|
} else {
|
|
|
|
|
return path.resolve(path.join(tmpDir, sanitizedName));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sanitize the specified path name by removing all quote characters.
|
|
|
|
|
*
|
|
|
|
|
* @param name
|
|
|
|
|
* @returns {string}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _sanitizeName(name) {
|
|
|
|
|
if (_isBlank(name)) {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
return name.replace(/["']/g, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Asserts whether specified name is relative to the specified tmpDir.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} name
|
|
|
|
|
* @param {string} option
|
|
|
|
|
* @param {string} tmpDir
|
|
|
|
|
* @throws {Error}
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _assertIsRelative(name, option, tmpDir) {
|
|
|
|
|
if (option === 'name') {
|
|
|
|
|
// assert that name is not absolute and does not contain a path
|
|
|
|
|
if (path.isAbsolute(name))
|
|
|
|
|
throw new Error(`${option} option must not contain an absolute path, found "${name}".`);
|
|
|
|
|
// must not fail on valid .<name> or ..<name> or similar such constructs
|
|
|
|
|
let basename = path.basename(name);
|
|
|
|
|
if (basename === '..' || basename === '.' || basename !== name)
|
|
|
|
|
throw new Error(`${option} option must not contain a path, found "${name}".`);
|
|
|
|
|
}
|
|
|
|
|
else { // if (option === 'dir' || option === 'template') {
|
|
|
|
|
// assert that dir or template are relative to tmpDir
|
|
|
|
|
if (path.isAbsolute(name) && !name.startsWith(tmpDir)) {
|
|
|
|
|
throw new Error(`${option} option must be relative to "${tmpDir}", found "${name}".`);
|
|
|
|
|
}
|
|
|
|
|
let resolvedPath = _resolvePath(name, tmpDir);
|
|
|
|
|
if (!resolvedPath.startsWith(tmpDir))
|
|
|
|
|
throw new Error(`${option} option must be relative to "${tmpDir}", found "${resolvedPath}".`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper for testing against EBADF to compensate changes made to Node 7.x under Windows.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _isEBADF(error) {
|
|
|
|
|
return _isExpectedError(error, -EBADF, 'EBADF');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _isENOENT(error) {
|
|
|
|
|
return _isExpectedError(error, -ENOENT, 'ENOENT');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper to determine whether the expected error code matches the actual code and errno,
|
|
|
|
|
* which will differ between the supported node versions.
|
|
|
|
|
*
|
|
|
|
|
* - Node >= 7.0:
|
|
|
|
|
* error.code {string}
|
|
|
|
|
* error.errno {number} any numerical value will be negated
|
|
|
|
|
*
|
|
|
|
|
* CAVEAT
|
|
|
|
|
*
|
|
|
|
|
* On windows, the errno for EBADF is -4083 but os.constants.errno.EBADF is different and we must assume that ENOENT
|
|
|
|
|
* is no different here.
|
|
|
|
|
*
|
|
|
|
|
* @param {SystemError} error
|
|
|
|
|
* @param {number} errno
|
|
|
|
|
* @param {string} code
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _isExpectedError(error, errno, code) {
|
|
|
|
|
return IS_WIN32 ? error.code === code : error.code === code && error.errno === errno;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the graceful cleanup.
|
|
|
|
|
*
|
|
|
|
|
* If graceful cleanup is set, tmp will remove all controlled temporary objects on process exit, otherwise the
|
|
|
|
|
* temporary objects will remain in place, waiting to be cleaned up on system restart or otherwise scheduled temporary
|
|
|
|
|
* object removals.
|
|
|
|
|
*/
|
|
|
|
|
function setGracefulCleanup() {
|
|
|
|
|
_gracefulCleanup = true;
|
|
|
|
@@ -2305,120 +3046,38 @@ function setGracefulCleanup() {
|
|
|
|
|
* Returns the currently configured tmp dir from os.tmpdir().
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
* @param {?Options} options
|
|
|
|
|
* @returns {string} the currently configured tmp dir
|
|
|
|
|
*/
|
|
|
|
|
function _getTmpDir() {
|
|
|
|
|
return os.tmpdir();
|
|
|
|
|
function _getTmpDir(options) {
|
|
|
|
|
return path.resolve(_sanitizeName(options && options.tmpdir || os.tmpdir()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If there are multiple different versions of tmp in place, make sure that
|
|
|
|
|
* we recognize the old listeners.
|
|
|
|
|
*
|
|
|
|
|
* @param {Function} listener
|
|
|
|
|
* @private
|
|
|
|
|
* @returns {Boolean} true whether listener is a legacy listener
|
|
|
|
|
*/
|
|
|
|
|
function _is_legacy_listener(listener) {
|
|
|
|
|
return (listener.name === '_exit' || listener.name === '_uncaughtExceptionThrown')
|
|
|
|
|
&& listener.toString().indexOf('_garbageCollector();') > -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Safely install SIGINT listener.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: this will only work on OSX and Linux.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _safely_install_sigint_listener() {
|
|
|
|
|
|
|
|
|
|
const listeners = process.listeners(SIGINT);
|
|
|
|
|
const existingListeners = [];
|
|
|
|
|
for (let i = 0, length = listeners.length; i < length; i++) {
|
|
|
|
|
const lstnr = listeners[i];
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
if (lstnr.name === '_tmp$sigint_listener') {
|
|
|
|
|
existingListeners.push(lstnr);
|
|
|
|
|
process.removeListener(SIGINT, lstnr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
process.on(SIGINT, function _tmp$sigint_listener(doExit) {
|
|
|
|
|
for (let i = 0, length = existingListeners.length; i < length; i++) {
|
|
|
|
|
// let the existing listener do the garbage collection (e.g. jest sandbox)
|
|
|
|
|
try {
|
|
|
|
|
existingListeners[i](false);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
// ignore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
// force the garbage collector even it is called again in the exit listener
|
|
|
|
|
_garbageCollector();
|
|
|
|
|
} finally {
|
|
|
|
|
if (!!doExit) {
|
|
|
|
|
process.exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Safely install process exit listener.
|
|
|
|
|
*
|
|
|
|
|
* @private
|
|
|
|
|
*/
|
|
|
|
|
function _safely_install_exit_listener() {
|
|
|
|
|
const listeners = process.listeners(EXIT);
|
|
|
|
|
|
|
|
|
|
// collect any existing listeners
|
|
|
|
|
const existingListeners = [];
|
|
|
|
|
for (let i = 0, length = listeners.length; i < length; i++) {
|
|
|
|
|
const lstnr = listeners[i];
|
|
|
|
|
/* istanbul ignore else */
|
|
|
|
|
// TODO: remove support for legacy listeners once release 1.0.0 is out
|
|
|
|
|
if (lstnr.name === '_tmp$safe_listener' || _is_legacy_listener(lstnr)) {
|
|
|
|
|
// we must forget about the uncaughtException listener, hopefully it is ours
|
|
|
|
|
if (lstnr.name !== '_uncaughtExceptionThrown') {
|
|
|
|
|
existingListeners.push(lstnr);
|
|
|
|
|
}
|
|
|
|
|
process.removeListener(EXIT, lstnr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// TODO: what was the data parameter good for?
|
|
|
|
|
process.addListener(EXIT, function _tmp$safe_listener(data) {
|
|
|
|
|
for (let i = 0, length = existingListeners.length; i < length; i++) {
|
|
|
|
|
// let the existing listener do the garbage collection (e.g. jest sandbox)
|
|
|
|
|
try {
|
|
|
|
|
existingListeners[i](data);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
// ignore
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_garbageCollector();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_safely_install_exit_listener();
|
|
|
|
|
_safely_install_sigint_listener();
|
|
|
|
|
// Install process exit listener
|
|
|
|
|
process.addListener(EXIT, _garbageCollector);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configuration options.
|
|
|
|
|
*
|
|
|
|
|
* @typedef {Object} Options
|
|
|
|
|
* @property {?boolean} keep the temporary object (file or dir) will not be garbage collected
|
|
|
|
|
* @property {?number} tries the number of tries before give up the name generation
|
|
|
|
|
* @property (?int) mode the access mode, defaults are 0o700 for directories and 0o600 for files
|
|
|
|
|
* @property {?string} template the "mkstemp" like filename template
|
|
|
|
|
* @property {?string} name fix name
|
|
|
|
|
* @property {?string} dir the tmp directory to use
|
|
|
|
|
* @property {?string} name fixed name relative to tmpdir or the specified dir option
|
|
|
|
|
* @property {?string} dir tmp directory relative to the root tmp directory in use
|
|
|
|
|
* @property {?string} prefix prefix for the generated name
|
|
|
|
|
* @property {?string} postfix postfix for the generated name
|
|
|
|
|
* @property {?string} tmpdir the root tmp directory which overrides the os tmpdir
|
|
|
|
|
* @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty
|
|
|
|
|
* @property {?boolean} detachDescriptor detaches the file descriptor, caller is responsible for closing the file, tmp will no longer try closing the file during garbage collection
|
|
|
|
|
* @property {?boolean} discardDescriptor discards the file descriptor (closes file, fd is -1), tmp will no longer try closing the file during garbage collection
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @typedef {Object} FileSyncObject
|
|
|
|
|
* @property {string} name the name of the file
|
|
|
|
|
* @property {string} fd the file descriptor
|
|
|
|
|
* @property {string} fd the file descriptor or -1 if the fd has been discarded
|
|
|
|
|
* @property {fileCallback} removeCallback the callback function to remove the file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
@@ -2438,10 +3097,18 @@ _safely_install_sigint_listener();
|
|
|
|
|
* @callback fileCallback
|
|
|
|
|
* @param {?Error} err the error object if anything goes wrong
|
|
|
|
|
* @param {string} name the temporary file name
|
|
|
|
|
* @param {number} fd the file descriptor
|
|
|
|
|
* @param {number} fd the file descriptor or -1 if the fd had been discarded
|
|
|
|
|
* @param {cleanupCallback} fn the cleanup callback function
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @callback fileCallbackSync
|
|
|
|
|
* @param {?Error} err the error object if anything goes wrong
|
|
|
|
|
* @param {string} name the temporary file name
|
|
|
|
|
* @param {number} fd the file descriptor or -1 if the fd had been discarded
|
|
|
|
|
* @param {cleanupCallbackSync} fn the cleanup callback function
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @callback dirCallback
|
|
|
|
|
* @param {?Error} err the error object if anything goes wrong
|
|
|
|
@@ -2449,11 +3116,24 @@ _safely_install_sigint_listener();
|
|
|
|
|
* @param {cleanupCallback} fn the cleanup callback function
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @callback dirCallbackSync
|
|
|
|
|
* @param {?Error} err the error object if anything goes wrong
|
|
|
|
|
* @param {string} name the temporary file name
|
|
|
|
|
* @param {cleanupCallbackSync} fn the cleanup callback function
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes the temporary created file or directory.
|
|
|
|
|
*
|
|
|
|
|
* @callback cleanupCallback
|
|
|
|
|
* @param {simpleCallback} [next] function to call after entry was removed
|
|
|
|
|
* @param {simpleCallback} [next] function to call whenever the tmp object needs to be removed
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes the temporary created file or directory.
|
|
|
|
|
*
|
|
|
|
|
* @callback cleanupCallbackSync
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -2465,7 +3145,7 @@ _safely_install_sigint_listener();
|
|
|
|
|
|
|
|
|
|
// exporting all the needed methods
|
|
|
|
|
|
|
|
|
|
// evaluate os.tmpdir() lazily, mainly for simplifying testing but it also will
|
|
|
|
|
// evaluate _getTmpDir() lazily, mainly for simplifying testing but it also will
|
|
|
|
|
// allow users to reconfigure the temporary directory
|
|
|
|
|
Object.defineProperty(module.exports, 'tmpdir', {
|
|
|
|
|
enumerable: true,
|
|
|
|
@@ -2509,11 +3189,11 @@ class StatusReporter {
|
|
|
|
|
this.processedCount = 0;
|
|
|
|
|
this.largeFiles = new Map();
|
|
|
|
|
this.totalFileStatus = undefined;
|
|
|
|
|
this.largeFileStatus = undefined;
|
|
|
|
|
this.displayFrequencyInMilliseconds = displayFrequencyInMilliseconds;
|
|
|
|
|
}
|
|
|
|
|
setTotalNumberOfFilesToProcess(fileTotal) {
|
|
|
|
|
this.totalNumberOfFilesToProcess = fileTotal;
|
|
|
|
|
this.processedCount = 0;
|
|
|
|
|
}
|
|
|
|
|
start() {
|
|
|
|
|
// displays information about the total upload/download status
|
|
|
|
@@ -2522,30 +3202,17 @@ class StatusReporter {
|
|
|
|
|
const percentage = this.formatPercentage(this.processedCount, this.totalNumberOfFilesToProcess);
|
|
|
|
|
core_1.info(`Total file count: ${this.totalNumberOfFilesToProcess} ---- Processed file #${this.processedCount} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`);
|
|
|
|
|
}, this.displayFrequencyInMilliseconds);
|
|
|
|
|
// displays extra information about any large files that take a significant amount of time to upload or download every 1 second
|
|
|
|
|
this.largeFileStatus = setInterval(() => {
|
|
|
|
|
for (const value of Array.from(this.largeFiles.values())) {
|
|
|
|
|
core_1.info(value);
|
|
|
|
|
}
|
|
|
|
|
// delete all entries in the map after displaying the information so it will not be displayed again unless explicitly added
|
|
|
|
|
this.largeFiles.clear();
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
// if there is a large file that is being uploaded in chunks, this is used to display extra information about the status of the upload
|
|
|
|
|
updateLargeFileStatus(fileName, numerator, denominator) {
|
|
|
|
|
updateLargeFileStatus(fileName, chunkStartIndex, chunkEndIndex, totalUploadFileSize) {
|
|
|
|
|
// display 1 decimal place without any rounding
|
|
|
|
|
const percentage = this.formatPercentage(numerator, denominator);
|
|
|
|
|
const displayInformation = `Uploading ${fileName} (${percentage.slice(0, percentage.indexOf('.') + 2)}%)`;
|
|
|
|
|
// any previously added display information should be overwritten for the specific large file because a map is being used
|
|
|
|
|
this.largeFiles.set(fileName, displayInformation);
|
|
|
|
|
const percentage = this.formatPercentage(chunkEndIndex, totalUploadFileSize);
|
|
|
|
|
core_1.info(`Uploaded ${fileName} (${percentage.slice(0, percentage.indexOf('.') + 2)}%) bytes ${chunkStartIndex}:${chunkEndIndex}`);
|
|
|
|
|
}
|
|
|
|
|
stop() {
|
|
|
|
|
if (this.totalFileStatus) {
|
|
|
|
|
clearInterval(this.totalFileStatus);
|
|
|
|
|
}
|
|
|
|
|
if (this.largeFileStatus) {
|
|
|
|
|
clearInterval(this.largeFileStatus);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
incrementProcessedCount() {
|
|
|
|
|
this.processedCount++;
|
|
|
|
@@ -2560,6 +3227,29 @@ exports.StatusReporter = StatusReporter;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 209:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _v = _interopRequireDefault(__webpack_require__(212));
|
|
|
|
|
|
|
|
|
|
var _md = _interopRequireDefault(__webpack_require__(803));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
const v3 = (0, _v.default)('v3', 0x30, _md.default);
|
|
|
|
|
var _default = v3;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 211:
|
|
|
|
|
/***/ (function(module) {
|
|
|
|
|
|
|
|
|
@@ -2567,6 +3257,91 @@ module.exports = require("https");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 212:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
exports.URL = exports.DNS = void 0;
|
|
|
|
|
|
|
|
|
|
var _stringify = _interopRequireDefault(__webpack_require__(411));
|
|
|
|
|
|
|
|
|
|
var _parse = _interopRequireDefault(__webpack_require__(22));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
function stringToBytes(str) {
|
|
|
|
|
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
|
|
|
|
|
|
|
|
const bytes = [];
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < str.length; ++i) {
|
|
|
|
|
bytes.push(str.charCodeAt(i));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bytes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
|
|
|
exports.DNS = DNS;
|
|
|
|
|
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
|
|
|
exports.URL = URL;
|
|
|
|
|
|
|
|
|
|
function _default(name, version, hashfunc) {
|
|
|
|
|
function generateUUID(value, namespace, buf, offset) {
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
|
value = stringToBytes(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (typeof namespace === 'string') {
|
|
|
|
|
namespace = (0, _parse.default)(namespace);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (namespace.length !== 16) {
|
|
|
|
|
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
|
|
|
} // Compute hash of namespace and value, Per 4.3
|
|
|
|
|
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
|
|
|
// hashfunc([...namespace, ... value])`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let bytes = new Uint8Array(16 + value.length);
|
|
|
|
|
bytes.set(namespace);
|
|
|
|
|
bytes.set(value, namespace.length);
|
|
|
|
|
bytes = hashfunc(bytes);
|
|
|
|
|
bytes[6] = bytes[6] & 0x0f | version;
|
|
|
|
|
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
|
|
|
|
|
|
|
|
if (buf) {
|
|
|
|
|
offset = offset || 0;
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 16; ++i) {
|
|
|
|
|
buf[offset + i] = bytes[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (0, _stringify.default)(bytes);
|
|
|
|
|
} // Function#name is not settable on some platforms (#270)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
|
|
|
} catch (err) {} // For CommonJS default export support
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generateUUID.DNS = DNS;
|
|
|
|
|
generateUUID.URL = URL;
|
|
|
|
|
return generateUUID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 214:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
@@ -3457,6 +4232,21 @@ if (typeof Object.create === 'function') {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 327:
|
|
|
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
var _default = '00000000-0000-0000-0000-000000000000';
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 357:
|
|
|
|
@@ -3492,6 +4282,7 @@ const core = __importStar(__webpack_require__(470));
|
|
|
|
|
const upload_specification_1 = __webpack_require__(590);
|
|
|
|
|
const upload_http_client_1 = __webpack_require__(608);
|
|
|
|
|
const utils_1 = __webpack_require__(870);
|
|
|
|
|
const path_and_artifact_name_validation_1 = __webpack_require__(553);
|
|
|
|
|
const download_http_client_1 = __webpack_require__(855);
|
|
|
|
|
const download_specification_1 = __webpack_require__(532);
|
|
|
|
|
const config_variables_1 = __webpack_require__(401);
|
|
|
|
@@ -3508,7 +4299,9 @@ class DefaultArtifactClient {
|
|
|
|
|
*/
|
|
|
|
|
uploadArtifact(name, files, rootDirectory, options) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
utils_1.checkArtifactName(name);
|
|
|
|
|
core.info(`Starting artifact upload
|
|
|
|
|
For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging`);
|
|
|
|
|
path_and_artifact_name_validation_1.checkArtifactName(name);
|
|
|
|
|
// Get specification for the files being uploaded
|
|
|
|
|
const uploadSpecification = upload_specification_1.getUploadSpecification(name, rootDirectory, files);
|
|
|
|
|
const uploadResponse = {
|
|
|
|
@@ -3529,12 +4322,24 @@ class DefaultArtifactClient {
|
|
|
|
|
throw new Error('No URL provided by the Artifact Service to upload an artifact to');
|
|
|
|
|
}
|
|
|
|
|
core.debug(`Upload Resource URL: ${response.fileContainerResourceUrl}`);
|
|
|
|
|
core.info(`Container for artifact "${name}" successfully created. Starting upload of file(s)`);
|
|
|
|
|
// Upload each of the files that were found concurrently
|
|
|
|
|
const uploadResult = yield uploadHttpClient.uploadArtifactToFileContainer(response.fileContainerResourceUrl, uploadSpecification, options);
|
|
|
|
|
// Update the size of the artifact to indicate we are done uploading
|
|
|
|
|
// The uncompressed size is used for display when downloading a zip of the artifact from the UI
|
|
|
|
|
core.info(`File upload process has finished. Finalizing the artifact upload`);
|
|
|
|
|
yield uploadHttpClient.patchArtifactSize(uploadResult.totalSize, name);
|
|
|
|
|
core.info(`Finished uploading artifact ${name}. Reported size is ${uploadResult.uploadSize} bytes. There were ${uploadResult.failedItems.length} items that failed to upload`);
|
|
|
|
|
if (uploadResult.failedItems.length > 0) {
|
|
|
|
|
core.info(`Upload finished. There were ${uploadResult.failedItems.length} items that failed to upload`);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
core.info(`Artifact has been finalized. All files have been successfully uploaded!`);
|
|
|
|
|
}
|
|
|
|
|
core.info(`
|
|
|
|
|
The raw size of all the files that were specified for upload is ${uploadResult.totalSize} bytes
|
|
|
|
|
The size of all the files that were uploaded is ${uploadResult.uploadSize} bytes. This takes into account any gzip compression used to reduce the upload size, time and storage
|
|
|
|
|
|
|
|
|
|
Note: The size of downloaded zips can differ significantly from the reported size. For more information see: https://github.com/actions/upload-artifact#zipped-artifact-downloads \r\n`);
|
|
|
|
|
uploadResponse.artifactItems = uploadSpecification.map(item => item.absoluteFilePath);
|
|
|
|
|
uploadResponse.size = uploadResult.uploadSize;
|
|
|
|
|
uploadResponse.failedItems = uploadResult.failedItems;
|
|
|
|
@@ -3597,6 +4402,7 @@ class DefaultArtifactClient {
|
|
|
|
|
while (downloadedArtifacts < artifacts.count) {
|
|
|
|
|
const currentArtifactToDownload = artifacts.value[downloadedArtifacts];
|
|
|
|
|
downloadedArtifacts += 1;
|
|
|
|
|
core.info(`starting download of artifact ${currentArtifactToDownload.name} : ${downloadedArtifacts}/${artifacts.count}`);
|
|
|
|
|
// Get container entries for the specific artifact
|
|
|
|
|
const items = yield downloadHttpClient.getContainerItems(currentArtifactToDownload.name, currentArtifactToDownload.fileContainerResourceUrl);
|
|
|
|
|
const downloadSpecification = download_specification_1.getDownloadSpecification(currentArtifactToDownload.name, items.value, path, true);
|
|
|
|
@@ -3622,6 +4428,117 @@ exports.DefaultArtifactClient = DefaultArtifactClient;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 363:
|
|
|
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
|
|
|
|
class BasicCredentialHandler {
|
|
|
|
|
constructor(username, password) {
|
|
|
|
|
this.username = username;
|
|
|
|
|
this.password = password;
|
|
|
|
|
}
|
|
|
|
|
prepareRequest(options) {
|
|
|
|
|
if (!options.headers) {
|
|
|
|
|
throw Error('The request has no headers');
|
|
|
|
|
}
|
|
|
|
|
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
|
|
|
|
}
|
|
|
|
|
// This handler cannot handle 401
|
|
|
|
|
canHandleAuthentication() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
handleAuthentication() {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
throw new Error('not implemented');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
|
|
|
class BearerCredentialHandler {
|
|
|
|
|
constructor(token) {
|
|
|
|
|
this.token = token;
|
|
|
|
|
}
|
|
|
|
|
// currently implements pre-authorization
|
|
|
|
|
// TODO: support preAuth = false where it hooks on 401
|
|
|
|
|
prepareRequest(options) {
|
|
|
|
|
if (!options.headers) {
|
|
|
|
|
throw Error('The request has no headers');
|
|
|
|
|
}
|
|
|
|
|
options.headers['Authorization'] = `Bearer ${this.token}`;
|
|
|
|
|
}
|
|
|
|
|
// This handler cannot handle 401
|
|
|
|
|
canHandleAuthentication() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
handleAuthentication() {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
throw new Error('not implemented');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.BearerCredentialHandler = BearerCredentialHandler;
|
|
|
|
|
class PersonalAccessTokenCredentialHandler {
|
|
|
|
|
constructor(token) {
|
|
|
|
|
this.token = token;
|
|
|
|
|
}
|
|
|
|
|
// currently implements pre-authorization
|
|
|
|
|
// TODO: support preAuth = false where it hooks on 401
|
|
|
|
|
prepareRequest(options) {
|
|
|
|
|
if (!options.headers) {
|
|
|
|
|
throw Error('The request has no headers');
|
|
|
|
|
}
|
|
|
|
|
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
|
|
|
|
}
|
|
|
|
|
// This handler cannot handle 401
|
|
|
|
|
canHandleAuthentication() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
handleAuthentication() {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
throw new Error('not implemented');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
|
|
|
|
//# sourceMappingURL=auth.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 384:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _v = _interopRequireDefault(__webpack_require__(212));
|
|
|
|
|
|
|
|
|
|
var _sha = _interopRequireDefault(__webpack_require__(498));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
const v5 = (0, _v.default)('v5', 0x50, _sha.default);
|
|
|
|
|
var _default = v5;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 401:
|
|
|
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
|
|
|
|
|
@@ -4495,6 +5412,52 @@ Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 411:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _validate = _interopRequireDefault(__webpack_require__(78));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert array of 16 byte values to UUID string format of the form:
|
|
|
|
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
|
|
|
*/
|
|
|
|
|
const byteToHex = [];
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 256; ++i) {
|
|
|
|
|
byteToHex.push((i + 0x100).toString(16).substr(1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function stringify(arr, offset = 0) {
|
|
|
|
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
|
|
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
|
|
|
const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
|
|
|
// of the following:
|
|
|
|
|
// - One or more input array values don't map to a hex octet (leading to
|
|
|
|
|
// "undefined" in the uuid)
|
|
|
|
|
// - Invalid input values for the RFC `version` or `variant` fields
|
|
|
|
|
|
|
|
|
|
if (!(0, _validate.default)(uuid)) {
|
|
|
|
|
throw TypeError('Stringified UUID is invalid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return uuid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = stringify;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 413:
|
|
|
|
@@ -4517,14 +5480,27 @@ module.exports = require("crypto");
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
o[k2] = m[k];
|
|
|
|
|
}));
|
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
|
}) : function(o, v) {
|
|
|
|
|
o["default"] = v;
|
|
|
|
|
});
|
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
|
var result = {};
|
|
|
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
|
|
|
result["default"] = mod;
|
|
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.issue = exports.issueCommand = void 0;
|
|
|
|
|
const os = __importStar(__webpack_require__(87));
|
|
|
|
|
const utils_1 = __webpack_require__(82);
|
|
|
|
|
/**
|
|
|
|
@@ -4636,11 +5612,45 @@ exports.HttpManager = HttpManager;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 456:
|
|
|
|
|
/***/ (function(__unusedmodule, exports) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 470:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
o[k2] = m[k];
|
|
|
|
|
}));
|
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
|
}) : function(o, v) {
|
|
|
|
|
o["default"] = v;
|
|
|
|
|
});
|
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
|
var result = {};
|
|
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
@@ -4650,19 +5660,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
|
var result = {};
|
|
|
|
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
|
|
|
result["default"] = mod;
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
|
|
|
|
const command_1 = __webpack_require__(431);
|
|
|
|
|
const file_command_1 = __webpack_require__(102);
|
|
|
|
|
const utils_1 = __webpack_require__(82);
|
|
|
|
|
const os = __importStar(__webpack_require__(87));
|
|
|
|
|
const path = __importStar(__webpack_require__(622));
|
|
|
|
|
const oidc_utils_1 = __webpack_require__(742);
|
|
|
|
|
/**
|
|
|
|
|
* The code to exit an action
|
|
|
|
|
*/
|
|
|
|
@@ -4691,13 +5696,9 @@ function exportVariable(name, val) {
|
|
|
|
|
process.env[name] = convertedVal;
|
|
|
|
|
const filePath = process.env['GITHUB_ENV'] || '';
|
|
|
|
|
if (filePath) {
|
|
|
|
|
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
|
|
|
|
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
|
|
|
|
file_command_1.issueCommand('ENV', commandValue);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
|
|
|
|
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
|
|
|
|
|
}
|
|
|
|
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
|
|
|
|
}
|
|
|
|
|
exports.exportVariable = exportVariable;
|
|
|
|
|
/**
|
|
|
|
@@ -4715,7 +5716,7 @@ exports.setSecret = setSecret;
|
|
|
|
|
function addPath(inputPath) {
|
|
|
|
|
const filePath = process.env['GITHUB_PATH'] || '';
|
|
|
|
|
if (filePath) {
|
|
|
|
|
file_command_1.issueCommand('PATH', inputPath);
|
|
|
|
|
file_command_1.issueFileCommand('PATH', inputPath);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
command_1.issueCommand('add-path', {}, inputPath);
|
|
|
|
@@ -4724,7 +5725,9 @@ function addPath(inputPath) {
|
|
|
|
|
}
|
|
|
|
|
exports.addPath = addPath;
|
|
|
|
|
/**
|
|
|
|
|
* Gets the value of an input. The value is also trimmed.
|
|
|
|
|
* Gets the value of an input.
|
|
|
|
|
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
|
|
|
|
|
* Returns an empty string if the value is not defined.
|
|
|
|
|
*
|
|
|
|
|
* @param name name of the input to get
|
|
|
|
|
* @param options optional. See InputOptions.
|
|
|
|
@@ -4735,9 +5738,52 @@ function getInput(name, options) {
|
|
|
|
|
if (options && options.required && !val) {
|
|
|
|
|
throw new Error(`Input required and not supplied: ${name}`);
|
|
|
|
|
}
|
|
|
|
|
if (options && options.trimWhitespace === false) {
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
return val.trim();
|
|
|
|
|
}
|
|
|
|
|
exports.getInput = getInput;
|
|
|
|
|
/**
|
|
|
|
|
* Gets the values of an multiline input. Each value is also trimmed.
|
|
|
|
|
*
|
|
|
|
|
* @param name name of the input to get
|
|
|
|
|
* @param options optional. See InputOptions.
|
|
|
|
|
* @returns string[]
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
function getMultilineInput(name, options) {
|
|
|
|
|
const inputs = getInput(name, options)
|
|
|
|
|
.split('\n')
|
|
|
|
|
.filter(x => x !== '');
|
|
|
|
|
if (options && options.trimWhitespace === false) {
|
|
|
|
|
return inputs;
|
|
|
|
|
}
|
|
|
|
|
return inputs.map(input => input.trim());
|
|
|
|
|
}
|
|
|
|
|
exports.getMultilineInput = getMultilineInput;
|
|
|
|
|
/**
|
|
|
|
|
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
|
|
|
|
|
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
|
|
|
|
|
* The return value is also in boolean type.
|
|
|
|
|
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
|
|
|
|
|
*
|
|
|
|
|
* @param name name of the input to get
|
|
|
|
|
* @param options optional. See InputOptions.
|
|
|
|
|
* @returns boolean
|
|
|
|
|
*/
|
|
|
|
|
function getBooleanInput(name, options) {
|
|
|
|
|
const trueValue = ['true', 'True', 'TRUE'];
|
|
|
|
|
const falseValue = ['false', 'False', 'FALSE'];
|
|
|
|
|
const val = getInput(name, options);
|
|
|
|
|
if (trueValue.includes(val))
|
|
|
|
|
return true;
|
|
|
|
|
if (falseValue.includes(val))
|
|
|
|
|
return false;
|
|
|
|
|
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
|
|
|
|
|
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
|
|
|
|
}
|
|
|
|
|
exports.getBooleanInput = getBooleanInput;
|
|
|
|
|
/**
|
|
|
|
|
* Sets the value of an output.
|
|
|
|
|
*
|
|
|
|
@@ -4746,7 +5792,12 @@ exports.getInput = getInput;
|
|
|
|
|
*/
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
function setOutput(name, value) {
|
|
|
|
|
command_1.issueCommand('set-output', { name }, value);
|
|
|
|
|
const filePath = process.env['GITHUB_OUTPUT'] || '';
|
|
|
|
|
if (filePath) {
|
|
|
|
|
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
|
|
|
|
|
}
|
|
|
|
|
process.stdout.write(os.EOL);
|
|
|
|
|
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
|
|
|
|
|
}
|
|
|
|
|
exports.setOutput = setOutput;
|
|
|
|
|
/**
|
|
|
|
@@ -4792,19 +5843,30 @@ exports.debug = debug;
|
|
|
|
|
/**
|
|
|
|
|
* Adds an error issue
|
|
|
|
|
* @param message error issue message. Errors will be converted to string via toString()
|
|
|
|
|
* @param properties optional properties to add to the annotation.
|
|
|
|
|
*/
|
|
|
|
|
function error(message) {
|
|
|
|
|
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
|
|
|
|
function error(message, properties = {}) {
|
|
|
|
|
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
|
|
|
|
}
|
|
|
|
|
exports.error = error;
|
|
|
|
|
/**
|
|
|
|
|
* Adds an warning issue
|
|
|
|
|
* Adds a warning issue
|
|
|
|
|
* @param message warning issue message. Errors will be converted to string via toString()
|
|
|
|
|
* @param properties optional properties to add to the annotation.
|
|
|
|
|
*/
|
|
|
|
|
function warning(message) {
|
|
|
|
|
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
|
|
|
|
function warning(message, properties = {}) {
|
|
|
|
|
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
|
|
|
|
}
|
|
|
|
|
exports.warning = warning;
|
|
|
|
|
/**
|
|
|
|
|
* Adds a notice issue
|
|
|
|
|
* @param message notice issue message. Errors will be converted to string via toString()
|
|
|
|
|
* @param properties optional properties to add to the annotation.
|
|
|
|
|
*/
|
|
|
|
|
function notice(message, properties = {}) {
|
|
|
|
|
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
|
|
|
|
}
|
|
|
|
|
exports.notice = notice;
|
|
|
|
|
/**
|
|
|
|
|
* Writes info to log with console.log.
|
|
|
|
|
* @param message info message
|
|
|
|
@@ -4864,7 +5926,11 @@ exports.group = group;
|
|
|
|
|
*/
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
|
function saveState(name, value) {
|
|
|
|
|
command_1.issueCommand('save-state', { name }, value);
|
|
|
|
|
const filePath = process.env['GITHUB_STATE'] || '';
|
|
|
|
|
if (filePath) {
|
|
|
|
|
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
|
|
|
|
|
}
|
|
|
|
|
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
|
|
|
|
|
}
|
|
|
|
|
exports.saveState = saveState;
|
|
|
|
|
/**
|
|
|
|
@@ -4877,6 +5943,29 @@ function getState(name) {
|
|
|
|
|
return process.env[`STATE_${name}`] || '';
|
|
|
|
|
}
|
|
|
|
|
exports.getState = getState;
|
|
|
|
|
function getIDToken(aud) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
exports.getIDToken = getIDToken;
|
|
|
|
|
/**
|
|
|
|
|
* Summary exports
|
|
|
|
|
*/
|
|
|
|
|
var summary_1 = __webpack_require__(665);
|
|
|
|
|
Object.defineProperty(exports, "summary", { enumerable: true, get: function () { return summary_1.summary; } });
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated use core.summary
|
|
|
|
|
*/
|
|
|
|
|
var summary_2 = __webpack_require__(665);
|
|
|
|
|
Object.defineProperty(exports, "markdownSummary", { enumerable: true, get: function () { return summary_2.markdownSummary; } });
|
|
|
|
|
/**
|
|
|
|
|
* Path exports
|
|
|
|
|
*/
|
|
|
|
|
var path_utils_1 = __webpack_require__(573);
|
|
|
|
|
Object.defineProperty(exports, "toPosixPath", { enumerable: true, get: function () { return path_utils_1.toPosixPath; } });
|
|
|
|
|
Object.defineProperty(exports, "toWin32Path", { enumerable: true, get: function () { return path_utils_1.toWin32Path; } });
|
|
|
|
|
Object.defineProperty(exports, "toPlatformPath", { enumerable: true, get: function () { return path_utils_1.toPlatformPath; } });
|
|
|
|
|
//# sourceMappingURL=core.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
@@ -4963,6 +6052,36 @@ exports.retryHttpClientRequest = retryHttpClientRequest;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 498:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _crypto = _interopRequireDefault(__webpack_require__(417));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
function sha1(bytes) {
|
|
|
|
|
if (Array.isArray(bytes)) {
|
|
|
|
|
bytes = Buffer.from(bytes);
|
|
|
|
|
} else if (typeof bytes === 'string') {
|
|
|
|
|
bytes = Buffer.from(bytes, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _crypto.default.createHash('sha1').update(bytes).digest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = sha1;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 532:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
@@ -5576,374 +6695,141 @@ exports.HttpClient = HttpClient;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 569:
|
|
|
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
|
/***/ 553:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
module.exports = rimraf
|
|
|
|
|
rimraf.sync = rimrafSync
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var assert = __webpack_require__(357)
|
|
|
|
|
var path = __webpack_require__(622)
|
|
|
|
|
var fs = __webpack_require__(747)
|
|
|
|
|
var glob = __webpack_require__(402)
|
|
|
|
|
var _0666 = parseInt('666', 8)
|
|
|
|
|
|
|
|
|
|
var defaultGlobOpts = {
|
|
|
|
|
nosort: true,
|
|
|
|
|
silent: true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// for EMFILE handling
|
|
|
|
|
var timeout = 0
|
|
|
|
|
|
|
|
|
|
var isWindows = (process.platform === "win32")
|
|
|
|
|
|
|
|
|
|
function defaults (options) {
|
|
|
|
|
var methods = [
|
|
|
|
|
'unlink',
|
|
|
|
|
'chmod',
|
|
|
|
|
'stat',
|
|
|
|
|
'lstat',
|
|
|
|
|
'rmdir',
|
|
|
|
|
'readdir'
|
|
|
|
|
]
|
|
|
|
|
methods.forEach(function(m) {
|
|
|
|
|
options[m] = options[m] || fs[m]
|
|
|
|
|
m = m + 'Sync'
|
|
|
|
|
options[m] = options[m] || fs[m]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
options.maxBusyTries = options.maxBusyTries || 3
|
|
|
|
|
options.emfileWait = options.emfileWait || 1000
|
|
|
|
|
if (options.glob === false) {
|
|
|
|
|
options.disableGlob = true
|
|
|
|
|
}
|
|
|
|
|
options.disableGlob = options.disableGlob || false
|
|
|
|
|
options.glob = options.glob || defaultGlobOpts
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rimraf (p, options, cb) {
|
|
|
|
|
if (typeof options === 'function') {
|
|
|
|
|
cb = options
|
|
|
|
|
options = {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(p, 'rimraf: missing path')
|
|
|
|
|
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
|
|
|
|
|
assert.equal(typeof cb, 'function', 'rimraf: callback function required')
|
|
|
|
|
assert(options, 'rimraf: invalid options argument provided')
|
|
|
|
|
assert.equal(typeof options, 'object', 'rimraf: options should be object')
|
|
|
|
|
|
|
|
|
|
defaults(options)
|
|
|
|
|
|
|
|
|
|
var busyTries = 0
|
|
|
|
|
var errState = null
|
|
|
|
|
var n = 0
|
|
|
|
|
|
|
|
|
|
if (options.disableGlob || !glob.hasMagic(p))
|
|
|
|
|
return afterGlob(null, [p])
|
|
|
|
|
|
|
|
|
|
options.lstat(p, function (er, stat) {
|
|
|
|
|
if (!er)
|
|
|
|
|
return afterGlob(null, [p])
|
|
|
|
|
|
|
|
|
|
glob(p, options.glob, afterGlob)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function next (er) {
|
|
|
|
|
errState = errState || er
|
|
|
|
|
if (--n === 0)
|
|
|
|
|
cb(errState)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function afterGlob (er, results) {
|
|
|
|
|
if (er)
|
|
|
|
|
return cb(er)
|
|
|
|
|
|
|
|
|
|
n = results.length
|
|
|
|
|
if (n === 0)
|
|
|
|
|
return cb()
|
|
|
|
|
|
|
|
|
|
results.forEach(function (p) {
|
|
|
|
|
rimraf_(p, options, function CB (er) {
|
|
|
|
|
if (er) {
|
|
|
|
|
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") &&
|
|
|
|
|
busyTries < options.maxBusyTries) {
|
|
|
|
|
busyTries ++
|
|
|
|
|
var time = busyTries * 100
|
|
|
|
|
// try again, with the same exact callback as this one.
|
|
|
|
|
return setTimeout(function () {
|
|
|
|
|
rimraf_(p, options, CB)
|
|
|
|
|
}, time)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this one won't happen if graceful-fs is used.
|
|
|
|
|
if (er.code === "EMFILE" && timeout < options.emfileWait) {
|
|
|
|
|
return setTimeout(function () {
|
|
|
|
|
rimraf_(p, options, CB)
|
|
|
|
|
}, timeout ++)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// already gone
|
|
|
|
|
if (er.code === "ENOENT") er = null
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
const core_1 = __webpack_require__(470);
|
|
|
|
|
/**
|
|
|
|
|
* Invalid characters that cannot be in the artifact name or an uploaded file. Will be rejected
|
|
|
|
|
* from the server if attempted to be sent over. These characters are not allowed due to limitations with certain
|
|
|
|
|
* file systems such as NTFS. To maintain platform-agnostic behavior, all characters that are not supported by an
|
|
|
|
|
* individual filesystem/platform will not be supported on all fileSystems/platforms
|
|
|
|
|
*
|
|
|
|
|
* FilePaths can include characters such as \ and / which are not permitted in the artifact name alone
|
|
|
|
|
*/
|
|
|
|
|
const invalidArtifactFilePathCharacters = new Map([
|
|
|
|
|
['"', ' Double quote "'],
|
|
|
|
|
[':', ' Colon :'],
|
|
|
|
|
['<', ' Less than <'],
|
|
|
|
|
['>', ' Greater than >'],
|
|
|
|
|
['|', ' Vertical bar |'],
|
|
|
|
|
['*', ' Asterisk *'],
|
|
|
|
|
['?', ' Question mark ?'],
|
|
|
|
|
['\r', ' Carriage return \\r'],
|
|
|
|
|
['\n', ' Line feed \\n']
|
|
|
|
|
]);
|
|
|
|
|
const invalidArtifactNameCharacters = new Map([
|
|
|
|
|
...invalidArtifactFilePathCharacters,
|
|
|
|
|
['\\', ' Backslash \\'],
|
|
|
|
|
['/', ' Forward slash /']
|
|
|
|
|
]);
|
|
|
|
|
/**
|
|
|
|
|
* Scans the name of the artifact to make sure there are no illegal characters
|
|
|
|
|
*/
|
|
|
|
|
function checkArtifactName(name) {
|
|
|
|
|
if (!name) {
|
|
|
|
|
throw new Error(`Artifact name: ${name}, is incorrectly provided`);
|
|
|
|
|
}
|
|
|
|
|
for (const [invalidCharacterKey, errorMessageForCharacter] of invalidArtifactNameCharacters) {
|
|
|
|
|
if (name.includes(invalidCharacterKey)) {
|
|
|
|
|
throw new Error(`Artifact name is not valid: ${name}. Contains the following character: ${errorMessageForCharacter}
|
|
|
|
|
|
|
|
|
|
Invalid characters include: ${Array.from(invalidArtifactNameCharacters.values()).toString()}
|
|
|
|
|
|
|
|
|
|
These characters are not allowed in the artifact name due to limitations with certain file systems such as NTFS. To maintain file system agnostic behavior, these characters are intentionally not allowed to prevent potential problems with downloads on different file systems.`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
timeout = 0
|
|
|
|
|
next(er)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Two possible strategies.
|
|
|
|
|
// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
|
|
|
|
|
// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
|
|
|
|
|
//
|
|
|
|
|
// Both result in an extra syscall when you guess wrong. However, there
|
|
|
|
|
// are likely far more normal files in the world than directories. This
|
|
|
|
|
// is based on the assumption that a the average number of files per
|
|
|
|
|
// directory is >= 1.
|
|
|
|
|
//
|
|
|
|
|
// If anyone ever complains about this, then I guess the strategy could
|
|
|
|
|
// be made configurable somehow. But until then, YAGNI.
|
|
|
|
|
function rimraf_ (p, options, cb) {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
|
|
|
|
|
// sunos lets the root user unlink directories, which is... weird.
|
|
|
|
|
// so we have to lstat here and make sure it's not a dir.
|
|
|
|
|
options.lstat(p, function (er, st) {
|
|
|
|
|
if (er && er.code === "ENOENT")
|
|
|
|
|
return cb(null)
|
|
|
|
|
|
|
|
|
|
// Windows can EPERM on stat. Life is suffering.
|
|
|
|
|
if (er && er.code === "EPERM" && isWindows)
|
|
|
|
|
fixWinEPERM(p, options, er, cb)
|
|
|
|
|
|
|
|
|
|
if (st && st.isDirectory())
|
|
|
|
|
return rmdir(p, options, er, cb)
|
|
|
|
|
|
|
|
|
|
options.unlink(p, function (er) {
|
|
|
|
|
if (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return cb(null)
|
|
|
|
|
if (er.code === "EPERM")
|
|
|
|
|
return (isWindows)
|
|
|
|
|
? fixWinEPERM(p, options, er, cb)
|
|
|
|
|
: rmdir(p, options, er, cb)
|
|
|
|
|
if (er.code === "EISDIR")
|
|
|
|
|
return rmdir(p, options, er, cb)
|
|
|
|
|
}
|
|
|
|
|
return cb(er)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fixWinEPERM (p, options, er, cb) {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
if (er)
|
|
|
|
|
assert(er instanceof Error)
|
|
|
|
|
|
|
|
|
|
options.chmod(p, _0666, function (er2) {
|
|
|
|
|
if (er2)
|
|
|
|
|
cb(er2.code === "ENOENT" ? null : er)
|
|
|
|
|
else
|
|
|
|
|
options.stat(p, function(er3, stats) {
|
|
|
|
|
if (er3)
|
|
|
|
|
cb(er3.code === "ENOENT" ? null : er)
|
|
|
|
|
else if (stats.isDirectory())
|
|
|
|
|
rmdir(p, options, er, cb)
|
|
|
|
|
else
|
|
|
|
|
options.unlink(p, cb)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function fixWinEPERMSync (p, options, er) {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
if (er)
|
|
|
|
|
assert(er instanceof Error)
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
options.chmodSync(p, _0666)
|
|
|
|
|
} catch (er2) {
|
|
|
|
|
if (er2.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
throw er
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var stats = options.statSync(p)
|
|
|
|
|
} catch (er3) {
|
|
|
|
|
if (er3.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
throw er
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stats.isDirectory())
|
|
|
|
|
rmdirSync(p, options, er)
|
|
|
|
|
else
|
|
|
|
|
options.unlinkSync(p)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rmdir (p, options, originalEr, cb) {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
if (originalEr)
|
|
|
|
|
assert(originalEr instanceof Error)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
|
|
|
|
|
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
|
|
|
|
|
// if we guessed wrong, and it's not a directory, then
|
|
|
|
|
// raise the original error.
|
|
|
|
|
options.rmdir(p, function (er) {
|
|
|
|
|
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
|
|
|
|
|
rmkids(p, options, cb)
|
|
|
|
|
else if (er && er.code === "ENOTDIR")
|
|
|
|
|
cb(originalEr)
|
|
|
|
|
else
|
|
|
|
|
cb(er)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rmkids(p, options, cb) {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
assert(typeof cb === 'function')
|
|
|
|
|
|
|
|
|
|
options.readdir(p, function (er, files) {
|
|
|
|
|
if (er)
|
|
|
|
|
return cb(er)
|
|
|
|
|
var n = files.length
|
|
|
|
|
if (n === 0)
|
|
|
|
|
return options.rmdir(p, cb)
|
|
|
|
|
var errState
|
|
|
|
|
files.forEach(function (f) {
|
|
|
|
|
rimraf(path.join(p, f), options, function (er) {
|
|
|
|
|
if (errState)
|
|
|
|
|
return
|
|
|
|
|
if (er)
|
|
|
|
|
return cb(errState = er)
|
|
|
|
|
if (--n === 0)
|
|
|
|
|
options.rmdir(p, cb)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// this looks simpler, and is strictly *faster*, but will
|
|
|
|
|
// tie up the JavaScript thread and fail on excessively
|
|
|
|
|
// deep directory trees.
|
|
|
|
|
function rimrafSync (p, options) {
|
|
|
|
|
options = options || {}
|
|
|
|
|
defaults(options)
|
|
|
|
|
|
|
|
|
|
assert(p, 'rimraf: missing path')
|
|
|
|
|
assert.equal(typeof p, 'string', 'rimraf: path should be a string')
|
|
|
|
|
assert(options, 'rimraf: missing options')
|
|
|
|
|
assert.equal(typeof options, 'object', 'rimraf: options should be object')
|
|
|
|
|
|
|
|
|
|
var results
|
|
|
|
|
|
|
|
|
|
if (options.disableGlob || !glob.hasMagic(p)) {
|
|
|
|
|
results = [p]
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
options.lstatSync(p)
|
|
|
|
|
results = [p]
|
|
|
|
|
} catch (er) {
|
|
|
|
|
results = glob.sync(p, options.glob)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!results.length)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < results.length; i++) {
|
|
|
|
|
var p = results[i]
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var st = options.lstatSync(p)
|
|
|
|
|
} catch (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
// Windows can EPERM on stat. Life is suffering.
|
|
|
|
|
if (er.code === "EPERM" && isWindows)
|
|
|
|
|
fixWinEPERMSync(p, options, er)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// sunos lets the root user unlink directories, which is... weird.
|
|
|
|
|
if (st && st.isDirectory())
|
|
|
|
|
rmdirSync(p, options, null)
|
|
|
|
|
else
|
|
|
|
|
options.unlinkSync(p)
|
|
|
|
|
} catch (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
if (er.code === "EPERM")
|
|
|
|
|
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er)
|
|
|
|
|
if (er.code !== "EISDIR")
|
|
|
|
|
throw er
|
|
|
|
|
|
|
|
|
|
rmdirSync(p, options, er)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
core_1.info(`Artifact name is valid!`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rmdirSync (p, options, originalEr) {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
if (originalEr)
|
|
|
|
|
assert(originalEr instanceof Error)
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
options.rmdirSync(p)
|
|
|
|
|
} catch (er) {
|
|
|
|
|
if (er.code === "ENOENT")
|
|
|
|
|
return
|
|
|
|
|
if (er.code === "ENOTDIR")
|
|
|
|
|
throw originalEr
|
|
|
|
|
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
|
|
|
|
|
rmkidsSync(p, options)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function rmkidsSync (p, options) {
|
|
|
|
|
assert(p)
|
|
|
|
|
assert(options)
|
|
|
|
|
options.readdirSync(p).forEach(function (f) {
|
|
|
|
|
rimrafSync(path.join(p, f), options)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// We only end up here once we got ENOTEMPTY at least once, and
|
|
|
|
|
// at this point, we are guaranteed to have removed all the kids.
|
|
|
|
|
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
|
|
|
|
|
// try really hard to delete stuff on windows, because it has a
|
|
|
|
|
// PROFOUNDLY annoying habit of not closing handles promptly when
|
|
|
|
|
// files are deleted, resulting in spurious ENOTEMPTY errors.
|
|
|
|
|
var retries = isWindows ? 100 : 1
|
|
|
|
|
var i = 0
|
|
|
|
|
do {
|
|
|
|
|
var threw = true
|
|
|
|
|
try {
|
|
|
|
|
var ret = options.rmdirSync(p, options)
|
|
|
|
|
threw = false
|
|
|
|
|
return ret
|
|
|
|
|
} finally {
|
|
|
|
|
if (++i < retries && threw)
|
|
|
|
|
continue
|
|
|
|
|
exports.checkArtifactName = checkArtifactName;
|
|
|
|
|
/**
|
|
|
|
|
* Scans the name of the filePath used to make sure there are no illegal characters
|
|
|
|
|
*/
|
|
|
|
|
function checkArtifactFilePath(path) {
|
|
|
|
|
if (!path) {
|
|
|
|
|
throw new Error(`Artifact path: ${path}, is incorrectly provided`);
|
|
|
|
|
}
|
|
|
|
|
for (const [invalidCharacterKey, errorMessageForCharacter] of invalidArtifactFilePathCharacters) {
|
|
|
|
|
if (path.includes(invalidCharacterKey)) {
|
|
|
|
|
throw new Error(`Artifact path is not valid: ${path}. Contains the following character: ${errorMessageForCharacter}
|
|
|
|
|
|
|
|
|
|
Invalid characters include: ${Array.from(invalidArtifactFilePathCharacters.values()).toString()}
|
|
|
|
|
|
|
|
|
|
The following characters are not allowed in files that are uploaded due to limitations with certain file systems such as NTFS. To maintain file system agnostic behavior, these characters are intentionally not allowed to prevent potential problems with downloads on different file systems.
|
|
|
|
|
`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} while (true)
|
|
|
|
|
}
|
|
|
|
|
exports.checkArtifactFilePath = checkArtifactFilePath;
|
|
|
|
|
//# sourceMappingURL=path-and-artifact-name-validation.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 573:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
o[k2] = m[k];
|
|
|
|
|
}));
|
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
|
}) : function(o, v) {
|
|
|
|
|
o["default"] = v;
|
|
|
|
|
});
|
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
|
var result = {};
|
|
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0;
|
|
|
|
|
const path = __importStar(__webpack_require__(622));
|
|
|
|
|
/**
|
|
|
|
|
* toPosixPath converts the given path to the posix form. On Windows, \\ will be
|
|
|
|
|
* replaced with /.
|
|
|
|
|
*
|
|
|
|
|
* @param pth. Path to transform.
|
|
|
|
|
* @return string Posix path.
|
|
|
|
|
*/
|
|
|
|
|
function toPosixPath(pth) {
|
|
|
|
|
return pth.replace(/[\\]/g, '/');
|
|
|
|
|
}
|
|
|
|
|
exports.toPosixPath = toPosixPath;
|
|
|
|
|
/**
|
|
|
|
|
* toWin32Path converts the given path to the win32 form. On Linux, / will be
|
|
|
|
|
* replaced with \\.
|
|
|
|
|
*
|
|
|
|
|
* @param pth. Path to transform.
|
|
|
|
|
* @return string Win32 path.
|
|
|
|
|
*/
|
|
|
|
|
function toWin32Path(pth) {
|
|
|
|
|
return pth.replace(/[/]/g, '\\');
|
|
|
|
|
}
|
|
|
|
|
exports.toWin32Path = toWin32Path;
|
|
|
|
|
/**
|
|
|
|
|
* toPlatformPath converts the given path to a platform-specific path. It does
|
|
|
|
|
* this by replacing instances of / and \ with the platform-specific path
|
|
|
|
|
* separator.
|
|
|
|
|
*
|
|
|
|
|
* @param pth The path to platformize.
|
|
|
|
|
* @return string The platform-specific path.
|
|
|
|
|
*/
|
|
|
|
|
function toPlatformPath(pth) {
|
|
|
|
|
return pth.replace(/[/\\]/g, path.sep);
|
|
|
|
|
}
|
|
|
|
|
exports.toPlatformPath = toPlatformPath;
|
|
|
|
|
//# sourceMappingURL=path-utils.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
@@ -5963,7 +6849,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
const fs = __importStar(__webpack_require__(747));
|
|
|
|
|
const core_1 = __webpack_require__(470);
|
|
|
|
|
const path_1 = __webpack_require__(622);
|
|
|
|
|
const utils_1 = __webpack_require__(870);
|
|
|
|
|
const path_and_artifact_name_validation_1 = __webpack_require__(553);
|
|
|
|
|
/**
|
|
|
|
|
* Creates a specification that describes how each file that is part of the artifact will be uploaded
|
|
|
|
|
* @param artifactName the name of the artifact being uploaded. Used during upload to denote where the artifact is stored on the server
|
|
|
|
@@ -5971,7 +6857,7 @@ const utils_1 = __webpack_require__(870);
|
|
|
|
|
* @param artifactFiles a list of absolute file paths that denote what should be uploaded as part of the artifact
|
|
|
|
|
*/
|
|
|
|
|
function getUploadSpecification(artifactName, rootDirectory, artifactFiles) {
|
|
|
|
|
utils_1.checkArtifactName(artifactName);
|
|
|
|
|
// artifact name was checked earlier on, no need to check again
|
|
|
|
|
const specifications = [];
|
|
|
|
|
if (!fs.existsSync(rootDirectory)) {
|
|
|
|
|
throw new Error(`Provided rootDirectory ${rootDirectory} does not exist`);
|
|
|
|
@@ -6014,7 +6900,7 @@ function getUploadSpecification(artifactName, rootDirectory, artifactFiles) {
|
|
|
|
|
}
|
|
|
|
|
// Check for forbidden characters in file paths that will be rejected during upload
|
|
|
|
|
const uploadPath = file.replace(rootDirectory, '');
|
|
|
|
|
utils_1.checkArtifactFilePath(uploadPath);
|
|
|
|
|
path_and_artifact_name_validation_1.checkArtifactFilePath(uploadPath);
|
|
|
|
|
/*
|
|
|
|
|
uploadFilePath denotes where the file will be uploaded in the file container on the server. During a run, if multiple artifacts are uploaded, they will all
|
|
|
|
|
be saved in the same container. The artifact name is used as the root directory in the container to separate and distinguish uploaded artifacts
|
|
|
|
@@ -6216,27 +7102,35 @@ class UploadHttpClient {
|
|
|
|
|
*/
|
|
|
|
|
uploadFileAsync(httpClientIndex, parameters) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const totalFileSize = (yield stat(parameters.file)).size;
|
|
|
|
|
const fileStat = yield stat(parameters.file);
|
|
|
|
|
const totalFileSize = fileStat.size;
|
|
|
|
|
// on Windows with mkfifo from MSYS2 stats.isFIFO returns false, so we check if running on Windows node and
|
|
|
|
|
// if the file has size of 0 to compensate
|
|
|
|
|
const isFIFO = fileStat.isFIFO() || (process.platform === 'win32' && totalFileSize === 0);
|
|
|
|
|
let offset = 0;
|
|
|
|
|
let isUploadSuccessful = true;
|
|
|
|
|
let failedChunkSizes = 0;
|
|
|
|
|
let uploadFileSize = 0;
|
|
|
|
|
let isGzip = true;
|
|
|
|
|
// the file that is being uploaded is less than 64k in size, to increase throughput and to minimize disk I/O
|
|
|
|
|
// the file that is being uploaded is less than 64k in size to increase throughput and to minimize disk I/O
|
|
|
|
|
// for creating a new GZip file, an in-memory buffer is used for compression
|
|
|
|
|
if (totalFileSize < 65536) {
|
|
|
|
|
// with named pipes the file size is reported as zero in that case don't read the file in memory
|
|
|
|
|
if (!isFIFO && totalFileSize < 65536) {
|
|
|
|
|
core.debug(`${parameters.file} is less than 64k in size. Creating a gzip file in-memory to potentially reduce the upload size`);
|
|
|
|
|
const buffer = yield upload_gzip_1.createGZipFileInBuffer(parameters.file);
|
|
|
|
|
//An open stream is needed in the event of a failure and we need to retry. If a NodeJS.ReadableStream is directly passed in,
|
|
|
|
|
// An open stream is needed in the event of a failure and we need to retry. If a NodeJS.ReadableStream is directly passed in,
|
|
|
|
|
// it will not properly get reset to the start of the stream if a chunk upload needs to be retried
|
|
|
|
|
let openUploadStream;
|
|
|
|
|
if (totalFileSize < buffer.byteLength) {
|
|
|
|
|
// compression did not help with reducing the size, use a readable stream from the original file for upload
|
|
|
|
|
core.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`);
|
|
|
|
|
openUploadStream = () => fs.createReadStream(parameters.file);
|
|
|
|
|
isGzip = false;
|
|
|
|
|
uploadFileSize = totalFileSize;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// create a readable stream using a PassThrough stream that is both readable and writable
|
|
|
|
|
core.debug(`A gzip file created for ${parameters.file} helped with reducing the size of the original file. The file will be uploaded using gzip.`);
|
|
|
|
|
openUploadStream = () => {
|
|
|
|
|
const passThrough = new stream.PassThrough();
|
|
|
|
|
passThrough.end(buffer);
|
|
|
|
@@ -6261,25 +7155,27 @@ class UploadHttpClient {
|
|
|
|
|
// the file that is being uploaded is greater than 64k in size, a temporary file gets created on disk using the
|
|
|
|
|
// npm tmp-promise package and this file gets used to create a GZipped file
|
|
|
|
|
const tempFile = yield tmp.file();
|
|
|
|
|
core.debug(`${parameters.file} is greater than 64k in size. Creating a gzip file on-disk ${tempFile.path} to potentially reduce the upload size`);
|
|
|
|
|
// create a GZip file of the original file being uploaded, the original file should not be modified in any way
|
|
|
|
|
uploadFileSize = yield upload_gzip_1.createGZipFileOnDisk(parameters.file, tempFile.path);
|
|
|
|
|
let uploadFilePath = tempFile.path;
|
|
|
|
|
// compression did not help with size reduction, use the original file for upload and delete the temp GZip file
|
|
|
|
|
if (totalFileSize < uploadFileSize) {
|
|
|
|
|
// for named pipes totalFileSize is zero, this assumes compression did help
|
|
|
|
|
if (!isFIFO && totalFileSize < uploadFileSize) {
|
|
|
|
|
core.debug(`The gzip file created for ${parameters.file} did not help with reducing the size of the file. The original file will be uploaded as-is`);
|
|
|
|
|
uploadFileSize = totalFileSize;
|
|
|
|
|
uploadFilePath = parameters.file;
|
|
|
|
|
isGzip = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
core.debug(`The gzip file created for ${parameters.file} is smaller than the original file. The file will be uploaded using gzip.`);
|
|
|
|
|
}
|
|
|
|
|
let abortFileUpload = false;
|
|
|
|
|
// upload only a single chunk at a time
|
|
|
|
|
while (offset < uploadFileSize) {
|
|
|
|
|
const chunkSize = Math.min(uploadFileSize - offset, parameters.maxChunkSize);
|
|
|
|
|
// if an individual file is greater than 100MB (1024*1024*100) in size, display extra information about the upload status
|
|
|
|
|
if (uploadFileSize > 104857600) {
|
|
|
|
|
this.statusReporter.updateLargeFileStatus(parameters.file, offset, uploadFileSize);
|
|
|
|
|
}
|
|
|
|
|
const start = offset;
|
|
|
|
|
const end = offset + chunkSize - 1;
|
|
|
|
|
const startChunkIndex = offset;
|
|
|
|
|
const endChunkIndex = offset + chunkSize - 1;
|
|
|
|
|
offset += parameters.maxChunkSize;
|
|
|
|
|
if (abortFileUpload) {
|
|
|
|
|
// if we don't want to continue in the event of an error, any pending upload chunks will be marked as failed
|
|
|
|
@@ -6287,10 +7183,10 @@ class UploadHttpClient {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
const result = yield this.uploadChunk(httpClientIndex, parameters.resourceUrl, () => fs.createReadStream(uploadFilePath, {
|
|
|
|
|
start,
|
|
|
|
|
end,
|
|
|
|
|
start: startChunkIndex,
|
|
|
|
|
end: endChunkIndex,
|
|
|
|
|
autoClose: false
|
|
|
|
|
}), start, end, uploadFileSize, isGzip, totalFileSize);
|
|
|
|
|
}), startChunkIndex, endChunkIndex, uploadFileSize, isGzip, totalFileSize);
|
|
|
|
|
if (!result) {
|
|
|
|
|
// Chunk failed to upload, report as failed and do not continue uploading any more chunks for the file. It is possible that part of a chunk was
|
|
|
|
|
// successfully uploaded so the server may report a different size for what was uploaded
|
|
|
|
@@ -6299,9 +7195,16 @@ class UploadHttpClient {
|
|
|
|
|
core.warning(`Aborting upload for ${parameters.file} due to failure`);
|
|
|
|
|
abortFileUpload = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// if an individual file is greater than 8MB (1024*1024*8) in size, display extra information about the upload status
|
|
|
|
|
if (uploadFileSize > 8388608) {
|
|
|
|
|
this.statusReporter.updateLargeFileStatus(parameters.file, startChunkIndex, endChunkIndex, uploadFileSize);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Delete the temporary file that was created as part of the upload. If the temp file does not get manually deleted by
|
|
|
|
|
// calling cleanup, it gets removed when the node process exits. For more info see: https://www.npmjs.com/package/tmp-promise#about
|
|
|
|
|
core.debug(`deleting temporary gzip file ${tempFile.path}`);
|
|
|
|
|
yield tempFile.cleanup();
|
|
|
|
|
return {
|
|
|
|
|
isSuccess: isUploadSuccessful,
|
|
|
|
@@ -6563,6 +7466,19 @@ const fs = __importStar(__webpack_require__(747));
|
|
|
|
|
const zlib = __importStar(__webpack_require__(761));
|
|
|
|
|
const util_1 = __webpack_require__(669);
|
|
|
|
|
const stat = util_1.promisify(fs.stat);
|
|
|
|
|
/**
|
|
|
|
|
* GZipping certain files that are already compressed will likely not yield further size reductions. Creating large temporary gzip
|
|
|
|
|
* files then will just waste a lot of time before ultimately being discarded (especially for very large files).
|
|
|
|
|
* If any of these types of files are encountered then on-disk gzip creation will be skipped and the original file will be uploaded as-is
|
|
|
|
|
*/
|
|
|
|
|
const gzipExemptFileExtensions = [
|
|
|
|
|
'.gzip',
|
|
|
|
|
'.zip',
|
|
|
|
|
'.tar.lz',
|
|
|
|
|
'.tar.gz',
|
|
|
|
|
'.tar.bz2',
|
|
|
|
|
'.7z'
|
|
|
|
|
];
|
|
|
|
|
/**
|
|
|
|
|
* Creates a Gzip compressed file of an original file at the provided temporary filepath location
|
|
|
|
|
* @param {string} originalFilePath filepath of whatever will be compressed. The original file will be unmodified
|
|
|
|
@@ -6571,6 +7487,12 @@ const stat = util_1.promisify(fs.stat);
|
|
|
|
|
*/
|
|
|
|
|
function createGZipFileOnDisk(originalFilePath, tempFilePath) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
for (const gzipExemptExtension of gzipExemptFileExtensions) {
|
|
|
|
|
if (originalFilePath.endsWith(gzipExemptExtension)) {
|
|
|
|
|
// return a really large number so that the original file gets uploaded
|
|
|
|
|
return Number.MAX_SAFE_INTEGER;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const inputStream = fs.createReadStream(originalFilePath);
|
|
|
|
|
const gzip = zlib.createGzip();
|
|
|
|
@@ -6626,6 +7548,296 @@ exports.createGZipFileInBuffer = createGZipFileInBuffer;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 665:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
|
|
|
|
|
const os_1 = __webpack_require__(87);
|
|
|
|
|
const fs_1 = __webpack_require__(747);
|
|
|
|
|
const { access, appendFile, writeFile } = fs_1.promises;
|
|
|
|
|
exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY';
|
|
|
|
|
exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary';
|
|
|
|
|
class Summary {
|
|
|
|
|
constructor() {
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Finds the summary file path from the environment, rejects if env var is not found or file does not exist
|
|
|
|
|
* Also checks r/w permissions.
|
|
|
|
|
*
|
|
|
|
|
* @returns step summary file path
|
|
|
|
|
*/
|
|
|
|
|
filePath() {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
if (this._filePath) {
|
|
|
|
|
return this._filePath;
|
|
|
|
|
}
|
|
|
|
|
const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR];
|
|
|
|
|
if (!pathFromEnv) {
|
|
|
|
|
throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK);
|
|
|
|
|
}
|
|
|
|
|
catch (_a) {
|
|
|
|
|
throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`);
|
|
|
|
|
}
|
|
|
|
|
this._filePath = pathFromEnv;
|
|
|
|
|
return this._filePath;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Wraps content in an HTML tag, adding any HTML attributes
|
|
|
|
|
*
|
|
|
|
|
* @param {string} tag HTML tag to wrap
|
|
|
|
|
* @param {string | null} content content within the tag
|
|
|
|
|
* @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
|
|
|
|
|
*
|
|
|
|
|
* @returns {string} content wrapped in HTML element
|
|
|
|
|
*/
|
|
|
|
|
wrap(tag, content, attrs = {}) {
|
|
|
|
|
const htmlAttrs = Object.entries(attrs)
|
|
|
|
|
.map(([key, value]) => ` ${key}="${value}"`)
|
|
|
|
|
.join('');
|
|
|
|
|
if (!content) {
|
|
|
|
|
return `<${tag}${htmlAttrs}>`;
|
|
|
|
|
}
|
|
|
|
|
return `<${tag}${htmlAttrs}>${content}</${tag}>`;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
|
|
|
|
|
*
|
|
|
|
|
* @param {SummaryWriteOptions} [options] (optional) options for write operation
|
|
|
|
|
*
|
|
|
|
|
* @returns {Promise<Summary>} summary instance
|
|
|
|
|
*/
|
|
|
|
|
write(options) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
|
|
|
|
|
const filePath = yield this.filePath();
|
|
|
|
|
const writeFunc = overwrite ? writeFile : appendFile;
|
|
|
|
|
yield writeFunc(filePath, this._buffer, { encoding: 'utf8' });
|
|
|
|
|
return this.emptyBuffer();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Clears the summary buffer and wipes the summary file
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
clear() {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.emptyBuffer().write({ overwrite: true });
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Returns the current summary buffer as a string
|
|
|
|
|
*
|
|
|
|
|
* @returns {string} string of summary buffer
|
|
|
|
|
*/
|
|
|
|
|
stringify() {
|
|
|
|
|
return this._buffer;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* If the summary buffer is empty
|
|
|
|
|
*
|
|
|
|
|
* @returns {boolen} true if the buffer is empty
|
|
|
|
|
*/
|
|
|
|
|
isEmptyBuffer() {
|
|
|
|
|
return this._buffer.length === 0;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Resets the summary buffer without writing to summary file
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
emptyBuffer() {
|
|
|
|
|
this._buffer = '';
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds raw text to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {string} text content to add
|
|
|
|
|
* @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addRaw(text, addEOL = false) {
|
|
|
|
|
this._buffer += text;
|
|
|
|
|
return addEOL ? this.addEOL() : this;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds the operating system-specific end-of-line marker to the buffer
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addEOL() {
|
|
|
|
|
return this.addRaw(os_1.EOL);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML codeblock to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {string} code content to render within fenced code block
|
|
|
|
|
* @param {string} lang (optional) language to syntax highlight code
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addCodeBlock(code, lang) {
|
|
|
|
|
const attrs = Object.assign({}, (lang && { lang }));
|
|
|
|
|
const element = this.wrap('pre', this.wrap('code', code), attrs);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML list to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {string[]} items list of items to render
|
|
|
|
|
* @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addList(items, ordered = false) {
|
|
|
|
|
const tag = ordered ? 'ol' : 'ul';
|
|
|
|
|
const listItems = items.map(item => this.wrap('li', item)).join('');
|
|
|
|
|
const element = this.wrap(tag, listItems);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML table to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {SummaryTableCell[]} rows table rows
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addTable(rows) {
|
|
|
|
|
const tableBody = rows
|
|
|
|
|
.map(row => {
|
|
|
|
|
const cells = row
|
|
|
|
|
.map(cell => {
|
|
|
|
|
if (typeof cell === 'string') {
|
|
|
|
|
return this.wrap('td', cell);
|
|
|
|
|
}
|
|
|
|
|
const { header, data, colspan, rowspan } = cell;
|
|
|
|
|
const tag = header ? 'th' : 'td';
|
|
|
|
|
const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan }));
|
|
|
|
|
return this.wrap(tag, data, attrs);
|
|
|
|
|
})
|
|
|
|
|
.join('');
|
|
|
|
|
return this.wrap('tr', cells);
|
|
|
|
|
})
|
|
|
|
|
.join('');
|
|
|
|
|
const element = this.wrap('table', tableBody);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds a collapsable HTML details element to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {string} label text for the closed state
|
|
|
|
|
* @param {string} content collapsable content
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addDetails(label, content) {
|
|
|
|
|
const element = this.wrap('details', this.wrap('summary', label) + content);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML image tag to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {string} src path to the image you to embed
|
|
|
|
|
* @param {string} alt text description of the image
|
|
|
|
|
* @param {SummaryImageOptions} options (optional) addition image attributes
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addImage(src, alt, options) {
|
|
|
|
|
const { width, height } = options || {};
|
|
|
|
|
const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height }));
|
|
|
|
|
const element = this.wrap('img', null, Object.assign({ src, alt }, attrs));
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML section heading element
|
|
|
|
|
*
|
|
|
|
|
* @param {string} text heading text
|
|
|
|
|
* @param {number | string} [level=1] (optional) the heading level, default: 1
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addHeading(text, level) {
|
|
|
|
|
const tag = `h${level}`;
|
|
|
|
|
const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag)
|
|
|
|
|
? tag
|
|
|
|
|
: 'h1';
|
|
|
|
|
const element = this.wrap(allowedTag, text);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML thematic break (<hr>) to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addSeparator() {
|
|
|
|
|
const element = this.wrap('hr', null);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML line break (<br>) to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addBreak() {
|
|
|
|
|
const element = this.wrap('br', null);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML blockquote to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {string} text quote text
|
|
|
|
|
* @param {string} cite (optional) citation url
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addQuote(text, cite) {
|
|
|
|
|
const attrs = Object.assign({}, (cite && { cite }));
|
|
|
|
|
const element = this.wrap('blockquote', text, attrs);
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Adds an HTML anchor tag to the summary buffer
|
|
|
|
|
*
|
|
|
|
|
* @param {string} text link text/content
|
|
|
|
|
* @param {string} href hyperlink
|
|
|
|
|
*
|
|
|
|
|
* @returns {Summary} summary instance
|
|
|
|
|
*/
|
|
|
|
|
addLink(text, href) {
|
|
|
|
|
const element = this.wrap('a', text, { href });
|
|
|
|
|
return this.addRaw(element).addEOL();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const _summary = new Summary();
|
|
|
|
|
/**
|
|
|
|
|
* @deprecated use `core.summary`
|
|
|
|
|
*/
|
|
|
|
|
exports.markdownSummary = _summary;
|
|
|
|
|
exports.summary = _summary;
|
|
|
|
|
//# sourceMappingURL=summary.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 669:
|
|
|
|
|
/***/ (function(module) {
|
|
|
|
|
|
|
|
|
@@ -6755,6 +7967,162 @@ var Outputs;
|
|
|
|
|
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 695:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _validate = _interopRequireDefault(__webpack_require__(78));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
function version(uuid) {
|
|
|
|
|
if (!(0, _validate.default)(uuid)) {
|
|
|
|
|
throw TypeError('Invalid UUID');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parseInt(uuid.substr(14, 1), 16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = version;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 733:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _rng = _interopRequireDefault(__webpack_require__(844));
|
|
|
|
|
|
|
|
|
|
var _stringify = _interopRequireDefault(__webpack_require__(411));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
function v4(options, buf, offset) {
|
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
|
|
const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
|
|
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
|
|
|
|
|
|
|
|
if (buf) {
|
|
|
|
|
offset = offset || 0;
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < 16; ++i) {
|
|
|
|
|
buf[offset + i] = rnds[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (0, _stringify.default)(rnds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = v4;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 742:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.OidcClient = void 0;
|
|
|
|
|
const http_client_1 = __webpack_require__(993);
|
|
|
|
|
const auth_1 = __webpack_require__(363);
|
|
|
|
|
const core_1 = __webpack_require__(470);
|
|
|
|
|
class OidcClient {
|
|
|
|
|
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
|
|
|
|
const requestOptions = {
|
|
|
|
|
allowRetries: allowRetry,
|
|
|
|
|
maxRetries: maxRetry
|
|
|
|
|
};
|
|
|
|
|
return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
|
|
|
|
|
}
|
|
|
|
|
static getRequestToken() {
|
|
|
|
|
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
|
|
|
|
|
if (!token) {
|
|
|
|
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
|
|
|
|
|
}
|
|
|
|
|
return token;
|
|
|
|
|
}
|
|
|
|
|
static getIDTokenUrl() {
|
|
|
|
|
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
|
|
|
|
|
if (!runtimeUrl) {
|
|
|
|
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
|
|
|
|
|
}
|
|
|
|
|
return runtimeUrl;
|
|
|
|
|
}
|
|
|
|
|
static getCall(id_token_url) {
|
|
|
|
|
var _a;
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const httpclient = OidcClient.createHttpClient();
|
|
|
|
|
const res = yield httpclient
|
|
|
|
|
.getJson(id_token_url)
|
|
|
|
|
.catch(error => {
|
|
|
|
|
throw new Error(`Failed to get ID Token. \n
|
|
|
|
|
Error Code : ${error.statusCode}\n
|
|
|
|
|
Error Message: ${error.result.message}`);
|
|
|
|
|
});
|
|
|
|
|
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
|
|
|
|
if (!id_token) {
|
|
|
|
|
throw new Error('Response json body do not have ID Token field');
|
|
|
|
|
}
|
|
|
|
|
return id_token;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
static getIDToken(audience) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
try {
|
|
|
|
|
// New ID Token is requested from action service
|
|
|
|
|
let id_token_url = OidcClient.getIDTokenUrl();
|
|
|
|
|
if (audience) {
|
|
|
|
|
const encodedAudience = encodeURIComponent(audience);
|
|
|
|
|
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
|
|
|
|
|
}
|
|
|
|
|
core_1.debug(`ID token url is ${id_token_url}`);
|
|
|
|
|
const id_token = yield OidcClient.getCall(id_token_url);
|
|
|
|
|
core_1.setSecret(id_token);
|
|
|
|
|
return id_token;
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
|
|
|
|
throw new Error(`Error message: ${error.message}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.OidcClient = OidcClient;
|
|
|
|
|
//# sourceMappingURL=oidc-utils.js.map
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 747:
|
|
|
|
@@ -6852,6 +8220,36 @@ function run() {
|
|
|
|
|
run();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 803:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _crypto = _interopRequireDefault(__webpack_require__(417));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
function md5(bytes) {
|
|
|
|
|
if (Array.isArray(bytes)) {
|
|
|
|
|
bytes = Buffer.from(bytes);
|
|
|
|
|
} else if (typeof bytes === 'string') {
|
|
|
|
|
bytes = Buffer.from(bytes, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _crypto.default.createHash('md5').update(bytes).digest();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = md5;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 835:
|
|
|
|
@@ -6861,6 +8259,37 @@ module.exports = require("url");
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 844:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = rng;
|
|
|
|
|
|
|
|
|
|
var _crypto = _interopRequireDefault(__webpack_require__(417));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
|
|
|
|
|
|
|
|
|
|
let poolPtr = rnds8Pool.length;
|
|
|
|
|
|
|
|
|
|
function rng() {
|
|
|
|
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
|
|
|
_crypto.default.randomFillSync(rnds8Pool);
|
|
|
|
|
|
|
|
|
|
poolPtr = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 855:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
@@ -7034,9 +8463,6 @@ class DownloadHttpClient {
|
|
|
|
|
let response;
|
|
|
|
|
try {
|
|
|
|
|
response = yield makeDownloadRequest();
|
|
|
|
|
if (core.isDebug()) {
|
|
|
|
|
utils_1.displayHttpDiagnostics(response);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (error) {
|
|
|
|
|
// if an error is caught, it is usually indicative of a timeout so retry the download
|
|
|
|
@@ -7424,7 +8850,7 @@ function getExponentialRetryTimeInMilliseconds(retryCount) {
|
|
|
|
|
const minTime = config_variables_1.getInitialRetryIntervalInMilliseconds() * config_variables_1.getRetryMultiplier() * retryCount;
|
|
|
|
|
const maxTime = minTime * config_variables_1.getRetryMultiplier();
|
|
|
|
|
// returns a random number between the minTime (inclusive) and the maxTime (exclusive)
|
|
|
|
|
return Math.random() * (maxTime - minTime) + minTime;
|
|
|
|
|
return Math.trunc(Math.random() * (maxTime - minTime) + minTime);
|
|
|
|
|
}
|
|
|
|
|
exports.getExponentialRetryTimeInMilliseconds = getExponentialRetryTimeInMilliseconds;
|
|
|
|
|
/**
|
|
|
|
@@ -7465,8 +8891,9 @@ function isRetryableStatusCode(statusCode) {
|
|
|
|
|
}
|
|
|
|
|
const retryableStatusCodes = [
|
|
|
|
|
http_client_1.HttpCodes.BadGateway,
|
|
|
|
|
http_client_1.HttpCodes.ServiceUnavailable,
|
|
|
|
|
http_client_1.HttpCodes.GatewayTimeout,
|
|
|
|
|
http_client_1.HttpCodes.InternalServerError,
|
|
|
|
|
http_client_1.HttpCodes.ServiceUnavailable,
|
|
|
|
|
http_client_1.HttpCodes.TooManyRequests,
|
|
|
|
|
413 // Payload Too Large
|
|
|
|
|
];
|
|
|
|
@@ -7602,48 +9029,6 @@ Header Information: ${JSON.stringify(response.message.headers, undefined, 2)}
|
|
|
|
|
###### End Diagnostic HTTP information ######`);
|
|
|
|
|
}
|
|
|
|
|
exports.displayHttpDiagnostics = displayHttpDiagnostics;
|
|
|
|
|
/**
|
|
|
|
|
* Invalid characters that cannot be in the artifact name or an uploaded file. Will be rejected
|
|
|
|
|
* from the server if attempted to be sent over. These characters are not allowed due to limitations with certain
|
|
|
|
|
* file systems such as NTFS. To maintain platform-agnostic behavior, all characters that are not supported by an
|
|
|
|
|
* individual filesystem/platform will not be supported on all fileSystems/platforms
|
|
|
|
|
*
|
|
|
|
|
* FilePaths can include characters such as \ and / which are not permitted in the artifact name alone
|
|
|
|
|
*/
|
|
|
|
|
const invalidArtifactFilePathCharacters = ['"', ':', '<', '>', '|', '*', '?'];
|
|
|
|
|
const invalidArtifactNameCharacters = [
|
|
|
|
|
...invalidArtifactFilePathCharacters,
|
|
|
|
|
'\\',
|
|
|
|
|
'/'
|
|
|
|
|
];
|
|
|
|
|
/**
|
|
|
|
|
* Scans the name of the artifact to make sure there are no illegal characters
|
|
|
|
|
*/
|
|
|
|
|
function checkArtifactName(name) {
|
|
|
|
|
if (!name) {
|
|
|
|
|
throw new Error(`Artifact name: ${name}, is incorrectly provided`);
|
|
|
|
|
}
|
|
|
|
|
for (const invalidChar of invalidArtifactNameCharacters) {
|
|
|
|
|
if (name.includes(invalidChar)) {
|
|
|
|
|
throw new Error(`Artifact name is not valid: ${name}. Contains character: "${invalidChar}". Invalid artifact name characters include: ${invalidArtifactNameCharacters.toString()}.`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.checkArtifactName = checkArtifactName;
|
|
|
|
|
/**
|
|
|
|
|
* Scans the name of the filePath used to make sure there are no illegal characters
|
|
|
|
|
*/
|
|
|
|
|
function checkArtifactFilePath(path) {
|
|
|
|
|
if (!path) {
|
|
|
|
|
throw new Error(`Artifact path: ${path}, is incorrectly provided`);
|
|
|
|
|
}
|
|
|
|
|
for (const invalidChar of invalidArtifactFilePathCharacters) {
|
|
|
|
|
if (path.includes(invalidChar)) {
|
|
|
|
|
throw new Error(`Artifact path is not valid: ${path}. Contains character: "${invalidChar}". Invalid characters include: ${invalidArtifactFilePathCharacters.toString()}.`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.checkArtifactFilePath = checkArtifactFilePath;
|
|
|
|
|
function createDirectoriesForArtifact(directories) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
for (const directory of directories) {
|
|
|
|
@@ -7704,7 +9089,10 @@ exports.sleep = sleep;
|
|
|
|
|
/***/ 875:
|
|
|
|
|
/***/ (function(module, __unusedexports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
const {promisify} = __webpack_require__(669);
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { promisify } = __webpack_require__(669);
|
|
|
|
|
const tmp = __webpack_require__(150);
|
|
|
|
|
|
|
|
|
|
// file
|
|
|
|
@@ -7754,6 +9142,120 @@ module.exports.tmpdir = tmp.tmpdir;
|
|
|
|
|
module.exports.setGracefulCleanup = tmp.setGracefulCleanup;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 893:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
|
|
|
value: true
|
|
|
|
|
});
|
|
|
|
|
exports.default = void 0;
|
|
|
|
|
|
|
|
|
|
var _rng = _interopRequireDefault(__webpack_require__(844));
|
|
|
|
|
|
|
|
|
|
var _stringify = _interopRequireDefault(__webpack_require__(411));
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
// **`v1()` - Generate time-based UUID**
|
|
|
|
|
//
|
|
|
|
|
// Inspired by https://github.com/LiosK/UUID.js
|
|
|
|
|
// and http://docs.python.org/library/uuid.html
|
|
|
|
|
let _nodeId;
|
|
|
|
|
|
|
|
|
|
let _clockseq; // Previous uuid creation time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let _lastMSecs = 0;
|
|
|
|
|
let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
|
|
|
|
|
|
|
|
|
|
function v1(options, buf, offset) {
|
|
|
|
|
let i = buf && offset || 0;
|
|
|
|
|
const b = buf || new Array(16);
|
|
|
|
|
options = options || {};
|
|
|
|
|
let node = options.node || _nodeId;
|
|
|
|
|
let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
|
|
|
|
|
// specified. We do this lazily to minimize issues related to insufficient
|
|
|
|
|
// system entropy. See #189
|
|
|
|
|
|
|
|
|
|
if (node == null || clockseq == null) {
|
|
|
|
|
const seedBytes = options.random || (options.rng || _rng.default)();
|
|
|
|
|
|
|
|
|
|
if (node == null) {
|
|
|
|
|
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
|
|
|
|
node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clockseq == null) {
|
|
|
|
|
// Per 4.2.2, randomize (14 bit) clockseq
|
|
|
|
|
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
|
|
|
|
|
}
|
|
|
|
|
} // UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
|
|
|
|
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
|
|
|
|
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
|
|
|
|
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
|
|
|
|
|
// cycle to simulate higher resolution clock
|
|
|
|
|
|
|
|
|
|
let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
|
|
|
|
|
|
|
|
|
|
const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
|
|
|
|
|
|
|
|
|
|
if (dt < 0 && options.clockseq === undefined) {
|
|
|
|
|
clockseq = clockseq + 1 & 0x3fff;
|
|
|
|
|
} // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
|
|
|
|
// time interval
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
|
|
|
|
|
nsecs = 0;
|
|
|
|
|
} // Per 4.2.1.2 Throw error if too many uuids are requested
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (nsecs >= 10000) {
|
|
|
|
|
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_lastMSecs = msecs;
|
|
|
|
|
_lastNSecs = nsecs;
|
|
|
|
|
_clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
|
|
|
|
|
|
|
|
|
msecs += 12219292800000; // `time_low`
|
|
|
|
|
|
|
|
|
|
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
|
|
|
|
b[i++] = tl >>> 24 & 0xff;
|
|
|
|
|
b[i++] = tl >>> 16 & 0xff;
|
|
|
|
|
b[i++] = tl >>> 8 & 0xff;
|
|
|
|
|
b[i++] = tl & 0xff; // `time_mid`
|
|
|
|
|
|
|
|
|
|
const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
|
|
|
|
|
b[i++] = tmh >>> 8 & 0xff;
|
|
|
|
|
b[i++] = tmh & 0xff; // `time_high_and_version`
|
|
|
|
|
|
|
|
|
|
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
|
|
|
|
|
|
|
|
|
|
b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
|
|
|
|
|
|
|
|
|
b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
|
|
|
|
|
|
|
|
|
|
b[i++] = clockseq & 0xff; // `node`
|
|
|
|
|
|
|
|
|
|
for (let n = 0; n < 6; ++n) {
|
|
|
|
|
b[i + n] = node[n];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buf || (0, _stringify.default)(b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var _default = v1;
|
|
|
|
|
exports.default = _default;
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 896:
|
|
|
|
@@ -7839,6 +9341,618 @@ function checkBypass(reqUrl) {
|
|
|
|
|
exports.checkBypass = checkBypass;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
|
|
/***/ 993:
|
|
|
|
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
|
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
|
|
|
}) : (function(o, m, k, k2) {
|
|
|
|
|
if (k2 === undefined) k2 = k;
|
|
|
|
|
o[k2] = m[k];
|
|
|
|
|
}));
|
|
|
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
|
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
|
|
|
}) : function(o, v) {
|
|
|
|
|
o["default"] = v;
|
|
|
|
|
});
|
|
|
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
|
|
if (mod && mod.__esModule) return mod;
|
|
|
|
|
var result = {};
|
|
|
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
|
|
|
__setModuleDefault(result, mod);
|
|
|
|
|
return result;
|
|
|
|
|
};
|
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
|
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
|
|
|
|
const http = __importStar(__webpack_require__(605));
|
|
|
|
|
const https = __importStar(__webpack_require__(211));
|
|
|
|
|
const pm = __importStar(__webpack_require__(95));
|
|
|
|
|
const tunnel = __importStar(__webpack_require__(413));
|
|
|
|
|
var HttpCodes;
|
|
|
|
|
(function (HttpCodes) {
|
|
|
|
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
|
|
|
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
|
|
|
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
|
|
|
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
|
|
|
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
|
|
|
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
|
|
|
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
|
|
|
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
|
|
|
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
|
|
|
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
|
|
|
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
|
|
|
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
|
|
|
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
|
|
|
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
|
|
|
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
|
|
|
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
|
|
|
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
|
|
|
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
|
|
|
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
|
|
|
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
|
|
|
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
|
|
|
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
|
|
|
|
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
|
|
|
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
|
|
|
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
|
|
|
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
|
|
|
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
|
|
|
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
|
|
|
var Headers;
|
|
|
|
|
(function (Headers) {
|
|
|
|
|
Headers["Accept"] = "accept";
|
|
|
|
|
Headers["ContentType"] = "content-type";
|
|
|
|
|
})(Headers = exports.Headers || (exports.Headers = {}));
|
|
|
|
|
var MediaTypes;
|
|
|
|
|
(function (MediaTypes) {
|
|
|
|
|
MediaTypes["ApplicationJson"] = "application/json";
|
|
|
|
|
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
|
|
|
|
/**
|
|
|
|
|
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
|
|
|
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
|
|
|
*/
|
|
|
|
|
function getProxyUrl(serverUrl) {
|
|
|
|
|
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
|
|
|
|
return proxyUrl ? proxyUrl.href : '';
|
|
|
|
|
}
|
|
|
|
|
exports.getProxyUrl = getProxyUrl;
|
|
|
|
|
const HttpRedirectCodes = [
|
|
|
|
|
HttpCodes.MovedPermanently,
|
|
|
|
|
HttpCodes.ResourceMoved,
|
|
|
|
|
HttpCodes.SeeOther,
|
|
|
|
|
HttpCodes.TemporaryRedirect,
|
|
|
|
|
HttpCodes.PermanentRedirect
|
|
|
|
|
];
|
|
|
|
|
const HttpResponseRetryCodes = [
|
|
|
|
|
HttpCodes.BadGateway,
|
|
|
|
|
HttpCodes.ServiceUnavailable,
|
|
|
|
|
HttpCodes.GatewayTimeout
|
|
|
|
|
];
|
|
|
|
|
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
|
|
|
const ExponentialBackoffCeiling = 10;
|
|
|
|
|
const ExponentialBackoffTimeSlice = 5;
|
|
|
|
|
class HttpClientError extends Error {
|
|
|
|
|
constructor(message, statusCode) {
|
|
|
|
|
super(message);
|
|
|
|
|
this.name = 'HttpClientError';
|
|
|
|
|
this.statusCode = statusCode;
|
|
|
|
|
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.HttpClientError = HttpClientError;
|
|
|
|
|
class HttpClientResponse {
|
|
|
|
|
constructor(message) {
|
|
|
|
|
this.message = message;
|
|
|
|
|
}
|
|
|
|
|
readBody() {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
let output = Buffer.alloc(0);
|
|
|
|
|
this.message.on('data', (chunk) => {
|
|
|
|
|
output = Buffer.concat([output, chunk]);
|
|
|
|
|
});
|
|
|
|
|
this.message.on('end', () => {
|
|
|
|
|
resolve(output.toString());
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.HttpClientResponse = HttpClientResponse;
|
|
|
|
|
function isHttps(requestUrl) {
|
|
|
|
|
const parsedUrl = new URL(requestUrl);
|
|
|
|
|
return parsedUrl.protocol === 'https:';
|
|
|
|
|
}
|
|
|
|
|
exports.isHttps = isHttps;
|
|
|
|
|
class HttpClient {
|
|
|
|
|
constructor(userAgent, handlers, requestOptions) {
|
|
|
|
|
this._ignoreSslError = false;
|
|
|
|
|
this._allowRedirects = true;
|
|
|
|
|
this._allowRedirectDowngrade = false;
|
|
|
|
|
this._maxRedirects = 50;
|
|
|
|
|
this._allowRetries = false;
|
|
|
|
|
this._maxRetries = 1;
|
|
|
|
|
this._keepAlive = false;
|
|
|
|
|
this._disposed = false;
|
|
|
|
|
this.userAgent = userAgent;
|
|
|
|
|
this.handlers = handlers || [];
|
|
|
|
|
this.requestOptions = requestOptions;
|
|
|
|
|
if (requestOptions) {
|
|
|
|
|
if (requestOptions.ignoreSslError != null) {
|
|
|
|
|
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
|
|
|
}
|
|
|
|
|
this._socketTimeout = requestOptions.socketTimeout;
|
|
|
|
|
if (requestOptions.allowRedirects != null) {
|
|
|
|
|
this._allowRedirects = requestOptions.allowRedirects;
|
|
|
|
|
}
|
|
|
|
|
if (requestOptions.allowRedirectDowngrade != null) {
|
|
|
|
|
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
|
|
|
}
|
|
|
|
|
if (requestOptions.maxRedirects != null) {
|
|
|
|
|
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
|
|
|
}
|
|
|
|
|
if (requestOptions.keepAlive != null) {
|
|
|
|
|
this._keepAlive = requestOptions.keepAlive;
|
|
|
|
|
}
|
|
|
|
|
if (requestOptions.allowRetries != null) {
|
|
|
|
|
this._allowRetries = requestOptions.allowRetries;
|
|
|
|
|
}
|
|
|
|
|
if (requestOptions.maxRetries != null) {
|
|
|
|
|
this._maxRetries = requestOptions.maxRetries;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
options(requestUrl, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
get(requestUrl, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
del(requestUrl, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
post(requestUrl, data, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
patch(requestUrl, data, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
put(requestUrl, data, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
head(requestUrl, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Gets a typed object from an endpoint
|
|
|
|
|
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
|
|
|
|
*/
|
|
|
|
|
getJson(requestUrl, additionalHeaders = {}) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
|
|
|
const res = yield this.get(requestUrl, additionalHeaders);
|
|
|
|
|
return this._processResponse(res, this.requestOptions);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
postJson(requestUrl, obj, additionalHeaders = {}) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const data = JSON.stringify(obj, null, 2);
|
|
|
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
|
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
|
|
|
const res = yield this.post(requestUrl, data, additionalHeaders);
|
|
|
|
|
return this._processResponse(res, this.requestOptions);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
putJson(requestUrl, obj, additionalHeaders = {}) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const data = JSON.stringify(obj, null, 2);
|
|
|
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
|
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
|
|
|
const res = yield this.put(requestUrl, data, additionalHeaders);
|
|
|
|
|
return this._processResponse(res, this.requestOptions);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const data = JSON.stringify(obj, null, 2);
|
|
|
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
|
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
|
|
|
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
|
|
|
|
return this._processResponse(res, this.requestOptions);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Makes a raw http request.
|
|
|
|
|
* All other methods such as get, post, patch, and request ultimately call this.
|
|
|
|
|
* Prefer get, del, post and patch
|
|
|
|
|
*/
|
|
|
|
|
request(verb, requestUrl, data, headers) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
if (this._disposed) {
|
|
|
|
|
throw new Error('Client has already been disposed.');
|
|
|
|
|
}
|
|
|
|
|
const parsedUrl = new URL(requestUrl);
|
|
|
|
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
|
|
|
// Only perform retries on reads since writes may not be idempotent.
|
|
|
|
|
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
|
|
|
|
? this._maxRetries + 1
|
|
|
|
|
: 1;
|
|
|
|
|
let numTries = 0;
|
|
|
|
|
let response;
|
|
|
|
|
do {
|
|
|
|
|
response = yield this.requestRaw(info, data);
|
|
|
|
|
// Check if it's an authentication challenge
|
|
|
|
|
if (response &&
|
|
|
|
|
response.message &&
|
|
|
|
|
response.message.statusCode === HttpCodes.Unauthorized) {
|
|
|
|
|
let authenticationHandler;
|
|
|
|
|
for (const handler of this.handlers) {
|
|
|
|
|
if (handler.canHandleAuthentication(response)) {
|
|
|
|
|
authenticationHandler = handler;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (authenticationHandler) {
|
|
|
|
|
return authenticationHandler.handleAuthentication(this, info, data);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// We have received an unauthorized response but have no handlers to handle it.
|
|
|
|
|
// Let the response return to the caller.
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let redirectsRemaining = this._maxRedirects;
|
|
|
|
|
while (response.message.statusCode &&
|
|
|
|
|
HttpRedirectCodes.includes(response.message.statusCode) &&
|
|
|
|
|
this._allowRedirects &&
|
|
|
|
|
redirectsRemaining > 0) {
|
|
|
|
|
const redirectUrl = response.message.headers['location'];
|
|
|
|
|
if (!redirectUrl) {
|
|
|
|
|
// if there's no location to redirect to, we won't
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
const parsedRedirectUrl = new URL(redirectUrl);
|
|
|
|
|
if (parsedUrl.protocol === 'https:' &&
|
|
|
|
|
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
|
|
|
|
!this._allowRedirectDowngrade) {
|
|
|
|
|
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
|
|
|
|
}
|
|
|
|
|
// we need to finish reading the response before reassigning response
|
|
|
|
|
// which will leak the open socket.
|
|
|
|
|
yield response.readBody();
|
|
|
|
|
// strip authorization header if redirected to a different hostname
|
|
|
|
|
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
|
|
|
|
for (const header in headers) {
|
|
|
|
|
// header names are case insensitive
|
|
|
|
|
if (header.toLowerCase() === 'authorization') {
|
|
|
|
|
delete headers[header];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// let's make the request with the new redirectUrl
|
|
|
|
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
|
|
|
response = yield this.requestRaw(info, data);
|
|
|
|
|
redirectsRemaining--;
|
|
|
|
|
}
|
|
|
|
|
if (!response.message.statusCode ||
|
|
|
|
|
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
|
|
|
|
// If not a retry code, return immediately instead of retrying
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
numTries += 1;
|
|
|
|
|
if (numTries < maxTries) {
|
|
|
|
|
yield response.readBody();
|
|
|
|
|
yield this._performExponentialBackoff(numTries);
|
|
|
|
|
}
|
|
|
|
|
} while (numTries < maxTries);
|
|
|
|
|
return response;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Needs to be called if keepAlive is set to true in request options.
|
|
|
|
|
*/
|
|
|
|
|
dispose() {
|
|
|
|
|
if (this._agent) {
|
|
|
|
|
this._agent.destroy();
|
|
|
|
|
}
|
|
|
|
|
this._disposed = true;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Raw request.
|
|
|
|
|
* @param info
|
|
|
|
|
* @param data
|
|
|
|
|
*/
|
|
|
|
|
requestRaw(info, data) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
function callbackForResult(err, res) {
|
|
|
|
|
if (err) {
|
|
|
|
|
reject(err);
|
|
|
|
|
}
|
|
|
|
|
else if (!res) {
|
|
|
|
|
// If `err` is not passed, then `res` must be passed.
|
|
|
|
|
reject(new Error('Unknown error'));
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
resolve(res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.requestRawWithCallback(info, data, callbackForResult);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Raw request with callback.
|
|
|
|
|
* @param info
|
|
|
|
|
* @param data
|
|
|
|
|
* @param onResult
|
|
|
|
|
*/
|
|
|
|
|
requestRawWithCallback(info, data, onResult) {
|
|
|
|
|
if (typeof data === 'string') {
|
|
|
|
|
if (!info.options.headers) {
|
|
|
|
|
info.options.headers = {};
|
|
|
|
|
}
|
|
|
|
|
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
let callbackCalled = false;
|
|
|
|
|
function handleResult(err, res) {
|
|
|
|
|
if (!callbackCalled) {
|
|
|
|
|
callbackCalled = true;
|
|
|
|
|
onResult(err, res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const req = info.httpModule.request(info.options, (msg) => {
|
|
|
|
|
const res = new HttpClientResponse(msg);
|
|
|
|
|
handleResult(undefined, res);
|
|
|
|
|
});
|
|
|
|
|
let socket;
|
|
|
|
|
req.on('socket', sock => {
|
|
|
|
|
socket = sock;
|
|
|
|
|
});
|
|
|
|
|
// If we ever get disconnected, we want the socket to timeout eventually
|
|
|
|
|
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
|
|
|
if (socket) {
|
|
|
|
|
socket.end();
|
|
|
|
|
}
|
|
|
|
|
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
|
|
|
|
});
|
|
|
|
|
req.on('error', function (err) {
|
|
|
|
|
// err has statusCode property
|
|
|
|
|
// res should have headers
|
|
|
|
|
handleResult(err);
|
|
|
|
|
});
|
|
|
|
|
if (data && typeof data === 'string') {
|
|
|
|
|
req.write(data, 'utf8');
|
|
|
|
|
}
|
|
|
|
|
if (data && typeof data !== 'string') {
|
|
|
|
|
data.on('close', function () {
|
|
|
|
|
req.end();
|
|
|
|
|
});
|
|
|
|
|
data.pipe(req);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
req.end();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Gets an http agent. This function is useful when you need an http agent that handles
|
|
|
|
|
* routing through a proxy server - depending upon the url and proxy environment variables.
|
|
|
|
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
|
|
|
*/
|
|
|
|
|
getAgent(serverUrl) {
|
|
|
|
|
const parsedUrl = new URL(serverUrl);
|
|
|
|
|
return this._getAgent(parsedUrl);
|
|
|
|
|
}
|
|
|
|
|
_prepareRequest(method, requestUrl, headers) {
|
|
|
|
|
const info = {};
|
|
|
|
|
info.parsedUrl = requestUrl;
|
|
|
|
|
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
|
|
|
info.httpModule = usingSsl ? https : http;
|
|
|
|
|
const defaultPort = usingSsl ? 443 : 80;
|
|
|
|
|
info.options = {};
|
|
|
|
|
info.options.host = info.parsedUrl.hostname;
|
|
|
|
|
info.options.port = info.parsedUrl.port
|
|
|
|
|
? parseInt(info.parsedUrl.port)
|
|
|
|
|
: defaultPort;
|
|
|
|
|
info.options.path =
|
|
|
|
|
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
|
|
|
info.options.method = method;
|
|
|
|
|
info.options.headers = this._mergeHeaders(headers);
|
|
|
|
|
if (this.userAgent != null) {
|
|
|
|
|
info.options.headers['user-agent'] = this.userAgent;
|
|
|
|
|
}
|
|
|
|
|
info.options.agent = this._getAgent(info.parsedUrl);
|
|
|
|
|
// gives handlers an opportunity to participate
|
|
|
|
|
if (this.handlers) {
|
|
|
|
|
for (const handler of this.handlers) {
|
|
|
|
|
handler.prepareRequest(info.options);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
_mergeHeaders(headers) {
|
|
|
|
|
if (this.requestOptions && this.requestOptions.headers) {
|
|
|
|
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
|
|
|
|
}
|
|
|
|
|
return lowercaseKeys(headers || {});
|
|
|
|
|
}
|
|
|
|
|
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
|
|
|
|
let clientHeader;
|
|
|
|
|
if (this.requestOptions && this.requestOptions.headers) {
|
|
|
|
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
|
|
|
|
}
|
|
|
|
|
return additionalHeaders[header] || clientHeader || _default;
|
|
|
|
|
}
|
|
|
|
|
_getAgent(parsedUrl) {
|
|
|
|
|
let agent;
|
|
|
|
|
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
|
|
|
|
const useProxy = proxyUrl && proxyUrl.hostname;
|
|
|
|
|
if (this._keepAlive && useProxy) {
|
|
|
|
|
agent = this._proxyAgent;
|
|
|
|
|
}
|
|
|
|
|
if (this._keepAlive && !useProxy) {
|
|
|
|
|
agent = this._agent;
|
|
|
|
|
}
|
|
|
|
|
// if agent is already assigned use that agent.
|
|
|
|
|
if (agent) {
|
|
|
|
|
return agent;
|
|
|
|
|
}
|
|
|
|
|
const usingSsl = parsedUrl.protocol === 'https:';
|
|
|
|
|
let maxSockets = 100;
|
|
|
|
|
if (this.requestOptions) {
|
|
|
|
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
|
|
|
}
|
|
|
|
|
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
|
|
|
|
if (proxyUrl && proxyUrl.hostname) {
|
|
|
|
|
const agentOptions = {
|
|
|
|
|
maxSockets,
|
|
|
|
|
keepAlive: this._keepAlive,
|
|
|
|
|
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
|
|
|
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
|
|
|
|
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
|
|
|
|
};
|
|
|
|
|
let tunnelAgent;
|
|
|
|
|
const overHttps = proxyUrl.protocol === 'https:';
|
|
|
|
|
if (usingSsl) {
|
|
|
|
|
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
|
|
|
}
|
|
|
|
|
agent = tunnelAgent(agentOptions);
|
|
|
|
|
this._proxyAgent = agent;
|
|
|
|
|
}
|
|
|
|
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
|
|
|
if (this._keepAlive && !agent) {
|
|
|
|
|
const options = { keepAlive: this._keepAlive, maxSockets };
|
|
|
|
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
|
|
|
this._agent = agent;
|
|
|
|
|
}
|
|
|
|
|
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
|
|
|
if (!agent) {
|
|
|
|
|
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
|
|
|
}
|
|
|
|
|
if (usingSsl && this._ignoreSslError) {
|
|
|
|
|
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
|
|
|
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
|
|
|
// we have to cast it to any and change it directly
|
|
|
|
|
agent.options = Object.assign(agent.options || {}, {
|
|
|
|
|
rejectUnauthorized: false
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return agent;
|
|
|
|
|
}
|
|
|
|
|
_performExponentialBackoff(retryNumber) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
|
|
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
|
|
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
_processResponse(res, options) {
|
|
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
|
|
|
const statusCode = res.message.statusCode || 0;
|
|
|
|
|
const response = {
|
|
|
|
|
statusCode,
|
|
|
|
|
result: null,
|
|
|
|
|
headers: {}
|
|
|
|
|
};
|
|
|
|
|
// not found leads to null obj returned
|
|
|
|
|
if (statusCode === HttpCodes.NotFound) {
|
|
|
|
|
resolve(response);
|
|
|
|
|
}
|
|
|
|
|
// get the result from the body
|
|
|
|
|
function dateTimeDeserializer(key, value) {
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
|
const a = new Date(value);
|
|
|
|
|
if (!isNaN(a.valueOf())) {
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
let obj;
|
|
|
|
|
let contents;
|
|
|
|
|
try {
|
|
|
|
|
contents = yield res.readBody();
|
|
|
|
|
if (contents && contents.length > 0) {
|
|
|
|
|
if (options && options.deserializeDates) {
|
|
|
|
|
obj = JSON.parse(contents, dateTimeDeserializer);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
obj = JSON.parse(contents);
|
|
|
|
|
}
|
|
|
|
|
response.result = obj;
|
|
|
|
|
}
|
|
|
|
|
response.headers = res.message.headers;
|
|
|
|
|
}
|
|
|
|
|
catch (err) {
|
|
|
|
|
// Invalid resource (contents not json); leaving result obj null
|
|
|
|
|
}
|
|
|
|
|
// note that 3xx redirects are handled by the http layer.
|
|
|
|
|
if (statusCode > 299) {
|
|
|
|
|
let msg;
|
|
|
|
|
// if exception/error in body, attempt to get better error
|
|
|
|
|
if (obj && obj.message) {
|
|
|
|
|
msg = obj.message;
|
|
|
|
|
}
|
|
|
|
|
else if (contents && contents.length > 0) {
|
|
|
|
|
// it may be the case that the exception is in the body message as string
|
|
|
|
|
msg = contents;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
msg = `Failed request: (${statusCode})`;
|
|
|
|
|
}
|
|
|
|
|
const err = new HttpClientError(msg, statusCode);
|
|
|
|
|
err.result = response.result;
|
|
|
|
|
reject(err);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
resolve(response);
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
exports.HttpClient = HttpClient;
|
|
|
|
|
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
|
|
|
//# sourceMappingURL=index.js.map
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
|
|
|
|
|
/******/ });
|