diff --git a/action.yml b/action.yml index 82cc04e..268bc12 100644 --- a/action.yml +++ b/action.yml @@ -14,4 +14,4 @@ outputs: description: 'The time we greeted you' runs: using: node12 - main: dist/github/index.js \ No newline at end of file + main: dist/github/setup/index.js \ No newline at end of file diff --git a/dist/github/index.js b/dist/github/setup/index.js similarity index 94% rename from dist/github/index.js rename to dist/github/setup/index.js index 836c950..69fa574 100644 --- a/dist/github/index.js +++ b/dist/github/setup/index.js @@ -34,7 +34,7 @@ module.exports = /******/ // the startup function /******/ function startup() { /******/ // Load entry module and return exports -/******/ return __webpack_require__(545); +/******/ return __webpack_require__(116); /******/ }; /******/ /******/ // run startup @@ -43,89 +43,323 @@ module.exports = /************************************************************************/ /******/ ({ -/***/ 2: +/***/ 1: +/***/ (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 }); +const childProcess = __webpack_require__(129); +const path = __webpack_require__(622); +const util_1 = __webpack_require__(669); +const ioUtil = __webpack_require__(672); +const exec = util_1.promisify(childProcess.exec); +/** + * Copies a file or folder. + * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js + * + * @param source source path + * @param dest destination path + * @param options optional. See CopyOptions. + */ +function cp(source, dest, options = {}) { + return __awaiter(this, void 0, void 0, function* () { + const { force, recursive } = readCopyOptions(options); + const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null; + // Dest is an existing file, but not forcing + if (destStat && destStat.isFile() && !force) { + return; + } + // If dest is an existing directory, should copy inside. + const newDest = destStat && destStat.isDirectory() + ? path.join(dest, path.basename(source)) + : dest; + if (!(yield ioUtil.exists(source))) { + throw new Error(`no such file or directory: ${source}`); + } + const sourceStat = yield ioUtil.stat(source); + if (sourceStat.isDirectory()) { + if (!recursive) { + throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`); + } + else { + yield cpDirRecursive(source, newDest, 0, force); + } + } + else { + if (path.relative(source, newDest) === '') { + // a file cannot be copied to itself + throw new Error(`'${newDest}' and '${source}' are the same file`); + } + yield copyFile(source, newDest, force); + } + }); +} +exports.cp = cp; +/** + * Moves a path. + * + * @param source source path + * @param dest destination path + * @param options optional. See MoveOptions. + */ +function mv(source, dest, options = {}) { + return __awaiter(this, void 0, void 0, function* () { + if (yield ioUtil.exists(dest)) { + let destExists = true; + if (yield ioUtil.isDirectory(dest)) { + // If dest is directory copy src into dest + dest = path.join(dest, path.basename(source)); + destExists = yield ioUtil.exists(dest); + } + if (destExists) { + if (options.force == null || options.force) { + yield rmRF(dest); + } + else { + throw new Error('Destination already exists'); + } + } + } + yield mkdirP(path.dirname(dest)); + yield ioUtil.rename(source, dest); + }); +} +exports.mv = mv; +/** + * Remove a path recursively with force + * + * @param inputPath path to remove + */ +function rmRF(inputPath) { + return __awaiter(this, void 0, void 0, function* () { + if (ioUtil.IS_WINDOWS) { + // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another + // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. + try { + if (yield ioUtil.isDirectory(inputPath, true)) { + yield exec(`rd /s /q "${inputPath}"`); + } + else { + yield exec(`del /f /a "${inputPath}"`); + } + } + catch (err) { + // if you try to delete a file that doesn't exist, desired result is achieved + // other errors are valid + if (err.code !== 'ENOENT') + throw err; + } + // Shelling out fails to remove a symlink folder with missing source, this unlink catches that + try { + yield ioUtil.unlink(inputPath); + } + catch (err) { + // if you try to delete a file that doesn't exist, desired result is achieved + // other errors are valid + if (err.code !== 'ENOENT') + throw err; + } + } + else { + let isDir = false; + try { + isDir = yield ioUtil.isDirectory(inputPath); + } + catch (err) { + // if you try to delete a file that doesn't exist, desired result is achieved + // other errors are valid + if (err.code !== 'ENOENT') + throw err; + return; + } + if (isDir) { + yield exec(`rm -rf "${inputPath}"`); + } + else { + yield ioUtil.unlink(inputPath); + } + } + }); +} +exports.rmRF = rmRF; +/** + * Make a directory. Creates the full path with folders in between + * Will throw if it fails + * + * @param fsPath path to create + * @returns Promise + */ +function mkdirP(fsPath) { + return __awaiter(this, void 0, void 0, function* () { + yield ioUtil.mkdirP(fsPath); + }); +} +exports.mkdirP = mkdirP; +/** + * Returns path of a tool had the tool actually been invoked. Resolves via paths. + * If you check and the tool does not exist, it will throw. + * + * @param tool name of the tool + * @param check whether to check if tool exists + * @returns Promise path to tool + */ +function which(tool, check) { + return __awaiter(this, void 0, void 0, function* () { + if (!tool) { + throw new Error("parameter 'tool' is required"); + } + // recursive when check=true + if (check) { + const result = yield which(tool, false); + if (!result) { + if (ioUtil.IS_WINDOWS) { + throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); + } + else { + throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); + } + } + } + try { + // build the list of extensions to try + const extensions = []; + if (ioUtil.IS_WINDOWS && process.env.PATHEXT) { + for (const extension of process.env.PATHEXT.split(path.delimiter)) { + if (extension) { + extensions.push(extension); + } + } + } + // if it's rooted, return it if exists. otherwise return empty. + if (ioUtil.isRooted(tool)) { + const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions); + if (filePath) { + return filePath; + } + return ''; + } + // if any path separators, return empty + if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) { + return ''; + } + // build the list of directories + // + // Note, technically "where" checks the current directory on Windows. From a toolkit perspective, + // it feels like we should not do this. Checking the current directory seems like more of a use + // case of a shell, and the which() function exposed by the toolkit should strive for consistency + // across platforms. + const directories = []; + if (process.env.PATH) { + for (const p of process.env.PATH.split(path.delimiter)) { + if (p) { + directories.push(p); + } + } + } + // return the first match + for (const directory of directories) { + const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions); + if (filePath) { + return filePath; + } + } + return ''; + } + catch (err) { + throw new Error(`which failed with message ${err.message}`); + } + }); +} +exports.which = which; +function readCopyOptions(options) { + const force = options.force == null ? true : options.force; + const recursive = Boolean(options.recursive); + return { force, recursive }; +} +function cpDirRecursive(sourceDir, destDir, currentDepth, force) { + return __awaiter(this, void 0, void 0, function* () { + // Ensure there is not a run away recursive copy + if (currentDepth >= 255) + return; + currentDepth++; + yield mkdirP(destDir); + const files = yield ioUtil.readdir(sourceDir); + for (const fileName of files) { + const srcFile = `${sourceDir}/${fileName}`; + const destFile = `${destDir}/${fileName}`; + const srcFileStat = yield ioUtil.lstat(srcFile); + if (srcFileStat.isDirectory()) { + // Recurse + yield cpDirRecursive(srcFile, destFile, currentDepth, force); + } + else { + yield copyFile(srcFile, destFile, force); + } + } + // Change the mode for the newly created directory + yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode); + }); +} +// Buffered file copy +function copyFile(srcFile, destFile, force) { + return __awaiter(this, void 0, void 0, function* () { + if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) { + // unlink/re-link it + try { + yield ioUtil.lstat(destFile); + yield ioUtil.unlink(destFile); + } + catch (e) { + // Try to override file permission + if (e.code === 'EPERM') { + yield ioUtil.chmod(destFile, '0666'); + yield ioUtil.unlink(destFile); + } + // other errors = it doesn't exist, no work to do + } + // Copy over symlink + const symlinkFull = yield ioUtil.readlink(srcFile); + yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null); + } + else if (!(yield ioUtil.exists(destFile)) || force) { + yield ioUtil.copyFile(srcFile, destFile); + } + }); +} +//# sourceMappingURL=io.js.map + +/***/ }), + +/***/ 7: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var ERROR_MSGS = __webpack_require__(516); -var Lookup = (function () { - function Lookup() { - this._map = new Map(); - } - Lookup.prototype.getMap = function () { - return this._map; - }; - Lookup.prototype.add = function (serviceIdentifier, value) { - if (serviceIdentifier === null || serviceIdentifier === undefined) { - throw new Error(ERROR_MSGS.NULL_ARGUMENT); - } - if (value === null || value === undefined) { - throw new Error(ERROR_MSGS.NULL_ARGUMENT); - } - var entry = this._map.get(serviceIdentifier); - if (entry !== undefined) { - entry.push(value); - this._map.set(serviceIdentifier, entry); +var metadata_1 = __webpack_require__(355); +var decorator_utils_1 = __webpack_require__(309); +function tagged(metadataKey, metadataValue) { + return function (target, targetKey, index) { + var metadata = new metadata_1.Metadata(metadataKey, metadataValue); + if (typeof index === "number") { + decorator_utils_1.tagParameter(target, targetKey, index, metadata); } else { - this._map.set(serviceIdentifier, [value]); + decorator_utils_1.tagProperty(target, targetKey, metadata); } }; - Lookup.prototype.get = function (serviceIdentifier) { - if (serviceIdentifier === null || serviceIdentifier === undefined) { - throw new Error(ERROR_MSGS.NULL_ARGUMENT); - } - var entry = this._map.get(serviceIdentifier); - if (entry !== undefined) { - return entry; - } - else { - throw new Error(ERROR_MSGS.KEY_NOT_FOUND); - } - }; - Lookup.prototype.remove = function (serviceIdentifier) { - if (serviceIdentifier === null || serviceIdentifier === undefined) { - throw new Error(ERROR_MSGS.NULL_ARGUMENT); - } - if (!this._map.delete(serviceIdentifier)) { - throw new Error(ERROR_MSGS.KEY_NOT_FOUND); - } - }; - Lookup.prototype.removeByCondition = function (condition) { - var _this = this; - this._map.forEach(function (entries, key) { - var updatedEntries = entries.filter(function (entry) { return !condition(entry); }); - if (updatedEntries.length > 0) { - _this._map.set(key, updatedEntries); - } - else { - _this._map.delete(key); - } - }); - }; - Lookup.prototype.hasKey = function (serviceIdentifier) { - if (serviceIdentifier === null || serviceIdentifier === undefined) { - throw new Error(ERROR_MSGS.NULL_ARGUMENT); - } - return this._map.has(serviceIdentifier); - }; - Lookup.prototype.clone = function () { - var copy = new Lookup(); - this._map.forEach(function (value, key) { - value.forEach(function (b) { return copy.add(key, b.clone()); }); - }); - return copy; - }; - Lookup.prototype.traverse = function (func) { - this._map.forEach(function (value, key) { - func(key, value); - }); - }; - return Lookup; -}()); -exports.Lookup = Lookup; +} +exports.tagged = tagged; /***/ }), @@ -135,10 +369,816 @@ exports.Lookup = Lookup; "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 }); -var error_msgs_1 = __webpack_require__(516); -var literal_types_1 = __webpack_require__(186); -var METADATA_KEY = __webpack_require__(677); +const os = __webpack_require__(87); +const events = __webpack_require__(614); +const child = __webpack_require__(129); +/* eslint-disable @typescript-eslint/unbound-method */ +const IS_WINDOWS = process.platform === 'win32'; +/* + * Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way. + */ +class ToolRunner extends events.EventEmitter { + constructor(toolPath, args, options) { + super(); + if (!toolPath) { + throw new Error("Parameter 'toolPath' cannot be null or empty."); + } + this.toolPath = toolPath; + this.args = args || []; + this.options = options || {}; + } + _debug(message) { + if (this.options.listeners && this.options.listeners.debug) { + this.options.listeners.debug(message); + } + } + _getCommandString(options, noPrefix) { + const toolPath = this._getSpawnFileName(); + const args = this._getSpawnArgs(options); + let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool + if (IS_WINDOWS) { + // Windows + cmd file + if (this._isCmdFile()) { + cmd += toolPath; + for (const a of args) { + cmd += ` ${a}`; + } + } + // Windows + verbatim + else if (options.windowsVerbatimArguments) { + cmd += `"${toolPath}"`; + for (const a of args) { + cmd += ` ${a}`; + } + } + // Windows (regular) + else { + cmd += this._windowsQuoteCmdArg(toolPath); + for (const a of args) { + cmd += ` ${this._windowsQuoteCmdArg(a)}`; + } + } + } + else { + // OSX/Linux - this can likely be improved with some form of quoting. + // creating processes on Unix is fundamentally different than Windows. + // on Unix, execvp() takes an arg array. + cmd += toolPath; + for (const a of args) { + cmd += ` ${a}`; + } + } + return cmd; + } + _processLineBuffer(data, strBuffer, onLine) { + try { + let s = strBuffer + data.toString(); + let n = s.indexOf(os.EOL); + while (n > -1) { + const line = s.substring(0, n); + onLine(line); + // the rest of the string ... + s = s.substring(n + os.EOL.length); + n = s.indexOf(os.EOL); + } + strBuffer = s; + } + catch (err) { + // streaming lines to console is best effort. Don't fail a build. + this._debug(`error processing line. Failed with error ${err}`); + } + } + _getSpawnFileName() { + if (IS_WINDOWS) { + if (this._isCmdFile()) { + return process.env['COMSPEC'] || 'cmd.exe'; + } + } + return this.toolPath; + } + _getSpawnArgs(options) { + if (IS_WINDOWS) { + if (this._isCmdFile()) { + let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`; + for (const a of this.args) { + argline += ' '; + argline += options.windowsVerbatimArguments + ? a + : this._windowsQuoteCmdArg(a); + } + argline += '"'; + return [argline]; + } + } + return this.args; + } + _endsWith(str, end) { + return str.endsWith(end); + } + _isCmdFile() { + const upperToolPath = this.toolPath.toUpperCase(); + return (this._endsWith(upperToolPath, '.CMD') || + this._endsWith(upperToolPath, '.BAT')); + } + _windowsQuoteCmdArg(arg) { + // for .exe, apply the normal quoting rules that libuv applies + if (!this._isCmdFile()) { + return this._uvQuoteCmdArg(arg); + } + // otherwise apply quoting rules specific to the cmd.exe command line parser. + // the libuv rules are generic and are not designed specifically for cmd.exe + // command line parser. + // + // for a detailed description of the cmd.exe command line parser, refer to + // http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912 + // need quotes for empty arg + if (!arg) { + return '""'; + } + // determine whether the arg needs to be quoted + const cmdSpecialChars = [ + ' ', + '\t', + '&', + '(', + ')', + '[', + ']', + '{', + '}', + '^', + '=', + ';', + '!', + "'", + '+', + ',', + '`', + '~', + '|', + '<', + '>', + '"' + ]; + let needsQuotes = false; + for (const char of arg) { + if (cmdSpecialChars.some(x => x === char)) { + needsQuotes = true; + break; + } + } + // short-circuit if quotes not needed + if (!needsQuotes) { + return arg; + } + // the following quoting rules are very similar to the rules that by libuv applies. + // + // 1) wrap the string in quotes + // + // 2) double-up quotes - i.e. " => "" + // + // this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately + // doesn't work well with a cmd.exe command line. + // + // note, replacing " with "" also works well if the arg is passed to a downstream .NET console app. + // for example, the command line: + // foo.exe "myarg:""my val""" + // is parsed by a .NET console app into an arg array: + // [ "myarg:\"my val\"" ] + // which is the same end result when applying libuv quoting rules. although the actual + // command line from libuv quoting rules would look like: + // foo.exe "myarg:\"my val\"" + // + // 3) double-up slashes that precede a quote, + // e.g. hello \world => "hello \world" + // hello\"world => "hello\\""world" + // hello\\"world => "hello\\\\""world" + // hello world\ => "hello world\\" + // + // technically this is not required for a cmd.exe command line, or the batch argument parser. + // the reasons for including this as a .cmd quoting rule are: + // + // a) this is optimized for the scenario where the argument is passed from the .cmd file to an + // external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule. + // + // b) it's what we've been doing previously (by deferring to node default behavior) and we + // haven't heard any complaints about that aspect. + // + // note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be + // escaped when used on the command line directly - even though within a .cmd file % can be escaped + // by using %%. + // + // the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts + // the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing. + // + // one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would + // often work, since it is unlikely that var^ would exist, and the ^ character is removed when the + // variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args + // to an external program. + // + // an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file. + // % can be escaped within a .cmd file. + let reverse = '"'; + let quoteHit = true; + for (let i = arg.length; i > 0; i--) { + // walk the string in reverse + reverse += arg[i - 1]; + if (quoteHit && arg[i - 1] === '\\') { + reverse += '\\'; // double the slash + } + else if (arg[i - 1] === '"') { + quoteHit = true; + reverse += '"'; // double the quote + } + else { + quoteHit = false; + } + } + reverse += '"'; + return reverse + .split('') + .reverse() + .join(''); + } + _uvQuoteCmdArg(arg) { + // Tool runner wraps child_process.spawn() and needs to apply the same quoting as + // Node in certain cases where the undocumented spawn option windowsVerbatimArguments + // is used. + // + // Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV, + // see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details), + // pasting copyright notice from Node within this function: + // + // Copyright Joyent, Inc. and other Node contributors. All rights reserved. + // + // Permission is hereby granted, free of charge, to any person obtaining a copy + // of this software and associated documentation files (the "Software"), to + // deal in the Software without restriction, including without limitation the + // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + // sell copies of the Software, and to permit persons to whom the Software is + // furnished to do so, subject to the following conditions: + // + // The above copyright notice and this permission notice shall be included in + // all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + // IN THE SOFTWARE. + if (!arg) { + // Need double quotation for empty argument + return '""'; + } + if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) { + // No quotation needed + return arg; + } + if (!arg.includes('"') && !arg.includes('\\')) { + // No embedded double quotes or backslashes, so I can just wrap + // quote marks around the whole thing. + return `"${arg}"`; + } + // Expected input/output: + // input : hello"world + // output: "hello\"world" + // input : hello""world + // output: "hello\"\"world" + // input : hello\world + // output: hello\world + // input : hello\\world + // output: hello\\world + // input : hello\"world + // output: "hello\\\"world" + // input : hello\\"world + // output: "hello\\\\\"world" + // input : hello world\ + // output: "hello world\\" - note the comment in libuv actually reads "hello world\" + // but it appears the comment is wrong, it should be "hello world\\" + let reverse = '"'; + let quoteHit = true; + for (let i = arg.length; i > 0; i--) { + // walk the string in reverse + reverse += arg[i - 1]; + if (quoteHit && arg[i - 1] === '\\') { + reverse += '\\'; + } + else if (arg[i - 1] === '"') { + quoteHit = true; + reverse += '\\'; + } + else { + quoteHit = false; + } + } + reverse += '"'; + return reverse + .split('') + .reverse() + .join(''); + } + _cloneExecOptions(options) { + options = options || {}; + const result = { + cwd: options.cwd || process.cwd(), + env: options.env || process.env, + silent: options.silent || false, + windowsVerbatimArguments: options.windowsVerbatimArguments || false, + failOnStdErr: options.failOnStdErr || false, + ignoreReturnCode: options.ignoreReturnCode || false, + delay: options.delay || 10000 + }; + result.outStream = options.outStream || process.stdout; + result.errStream = options.errStream || process.stderr; + return result; + } + _getSpawnOptions(options, toolPath) { + options = options || {}; + const result = {}; + result.cwd = options.cwd; + result.env = options.env; + result['windowsVerbatimArguments'] = + options.windowsVerbatimArguments || this._isCmdFile(); + if (options.windowsVerbatimArguments) { + result.argv0 = `"${toolPath}"`; + } + return result; + } + /** + * Exec a tool. + * Output will be streamed to the live console. + * Returns promise with return code + * + * @param tool path to tool to exec + * @param options optional exec options. See ExecOptions + * @returns number + */ + exec() { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => { + this._debug(`exec tool: ${this.toolPath}`); + this._debug('arguments:'); + for (const arg of this.args) { + this._debug(` ${arg}`); + } + const optionsNonNull = this._cloneExecOptions(this.options); + if (!optionsNonNull.silent && optionsNonNull.outStream) { + optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL); + } + const state = new ExecState(optionsNonNull, this.toolPath); + state.on('debug', (message) => { + this._debug(message); + }); + const fileName = this._getSpawnFileName(); + const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); + const stdbuffer = ''; + if (cp.stdout) { + cp.stdout.on('data', (data) => { + if (this.options.listeners && this.options.listeners.stdout) { + this.options.listeners.stdout(data); + } + if (!optionsNonNull.silent && optionsNonNull.outStream) { + optionsNonNull.outStream.write(data); + } + this._processLineBuffer(data, stdbuffer, (line) => { + if (this.options.listeners && this.options.listeners.stdline) { + this.options.listeners.stdline(line); + } + }); + }); + } + const errbuffer = ''; + if (cp.stderr) { + cp.stderr.on('data', (data) => { + state.processStderr = true; + if (this.options.listeners && this.options.listeners.stderr) { + this.options.listeners.stderr(data); + } + if (!optionsNonNull.silent && + optionsNonNull.errStream && + optionsNonNull.outStream) { + const s = optionsNonNull.failOnStdErr + ? optionsNonNull.errStream + : optionsNonNull.outStream; + s.write(data); + } + this._processLineBuffer(data, errbuffer, (line) => { + if (this.options.listeners && this.options.listeners.errline) { + this.options.listeners.errline(line); + } + }); + }); + } + cp.on('error', (err) => { + state.processError = err.message; + state.processExited = true; + state.processClosed = true; + state.CheckComplete(); + }); + cp.on('exit', (code) => { + state.processExitCode = code; + state.processExited = true; + this._debug(`Exit code ${code} received from tool '${this.toolPath}'`); + state.CheckComplete(); + }); + cp.on('close', (code) => { + state.processExitCode = code; + state.processExited = true; + state.processClosed = true; + this._debug(`STDIO streams have closed for tool '${this.toolPath}'`); + state.CheckComplete(); + }); + state.on('done', (error, exitCode) => { + if (stdbuffer.length > 0) { + this.emit('stdline', stdbuffer); + } + if (errbuffer.length > 0) { + this.emit('errline', errbuffer); + } + cp.removeAllListeners(); + if (error) { + reject(error); + } + else { + resolve(exitCode); + } + }); + }); + }); + } +} +exports.ToolRunner = ToolRunner; +/** + * Convert an arg string to an array of args. Handles escaping + * + * @param argString string of arguments + * @returns string[] array of arguments + */ +function argStringToArray(argString) { + const args = []; + let inQuotes = false; + let escaped = false; + let arg = ''; + function append(c) { + // we only escape double quotes. + if (escaped && c !== '"') { + arg += '\\'; + } + arg += c; + escaped = false; + } + for (let i = 0; i < argString.length; i++) { + const c = argString.charAt(i); + if (c === '"') { + if (!escaped) { + inQuotes = !inQuotes; + } + else { + append(c); + } + continue; + } + if (c === '\\' && escaped) { + append(c); + continue; + } + if (c === '\\' && inQuotes) { + escaped = true; + continue; + } + if (c === ' ' && !inQuotes) { + if (arg.length > 0) { + args.push(arg); + arg = ''; + } + continue; + } + append(c); + } + if (arg.length > 0) { + args.push(arg.trim()); + } + return args; +} +exports.argStringToArray = argStringToArray; +class ExecState extends events.EventEmitter { + constructor(options, toolPath) { + super(); + this.processClosed = false; // tracks whether the process has exited and stdio is closed + this.processError = ''; + this.processExitCode = 0; + this.processExited = false; // tracks whether the process has exited + this.processStderr = false; // tracks whether stderr was written to + this.delay = 10000; // 10 seconds + this.done = false; + this.timeout = null; + if (!toolPath) { + throw new Error('toolPath must not be empty'); + } + this.options = options; + this.toolPath = toolPath; + if (options.delay) { + this.delay = options.delay; + } + } + CheckComplete() { + if (this.done) { + return; + } + if (this.processClosed) { + this._setResult(); + } + else if (this.processExited) { + this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this); + } + } + _debug(message) { + this.emit('debug', message); + } + _setResult() { + // determine whether there is an error + let error; + if (this.processExited) { + if (this.processError) { + error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`); + } + else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) { + error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`); + } + else if (this.processStderr && this.options.failOnStdErr) { + error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`); + } + } + // clear the timeout + if (this.timeout) { + clearTimeout(this.timeout); + this.timeout = null; + } + this.done = true; + this.emit('done', error, this.processExitCode); + } + static HandleTimeout(state) { + if (state.done) { + return; + } + if (!state.processClosed && state.processExited) { + const message = `The STDIO streams did not close within ${state.delay / + 1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`; + state._debug(message); + } + state._setResult(); + } +} +//# sourceMappingURL=toolrunner.js.map + +/***/ }), + +/***/ 15: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var ContainerSnapshot = (function () { + function ContainerSnapshot() { + } + ContainerSnapshot.of = function (bindings, middleware) { + var snapshot = new ContainerSnapshot(); + snapshot.bindings = bindings; + snapshot.middleware = middleware; + return snapshot; + }; + return ContainerSnapshot; +}()); +exports.ContainerSnapshot = ContainerSnapshot; + + +/***/ }), + +/***/ 16: +/***/ (function(module) { + +module.exports = require("tls"); + +/***/ }), + +/***/ 22: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var QueryableString = (function () { + function QueryableString(str) { + this.str = str; + } + QueryableString.prototype.startsWith = function (searchString) { + return this.str.indexOf(searchString) === 0; + }; + QueryableString.prototype.endsWith = function (searchString) { + var reverseString = ""; + var reverseSearchString = searchString.split("").reverse().join(""); + reverseString = this.str.split("").reverse().join(""); + return this.startsWith.call({ str: reverseString }, reverseSearchString); + }; + QueryableString.prototype.contains = function (searchString) { + return (this.str.indexOf(searchString) !== -1); + }; + QueryableString.prototype.equals = function (compareString) { + return this.str === compareString; + }; + QueryableString.prototype.value = function () { + return this.str; + }; + return QueryableString; +}()); +exports.QueryableString = QueryableString; + + +/***/ }), + +/***/ 32: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var id_1 = __webpack_require__(862); +var Context = (function () { + function Context(container) { + this.id = id_1.id(); + this.container = container; + } + Context.prototype.addPlan = function (plan) { + this.plan = plan; + }; + Context.prototype.setCurrentRequest = function (currentRequest) { + this.currentRequest = currentRequest; + }; + return Context; +}()); +exports.Context = Context; + + +/***/ }), + +/***/ 87: +/***/ (function(module) { + +module.exports = require("os"); + +/***/ }), + +/***/ 96: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.multiBindToService = function (container) { + return function (service) { + return function () { + var types = []; + for (var _i = 0; _i < arguments.length; _i++) { + types[_i] = arguments[_i]; + } + return types.forEach(function (t) { return container.bind(t).toService(service); }); + }; + }; +}; + + +/***/ }), + +/***/ 107: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var binding_on_syntax_1 = __webpack_require__(956); +var binding_when_syntax_1 = __webpack_require__(954); +var BindingWhenOnSyntax = (function () { + function BindingWhenOnSyntax(binding) { + this._binding = binding; + this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding); + this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding); + } + BindingWhenOnSyntax.prototype.when = function (constraint) { + return this._bindingWhenSyntax.when(constraint); + }; + BindingWhenOnSyntax.prototype.whenTargetNamed = function (name) { + return this._bindingWhenSyntax.whenTargetNamed(name); + }; + BindingWhenOnSyntax.prototype.whenTargetIsDefault = function () { + return this._bindingWhenSyntax.whenTargetIsDefault(); + }; + BindingWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) { + return this._bindingWhenSyntax.whenTargetTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenInjectedInto = function (parent) { + return this._bindingWhenSyntax.whenInjectedInto(parent); + }; + BindingWhenOnSyntax.prototype.whenParentNamed = function (name) { + return this._bindingWhenSyntax.whenParentNamed(name); + }; + BindingWhenOnSyntax.prototype.whenParentTagged = function (tag, value) { + return this._bindingWhenSyntax.whenParentTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenNoAncestorIs(ancestor); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenAnyAncestorNamed(name); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenNoAncestorNamed(name); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value); + }; + BindingWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint); + }; + BindingWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenNoAncestorMatches(constraint); + }; + BindingWhenOnSyntax.prototype.onActivation = function (handler) { + return this._bindingOnSyntax.onActivation(handler); + }; + return BindingWhenOnSyntax; +}()); +exports.BindingWhenOnSyntax = BindingWhenOnSyntax; + + +/***/ }), + +/***/ 116: +/***/ (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 }); +__webpack_require__(307); +const types_1 = __webpack_require__(639); +const ioc_1 = __webpack_require__(768); +const gitVersionTool = ioc_1.ioc.get(types_1.TYPES.IGitVersionTool); +const buildAgent = ioc_1.ioc.get(types_1.TYPES.IBuildAgent); +function run() { + return __awaiter(this, void 0, void 0, function* () { + try { + const version = "5.1.2"; + const includePrerelease = false; + yield gitVersionTool.install(version, includePrerelease); + buildAgent.setSucceeded("GitVersion executed successfully", true); + } + catch (error) { + buildAgent.setFailed(error.message, true); + } + }); +} +exports.run = run; +run(); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImZpbGU6Ly8vRDovUHJvamVjdHMvT1NTL0dpdFRvb2xzL3VzZS1naXR2ZXJzaW9uL3NyYy9naXRodWIvbWFpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7OztBQUFBLDRCQUEwQjtBQUcxQixvQ0FBaUM7QUFDakMsK0JBQTRCO0FBRTVCLE1BQU0sY0FBYyxHQUFHLFNBQUcsQ0FBQyxHQUFHLENBQWtCLGFBQUssQ0FBQyxlQUFlLENBQUMsQ0FBQztBQUN2RSxNQUFNLFVBQVUsR0FBRyxTQUFHLENBQUMsR0FBRyxDQUFjLGFBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUUzRCxTQUFzQixHQUFHOztRQUNyQixJQUFJO1lBRUEsTUFBTSxPQUFPLEdBQUcsT0FBTyxDQUFDO1lBQ3hCLE1BQU0saUJBQWlCLEdBQUcsS0FBSyxDQUFDO1lBRWhDLE1BQU0sY0FBYyxDQUFDLE9BQU8sQ0FBQyxPQUFPLEVBQUUsaUJBQWlCLENBQUMsQ0FBQztZQUV6RCxVQUFVLENBQUMsWUFBWSxDQUFDLGtDQUFrQyxFQUFFLElBQUksQ0FBQyxDQUFDO1NBQ3JFO1FBQUMsT0FBTyxLQUFLLEVBQUU7WUFDWixVQUFVLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyxPQUFPLEVBQUUsSUFBSSxDQUFDLENBQUM7U0FDN0M7SUFDTCxDQUFDO0NBQUE7QUFaRCxrQkFZQztBQUVELEdBQUcsRUFBRSxDQUFDIn0= + +/***/ }), + +/***/ 124: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var error_msgs_1 = __webpack_require__(800); +var literal_types_1 = __webpack_require__(274); +var METADATA_KEY = __webpack_require__(946); function _injectProperties(instance, childRequests, resolveRequest) { var propertyInjectionsRequests = childRequests.filter(function (childRequest) { return (childRequest.target !== null && @@ -188,375 +1228,297 @@ exports.resolveInstance = resolveInstance; /***/ }), -/***/ 15: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __generator = (this && this.__generator) || function (thisArg, body) { - var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; - return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; - function verb(n) { return function (v) { return step([n, v]); }; } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while (_) try { - if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [0, t.value]; - switch (op[0]) { - case 0: case 1: t = op; break; - case 4: _.label++; return { value: op[1], done: false }; - case 5: _.label++; y = op[1]; op = [0]; continue; - case 7: op = _.ops.pop(); _.trys.pop(); continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } - if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } - if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } - if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } - if (t[2]) _.ops.pop(); - _.trys.pop(); continue; - } - op = body.call(thisArg, _); - } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } - if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; - } -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var binding_1 = __webpack_require__(119); -var ERROR_MSGS = __webpack_require__(516); -var literal_types_1 = __webpack_require__(186); -var METADATA_KEY = __webpack_require__(677); -var metadata_reader_1 = __webpack_require__(202); -var planner_1 = __webpack_require__(787); -var resolver_1 = __webpack_require__(502); -var binding_to_syntax_1 = __webpack_require__(538); -var id_1 = __webpack_require__(786); -var serialization_1 = __webpack_require__(571); -var container_snapshot_1 = __webpack_require__(649); -var lookup_1 = __webpack_require__(2); -var Container = (function () { - function Container(containerOptions) { - var options = containerOptions || {}; - if (typeof options !== "object") { - throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT); - } - if (options.defaultScope === undefined) { - options.defaultScope = literal_types_1.BindingScopeEnum.Transient; - } - else if (options.defaultScope !== literal_types_1.BindingScopeEnum.Singleton && - options.defaultScope !== literal_types_1.BindingScopeEnum.Transient && - options.defaultScope !== literal_types_1.BindingScopeEnum.Request) { - throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE); - } - if (options.autoBindInjectable === undefined) { - options.autoBindInjectable = false; - } - else if (typeof options.autoBindInjectable !== "boolean") { - throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE); - } - if (options.skipBaseClassChecks === undefined) { - options.skipBaseClassChecks = false; - } - else if (typeof options.skipBaseClassChecks !== "boolean") { - throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK); - } - this.options = { - autoBindInjectable: options.autoBindInjectable, - defaultScope: options.defaultScope, - skipBaseClassChecks: options.skipBaseClassChecks - }; - this.id = id_1.id(); - this._bindingDictionary = new lookup_1.Lookup(); - this._snapshots = []; - this._middleware = null; - this.parent = null; - this._metadataReader = new metadata_reader_1.MetadataReader(); - } - Container.merge = function (container1, container2) { - var container = new Container(); - var bindingDictionary = planner_1.getBindingDictionary(container); - var bindingDictionary1 = planner_1.getBindingDictionary(container1); - var bindingDictionary2 = planner_1.getBindingDictionary(container2); - function copyDictionary(origin, destination) { - origin.traverse(function (key, value) { - value.forEach(function (binding) { - destination.add(binding.serviceIdentifier, binding.clone()); - }); - }); - } - copyDictionary(bindingDictionary1, bindingDictionary); - copyDictionary(bindingDictionary2, bindingDictionary); - return container; - }; - Container.prototype.load = function () { - var modules = []; - for (var _i = 0; _i < arguments.length; _i++) { - modules[_i] = arguments[_i]; - } - var getHelpers = this._getContainerModuleHelpersFactory(); - for (var _a = 0, modules_1 = modules; _a < modules_1.length; _a++) { - var currentModule = modules_1[_a]; - var containerModuleHelpers = getHelpers(currentModule.id); - currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction); - } - }; - Container.prototype.loadAsync = function () { - var modules = []; - for (var _i = 0; _i < arguments.length; _i++) { - modules[_i] = arguments[_i]; - } - return __awaiter(this, void 0, void 0, function () { - var getHelpers, _a, modules_2, currentModule, containerModuleHelpers; - return __generator(this, function (_b) { - switch (_b.label) { - case 0: - getHelpers = this._getContainerModuleHelpersFactory(); - _a = 0, modules_2 = modules; - _b.label = 1; - case 1: - if (!(_a < modules_2.length)) return [3, 4]; - currentModule = modules_2[_a]; - containerModuleHelpers = getHelpers(currentModule.id); - return [4, currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction)]; - case 2: - _b.sent(); - _b.label = 3; - case 3: - _a++; - return [3, 1]; - case 4: return [2]; - } - }); - }); - }; - Container.prototype.unload = function () { - var _this = this; - var modules = []; - for (var _i = 0; _i < arguments.length; _i++) { - modules[_i] = arguments[_i]; - } - var conditionFactory = function (expected) { return function (item) { - return item.moduleId === expected; - }; }; - modules.forEach(function (module) { - var condition = conditionFactory(module.id); - _this._bindingDictionary.removeByCondition(condition); - }); - }; - Container.prototype.bind = function (serviceIdentifier) { - var scope = this.options.defaultScope || literal_types_1.BindingScopeEnum.Transient; - var binding = new binding_1.Binding(serviceIdentifier, scope); - this._bindingDictionary.add(serviceIdentifier, binding); - return new binding_to_syntax_1.BindingToSyntax(binding); - }; - Container.prototype.rebind = function (serviceIdentifier) { - this.unbind(serviceIdentifier); - return this.bind(serviceIdentifier); - }; - Container.prototype.unbind = function (serviceIdentifier) { - try { - this._bindingDictionary.remove(serviceIdentifier); - } - catch (e) { - throw new Error(ERROR_MSGS.CANNOT_UNBIND + " " + serialization_1.getServiceIdentifierAsString(serviceIdentifier)); - } - }; - Container.prototype.unbindAll = function () { - this._bindingDictionary = new lookup_1.Lookup(); - }; - Container.prototype.isBound = function (serviceIdentifier) { - var bound = this._bindingDictionary.hasKey(serviceIdentifier); - if (!bound && this.parent) { - bound = this.parent.isBound(serviceIdentifier); - } - return bound; - }; - Container.prototype.isBoundNamed = function (serviceIdentifier, named) { - return this.isBoundTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named); - }; - Container.prototype.isBoundTagged = function (serviceIdentifier, key, value) { - var bound = false; - if (this._bindingDictionary.hasKey(serviceIdentifier)) { - var bindings = this._bindingDictionary.get(serviceIdentifier); - var request_1 = planner_1.createMockRequest(this, serviceIdentifier, key, value); - bound = bindings.some(function (b) { return b.constraint(request_1); }); - } - if (!bound && this.parent) { - bound = this.parent.isBoundTagged(serviceIdentifier, key, value); - } - return bound; - }; - Container.prototype.snapshot = function () { - this._snapshots.push(container_snapshot_1.ContainerSnapshot.of(this._bindingDictionary.clone(), this._middleware)); - }; - Container.prototype.restore = function () { - var snapshot = this._snapshots.pop(); - if (snapshot === undefined) { - throw new Error(ERROR_MSGS.NO_MORE_SNAPSHOTS_AVAILABLE); - } - this._bindingDictionary = snapshot.bindings; - this._middleware = snapshot.middleware; - }; - Container.prototype.createChild = function (containerOptions) { - var child = new Container(containerOptions || this.options); - child.parent = this; - return child; - }; - Container.prototype.applyMiddleware = function () { - var middlewares = []; - for (var _i = 0; _i < arguments.length; _i++) { - middlewares[_i] = arguments[_i]; - } - var initial = (this._middleware) ? this._middleware : this._planAndResolve(); - this._middleware = middlewares.reduce(function (prev, curr) { return curr(prev); }, initial); - }; - Container.prototype.applyCustomMetadataReader = function (metadataReader) { - this._metadataReader = metadataReader; - }; - Container.prototype.get = function (serviceIdentifier) { - return this._get(false, false, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier); - }; - Container.prototype.getTagged = function (serviceIdentifier, key, value) { - return this._get(false, false, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier, key, value); - }; - Container.prototype.getNamed = function (serviceIdentifier, named) { - return this.getTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named); - }; - Container.prototype.getAll = function (serviceIdentifier) { - return this._get(true, true, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier); - }; - Container.prototype.getAllTagged = function (serviceIdentifier, key, value) { - return this._get(false, true, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier, key, value); - }; - Container.prototype.getAllNamed = function (serviceIdentifier, named) { - return this.getAllTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named); - }; - Container.prototype.resolve = function (constructorFunction) { - var tempContainer = this.createChild(); - tempContainer.bind(constructorFunction).toSelf(); - return tempContainer.get(constructorFunction); - }; - Container.prototype._getContainerModuleHelpersFactory = function () { - var _this = this; - var setModuleId = function (bindingToSyntax, moduleId) { - bindingToSyntax._binding.moduleId = moduleId; - }; - var getBindFunction = function (moduleId) { - return function (serviceIdentifier) { - var _bind = _this.bind.bind(_this); - var bindingToSyntax = _bind(serviceIdentifier); - setModuleId(bindingToSyntax, moduleId); - return bindingToSyntax; - }; - }; - var getUnbindFunction = function (moduleId) { - return function (serviceIdentifier) { - var _unbind = _this.unbind.bind(_this); - _unbind(serviceIdentifier); - }; - }; - var getIsboundFunction = function (moduleId) { - return function (serviceIdentifier) { - var _isBound = _this.isBound.bind(_this); - return _isBound(serviceIdentifier); - }; - }; - var getRebindFunction = function (moduleId) { - return function (serviceIdentifier) { - var _rebind = _this.rebind.bind(_this); - var bindingToSyntax = _rebind(serviceIdentifier); - setModuleId(bindingToSyntax, moduleId); - return bindingToSyntax; - }; - }; - return function (mId) { return ({ - bindFunction: getBindFunction(mId), - isboundFunction: getIsboundFunction(mId), - rebindFunction: getRebindFunction(mId), - unbindFunction: getUnbindFunction(mId) - }); }; - }; - Container.prototype._get = function (avoidConstraints, isMultiInject, targetType, serviceIdentifier, key, value) { - var result = null; - var defaultArgs = { - avoidConstraints: avoidConstraints, - contextInterceptor: function (context) { return context; }, - isMultiInject: isMultiInject, - key: key, - serviceIdentifier: serviceIdentifier, - targetType: targetType, - value: value - }; - if (this._middleware) { - result = this._middleware(defaultArgs); - if (result === undefined || result === null) { - throw new Error(ERROR_MSGS.INVALID_MIDDLEWARE_RETURN); - } - } - else { - result = this._planAndResolve()(defaultArgs); - } - return result; - }; - Container.prototype._planAndResolve = function () { - var _this = this; - return function (args) { - var context = planner_1.plan(_this._metadataReader, _this, args.isMultiInject, args.targetType, args.serviceIdentifier, args.key, args.value, args.avoidConstraints); - context = args.contextInterceptor(context); - var result = resolver_1.resolve(context); - return result; - }; - }; - return Container; -}()); -exports.Container = Container; - - -/***/ }), - -/***/ 16: +/***/ 129: /***/ (function(module) { -module.exports = require("tls"); +module.exports = require("child_process"); /***/ }), -/***/ 20: +/***/ 139: +/***/ (function(module, __unusedexports, __webpack_require__) { + +// Unique ID creation requires a high quality random # generator. In node.js +// this is pretty straight-forward - we use the crypto API. + +var crypto = __webpack_require__(417); + +module.exports = function nodeRNG() { + return crypto.randomBytes(16); +}; + + +/***/ }), + +/***/ 141: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var binding_when_syntax_1 = __webpack_require__(653); -var BindingOnSyntax = (function () { - function BindingOnSyntax(binding) { - this._binding = binding; + +var net = __webpack_require__(631); +var tls = __webpack_require__(16); +var http = __webpack_require__(876); +var https = __webpack_require__(211); +var events = __webpack_require__(614); +var assert = __webpack_require__(357); +var util = __webpack_require__(669); + + +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; + + +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; +} + +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + return agent; +} + +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} + +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + return agent; +} + + +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; + + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } } - BindingOnSyntax.prototype.onActivation = function (handler) { - this._binding.onActivation = handler; - return new binding_when_syntax_1.BindingWhenSyntax(this._binding); + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); + +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); + + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; + } + + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); + + function onFree() { + self.emit('free', socket, options); + } + + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; + +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); + + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false + }); + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } + + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); + + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } + + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); + } + + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); + + if (res.statusCode === 200) { + assert.equal(head.length, 0); + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + cb(socket); + } else { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } + } + + function onError(cause) { + connectReq.removeAllListeners(); + + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + } +}; + +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); + + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; + +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); + + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); +} + + +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress }; - return BindingOnSyntax; -}()); -exports.BindingOnSyntax = BindingOnSyntax; + } + return host; // for v0.11 or later +} + +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} + + +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); + } +} else { + debug = function() {}; +} +exports.debug = debug; // for test /***/ }), -/***/ 87: +/***/ 211: +/***/ (function(module) { + +module.exports = require("https"); + +/***/ }), + +/***/ 231: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var id_1 = __webpack_require__(786); +var id_1 = __webpack_require__(862); var Request = (function () { function Request(serviceIdentifier, parentContext, parentRequest, bindings, target) { this.id = id_1.id(); @@ -582,22 +1544,40 @@ exports.Request = Request; /***/ }), -/***/ 95: -/***/ (function(module, __unusedexports, __webpack_require__) { +/***/ 274: +/***/ (function(__unusedmodule, exports) { -// Unique ID creation requires a high quality random # generator. In node.js -// this is pretty straight-forward - we use the crypto API. +"use strict"; -var crypto = __webpack_require__(417); - -module.exports = function nodeRNG() { - return crypto.randomBytes(16); +Object.defineProperty(exports, "__esModule", { value: true }); +var BindingScopeEnum = { + Request: "Request", + Singleton: "Singleton", + Transient: "Transient" }; +exports.BindingScopeEnum = BindingScopeEnum; +var BindingTypeEnum = { + ConstantValue: "ConstantValue", + Constructor: "Constructor", + DynamicValue: "DynamicValue", + Factory: "Factory", + Function: "Function", + Instance: "Instance", + Invalid: "Invalid", + Provider: "Provider" +}; +exports.BindingTypeEnum = BindingTypeEnum; +var TargetTypeEnum = { + ClassProperty: "ClassProperty", + ConstructorArgument: "ConstructorArgument", + Variable: "Variable" +}; +exports.TargetTypeEnum = TargetTypeEnum; /***/ }), -/***/ 105: +/***/ 280: /***/ (function(module, exports) { exports = module.exports = SemVer @@ -2087,13 +3067,1707 @@ function coerce (version) { /***/ }), -/***/ 106: +/***/ 307: +/***/ (function() { + +/*! ***************************************************************************** +Copyright (C) Microsoft. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +var Reflect; +(function (Reflect) { + // Metadata Proposal + // https://rbuckton.github.io/reflect-metadata/ + (function (factory) { + var root = typeof global === "object" ? global : + typeof self === "object" ? self : + typeof this === "object" ? this : + Function("return this;")(); + var exporter = makeExporter(Reflect); + if (typeof root.Reflect === "undefined") { + root.Reflect = Reflect; + } + else { + exporter = makeExporter(root.Reflect, exporter); + } + factory(exporter); + function makeExporter(target, previous) { + return function (key, value) { + if (typeof target[key] !== "function") { + Object.defineProperty(target, key, { configurable: true, writable: true, value: value }); + } + if (previous) + previous(key, value); + }; + } + })(function (exporter) { + var hasOwn = Object.prototype.hasOwnProperty; + // feature test for Symbol support + var supportsSymbol = typeof Symbol === "function"; + var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive"; + var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator"; + var supportsCreate = typeof Object.create === "function"; // feature test for Object.create support + var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support + var downLevel = !supportsCreate && !supportsProto; + var HashMap = { + // create an object in dictionary mode (a.k.a. "slow" mode in v8) + create: supportsCreate + ? function () { return MakeDictionary(Object.create(null)); } + : supportsProto + ? function () { return MakeDictionary({ __proto__: null }); } + : function () { return MakeDictionary({}); }, + has: downLevel + ? function (map, key) { return hasOwn.call(map, key); } + : function (map, key) { return key in map; }, + get: downLevel + ? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; } + : function (map, key) { return map[key]; }, + }; + // Load global or shim versions of Map, Set, and WeakMap + var functionPrototype = Object.getPrototypeOf(Function); + var usePolyfill = typeof process === "object" && process.env && process.env["REFLECT_METADATA_USE_MAP_POLYFILL"] === "true"; + var _Map = !usePolyfill && typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill(); + var _Set = !usePolyfill && typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill(); + var _WeakMap = !usePolyfill && typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill(); + // [[Metadata]] internal slot + // https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots + var Metadata = new _WeakMap(); + /** + * Applies a set of decorators to a property of a target object. + * @param decorators An array of decorators. + * @param target The target object. + * @param propertyKey (Optional) The property key to decorate. + * @param attributes (Optional) The property descriptor for the target key. + * @remarks Decorators are applied in reverse order. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * Example = Reflect.decorate(decoratorsArray, Example); + * + * // property (on constructor) + * Reflect.decorate(decoratorsArray, Example, "staticProperty"); + * + * // property (on prototype) + * Reflect.decorate(decoratorsArray, Example.prototype, "property"); + * + * // method (on constructor) + * Object.defineProperty(Example, "staticMethod", + * Reflect.decorate(decoratorsArray, Example, "staticMethod", + * Object.getOwnPropertyDescriptor(Example, "staticMethod"))); + * + * // method (on prototype) + * Object.defineProperty(Example.prototype, "method", + * Reflect.decorate(decoratorsArray, Example.prototype, "method", + * Object.getOwnPropertyDescriptor(Example.prototype, "method"))); + * + */ + function decorate(decorators, target, propertyKey, attributes) { + if (!IsUndefined(propertyKey)) { + if (!IsArray(decorators)) + throw new TypeError(); + if (!IsObject(target)) + throw new TypeError(); + if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes)) + throw new TypeError(); + if (IsNull(attributes)) + attributes = undefined; + propertyKey = ToPropertyKey(propertyKey); + return DecorateProperty(decorators, target, propertyKey, attributes); + } + else { + if (!IsArray(decorators)) + throw new TypeError(); + if (!IsConstructor(target)) + throw new TypeError(); + return DecorateConstructor(decorators, target); + } + } + exporter("decorate", decorate); + // 4.1.2 Reflect.metadata(metadataKey, metadataValue) + // https://rbuckton.github.io/reflect-metadata/#reflect.metadata + /** + * A default metadata decorator factory that can be used on a class, class member, or parameter. + * @param metadataKey The key for the metadata entry. + * @param metadataValue The value for the metadata entry. + * @returns A decorator function. + * @remarks + * If `metadataKey` is already defined for the target and target key, the + * metadataValue for that key will be overwritten. + * @example + * + * // constructor + * @Reflect.metadata(key, value) + * class Example { + * } + * + * // property (on constructor, TypeScript only) + * class Example { + * @Reflect.metadata(key, value) + * static staticProperty; + * } + * + * // property (on prototype, TypeScript only) + * class Example { + * @Reflect.metadata(key, value) + * property; + * } + * + * // method (on constructor) + * class Example { + * @Reflect.metadata(key, value) + * static staticMethod() { } + * } + * + * // method (on prototype) + * class Example { + * @Reflect.metadata(key, value) + * method() { } + * } + * + */ + function metadata(metadataKey, metadataValue) { + function decorator(target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey)) + throw new TypeError(); + OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey); + } + return decorator; + } + exporter("metadata", metadata); + /** + * Define a unique metadata entry on the target. + * @param metadataKey A key used to store and retrieve metadata. + * @param metadataValue A value that contains attached metadata. + * @param target The target object on which to define metadata. + * @param propertyKey (Optional) The property key for the target. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * Reflect.defineMetadata("custom:annotation", options, Example); + * + * // property (on constructor) + * Reflect.defineMetadata("custom:annotation", options, Example, "staticProperty"); + * + * // property (on prototype) + * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "property"); + * + * // method (on constructor) + * Reflect.defineMetadata("custom:annotation", options, Example, "staticMethod"); + * + * // method (on prototype) + * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "method"); + * + * // decorator factory as metadata-producing annotation. + * function MyAnnotation(options): Decorator { + * return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key); + * } + * + */ + function defineMetadata(metadataKey, metadataValue, target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey); + } + exporter("defineMetadata", defineMetadata); + /** + * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param propertyKey (Optional) The property key for the target. + * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.hasMetadata("custom:annotation", Example); + * + * // property (on constructor) + * result = Reflect.hasMetadata("custom:annotation", Example, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.hasMetadata("custom:annotation", Example, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "method"); + * + */ + function hasMetadata(metadataKey, target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + return OrdinaryHasMetadata(metadataKey, target, propertyKey); + } + exporter("hasMetadata", hasMetadata); + /** + * Gets a value indicating whether the target object has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param propertyKey (Optional) The property key for the target. + * @returns `true` if the metadata key was defined on the target object; otherwise, `false`. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.hasOwnMetadata("custom:annotation", Example); + * + * // property (on constructor) + * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "method"); + * + */ + function hasOwnMetadata(metadataKey, target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey); + } + exporter("hasOwnMetadata", hasOwnMetadata); + /** + * Gets the metadata value for the provided metadata key on the target object or its prototype chain. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param propertyKey (Optional) The property key for the target. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getMetadata("custom:annotation", Example); + * + * // property (on constructor) + * result = Reflect.getMetadata("custom:annotation", Example, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getMetadata("custom:annotation", Example.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getMetadata("custom:annotation", Example, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getMetadata("custom:annotation", Example.prototype, "method"); + * + */ + function getMetadata(metadataKey, target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + return OrdinaryGetMetadata(metadataKey, target, propertyKey); + } + exporter("getMetadata", getMetadata); + /** + * Gets the metadata value for the provided metadata key on the target object. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param propertyKey (Optional) The property key for the target. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getOwnMetadata("custom:annotation", Example); + * + * // property (on constructor) + * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "method"); + * + */ + function getOwnMetadata(metadataKey, target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey); + } + exporter("getOwnMetadata", getOwnMetadata); + /** + * Gets the metadata keys defined on the target object or its prototype chain. + * @param target The target object on which the metadata is defined. + * @param propertyKey (Optional) The property key for the target. + * @returns An array of unique metadata keys. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getMetadataKeys(Example); + * + * // property (on constructor) + * result = Reflect.getMetadataKeys(Example, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getMetadataKeys(Example.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getMetadataKeys(Example, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getMetadataKeys(Example.prototype, "method"); + * + */ + function getMetadataKeys(target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + return OrdinaryMetadataKeys(target, propertyKey); + } + exporter("getMetadataKeys", getMetadataKeys); + /** + * Gets the unique metadata keys defined on the target object. + * @param target The target object on which the metadata is defined. + * @param propertyKey (Optional) The property key for the target. + * @returns An array of unique metadata keys. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getOwnMetadataKeys(Example); + * + * // property (on constructor) + * result = Reflect.getOwnMetadataKeys(Example, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getOwnMetadataKeys(Example.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getOwnMetadataKeys(Example, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getOwnMetadataKeys(Example.prototype, "method"); + * + */ + function getOwnMetadataKeys(target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + return OrdinaryOwnMetadataKeys(target, propertyKey); + } + exporter("getOwnMetadataKeys", getOwnMetadataKeys); + /** + * Deletes the metadata entry from the target object with the provided key. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param propertyKey (Optional) The property key for the target. + * @returns `true` if the metadata entry was found and deleted; otherwise, false. + * @example + * + * class Example { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.deleteMetadata("custom:annotation", Example); + * + * // property (on constructor) + * result = Reflect.deleteMetadata("custom:annotation", Example, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.deleteMetadata("custom:annotation", Example, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "method"); + * + */ + function deleteMetadata(metadataKey, target, propertyKey) { + if (!IsObject(target)) + throw new TypeError(); + if (!IsUndefined(propertyKey)) + propertyKey = ToPropertyKey(propertyKey); + var metadataMap = GetOrCreateMetadataMap(target, propertyKey, /*Create*/ false); + if (IsUndefined(metadataMap)) + return false; + if (!metadataMap.delete(metadataKey)) + return false; + if (metadataMap.size > 0) + return true; + var targetMetadata = Metadata.get(target); + targetMetadata.delete(propertyKey); + if (targetMetadata.size > 0) + return true; + Metadata.delete(target); + return true; + } + exporter("deleteMetadata", deleteMetadata); + function DecorateConstructor(decorators, target) { + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + var decorated = decorator(target); + if (!IsUndefined(decorated) && !IsNull(decorated)) { + if (!IsConstructor(decorated)) + throw new TypeError(); + target = decorated; + } + } + return target; + } + function DecorateProperty(decorators, target, propertyKey, descriptor) { + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + var decorated = decorator(target, propertyKey, descriptor); + if (!IsUndefined(decorated) && !IsNull(decorated)) { + if (!IsObject(decorated)) + throw new TypeError(); + descriptor = decorated; + } + } + return descriptor; + } + function GetOrCreateMetadataMap(O, P, Create) { + var targetMetadata = Metadata.get(O); + if (IsUndefined(targetMetadata)) { + if (!Create) + return undefined; + targetMetadata = new _Map(); + Metadata.set(O, targetMetadata); + } + var metadataMap = targetMetadata.get(P); + if (IsUndefined(metadataMap)) { + if (!Create) + return undefined; + metadataMap = new _Map(); + targetMetadata.set(P, metadataMap); + } + return metadataMap; + } + // 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P) + // https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata + function OrdinaryHasMetadata(MetadataKey, O, P) { + var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) + return true; + var parent = OrdinaryGetPrototypeOf(O); + if (!IsNull(parent)) + return OrdinaryHasMetadata(MetadataKey, parent, P); + return false; + } + // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P) + // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata + function OrdinaryHasOwnMetadata(MetadataKey, O, P) { + var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false); + if (IsUndefined(metadataMap)) + return false; + return ToBoolean(metadataMap.has(MetadataKey)); + } + // 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P) + // https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata + function OrdinaryGetMetadata(MetadataKey, O, P) { + var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) + return OrdinaryGetOwnMetadata(MetadataKey, O, P); + var parent = OrdinaryGetPrototypeOf(O); + if (!IsNull(parent)) + return OrdinaryGetMetadata(MetadataKey, parent, P); + return undefined; + } + // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P) + // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata + function OrdinaryGetOwnMetadata(MetadataKey, O, P) { + var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false); + if (IsUndefined(metadataMap)) + return undefined; + return metadataMap.get(MetadataKey); + } + // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) + // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata + function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) { + var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true); + metadataMap.set(MetadataKey, MetadataValue); + } + // 3.1.6.1 OrdinaryMetadataKeys(O, P) + // https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys + function OrdinaryMetadataKeys(O, P) { + var ownKeys = OrdinaryOwnMetadataKeys(O, P); + var parent = OrdinaryGetPrototypeOf(O); + if (parent === null) + return ownKeys; + var parentKeys = OrdinaryMetadataKeys(parent, P); + if (parentKeys.length <= 0) + return ownKeys; + if (ownKeys.length <= 0) + return parentKeys; + var set = new _Set(); + var keys = []; + for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) { + var key = ownKeys_1[_i]; + var hasKey = set.has(key); + if (!hasKey) { + set.add(key); + keys.push(key); + } + } + for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) { + var key = parentKeys_1[_a]; + var hasKey = set.has(key); + if (!hasKey) { + set.add(key); + keys.push(key); + } + } + return keys; + } + // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P) + // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys + function OrdinaryOwnMetadataKeys(O, P) { + var keys = []; + var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false); + if (IsUndefined(metadataMap)) + return keys; + var keysObj = metadataMap.keys(); + var iterator = GetIterator(keysObj); + var k = 0; + while (true) { + var next = IteratorStep(iterator); + if (!next) { + keys.length = k; + return keys; + } + var nextValue = IteratorValue(next); + try { + keys[k] = nextValue; + } + catch (e) { + try { + IteratorClose(iterator); + } + finally { + throw e; + } + } + k++; + } + } + // 6 ECMAScript Data Typ0es and Values + // https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values + function Type(x) { + if (x === null) + return 1 /* Null */; + switch (typeof x) { + case "undefined": return 0 /* Undefined */; + case "boolean": return 2 /* Boolean */; + case "string": return 3 /* String */; + case "symbol": return 4 /* Symbol */; + case "number": return 5 /* Number */; + case "object": return x === null ? 1 /* Null */ : 6 /* Object */; + default: return 6 /* Object */; + } + } + // 6.1.1 The Undefined Type + // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type + function IsUndefined(x) { + return x === undefined; + } + // 6.1.2 The Null Type + // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type + function IsNull(x) { + return x === null; + } + // 6.1.5 The Symbol Type + // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type + function IsSymbol(x) { + return typeof x === "symbol"; + } + // 6.1.7 The Object Type + // https://tc39.github.io/ecma262/#sec-object-type + function IsObject(x) { + return typeof x === "object" ? x !== null : typeof x === "function"; + } + // 7.1 Type Conversion + // https://tc39.github.io/ecma262/#sec-type-conversion + // 7.1.1 ToPrimitive(input [, PreferredType]) + // https://tc39.github.io/ecma262/#sec-toprimitive + function ToPrimitive(input, PreferredType) { + switch (Type(input)) { + case 0 /* Undefined */: return input; + case 1 /* Null */: return input; + case 2 /* Boolean */: return input; + case 3 /* String */: return input; + case 4 /* Symbol */: return input; + case 5 /* Number */: return input; + } + var hint = PreferredType === 3 /* String */ ? "string" : PreferredType === 5 /* Number */ ? "number" : "default"; + var exoticToPrim = GetMethod(input, toPrimitiveSymbol); + if (exoticToPrim !== undefined) { + var result = exoticToPrim.call(input, hint); + if (IsObject(result)) + throw new TypeError(); + return result; + } + return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint); + } + // 7.1.1.1 OrdinaryToPrimitive(O, hint) + // https://tc39.github.io/ecma262/#sec-ordinarytoprimitive + function OrdinaryToPrimitive(O, hint) { + if (hint === "string") { + var toString_1 = O.toString; + if (IsCallable(toString_1)) { + var result = toString_1.call(O); + if (!IsObject(result)) + return result; + } + var valueOf = O.valueOf; + if (IsCallable(valueOf)) { + var result = valueOf.call(O); + if (!IsObject(result)) + return result; + } + } + else { + var valueOf = O.valueOf; + if (IsCallable(valueOf)) { + var result = valueOf.call(O); + if (!IsObject(result)) + return result; + } + var toString_2 = O.toString; + if (IsCallable(toString_2)) { + var result = toString_2.call(O); + if (!IsObject(result)) + return result; + } + } + throw new TypeError(); + } + // 7.1.2 ToBoolean(argument) + // https://tc39.github.io/ecma262/2016/#sec-toboolean + function ToBoolean(argument) { + return !!argument; + } + // 7.1.12 ToString(argument) + // https://tc39.github.io/ecma262/#sec-tostring + function ToString(argument) { + return "" + argument; + } + // 7.1.14 ToPropertyKey(argument) + // https://tc39.github.io/ecma262/#sec-topropertykey + function ToPropertyKey(argument) { + var key = ToPrimitive(argument, 3 /* String */); + if (IsSymbol(key)) + return key; + return ToString(key); + } + // 7.2 Testing and Comparison Operations + // https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations + // 7.2.2 IsArray(argument) + // https://tc39.github.io/ecma262/#sec-isarray + function IsArray(argument) { + return Array.isArray + ? Array.isArray(argument) + : argument instanceof Object + ? argument instanceof Array + : Object.prototype.toString.call(argument) === "[object Array]"; + } + // 7.2.3 IsCallable(argument) + // https://tc39.github.io/ecma262/#sec-iscallable + function IsCallable(argument) { + // NOTE: This is an approximation as we cannot check for [[Call]] internal method. + return typeof argument === "function"; + } + // 7.2.4 IsConstructor(argument) + // https://tc39.github.io/ecma262/#sec-isconstructor + function IsConstructor(argument) { + // NOTE: This is an approximation as we cannot check for [[Construct]] internal method. + return typeof argument === "function"; + } + // 7.2.7 IsPropertyKey(argument) + // https://tc39.github.io/ecma262/#sec-ispropertykey + function IsPropertyKey(argument) { + switch (Type(argument)) { + case 3 /* String */: return true; + case 4 /* Symbol */: return true; + default: return false; + } + } + // 7.3 Operations on Objects + // https://tc39.github.io/ecma262/#sec-operations-on-objects + // 7.3.9 GetMethod(V, P) + // https://tc39.github.io/ecma262/#sec-getmethod + function GetMethod(V, P) { + var func = V[P]; + if (func === undefined || func === null) + return undefined; + if (!IsCallable(func)) + throw new TypeError(); + return func; + } + // 7.4 Operations on Iterator Objects + // https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects + function GetIterator(obj) { + var method = GetMethod(obj, iteratorSymbol); + if (!IsCallable(method)) + throw new TypeError(); // from Call + var iterator = method.call(obj); + if (!IsObject(iterator)) + throw new TypeError(); + return iterator; + } + // 7.4.4 IteratorValue(iterResult) + // https://tc39.github.io/ecma262/2016/#sec-iteratorvalue + function IteratorValue(iterResult) { + return iterResult.value; + } + // 7.4.5 IteratorStep(iterator) + // https://tc39.github.io/ecma262/#sec-iteratorstep + function IteratorStep(iterator) { + var result = iterator.next(); + return result.done ? false : result; + } + // 7.4.6 IteratorClose(iterator, completion) + // https://tc39.github.io/ecma262/#sec-iteratorclose + function IteratorClose(iterator) { + var f = iterator["return"]; + if (f) + f.call(iterator); + } + // 9.1 Ordinary Object Internal Methods and Internal Slots + // https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots + // 9.1.1.1 OrdinaryGetPrototypeOf(O) + // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof + function OrdinaryGetPrototypeOf(O) { + var proto = Object.getPrototypeOf(O); + if (typeof O !== "function" || O === functionPrototype) + return proto; + // TypeScript doesn't set __proto__ in ES5, as it's non-standard. + // Try to determine the superclass constructor. Compatible implementations + // must either set __proto__ on a subclass constructor to the superclass constructor, + // or ensure each class has a valid `constructor` property on its prototype that + // points back to the constructor. + // If this is not the same as Function.[[Prototype]], then this is definately inherited. + // This is the case when in ES6 or when using __proto__ in a compatible browser. + if (proto !== functionPrototype) + return proto; + // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage. + var prototype = O.prototype; + var prototypeProto = prototype && Object.getPrototypeOf(prototype); + if (prototypeProto == null || prototypeProto === Object.prototype) + return proto; + // If the constructor was not a function, then we cannot determine the heritage. + var constructor = prototypeProto.constructor; + if (typeof constructor !== "function") + return proto; + // If we have some kind of self-reference, then we cannot determine the heritage. + if (constructor === O) + return proto; + // we have a pretty good guess at the heritage. + return constructor; + } + // naive Map shim + function CreateMapPolyfill() { + var cacheSentinel = {}; + var arraySentinel = []; + var MapIterator = /** @class */ (function () { + function MapIterator(keys, values, selector) { + this._index = 0; + this._keys = keys; + this._values = values; + this._selector = selector; + } + MapIterator.prototype["@@iterator"] = function () { return this; }; + MapIterator.prototype[iteratorSymbol] = function () { return this; }; + MapIterator.prototype.next = function () { + var index = this._index; + if (index >= 0 && index < this._keys.length) { + var result = this._selector(this._keys[index], this._values[index]); + if (index + 1 >= this._keys.length) { + this._index = -1; + this._keys = arraySentinel; + this._values = arraySentinel; + } + else { + this._index++; + } + return { value: result, done: false }; + } + return { value: undefined, done: true }; + }; + MapIterator.prototype.throw = function (error) { + if (this._index >= 0) { + this._index = -1; + this._keys = arraySentinel; + this._values = arraySentinel; + } + throw error; + }; + MapIterator.prototype.return = function (value) { + if (this._index >= 0) { + this._index = -1; + this._keys = arraySentinel; + this._values = arraySentinel; + } + return { value: value, done: true }; + }; + return MapIterator; + }()); + return /** @class */ (function () { + function Map() { + this._keys = []; + this._values = []; + this._cacheKey = cacheSentinel; + this._cacheIndex = -2; + } + Object.defineProperty(Map.prototype, "size", { + get: function () { return this._keys.length; }, + enumerable: true, + configurable: true + }); + Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; }; + Map.prototype.get = function (key) { + var index = this._find(key, /*insert*/ false); + return index >= 0 ? this._values[index] : undefined; + }; + Map.prototype.set = function (key, value) { + var index = this._find(key, /*insert*/ true); + this._values[index] = value; + return this; + }; + Map.prototype.delete = function (key) { + var index = this._find(key, /*insert*/ false); + if (index >= 0) { + var size = this._keys.length; + for (var i = index + 1; i < size; i++) { + this._keys[i - 1] = this._keys[i]; + this._values[i - 1] = this._values[i]; + } + this._keys.length--; + this._values.length--; + if (key === this._cacheKey) { + this._cacheKey = cacheSentinel; + this._cacheIndex = -2; + } + return true; + } + return false; + }; + Map.prototype.clear = function () { + this._keys.length = 0; + this._values.length = 0; + this._cacheKey = cacheSentinel; + this._cacheIndex = -2; + }; + Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); }; + Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); }; + Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); }; + Map.prototype["@@iterator"] = function () { return this.entries(); }; + Map.prototype[iteratorSymbol] = function () { return this.entries(); }; + Map.prototype._find = function (key, insert) { + if (this._cacheKey !== key) { + this._cacheIndex = this._keys.indexOf(this._cacheKey = key); + } + if (this._cacheIndex < 0 && insert) { + this._cacheIndex = this._keys.length; + this._keys.push(key); + this._values.push(undefined); + } + return this._cacheIndex; + }; + return Map; + }()); + function getKey(key, _) { + return key; + } + function getValue(_, value) { + return value; + } + function getEntry(key, value) { + return [key, value]; + } + } + // naive Set shim + function CreateSetPolyfill() { + return /** @class */ (function () { + function Set() { + this._map = new _Map(); + } + Object.defineProperty(Set.prototype, "size", { + get: function () { return this._map.size; }, + enumerable: true, + configurable: true + }); + Set.prototype.has = function (value) { return this._map.has(value); }; + Set.prototype.add = function (value) { return this._map.set(value, value), this; }; + Set.prototype.delete = function (value) { return this._map.delete(value); }; + Set.prototype.clear = function () { this._map.clear(); }; + Set.prototype.keys = function () { return this._map.keys(); }; + Set.prototype.values = function () { return this._map.values(); }; + Set.prototype.entries = function () { return this._map.entries(); }; + Set.prototype["@@iterator"] = function () { return this.keys(); }; + Set.prototype[iteratorSymbol] = function () { return this.keys(); }; + return Set; + }()); + } + // naive WeakMap shim + function CreateWeakMapPolyfill() { + var UUID_SIZE = 16; + var keys = HashMap.create(); + var rootKey = CreateUniqueKey(); + return /** @class */ (function () { + function WeakMap() { + this._key = CreateUniqueKey(); + } + WeakMap.prototype.has = function (target) { + var table = GetOrCreateWeakMapTable(target, /*create*/ false); + return table !== undefined ? HashMap.has(table, this._key) : false; + }; + WeakMap.prototype.get = function (target) { + var table = GetOrCreateWeakMapTable(target, /*create*/ false); + return table !== undefined ? HashMap.get(table, this._key) : undefined; + }; + WeakMap.prototype.set = function (target, value) { + var table = GetOrCreateWeakMapTable(target, /*create*/ true); + table[this._key] = value; + return this; + }; + WeakMap.prototype.delete = function (target) { + var table = GetOrCreateWeakMapTable(target, /*create*/ false); + return table !== undefined ? delete table[this._key] : false; + }; + WeakMap.prototype.clear = function () { + // NOTE: not a real clear, just makes the previous data unreachable + this._key = CreateUniqueKey(); + }; + return WeakMap; + }()); + function CreateUniqueKey() { + var key; + do + key = "@@WeakMap@@" + CreateUUID(); + while (HashMap.has(keys, key)); + keys[key] = true; + return key; + } + function GetOrCreateWeakMapTable(target, create) { + if (!hasOwn.call(target, rootKey)) { + if (!create) + return undefined; + Object.defineProperty(target, rootKey, { value: HashMap.create() }); + } + return target[rootKey]; + } + function FillRandomBytes(buffer, size) { + for (var i = 0; i < size; ++i) + buffer[i] = Math.random() * 0xff | 0; + return buffer; + } + function GenRandomBytes(size) { + if (typeof Uint8Array === "function") { + if (typeof crypto !== "undefined") + return crypto.getRandomValues(new Uint8Array(size)); + if (typeof msCrypto !== "undefined") + return msCrypto.getRandomValues(new Uint8Array(size)); + return FillRandomBytes(new Uint8Array(size), size); + } + return FillRandomBytes(new Array(size), size); + } + function CreateUUID() { + var data = GenRandomBytes(UUID_SIZE); + // mark as random - RFC 4122 ยง 4.4 + data[6] = data[6] & 0x4f | 0x40; + data[8] = data[8] & 0xbf | 0x80; + var result = ""; + for (var offset = 0; offset < UUID_SIZE; ++offset) { + var byte = data[offset]; + if (offset === 4 || offset === 6 || offset === 8) + result += "-"; + if (byte < 16) + result += "0"; + result += byte.toString(16).toLowerCase(); + } + return result; + } + } + // uses a heuristic used by v8 and chakra to force an object into dictionary mode. + function MakeDictionary(obj) { + obj.__ = undefined; + delete obj.__; + return obj; + } + }); +})(Reflect || (Reflect = {})); + + +/***/ }), + +/***/ 309: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -const os = __webpack_require__(365); +var ERROR_MSGS = __webpack_require__(800); +var METADATA_KEY = __webpack_require__(946); +function tagParameter(annotationTarget, propertyName, parameterIndex, metadata) { + var metadataKey = METADATA_KEY.TAGGED; + _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex); +} +exports.tagParameter = tagParameter; +function tagProperty(annotationTarget, propertyName, metadata) { + var metadataKey = METADATA_KEY.TAGGED_PROP; + _tagParameterOrProperty(metadataKey, annotationTarget.constructor, propertyName, metadata); +} +exports.tagProperty = tagProperty; +function _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex) { + var paramsOrPropertiesMetadata = {}; + var isParameterDecorator = (typeof parameterIndex === "number"); + var key = (parameterIndex !== undefined && isParameterDecorator) ? parameterIndex.toString() : propertyName; + if (isParameterDecorator && propertyName !== undefined) { + throw new Error(ERROR_MSGS.INVALID_DECORATOR_OPERATION); + } + if (Reflect.hasOwnMetadata(metadataKey, annotationTarget)) { + paramsOrPropertiesMetadata = Reflect.getMetadata(metadataKey, annotationTarget); + } + var paramOrPropertyMetadata = paramsOrPropertiesMetadata[key]; + if (!Array.isArray(paramOrPropertyMetadata)) { + paramOrPropertyMetadata = []; + } + else { + for (var _i = 0, paramOrPropertyMetadata_1 = paramOrPropertyMetadata; _i < paramOrPropertyMetadata_1.length; _i++) { + var m = paramOrPropertyMetadata_1[_i]; + if (m.key === metadata.key) { + throw new Error(ERROR_MSGS.DUPLICATED_METADATA + " " + m.key.toString()); + } + } + } + paramOrPropertyMetadata.push(metadata); + paramsOrPropertiesMetadata[key] = paramOrPropertyMetadata; + Reflect.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget); +} +function _decorate(decorators, target) { + Reflect.decorate(decorators, target); +} +function _param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); }; +} +function decorate(decorator, target, parameterIndex) { + if (typeof parameterIndex === "number") { + _decorate([_param(parameterIndex, decorator)], target); + } + else if (typeof parameterIndex === "string") { + Reflect.decorate([decorator], target, parameterIndex); + } + else { + _decorate([decorator], target); + } +} +exports.decorate = decorate; + + +/***/ }), + +/***/ 319: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var ERROR_MSGS = __webpack_require__(800); +var Lookup = (function () { + function Lookup() { + this._map = new Map(); + } + Lookup.prototype.getMap = function () { + return this._map; + }; + Lookup.prototype.add = function (serviceIdentifier, value) { + if (serviceIdentifier === null || serviceIdentifier === undefined) { + throw new Error(ERROR_MSGS.NULL_ARGUMENT); + } + if (value === null || value === undefined) { + throw new Error(ERROR_MSGS.NULL_ARGUMENT); + } + var entry = this._map.get(serviceIdentifier); + if (entry !== undefined) { + entry.push(value); + this._map.set(serviceIdentifier, entry); + } + else { + this._map.set(serviceIdentifier, [value]); + } + }; + Lookup.prototype.get = function (serviceIdentifier) { + if (serviceIdentifier === null || serviceIdentifier === undefined) { + throw new Error(ERROR_MSGS.NULL_ARGUMENT); + } + var entry = this._map.get(serviceIdentifier); + if (entry !== undefined) { + return entry; + } + else { + throw new Error(ERROR_MSGS.KEY_NOT_FOUND); + } + }; + Lookup.prototype.remove = function (serviceIdentifier) { + if (serviceIdentifier === null || serviceIdentifier === undefined) { + throw new Error(ERROR_MSGS.NULL_ARGUMENT); + } + if (!this._map.delete(serviceIdentifier)) { + throw new Error(ERROR_MSGS.KEY_NOT_FOUND); + } + }; + Lookup.prototype.removeByCondition = function (condition) { + var _this = this; + this._map.forEach(function (entries, key) { + var updatedEntries = entries.filter(function (entry) { return !condition(entry); }); + if (updatedEntries.length > 0) { + _this._map.set(key, updatedEntries); + } + else { + _this._map.delete(key); + } + }); + }; + Lookup.prototype.hasKey = function (serviceIdentifier) { + if (serviceIdentifier === null || serviceIdentifier === undefined) { + throw new Error(ERROR_MSGS.NULL_ARGUMENT); + } + return this._map.has(serviceIdentifier); + }; + Lookup.prototype.clone = function () { + var copy = new Lookup(); + this._map.forEach(function (value, key) { + value.forEach(function (b) { return copy.add(key, b.clone()); }); + }); + return copy; + }; + Lookup.prototype.traverse = function (func) { + this._map.forEach(function (value, key) { + func(key, value); + }); + }; + return Lookup; +}()); +exports.Lookup = Lookup; + + +/***/ }), + +/***/ 344: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); +var decorator_utils_1 = __webpack_require__(309); +function unmanaged() { + return function (target, targetKey, index) { + var metadata = new metadata_1.Metadata(METADATA_KEY.UNMANAGED_TAG, true); + decorator_utils_1.tagParameter(target, targetKey, index, metadata); + }; +} +exports.unmanaged = unmanaged; + + +/***/ }), + +/***/ 355: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var METADATA_KEY = __webpack_require__(946); +var Metadata = (function () { + function Metadata(key, value) { + this.key = key; + this.value = value; + } + Metadata.prototype.toString = function () { + if (this.key === METADATA_KEY.NAMED_TAG) { + return "named: " + this.value.toString() + " "; + } + else { + return "tagged: { key:" + this.key.toString() + ", value: " + this.value + " }"; + } + }; + return Metadata; +}()); +exports.Metadata = Metadata; + + +/***/ }), + +/***/ 357: +/***/ (function(module) { + +module.exports = require("assert"); + +/***/ }), + +/***/ 388: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var ERRORS_MSGS = __webpack_require__(800); +var METADATA_KEY = __webpack_require__(946); +function injectable() { + return function (target) { + if (Reflect.hasOwnMetadata(METADATA_KEY.PARAM_TYPES, target)) { + throw new Error(ERRORS_MSGS.DUPLICATED_INJECTABLE_DECORATOR); + } + var types = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, target) || []; + Reflect.defineMetadata(METADATA_KEY.PARAM_TYPES, types, target); + return target; + }; +} +exports.injectable = injectable; + + +/***/ }), + +/***/ 395: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var ERROR_MSGS = __webpack_require__(800); +function getServiceIdentifierAsString(serviceIdentifier) { + if (typeof serviceIdentifier === "function") { + var _serviceIdentifier = serviceIdentifier; + return _serviceIdentifier.name; + } + else if (typeof serviceIdentifier === "symbol") { + return serviceIdentifier.toString(); + } + else { + var _serviceIdentifier = serviceIdentifier; + return _serviceIdentifier; + } +} +exports.getServiceIdentifierAsString = getServiceIdentifierAsString; +function listRegisteredBindingsForServiceIdentifier(container, serviceIdentifier, getBindings) { + var registeredBindingsList = ""; + var registeredBindings = getBindings(container, serviceIdentifier); + if (registeredBindings.length !== 0) { + registeredBindingsList = "\nRegistered bindings:"; + registeredBindings.forEach(function (binding) { + var name = "Object"; + if (binding.implementationType !== null) { + name = getFunctionName(binding.implementationType); + } + registeredBindingsList = registeredBindingsList + "\n " + name; + if (binding.constraint.metaData) { + registeredBindingsList = registeredBindingsList + " - " + binding.constraint.metaData; + } + }); + } + return registeredBindingsList; +} +exports.listRegisteredBindingsForServiceIdentifier = listRegisteredBindingsForServiceIdentifier; +function alreadyDependencyChain(request, serviceIdentifier) { + if (request.parentRequest === null) { + return false; + } + else if (request.parentRequest.serviceIdentifier === serviceIdentifier) { + return true; + } + else { + return alreadyDependencyChain(request.parentRequest, serviceIdentifier); + } +} +function dependencyChainToString(request) { + function _createStringArr(req, result) { + if (result === void 0) { result = []; } + var serviceIdentifier = getServiceIdentifierAsString(req.serviceIdentifier); + result.push(serviceIdentifier); + if (req.parentRequest !== null) { + return _createStringArr(req.parentRequest, result); + } + return result; + } + var stringArr = _createStringArr(request); + return stringArr.reverse().join(" --> "); +} +function circularDependencyToException(request) { + request.childRequests.forEach(function (childRequest) { + if (alreadyDependencyChain(childRequest, childRequest.serviceIdentifier)) { + var services = dependencyChainToString(childRequest); + throw new Error(ERROR_MSGS.CIRCULAR_DEPENDENCY + " " + services); + } + else { + circularDependencyToException(childRequest); + } + }); +} +exports.circularDependencyToException = circularDependencyToException; +function listMetadataForTarget(serviceIdentifierString, target) { + if (target.isTagged() || target.isNamed()) { + var m_1 = ""; + var namedTag = target.getNamedTag(); + var otherTags = target.getCustomTags(); + if (namedTag !== null) { + m_1 += namedTag.toString() + "\n"; + } + if (otherTags !== null) { + otherTags.forEach(function (tag) { + m_1 += tag.toString() + "\n"; + }); + } + return " " + serviceIdentifierString + "\n " + serviceIdentifierString + " - " + m_1; + } + else { + return " " + serviceIdentifierString; + } +} +exports.listMetadataForTarget = listMetadataForTarget; +function getFunctionName(v) { + if (v.name) { + return v.name; + } + else { + var name_1 = v.toString(); + var match = name_1.match(/^function\s*([^\s(]+)/); + return match ? match[1] : "Anonymous function: " + name_1; + } +} +exports.getFunctionName = getFunctionName; + + +/***/ }), + +/***/ 403: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var BindingCount = { + MultipleBindingsAvailable: 2, + NoBindingsAvailable: 0, + OnlyOneBindingAvailable: 1 +}; +exports.BindingCount = BindingCount; + + +/***/ }), + +/***/ 410: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var keys = __webpack_require__(946); +exports.METADATA_KEY = keys; +var container_1 = __webpack_require__(702); +exports.Container = container_1.Container; +var literal_types_1 = __webpack_require__(274); +exports.BindingScopeEnum = literal_types_1.BindingScopeEnum; +exports.BindingTypeEnum = literal_types_1.BindingTypeEnum; +exports.TargetTypeEnum = literal_types_1.TargetTypeEnum; +var container_module_1 = __webpack_require__(864); +exports.AsyncContainerModule = container_module_1.AsyncContainerModule; +exports.ContainerModule = container_module_1.ContainerModule; +var injectable_1 = __webpack_require__(388); +exports.injectable = injectable_1.injectable; +var tagged_1 = __webpack_require__(7); +exports.tagged = tagged_1.tagged; +var named_1 = __webpack_require__(904); +exports.named = named_1.named; +var inject_1 = __webpack_require__(625); +exports.inject = inject_1.inject; +exports.LazyServiceIdentifer = inject_1.LazyServiceIdentifer; +var optional_1 = __webpack_require__(804); +exports.optional = optional_1.optional; +var unmanaged_1 = __webpack_require__(344); +exports.unmanaged = unmanaged_1.unmanaged; +var multi_inject_1 = __webpack_require__(708); +exports.multiInject = multi_inject_1.multiInject; +var target_name_1 = __webpack_require__(567); +exports.targetName = target_name_1.targetName; +var post_construct_1 = __webpack_require__(871); +exports.postConstruct = post_construct_1.postConstruct; +var metadata_reader_1 = __webpack_require__(975); +exports.MetadataReader = metadata_reader_1.MetadataReader; +var id_1 = __webpack_require__(862); +exports.id = id_1.id; +var decorator_utils_1 = __webpack_require__(309); +exports.decorate = decorator_utils_1.decorate; +var constraint_helpers_1 = __webpack_require__(912); +exports.traverseAncerstors = constraint_helpers_1.traverseAncerstors; +exports.taggedConstraint = constraint_helpers_1.taggedConstraint; +exports.namedConstraint = constraint_helpers_1.namedConstraint; +exports.typeConstraint = constraint_helpers_1.typeConstraint; +var serialization_1 = __webpack_require__(395); +exports.getServiceIdentifierAsString = serialization_1.getServiceIdentifierAsString; +var binding_utils_1 = __webpack_require__(96); +exports.multiBindToService = binding_utils_1.multiBindToService; + + +/***/ }), + +/***/ 412: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var METADATA_KEY = __webpack_require__(946); +var id_1 = __webpack_require__(862); +var metadata_1 = __webpack_require__(355); +var queryable_string_1 = __webpack_require__(22); +var Target = (function () { + function Target(type, name, serviceIdentifier, namedOrTagged) { + this.id = id_1.id(); + this.type = type; + this.serviceIdentifier = serviceIdentifier; + this.name = new queryable_string_1.QueryableString(name || ""); + this.metadata = new Array(); + var metadataItem = null; + if (typeof namedOrTagged === "string") { + metadataItem = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, namedOrTagged); + } + else if (namedOrTagged instanceof metadata_1.Metadata) { + metadataItem = namedOrTagged; + } + if (metadataItem !== null) { + this.metadata.push(metadataItem); + } + } + Target.prototype.hasTag = function (key) { + for (var _i = 0, _a = this.metadata; _i < _a.length; _i++) { + var m = _a[_i]; + if (m.key === key) { + return true; + } + } + return false; + }; + Target.prototype.isArray = function () { + return this.hasTag(METADATA_KEY.MULTI_INJECT_TAG); + }; + Target.prototype.matchesArray = function (name) { + return this.matchesTag(METADATA_KEY.MULTI_INJECT_TAG)(name); + }; + Target.prototype.isNamed = function () { + return this.hasTag(METADATA_KEY.NAMED_TAG); + }; + Target.prototype.isTagged = function () { + return this.metadata.some(function (m) { + return (m.key !== METADATA_KEY.INJECT_TAG) && + (m.key !== METADATA_KEY.MULTI_INJECT_TAG) && + (m.key !== METADATA_KEY.NAME_TAG) && + (m.key !== METADATA_KEY.UNMANAGED_TAG) && + (m.key !== METADATA_KEY.NAMED_TAG); + }); + }; + Target.prototype.isOptional = function () { + return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true); + }; + Target.prototype.getNamedTag = function () { + if (this.isNamed()) { + return this.metadata.filter(function (m) { return m.key === METADATA_KEY.NAMED_TAG; })[0]; + } + return null; + }; + Target.prototype.getCustomTags = function () { + if (this.isTagged()) { + return this.metadata.filter(function (m) { + return (m.key !== METADATA_KEY.INJECT_TAG) && + (m.key !== METADATA_KEY.MULTI_INJECT_TAG) && + (m.key !== METADATA_KEY.NAME_TAG) && + (m.key !== METADATA_KEY.UNMANAGED_TAG) && + (m.key !== METADATA_KEY.NAMED_TAG); + }); + } + return null; + }; + Target.prototype.matchesNamedTag = function (name) { + return this.matchesTag(METADATA_KEY.NAMED_TAG)(name); + }; + Target.prototype.matchesTag = function (key) { + var _this = this; + return function (value) { + for (var _i = 0, _a = _this.metadata; _i < _a.length; _i++) { + var m = _a[_i]; + if (m.key === key && m.value === value) { + return true; + } + } + return false; + }; + }; + return Target; +}()); +exports.Target = Target; + + +/***/ }), + +/***/ 413: +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = __webpack_require__(141); + + +/***/ }), + +/***/ 415: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var literal_types_1 = __webpack_require__(274); +var binding_when_on_syntax_1 = __webpack_require__(107); +var BindingInSyntax = (function () { + function BindingInSyntax(binding) { + this._binding = binding; + } + BindingInSyntax.prototype.inRequestScope = function () { + this._binding.scope = literal_types_1.BindingScopeEnum.Request; + return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding); + }; + BindingInSyntax.prototype.inSingletonScope = function () { + this._binding.scope = literal_types_1.BindingScopeEnum.Singleton; + return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding); + }; + BindingInSyntax.prototype.inTransientScope = function () { + this._binding.scope = literal_types_1.BindingScopeEnum.Transient; + return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding); + }; + return BindingInSyntax; +}()); +exports.BindingInSyntax = BindingInSyntax; + + +/***/ }), + +/***/ 417: +/***/ (function(module) { + +module.exports = require("crypto"); + +/***/ }), + +/***/ 431: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const os = __webpack_require__(87); /** * Commands * @@ -2160,125 +4834,11 @@ function escape(s) { /***/ }), -/***/ 119: +/***/ 470: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var literal_types_1 = __webpack_require__(186); -var id_1 = __webpack_require__(786); -var Binding = (function () { - function Binding(serviceIdentifier, scope) { - this.id = id_1.id(); - this.activated = false; - this.serviceIdentifier = serviceIdentifier; - this.scope = scope; - this.type = literal_types_1.BindingTypeEnum.Invalid; - this.constraint = function (request) { return true; }; - this.implementationType = null; - this.cache = null; - this.factory = null; - this.provider = null; - this.onActivation = null; - this.dynamicValue = null; - } - Binding.prototype.clone = function () { - var clone = new Binding(this.serviceIdentifier, this.scope); - clone.activated = false; - clone.implementationType = this.implementationType; - clone.dynamicValue = this.dynamicValue; - clone.scope = this.scope; - clone.type = this.type; - clone.factory = this.factory; - clone.provider = this.provider; - clone.constraint = this.constraint; - clone.onActivation = this.onActivation; - clone.cache = this.cache; - return clone; - }; - return Binding; -}()); -exports.Binding = Binding; - - -/***/ }), - -/***/ 129: -/***/ (function(module) { - -module.exports = require("child_process"); - -/***/ }), - -/***/ 148: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var metadata_1 = __webpack_require__(173); -var decorator_utils_1 = __webpack_require__(289); -function tagged(metadataKey, metadataValue) { - return function (target, targetKey, index) { - var metadata = new metadata_1.Metadata(metadataKey, metadataValue); - if (typeof index === "number") { - decorator_utils_1.tagParameter(target, targetKey, index, metadata); - } - else { - decorator_utils_1.tagProperty(target, targetKey, metadata); - } - }; -} -exports.tagged = tagged; - - -/***/ }), - -/***/ 173: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var Metadata = (function () { - function Metadata(key, value) { - this.key = key; - this.value = value; - } - Metadata.prototype.toString = function () { - if (this.key === METADATA_KEY.NAMED_TAG) { - return "named: " + this.value.toString() + " "; - } - else { - return "tagged: { key:" + this.key.toString() + ", value: " + this.value + " }"; - } - }; - return Metadata; -}()); -exports.Metadata = Metadata; - - -/***/ }), - -/***/ 175: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; 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) { @@ -2289,505 +4849,675 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", { value: true }); -const fs = __webpack_require__(747); -const os = __webpack_require__(365); +const command_1 = __webpack_require__(431); +const os = __webpack_require__(87); const path = __webpack_require__(622); -const semver = __webpack_require__(105); -const http = __webpack_require__(549); -const inversify_1 = __webpack_require__(386); -const types_1 = __webpack_require__(834); -let DotnetTool = class DotnetTool { - constructor(buildAgent, versionManager) { - this.buildAgent = buildAgent; - this.versionManager = versionManager; - this.httpClient = new http.HttpClient("dotnet"); - } - run(args) { - return this.buildAgent.exec("dotnet", args); - } - toolInstall(toolName, versionSpec, checkLatest, includePre) { - return __awaiter(this, void 0, void 0, function* () { - console.log(""); - console.log("--------------------------"); - console.log(`Installing ${toolName} version ` + versionSpec); - console.log("--------------------------"); - if (this.versionManager.isExplicitVersion(versionSpec)) { - checkLatest = false; // check latest doesn't make sense when explicit version - } - let toolPath; - if (!checkLatest) { - // - // Let's try and resolve the version spec locally first - // - toolPath = this.buildAgent.find(toolName, versionSpec); - } - if (!toolPath) { - let version; - if (this.versionManager.isExplicitVersion(versionSpec)) { - // - // Explicit version was specified. No need to query for list of versions. - // - version = versionSpec; - } - else { - // - // Let's query and resolve the latest version for the versionSpec. - // If the version is an explicit version (1.1.1 or v1.1.1) then no need to query. - // If your tool doesn't offer a mechanism to query, - // then it can only support exact version inputs. - // - version = yield this.queryLatestMatch(toolName, versionSpec, includePre); - if (!version) { - throw new Error(`Unable to find ${toolName} version '${versionSpec}'.`); - } - // - // Check the cache for the resolved version. - // - toolPath = this.buildAgent.find(toolName, version); - } - if (!toolPath) { - // - // Download, extract, cache - // - toolPath = yield this.acquireTool(toolName, version); - } - } - // - // Prepend the tools path. This prepends the PATH for the current process and - // instructs the agent to prepend for each task that follows. - // - this.buildAgent.debug(`toolPath: ${toolPath}`); - if (os.platform() !== "win32") { - const dotnetRoot = path.dirname(fs.readlinkSync(yield this.buildAgent.which("dotnet"))); - this.buildAgent.exportVariable("DOTNET_ROOT", dotnetRoot); - } - this.buildAgent.addPath(toolPath); - return toolPath; - }); - } - queryLatestMatch(toolName, versionSpec, includePrerelease) { - return __awaiter(this, void 0, void 0, function* () { - this.buildAgent.debug(`querying tool versions for ${toolName}${versionSpec ? `@${versionSpec}` : ""} ${includePrerelease ? "including pre-releases" : ""}`); - const downloadPath = `https://api-v2v3search-0.nuget.org/query?q=${encodeURIComponent(toolName.toLowerCase())}&prerelease=${includePrerelease ? "true" : "false"}&semVerLevel=2.0.0`; - const res = yield this.httpClient.get(downloadPath); - if (!res || res.message.statusCode !== 200) { - return null; - } - const body = yield res.readBody(); - const data = JSON.parse(body).data; - const versions = data[0].versions.map((x) => x.version); - if (!versions || !versions.length) { - return null; - } - this.buildAgent.debug(`got versions: ${versions.join(", ")}`); - return this.versionManager.evaluateVersions(versions, versionSpec); - }); - } - acquireTool(toolName, version) { - return __awaiter(this, void 0, void 0, function* () { - const tempDirectory = yield this.buildAgent.createTempDir(); - let args = ["tool", "install", toolName, "--tool-path", tempDirectory]; - if (version) { - version = this.versionManager.cleanVersion(version); - args = args.concat(["--version", version]); - } - const result = yield this.run(args); - const status = result.code === 0 ? "success" : "failure"; - const message = result.code === 0 ? result.stdout : result.stderr; - this.buildAgent.debug(`tool install result: ${status} ${message}`); - if (result.code) { - throw new Error("Error installing tool"); - } - return yield this.buildAgent.cacheDir(tempDirectory, toolName, version); - }); - } -}; -DotnetTool = __decorate([ - inversify_1.injectable(), - __param(0, inversify_1.inject(types_1.TYPES.IBuildAgent)), - __param(1, inversify_1.inject(types_1.TYPES.IVersionManager)), - __metadata("design:paramtypes", [Object, Object]) -], DotnetTool); -exports.DotnetTool = DotnetTool; -let GitVersionTool = class GitVersionTool { - constructor(dotnetTool) { - this.dotnetTool = dotnetTool; - } - install(versionSpec, includePrerelease) { - return __awaiter(this, void 0, void 0, function* () { - const toolPath = yield this.dotnetTool.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease); - }); - } - run(...params) { - return; - } -}; -GitVersionTool = __decorate([ - inversify_1.injectable(), - __param(0, inversify_1.inject(types_1.TYPES.IDotnetTool)), - __metadata("design:paramtypes", [Object]) -], GitVersionTool); -exports.GitVersionTool = GitVersionTool; -const cmp = __webpack_require__(651); -let VersionManager = class VersionManager { - constructor(buildAgent) { - this.buildAgent = buildAgent; - } - isExplicitVersion(versionSpec) { - const c = semver.clean(versionSpec); - this.buildAgent.debug("isExplicit: " + c); - const valid = semver.valid(c) != null; - this.buildAgent.debug("explicit? " + valid); - return valid; - } - evaluateVersions(versions, versionSpec) { - let version; - this.buildAgent.debug("evaluating " + versions.length + " versions"); - versions = versions.sort(cmp); - for (let i = versions.length - 1; i >= 0; i--) { - const potential = versions[i]; - const satisfied = semver.satisfies(potential, versionSpec); - if (satisfied) { - version = potential; - break; - } - } - if (version) { - this.buildAgent.debug("matched: " + version); - } - else { - this.buildAgent.debug("match not found"); - } - return version; - } - cleanVersion(version) { - this.buildAgent.debug("cleaning: " + version); - return semver.clean(version); - } -}; -VersionManager = __decorate([ - inversify_1.injectable(), - __param(0, inversify_1.inject(types_1.TYPES.IBuildAgent)), - __metadata("design:paramtypes", [Object]) -], VersionManager); -exports.VersionManager = VersionManager; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9EOi9Qcm9qZWN0cy9PU1MvR2l0VG9vbHMvdXNlLWdpdHZlcnNpb24yL3NyYy9jb21tb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFDQSx5QkFBeUI7QUFDekIseUJBQXlCO0FBQ3pCLDZCQUE2QjtBQUM3QixpQ0FBaUM7QUFDakMscURBQXFEO0FBRXJELHlDQUErQztBQUcvQyxtQ0FBZ0M7QUFHaEMsSUFBTSxVQUFVLEdBQWhCLE1BQU0sVUFBVTtJQU1aLFlBQytCLFVBQXVCLEVBQ25CLGNBQStCO1FBRTlELElBQUksQ0FBQyxVQUFVLEdBQUcsVUFBVSxDQUFDO1FBQzdCLElBQUksQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFDO1FBQ3JDLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxDQUFDO0lBQ3BELENBQUM7SUFFTSxHQUFHLENBQUMsSUFBYztRQUNyQixPQ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__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var binding_on_syntax_1 = __webpack_require__(20); -var binding_when_syntax_1 = __webpack_require__(653); -var BindingWhenOnSyntax = (function () { - function BindingWhenOnSyntax(binding) { - this._binding = binding; - this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding); - this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding); - } - BindingWhenOnSyntax.prototype.when = function (constraint) { - return this._bindingWhenSyntax.when(constraint); - }; - BindingWhenOnSyntax.prototype.whenTargetNamed = function (name) { - return this._bindingWhenSyntax.whenTargetNamed(name); - }; - BindingWhenOnSyntax.prototype.whenTargetIsDefault = function () { - return this._bindingWhenSyntax.whenTargetIsDefault(); - }; - BindingWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) { - return this._bindingWhenSyntax.whenTargetTagged(tag, value); - }; - BindingWhenOnSyntax.prototype.whenInjectedInto = function (parent) { - return this._bindingWhenSyntax.whenInjectedInto(parent); - }; - BindingWhenOnSyntax.prototype.whenParentNamed = function (name) { - return this._bindingWhenSyntax.whenParentNamed(name); - }; - BindingWhenOnSyntax.prototype.whenParentTagged = function (tag, value) { - return this._bindingWhenSyntax.whenParentTagged(tag, value); - }; - BindingWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) { - return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor); - }; - BindingWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) { - return this._bindingWhenSyntax.whenNoAncestorIs(ancestor); - }; - BindingWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) { - return this._bindingWhenSyntax.whenAnyAncestorNamed(name); - }; - BindingWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) { - return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value); - }; - BindingWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) { - return this._bindingWhenSyntax.whenNoAncestorNamed(name); - }; - BindingWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) { - return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value); - }; - BindingWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) { - return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint); - }; - BindingWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) { - return this._bindingWhenSyntax.whenNoAncestorMatches(constraint); - }; - BindingWhenOnSyntax.prototype.onActivation = function (handler) { - return this._bindingOnSyntax.onActivation(handler); - }; - return BindingWhenOnSyntax; -}()); -exports.BindingWhenOnSyntax = BindingWhenOnSyntax; - - -/***/ }), - -/***/ 186: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var BindingScopeEnum = { - Request: "Request", - Singleton: "Singleton", - Transient: "Transient" -}; -exports.BindingScopeEnum = BindingScopeEnum; -var BindingTypeEnum = { - ConstantValue: "ConstantValue", - Constructor: "Constructor", - DynamicValue: "DynamicValue", - Factory: "Factory", - Function: "Function", - Instance: "Instance", - Invalid: "Invalid", - Provider: "Provider" -}; -exports.BindingTypeEnum = BindingTypeEnum; -var TargetTypeEnum = { - ClassProperty: "ClassProperty", - ConstructorArgument: "ConstructorArgument", - Variable: "Variable" -}; -exports.TargetTypeEnum = TargetTypeEnum; - - -/***/ }), - -/***/ 188: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); -var decorator_utils_1 = __webpack_require__(289); -function targetName(name) { - return function (target, targetKey, index) { - var metadata = new metadata_1.Metadata(METADATA_KEY.NAME_TAG, name); - decorator_utils_1.tagParameter(target, targetKey, index, metadata); - }; +/** + * The code to exit an action + */ +var ExitCode; +(function (ExitCode) { + /** + * A code indicating that the action was successful + */ + ExitCode[ExitCode["Success"] = 0] = "Success"; + /** + * A code indicating that the action was a failure + */ + ExitCode[ExitCode["Failure"] = 1] = "Failure"; +})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); +//----------------------------------------------------------------------- +// Variables +//----------------------------------------------------------------------- +/** + * Sets env variable for this action and future actions in the job + * @param name the name of the variable to set + * @param val the value of the variable + */ +function exportVariable(name, val) { + process.env[name] = val; + command_1.issueCommand('set-env', { name }, val); } -exports.targetName = targetName; - +exports.exportVariable = exportVariable; +/** + * Registers a secret which will get masked from logs + * @param secret value of the secret + */ +function setSecret(secret) { + command_1.issueCommand('add-mask', {}, secret); +} +exports.setSecret = setSecret; +/** + * Prepends inputPath to the PATH (for this action and future actions) + * @param inputPath + */ +function addPath(inputPath) { + command_1.issueCommand('add-path', {}, inputPath); + process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; +} +exports.addPath = addPath; +/** + * Gets the value of an input. The value is also trimmed. + * + * @param name name of the input to get + * @param options optional. See InputOptions. + * @returns string + */ +function getInput(name, options) { + const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; + if (options && options.required && !val) { + throw new Error(`Input required and not supplied: ${name}`); + } + return val.trim(); +} +exports.getInput = getInput; +/** + * Sets the value of an output. + * + * @param name name of the output to set + * @param value value to store + */ +function setOutput(name, value) { + command_1.issueCommand('set-output', { name }, value); +} +exports.setOutput = setOutput; +//----------------------------------------------------------------------- +// Results +//----------------------------------------------------------------------- +/** + * Sets the action status to failed. + * When the action exits it will be with an exit code of 1 + * @param message add error issue message + */ +function setFailed(message) { + process.exitCode = ExitCode.Failure; + error(message); +} +exports.setFailed = setFailed; +//----------------------------------------------------------------------- +// Logging Commands +//----------------------------------------------------------------------- +/** + * Writes debug message to user log + * @param message debug message + */ +function debug(message) { + command_1.issueCommand('debug', {}, message); +} +exports.debug = debug; +/** + * Adds an error issue + * @param message error issue message + */ +function error(message) { + command_1.issue('error', message); +} +exports.error = error; +/** + * Adds an warning issue + * @param message warning issue message + */ +function warning(message) { + command_1.issue('warning', message); +} +exports.warning = warning; +/** + * Writes info to log with console.log. + * @param message info message + */ +function info(message) { + process.stdout.write(message + os.EOL); +} +exports.info = info; +/** + * Begin an output group. + * + * Output until the next `groupEnd` will be foldable in this group + * + * @param name The name of the output group + */ +function startGroup(name) { + command_1.issue('group', name); +} +exports.startGroup = startGroup; +/** + * End an output group. + */ +function endGroup() { + command_1.issue('endgroup'); +} +exports.endGroup = endGroup; +/** + * Wrap an asynchronous function call in a group. + * + * Returns the same type as the function itself. + * + * @param name The name of the group + * @param fn The function to wrap in the group + */ +function group(name, fn) { + return __awaiter(this, void 0, void 0, function* () { + startGroup(name); + let result; + try { + result = yield fn(); + } + finally { + endGroup(); + } + return result; + }); +} +exports.group = group; +//----------------------------------------------------------------------- +// Wrapper action state +//----------------------------------------------------------------------- +/** + * Saves state for current action, the state can only be retrieved by this action's post job execution. + * + * @param name name of the state to store + * @param value value to store + */ +function saveState(name, value) { + command_1.issueCommand('save-state', { name }, value); +} +exports.saveState = saveState; +/** + * Gets the value of an state set by this action's main execution. + * + * @param name name of the state to get + * @returns string + */ +function getState(name) { + return process.env[`STATE_${name}`] || ''; +} +exports.getState = getState; +//# sourceMappingURL=core.js.map /***/ }), -/***/ 202: +/***/ 480: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var MetadataReader = (function () { - function MetadataReader() { - } - MetadataReader.prototype.getConstructorMetadata = function (constructorFunc) { - var compilerGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.PARAM_TYPES, constructorFunc); - var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED, constructorFunc); - return { - compilerGeneratedMetadata: compilerGeneratedMetadata, - userGeneratedMetadata: userGeneratedMetadata || {} - }; - }; - MetadataReader.prototype.getPropertiesMetadata = function (constructorFunc) { - var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, constructorFunc) || []; - return userGeneratedMetadata; - }; - return MetadataReader; -}()); -exports.MetadataReader = MetadataReader; +var ERROR_MSGS = __webpack_require__(800); +function isStackOverflowExeption(error) { + return (error instanceof RangeError || + error.message === ERROR_MSGS.STACK_OVERFLOW); +} +exports.isStackOverflowExeption = isStackOverflowExeption; /***/ }), -/***/ 211: +/***/ 523: /***/ (function(module) { -module.exports = require("https"); - -/***/ }), - -/***/ 212: -/***/ (function(module, __unusedexports, __webpack_require__) { - -module.exports = __webpack_require__(851); +module.exports = function cmp (a, b) { + var pa = a.split('.'); + var pb = b.split('.'); + for (var i = 0; i < 3; i++) { + var na = Number(pa[i]); + var nb = Number(pb[i]); + if (na > nb) return 1; + if (nb > na) return -1; + if (!isNaN(na) && isNaN(nb)) return 1; + if (isNaN(na) && !isNaN(nb)) return -1; + } + return 0; +}; /***/ }), -/***/ 226: +/***/ 533: /***/ (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 }); -var binding_in_syntax_1 = __webpack_require__(902); -var binding_on_syntax_1 = __webpack_require__(20); -var binding_when_syntax_1 = __webpack_require__(653); -var BindingInWhenOnSyntax = (function () { - function BindingInWhenOnSyntax(binding) { - this._binding = binding; - this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding); - this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding); - this._bindingInSyntax = new binding_in_syntax_1.BindingInSyntax(binding); +const core = __webpack_require__(470); +const io = __webpack_require__(1); +const fs = __webpack_require__(747); +const os = __webpack_require__(87); +const path = __webpack_require__(622); +const httpm = __webpack_require__(874); +const semver = __webpack_require__(550); +const uuidV4 = __webpack_require__(826); +const exec_1 = __webpack_require__(986); +const assert_1 = __webpack_require__(357); +class HTTPError extends Error { + constructor(httpStatusCode) { + super(`Unexpected HTTP response: ${httpStatusCode}`); + this.httpStatusCode = httpStatusCode; + Object.setPrototypeOf(this, new.target.prototype); } - BindingInWhenOnSyntax.prototype.inRequestScope = function () { - return this._bindingInSyntax.inRequestScope(); - }; - BindingInWhenOnSyntax.prototype.inSingletonScope = function () { - return this._bindingInSyntax.inSingletonScope(); - }; - BindingInWhenOnSyntax.prototype.inTransientScope = function () { - return this._bindingInSyntax.inTransientScope(); - }; - BindingInWhenOnSyntax.prototype.when = function (constraint) { - return this._bindingWhenSyntax.when(constraint); - }; - BindingInWhenOnSyntax.prototype.whenTargetNamed = function (name) { - return this._bindingWhenSyntax.whenTargetNamed(name); - }; - BindingInWhenOnSyntax.prototype.whenTargetIsDefault = function () { - return this._bindingWhenSyntax.whenTargetIsDefault(); - }; - BindingInWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) { - return this._bindingWhenSyntax.whenTargetTagged(tag, value); - }; - BindingInWhenOnSyntax.prototype.whenInjectedInto = function (parent) { - return this._bindingWhenSyntax.whenInjectedInto(parent); - }; - BindingInWhenOnSyntax.prototype.whenParentNamed = function (name) { - return this._bindingWhenSyntax.whenParentNamed(name); - }; - BindingInWhenOnSyntax.prototype.whenParentTagged = function (tag, value) { - return this._bindingWhenSyntax.whenParentTagged(tag, value); - }; - BindingInWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) { - return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor); - }; - BindingInWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) { - return this._bindingWhenSyntax.whenNoAncestorIs(ancestor); - }; - BindingInWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) { - return this._bindingWhenSyntax.whenAnyAncestorNamed(name); - }; - BindingInWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) { - return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value); - }; - BindingInWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) { - return this._bindingWhenSyntax.whenNoAncestorNamed(name); - }; - BindingInWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) { - return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value); - }; - BindingInWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) { - return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint); - }; - BindingInWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) { - return this._bindingWhenSyntax.whenNoAncestorMatches(constraint); - }; - BindingInWhenOnSyntax.prototype.onActivation = function (handler) { - return this._bindingOnSyntax.onActivation(handler); - }; - return BindingInWhenOnSyntax; -}()); -exports.BindingInWhenOnSyntax = BindingInWhenOnSyntax; - - -/***/ }), - -/***/ 289: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var ERROR_MSGS = __webpack_require__(516); -var METADATA_KEY = __webpack_require__(677); -function tagParameter(annotationTarget, propertyName, parameterIndex, metadata) { - var metadataKey = METADATA_KEY.TAGGED; - _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex); } -exports.tagParameter = tagParameter; -function tagProperty(annotationTarget, propertyName, metadata) { - var metadataKey = METADATA_KEY.TAGGED_PROP; - _tagParameterOrProperty(metadataKey, annotationTarget.constructor, propertyName, metadata); -} -exports.tagProperty = tagProperty; -function _tagParameterOrProperty(metadataKey, annotationTarget, propertyName, metadata, parameterIndex) { - var paramsOrPropertiesMetadata = {}; - var isParameterDecorator = (typeof parameterIndex === "number"); - var key = (parameterIndex !== undefined && isParameterDecorator) ? parameterIndex.toString() : propertyName; - if (isParameterDecorator && propertyName !== undefined) { - throw new Error(ERROR_MSGS.INVALID_DECORATOR_OPERATION); - } - if (Reflect.hasOwnMetadata(metadataKey, annotationTarget)) { - paramsOrPropertiesMetadata = Reflect.getMetadata(metadataKey, annotationTarget); - } - var paramOrPropertyMetadata = paramsOrPropertiesMetadata[key]; - if (!Array.isArray(paramOrPropertyMetadata)) { - paramOrPropertyMetadata = []; +exports.HTTPError = HTTPError; +const IS_WINDOWS = process.platform === 'win32'; +const userAgent = 'actions/tool-cache'; +// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this) +let tempDirectory = process.env['RUNNER_TEMP'] || ''; +let cacheRoot = process.env['RUNNER_TOOL_CACHE'] || ''; +// If directories not found, place them in common temp locations +if (!tempDirectory || !cacheRoot) { + let baseLocation; + if (IS_WINDOWS) { + // On windows use the USERPROFILE env variable + baseLocation = process.env['USERPROFILE'] || 'C:\\'; } else { - for (var _i = 0, paramOrPropertyMetadata_1 = paramOrPropertyMetadata; _i < paramOrPropertyMetadata_1.length; _i++) { - var m = paramOrPropertyMetadata_1[_i]; - if (m.key === metadata.key) { - throw new Error(ERROR_MSGS.DUPLICATED_METADATA + " " + m.key.toString()); + if (process.platform === 'darwin') { + baseLocation = '/Users'; + } + else { + baseLocation = '/home'; + } + } + if (!tempDirectory) { + tempDirectory = path.join(baseLocation, 'actions', 'temp'); + } + if (!cacheRoot) { + cacheRoot = path.join(baseLocation, 'actions', 'cache'); + } +} +/** + * Download a tool from an url and stream it into a file + * + * @param url url of tool to download + * @returns path to downloaded tool + */ +function downloadTool(url) { + return __awaiter(this, void 0, void 0, function* () { + // Wrap in a promise so that we can resolve from within stream callbacks + return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { + try { + const http = new httpm.HttpClient(userAgent, [], { + allowRetries: true, + maxRetries: 3 + }); + const destPath = path.join(tempDirectory, uuidV4()); + yield io.mkdirP(tempDirectory); + core.debug(`Downloading ${url}`); + core.debug(`Downloading ${destPath}`); + if (fs.existsSync(destPath)) { + throw new Error(`Destination file path ${destPath} already exists`); + } + const response = yield http.get(url); + if (response.message.statusCode !== 200) { + const err = new HTTPError(response.message.statusCode); + core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + throw err; + } + const file = fs.createWriteStream(destPath); + file.on('open', () => __awaiter(this, void 0, void 0, function* () { + try { + const stream = response.message.pipe(file); + stream.on('close', () => { + core.debug('download complete'); + resolve(destPath); + }); + } + catch (err) { + core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); + reject(err); + } + })); + file.on('error', err => { + file.end(); + reject(err); + }); + } + catch (err) { + reject(err); + } + })); + }); +} +exports.downloadTool = downloadTool; +/** + * Extract a .7z file + * + * @param file path to the .7z file + * @param dest destination directory. Optional. + * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this + * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will + * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is + * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line + * interface, it is smaller than the full command line interface, and it does support long paths. At the + * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. + * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path + * to 7zr.exe can be pass to this function. + * @returns path to the destination directory + */ +function extract7z(file, dest, _7zPath) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); + assert_1.ok(file, 'parameter "file" is required'); + dest = dest || (yield _createExtractFolder(dest)); + const originalCwd = process.cwd(); + process.chdir(dest); + if (_7zPath) { + try { + const args = [ + 'x', + '-bb1', + '-bd', + '-sccUTF-8', + file + ]; + const options = { + silent: true + }; + yield exec_1.exec(`"${_7zPath}"`, args, options); + } + finally { + process.chdir(originalCwd); + } + } + else { + const escapedScript = path + .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') + .replace(/'/g, "''") + .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + const options = { + silent: true + }; + try { + const powershellPath = yield io.which('powershell', true); + yield exec_1.exec(`"${powershellPath}"`, args, options); + } + finally { + process.chdir(originalCwd); + } + } + return dest; + }); +} +exports.extract7z = extract7z; +/** + * Extract a tar + * + * @param file path to the tar + * @param dest destination directory. Optional. + * @param flags flags for the tar. Optional. + * @returns path to the destination directory + */ +function extractTar(file, dest, flags = 'xz') { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); + } + dest = dest || (yield _createExtractFolder(dest)); + const tarPath = yield io.which('tar', true); + yield exec_1.exec(`"${tarPath}"`, [flags, '-C', dest, '-f', file]); + return dest; + }); +} +exports.extractTar = extractTar; +/** + * Extract a zip + * + * @param file path to the zip + * @param dest destination directory. Optional. + * @returns path to the destination directory + */ +function extractZip(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!file) { + throw new Error("parameter 'file' is required"); + } + dest = dest || (yield _createExtractFolder(dest)); + if (IS_WINDOWS) { + yield extractZipWin(file, dest); + } + else { + yield extractZipNix(file, dest); + } + return dest; + }); +} +exports.extractZip = extractZip; +function extractZipWin(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + // build the powershell command + const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines + const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); + const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; + // run powershell + const powershellPath = yield io.which('powershell'); + const args = [ + '-NoLogo', + '-Sta', + '-NoProfile', + '-NonInteractive', + '-ExecutionPolicy', + 'Unrestricted', + '-Command', + command + ]; + yield exec_1.exec(`"${powershellPath}"`, args); + }); +} +function extractZipNix(file, dest) { + return __awaiter(this, void 0, void 0, function* () { + const unzipPath = yield io.which('unzip'); + yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest }); + }); +} +/** + * Caches a directory and installs it into the tool cacheDir + * + * @param sourceDir the directory to cache into tools + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture + */ +function cacheDir(sourceDir, tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source dir: ${sourceDir}`); + if (!fs.statSync(sourceDir).isDirectory()) { + throw new Error('sourceDir is not a directory'); + } + // Create the tool dir + const destPath = yield _createToolPath(tool, version, arch); + // copy each child item. do not move. move can fail on Windows + // due to anti-virus software having an open handle on a file. + for (const itemName of fs.readdirSync(sourceDir)) { + const s = path.join(sourceDir, itemName); + yield io.cp(s, destPath, { recursive: true }); + } + // write .complete + _completeToolPath(tool, version, arch); + return destPath; + }); +} +exports.cacheDir = cacheDir; +/** + * Caches a downloaded file (GUID) and installs it + * into the tool cache with a given targetName + * + * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. + * @param targetFile the name of the file name in the tools directory + * @param tool tool name + * @param version version of the tool. semver format + * @param arch architecture of the tool. Optional. Defaults to machine architecture + */ +function cacheFile(sourceFile, targetFile, tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + version = semver.clean(version) || version; + arch = arch || os.arch(); + core.debug(`Caching tool ${tool} ${version} ${arch}`); + core.debug(`source file: ${sourceFile}`); + if (!fs.statSync(sourceFile).isFile()) { + throw new Error('sourceFile is not a file'); + } + // create the tool dir + const destFolder = yield _createToolPath(tool, version, arch); + // copy instead of move. move can fail on Windows due to + // anti-virus software having an open handle on a file. + const destPath = path.join(destFolder, targetFile); + core.debug(`destination file ${destPath}`); + yield io.cp(sourceFile, destPath); + // write .complete + _completeToolPath(tool, version, arch); + return destFolder; + }); +} +exports.cacheFile = cacheFile; +/** + * Finds the path to a tool version in the local installed tool cache + * + * @param toolName name of the tool + * @param versionSpec version of the tool + * @param arch optional arch. defaults to arch of computer + */ +function find(toolName, versionSpec, arch) { + if (!toolName) { + throw new Error('toolName parameter is required'); + } + if (!versionSpec) { + throw new Error('versionSpec parameter is required'); + } + arch = arch || os.arch(); + // attempt to resolve an explicit version + if (!_isExplicitVersion(versionSpec)) { + const localVersions = findAllVersions(toolName, arch); + const match = _evaluateVersions(localVersions, versionSpec); + versionSpec = match; + } + // check for the explicit version in the cache + let toolPath = ''; + if (versionSpec) { + versionSpec = semver.clean(versionSpec) || ''; + const cachePath = path.join(cacheRoot, toolName, versionSpec, arch); + core.debug(`checking cache: ${cachePath}`); + if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { + core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); + toolPath = cachePath; + } + else { + core.debug('not found'); + } + } + return toolPath; +} +exports.find = find; +/** + * Finds the paths to all versions of a tool that are installed in the local tool cache + * + * @param toolName name of the tool + * @param arch optional arch. defaults to arch of computer + */ +function findAllVersions(toolName, arch) { + const versions = []; + arch = arch || os.arch(); + const toolPath = path.join(cacheRoot, toolName); + if (fs.existsSync(toolPath)) { + const children = fs.readdirSync(toolPath); + for (const child of children) { + if (_isExplicitVersion(child)) { + const fullPath = path.join(toolPath, child, arch || ''); + if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { + versions.push(child); + } } } } - paramOrPropertyMetadata.push(metadata); - paramsOrPropertiesMetadata[key] = paramOrPropertyMetadata; - Reflect.defineMetadata(metadataKey, paramsOrPropertiesMetadata, annotationTarget); + return versions; } -function _decorate(decorators, target) { - Reflect.decorate(decorators, target); +exports.findAllVersions = findAllVersions; +function _createExtractFolder(dest) { + return __awaiter(this, void 0, void 0, function* () { + if (!dest) { + // create a temp dir + dest = path.join(tempDirectory, uuidV4()); + } + yield io.mkdirP(dest); + return dest; + }); } -function _param(paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); }; +function _createToolPath(tool, version, arch) { + return __awaiter(this, void 0, void 0, function* () { + const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); + core.debug(`destination ${folderPath}`); + const markerPath = `${folderPath}.complete`; + yield io.rmRF(folderPath); + yield io.rmRF(markerPath); + yield io.mkdirP(folderPath); + return folderPath; + }); } -function decorate(decorator, target, parameterIndex) { - if (typeof parameterIndex === "number") { - _decorate([_param(parameterIndex, decorator)], target); +function _completeToolPath(tool, version, arch) { + const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); + const markerPath = `${folderPath}.complete`; + fs.writeFileSync(markerPath, ''); + core.debug('finished caching tool'); +} +function _isExplicitVersion(versionSpec) { + const c = semver.clean(versionSpec) || ''; + core.debug(`isExplicit: ${c}`); + const valid = semver.valid(c) != null; + core.debug(`explicit? ${valid}`); + return valid; +} +function _evaluateVersions(versions, versionSpec) { + let version = ''; + core.debug(`evaluating ${versions.length} versions`); + versions = versions.sort((a, b) => { + if (semver.gt(a, b)) { + return 1; + } + return -1; + }); + for (let i = versions.length - 1; i >= 0; i--) { + const potential = versions[i]; + const satisfied = semver.satisfies(potential, versionSpec); + if (satisfied) { + version = potential; + break; + } } - else if (typeof parameterIndex === "string") { - Reflect.decorate([decorator], target, parameterIndex); + if (version) { + core.debug(`matched: ${version}`); } else { - _decorate([decorator], target); + core.debug('match not found'); } + return version; } -exports.decorate = decorate; - +//# sourceMappingURL=tool-cache.js.map /***/ }), -/***/ 323: +/***/ 550: /***/ (function(module, exports) { exports = module.exports = SemVer @@ -4390,46 +7120,263 @@ function coerce (version, options) { /***/ }), -/***/ 355: +/***/ 567: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var ERROR_MSGS = __webpack_require__(516); -function isStackOverflowExeption(error) { - return (error instanceof RangeError || - error.message === ERROR_MSGS.STACK_OVERFLOW); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); +var decorator_utils_1 = __webpack_require__(309); +function targetName(name) { + return function (target, targetKey, index) { + var metadata = new metadata_1.Metadata(METADATA_KEY.NAME_TAG, name); + decorator_utils_1.tagParameter(target, targetKey, index, metadata); + }; } -exports.isStackOverflowExeption = isStackOverflowExeption; +exports.targetName = targetName; /***/ }), -/***/ 357: +/***/ 605: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +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 }); +const fs = __webpack_require__(747); +const os = __webpack_require__(87); +const path = __webpack_require__(622); +const semver = __webpack_require__(280); +const http = __webpack_require__(874); +const inversify_1 = __webpack_require__(410); +const types_1 = __webpack_require__(639); +let DotnetTool = class DotnetTool { + constructor(buildAgent, versionManager) { + this.buildAgent = buildAgent; + this.versionManager = versionManager; + this.httpClient = new http.HttpClient("dotnet"); + } + run(args) { + return this.buildAgent.exec("dotnet", args); + } + toolInstall(toolName, versionSpec, checkLatest, includePre) { + return __awaiter(this, void 0, void 0, function* () { + console.log(""); + console.log("--------------------------"); + console.log(`Installing ${toolName} version ` + versionSpec); + console.log("--------------------------"); + if (this.versionManager.isExplicitVersion(versionSpec)) { + checkLatest = false; // check latest doesn't make sense when explicit version + } + let toolPath; + if (!checkLatest) { + // + // Let's try and resolve the version spec locally first + // + toolPath = this.buildAgent.find(toolName, versionSpec); + } + if (!toolPath) { + let version; + if (this.versionManager.isExplicitVersion(versionSpec)) { + // + // Explicit version was specified. No need to query for list of versions. + // + version = versionSpec; + } + else { + // + // Let's query and resolve the latest version for the versionSpec. + // If the version is an explicit version (1.1.1 or v1.1.1) then no need to query. + // If your tool doesn't offer a mechanism to query, + // then it can only support exact version inputs. + // + version = yield this.queryLatestMatch(toolName, versionSpec, includePre); + if (!version) { + throw new Error(`Unable to find ${toolName} version '${versionSpec}'.`); + } + // + // Check the cache for the resolved version. + // + toolPath = this.buildAgent.find(toolName, version); + } + if (!toolPath) { + // + // Download, extract, cache + // + toolPath = yield this.acquireTool(toolName, version); + } + } + // + // Prepend the tools path. This prepends the PATH for the current process and + // instructs the agent to prepend for each task that follows. + // + this.buildAgent.debug(`toolPath: ${toolPath}`); + if (os.platform() !== "win32") { + const dotnetRoot = path.dirname(fs.readlinkSync(yield this.buildAgent.which("dotnet"))); + this.buildAgent.exportVariable("DOTNET_ROOT", dotnetRoot); + } + this.buildAgent.addPath(toolPath); + return toolPath; + }); + } + queryLatestMatch(toolName, versionSpec, includePrerelease) { + return __awaiter(this, void 0, void 0, function* () { + this.buildAgent.debug(`querying tool versions for ${toolName}${versionSpec ? `@${versionSpec}` : ""} ${includePrerelease ? "including pre-releases" : ""}`); + const downloadPath = `https://api-v2v3search-0.nuget.org/query?q=${encodeURIComponent(toolName.toLowerCase())}&prerelease=${includePrerelease ? "true" : "false"}&semVerLevel=2.0.0`; + const res = yield this.httpClient.get(downloadPath); + if (!res || res.message.statusCode !== 200) { + return null; + } + const body = yield res.readBody(); + const data = JSON.parse(body).data; + const versions = data[0].versions.map((x) => x.version); + if (!versions || !versions.length) { + return null; + } + this.buildAgent.debug(`got versions: ${versions.join(", ")}`); + return this.versionManager.evaluateVersions(versions, versionSpec); + }); + } + acquireTool(toolName, version) { + return __awaiter(this, void 0, void 0, function* () { + const tempDirectory = yield this.buildAgent.createTempDir(); + let args = ["tool", "install", toolName, "--tool-path", tempDirectory]; + if (version) { + version = this.versionManager.cleanVersion(version); + args = args.concat(["--version", version]); + } + const result = yield this.run(args); + const status = result.code === 0 ? "success" : "failure"; + const message = result.code === 0 ? result.stdout : result.stderr; + this.buildAgent.debug(`tool install result: ${status} ${message}`); + if (result.code) { + throw new Error("Error installing tool"); + } + return yield this.buildAgent.cacheDir(tempDirectory, toolName, version); + }); + } +}; +DotnetTool = __decorate([ + inversify_1.injectable(), + __param(0, inversify_1.inject(types_1.TYPES.IBuildAgent)), + __param(1, inversify_1.inject(types_1.TYPES.IVersionManager)), + __metadata("design:paramtypes", [Object, Object]) +], DotnetTool); +exports.DotnetTool = DotnetTool; +let GitVersionTool = class GitVersionTool { + constructor(dotnetTool) { + this.dotnetTool = dotnetTool; + } + install(versionSpec, includePrerelease) { + return __awaiter(this, void 0, void 0, function* () { + const toolPath = yield this.dotnetTool.toolInstall("GitVersion.Tool", versionSpec, false, includePrerelease); + }); + } + run(...params) { + return; + } +}; +GitVersionTool = __decorate([ + inversify_1.injectable(), + __param(0, inversify_1.inject(types_1.TYPES.IDotnetTool)), + __metadata("design:paramtypes", [Object]) +], GitVersionTool); +exports.GitVersionTool = GitVersionTool; +const cmp = __webpack_require__(523); +let VersionManager = class VersionManager { + constructor(buildAgent) { + this.buildAgent = buildAgent; + } + isExplicitVersion(versionSpec) { + const c = semver.clean(versionSpec); + this.buildAgent.debug("isExplicit: " + c); + const valid = semver.valid(c) != null; + this.buildAgent.debug("explicit? " + valid); + return valid; + } + evaluateVersions(versions, versionSpec) { + let version; + this.buildAgent.debug("evaluating " + versions.length + " versions"); + versions = versions.sort(cmp); + for (let i = versions.length - 1; i >= 0; i--) { + const potential = versions[i]; + const satisfied = semver.satisfies(potential, versionSpec); + if (satisfied) { + version = potential; + break; + } + } + if (version) { + this.buildAgent.debug("matched: " + version); + } + else { + this.buildAgent.debug("match not found"); + } + return version; + } + cleanVersion(version) { + this.buildAgent.debug("cleaning: " + version); + return semver.clean(version); + } +}; +VersionManager = __decorate([ + inversify_1.injectable(), + __param(0, inversify_1.inject(types_1.TYPES.IBuildAgent)), + __metadata("design:paramtypes", [Object]) +], VersionManager); +exports.VersionManager = VersionManager; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9EOi9Qcm9qZWN0cy9PU1MvR2l0VG9vbHMvdXNlLWdpdHZlcnNpb24vc3JjL2NvbW1vbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUNBLHlCQUF5QjtBQUN6Qix5QkFBeUI7QUFDekIsNkJBQTZCO0FBQzdCLGlDQUFpQztBQUNqQyxxREFBcUQ7QUFFckQseUNBQStDO0FBRy9DLG1DQUFnQztBQUdoQyxJQUFNLFVBQVUsR0FBaEIsTUFBTSxVQUFVO0lBTVosWUFDK0IsVUFBdUIsRUFDbkIsY0FBK0I7UUFFOUQsSUFBSSxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUM7UUFDN0IsSUFBSSxDQUFDLGNBQWMsR0FBRyxjQUFjLENBQUM7UUFDckMsSUFBSSxDQUFDLFVBQVUsR0FBRyxJQUFJLElBQUksQ0FBQyxVQUFVLENBQUMsUUFBUSxDQUFDLENBQUM7S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VcsQ0FBQyxDQUFBOztHQUo1QixjQUFjLENBNkNuQjtBQUtHLHdDQUFjIn0= + +/***/ }), + +/***/ 614: /***/ (function(module) { -module.exports = require("assert"); +module.exports = require("events"); /***/ }), -/***/ 365: +/***/ 622: /***/ (function(module) { -module.exports = require("os"); +module.exports = require("path"); /***/ }), -/***/ 380: +/***/ 625: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var error_msgs_1 = __webpack_require__(516); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); -var decorator_utils_1 = __webpack_require__(289); +var error_msgs_1 = __webpack_require__(800); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); +var decorator_utils_1 = __webpack_require__(309); var LazyServiceIdentifer = (function () { function LazyServiceIdentifer(cb) { this._cb = cb; @@ -4459,62 +7406,38 @@ exports.inject = inject; /***/ }), -/***/ 386: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ 631: +/***/ (function(module) { + +module.exports = require("net"); + +/***/ }), + +/***/ 639: +/***/ (function(__unusedmodule, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var keys = __webpack_require__(677); -exports.METADATA_KEY = keys; -var container_1 = __webpack_require__(15); -exports.Container = container_1.Container; -var literal_types_1 = __webpack_require__(186); -exports.BindingScopeEnum = literal_types_1.BindingScopeEnum; -exports.BindingTypeEnum = literal_types_1.BindingTypeEnum; -exports.TargetTypeEnum = literal_types_1.TargetTypeEnum; -var container_module_1 = __webpack_require__(752); -exports.AsyncContainerModule = container_module_1.AsyncContainerModule; -exports.ContainerModule = container_module_1.ContainerModule; -var injectable_1 = __webpack_require__(919); -exports.injectable = injectable_1.injectable; -var tagged_1 = __webpack_require__(148); -exports.tagged = tagged_1.tagged; -var named_1 = __webpack_require__(758); -exports.named = named_1.named; -var inject_1 = __webpack_require__(380); -exports.inject = inject_1.inject; -exports.LazyServiceIdentifer = inject_1.LazyServiceIdentifer; -var optional_1 = __webpack_require__(996); -exports.optional = optional_1.optional; -var unmanaged_1 = __webpack_require__(656); -exports.unmanaged = unmanaged_1.unmanaged; -var multi_inject_1 = __webpack_require__(891); -exports.multiInject = multi_inject_1.multiInject; -var target_name_1 = __webpack_require__(188); -exports.targetName = target_name_1.targetName; -var post_construct_1 = __webpack_require__(442); -exports.postConstruct = post_construct_1.postConstruct; -var metadata_reader_1 = __webpack_require__(202); -exports.MetadataReader = metadata_reader_1.MetadataReader; -var id_1 = __webpack_require__(786); -exports.id = id_1.id; -var decorator_utils_1 = __webpack_require__(289); -exports.decorate = decorator_utils_1.decorate; -var constraint_helpers_1 = __webpack_require__(599); -exports.traverseAncerstors = constraint_helpers_1.traverseAncerstors; -exports.taggedConstraint = constraint_helpers_1.taggedConstraint; -exports.namedConstraint = constraint_helpers_1.namedConstraint; -exports.typeConstraint = constraint_helpers_1.typeConstraint; -var serialization_1 = __webpack_require__(571); -exports.getServiceIdentifierAsString = serialization_1.getServiceIdentifierAsString; -var binding_utils_1 = __webpack_require__(911); -exports.multiBindToService = binding_utils_1.multiBindToService; - +const TYPES = { + IBuildAgent: Symbol.for("BuildAgent"), + IDotnetTool: Symbol.for("DotnetTool"), + IGitVersionTool: Symbol.for("GitVersionTool"), + IVersionManager: Symbol.for("VersionManager"), +}; +exports.TYPES = TYPES; +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9EOi9Qcm9qZWN0cy9PU1MvR2l0VG9vbHMvdXNlLWdpdHZlcnNpb24vc3JjL3R5cGVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsTUFBTSxLQUFLLEdBQUc7SUFDVixXQUFXLEVBQUUsTUFBTSxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUM7SUFDckMsV0FBVyxFQUFFLE1BQU0sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDO0lBQ3JDLGVBQWUsRUFBRSxNQUFNLENBQUMsR0FBRyxDQUFDLGdCQUFnQixDQUFDO0lBQzdDLGVBQWUsRUFBRSxNQUFNLENBQUMsR0FBRyxDQUFDLGdCQUFnQixDQUFDO0NBQ2hELENBQUM7QUFFTyxzQkFBSyJ9 /***/ }), -/***/ 396: +/***/ 669: +/***/ (function(module) { + +module.exports = require("util"); + +/***/ }), + +/***/ 672: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; @@ -4528,903 +7451,204 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; +var _a; Object.defineProperty(exports, "__esModule", { value: true }); -const os = __webpack_require__(365); -const events = __webpack_require__(614); -const child = __webpack_require__(129); -/* eslint-disable @typescript-eslint/unbound-method */ -const IS_WINDOWS = process.platform === 'win32'; -/* - * Class for running command line tools. Handles quoting and arg parsing in a platform agnostic way. - */ -class ToolRunner extends events.EventEmitter { - constructor(toolPath, args, options) { - super(); - if (!toolPath) { - throw new Error("Parameter 'toolPath' cannot be null or empty."); - } - this.toolPath = toolPath; - this.args = args || []; - this.options = options || {}; - } - _debug(message) { - if (this.options.listeners && this.options.listeners.debug) { - this.options.listeners.debug(message); - } - } - _getCommandString(options, noPrefix) { - const toolPath = this._getSpawnFileName(); - const args = this._getSpawnArgs(options); - let cmd = noPrefix ? '' : '[command]'; // omit prefix when piped to a second tool - if (IS_WINDOWS) { - // Windows + cmd file - if (this._isCmdFile()) { - cmd += toolPath; - for (const a of args) { - cmd += ` ${a}`; - } - } - // Windows + verbatim - else if (options.windowsVerbatimArguments) { - cmd += `"${toolPath}"`; - for (const a of args) { - cmd += ` ${a}`; - } - } - // Windows (regular) - else { - cmd += this._windowsQuoteCmdArg(toolPath); - for (const a of args) { - cmd += ` ${this._windowsQuoteCmdArg(a)}`; - } - } - } - else { - // OSX/Linux - this can likely be improved with some form of quoting. - // creating processes on Unix is fundamentally different than Windows. - // on Unix, execvp() takes an arg array. - cmd += toolPath; - for (const a of args) { - cmd += ` ${a}`; - } - } - return cmd; - } - _processLineBuffer(data, strBuffer, onLine) { +const assert_1 = __webpack_require__(357); +const fs = __webpack_require__(747); +const path = __webpack_require__(622); +_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; +exports.IS_WINDOWS = process.platform === 'win32'; +function exists(fsPath) { + return __awaiter(this, void 0, void 0, function* () { try { - let s = strBuffer + data.toString(); - let n = s.indexOf(os.EOL); - while (n > -1) { - const line = s.substring(0, n); - onLine(line); - // the rest of the string ... - s = s.substring(n + os.EOL.length); - n = s.indexOf(os.EOL); - } - strBuffer = s; + yield exports.stat(fsPath); } catch (err) { - // streaming lines to console is best effort. Don't fail a build. - this._debug(`error processing line. Failed with error ${err}`); - } - } - _getSpawnFileName() { - if (IS_WINDOWS) { - if (this._isCmdFile()) { - return process.env['COMSPEC'] || 'cmd.exe'; + if (err.code === 'ENOENT') { + return false; } + throw err; } - return this.toolPath; - } - _getSpawnArgs(options) { - if (IS_WINDOWS) { - if (this._isCmdFile()) { - let argline = `/D /S /C "${this._windowsQuoteCmdArg(this.toolPath)}`; - for (const a of this.args) { - argline += ' '; - argline += options.windowsVerbatimArguments - ? a - : this._windowsQuoteCmdArg(a); - } - argline += '"'; - return [argline]; - } - } - return this.args; - } - _endsWith(str, end) { - return str.endsWith(end); - } - _isCmdFile() { - const upperToolPath = this.toolPath.toUpperCase(); - return (this._endsWith(upperToolPath, '.CMD') || - this._endsWith(upperToolPath, '.BAT')); - } - _windowsQuoteCmdArg(arg) { - // for .exe, apply the normal quoting rules that libuv applies - if (!this._isCmdFile()) { - return this._uvQuoteCmdArg(arg); - } - // otherwise apply quoting rules specific to the cmd.exe command line parser. - // the libuv rules are generic and are not designed specifically for cmd.exe - // command line parser. - // - // for a detailed description of the cmd.exe command line parser, refer to - // http://stackoverflow.com/questions/4094699/how-does-the-windows-command-interpreter-cmd-exe-parse-scripts/7970912#7970912 - // need quotes for empty arg - if (!arg) { - return '""'; - } - // determine whether the arg needs to be quoted - const cmdSpecialChars = [ - ' ', - '\t', - '&', - '(', - ')', - '[', - ']', - '{', - '}', - '^', - '=', - ';', - '!', - "'", - '+', - ',', - '`', - '~', - '|', - '<', - '>', - '"' - ]; - let needsQuotes = false; - for (const char of arg) { - if (cmdSpecialChars.some(x => x === char)) { - needsQuotes = true; - break; - } - } - // short-circuit if quotes not needed - if (!needsQuotes) { - return arg; - } - // the following quoting rules are very similar to the rules that by libuv applies. - // - // 1) wrap the string in quotes - // - // 2) double-up quotes - i.e. " => "" - // - // this is different from the libuv quoting rules. libuv replaces " with \", which unfortunately - // doesn't work well with a cmd.exe command line. - // - // note, replacing " with "" also works well if the arg is passed to a downstream .NET console app. - // for example, the command line: - // foo.exe "myarg:""my val""" - // is parsed by a .NET console app into an arg array: - // [ "myarg:\"my val\"" ] - // which is the same end result when applying libuv quoting rules. although the actual - // command line from libuv quoting rules would look like: - // foo.exe "myarg:\"my val\"" - // - // 3) double-up slashes that precede a quote, - // e.g. hello \world => "hello \world" - // hello\"world => "hello\\""world" - // hello\\"world => "hello\\\\""world" - // hello world\ => "hello world\\" - // - // technically this is not required for a cmd.exe command line, or the batch argument parser. - // the reasons for including this as a .cmd quoting rule are: - // - // a) this is optimized for the scenario where the argument is passed from the .cmd file to an - // external program. many programs (e.g. .NET console apps) rely on the slash-doubling rule. - // - // b) it's what we've been doing previously (by deferring to node default behavior) and we - // haven't heard any complaints about that aspect. - // - // note, a weakness of the quoting rules chosen here, is that % is not escaped. in fact, % cannot be - // escaped when used on the command line directly - even though within a .cmd file % can be escaped - // by using %%. - // - // the saving grace is, on the command line, %var% is left as-is if var is not defined. this contrasts - // the line parsing rules within a .cmd file, where if var is not defined it is replaced with nothing. - // - // one option that was explored was replacing % with ^% - i.e. %var% => ^%var^%. this hack would - // often work, since it is unlikely that var^ would exist, and the ^ character is removed when the - // variable is used. the problem, however, is that ^ is not removed when %* is used to pass the args - // to an external program. - // - // an unexplored potential solution for the % escaping problem, is to create a wrapper .cmd file. - // % can be escaped within a .cmd file. - let reverse = '"'; - let quoteHit = true; - for (let i = arg.length; i > 0; i--) { - // walk the string in reverse - reverse += arg[i - 1]; - if (quoteHit && arg[i - 1] === '\\') { - reverse += '\\'; // double the slash - } - else if (arg[i - 1] === '"') { - quoteHit = true; - reverse += '"'; // double the quote - } - else { - quoteHit = false; - } - } - reverse += '"'; - return reverse - .split('') - .reverse() - .join(''); - } - _uvQuoteCmdArg(arg) { - // Tool runner wraps child_process.spawn() and needs to apply the same quoting as - // Node in certain cases where the undocumented spawn option windowsVerbatimArguments - // is used. - // - // Since this function is a port of quote_cmd_arg from Node 4.x (technically, lib UV, - // see https://github.com/nodejs/node/blob/v4.x/deps/uv/src/win/process.c for details), - // pasting copyright notice from Node within this function: - // - // Copyright Joyent, Inc. and other Node contributors. All rights reserved. - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files (the "Software"), to - // deal in the Software without restriction, including without limitation the - // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - // sell copies of the Software, and to permit persons to whom the Software is - // furnished to do so, subject to the following conditions: - // - // The above copyright notice and this permission notice shall be included in - // all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - // IN THE SOFTWARE. - if (!arg) { - // Need double quotation for empty argument - return '""'; - } - if (!arg.includes(' ') && !arg.includes('\t') && !arg.includes('"')) { - // No quotation needed - return arg; - } - if (!arg.includes('"') && !arg.includes('\\')) { - // No embedded double quotes or backslashes, so I can just wrap - // quote marks around the whole thing. - return `"${arg}"`; - } - // Expected input/output: - // input : hello"world - // output: "hello\"world" - // input : hello""world - // output: "hello\"\"world" - // input : hello\world - // output: hello\world - // input : hello\\world - // output: hello\\world - // input : hello\"world - // output: "hello\\\"world" - // input : hello\\"world - // output: "hello\\\\\"world" - // input : hello world\ - // output: "hello world\\" - note the comment in libuv actually reads "hello world\" - // but it appears the comment is wrong, it should be "hello world\\" - let reverse = '"'; - let quoteHit = true; - for (let i = arg.length; i > 0; i--) { - // walk the string in reverse - reverse += arg[i - 1]; - if (quoteHit && arg[i - 1] === '\\') { - reverse += '\\'; - } - else if (arg[i - 1] === '"') { - quoteHit = true; - reverse += '\\'; - } - else { - quoteHit = false; - } - } - reverse += '"'; - return reverse - .split('') - .reverse() - .join(''); - } - _cloneExecOptions(options) { - options = options || {}; - const result = { - cwd: options.cwd || process.cwd(), - env: options.env || process.env, - silent: options.silent || false, - windowsVerbatimArguments: options.windowsVerbatimArguments || false, - failOnStdErr: options.failOnStdErr || false, - ignoreReturnCode: options.ignoreReturnCode || false, - delay: options.delay || 10000 - }; - result.outStream = options.outStream || process.stdout; - result.errStream = options.errStream || process.stderr; - return result; - } - _getSpawnOptions(options, toolPath) { - options = options || {}; - const result = {}; - result.cwd = options.cwd; - result.env = options.env; - result['windowsVerbatimArguments'] = - options.windowsVerbatimArguments || this._isCmdFile(); - if (options.windowsVerbatimArguments) { - result.argv0 = `"${toolPath}"`; - } - return result; - } - /** - * Exec a tool. - * Output will be streamed to the live console. - * Returns promise with return code - * - * @param tool path to tool to exec - * @param options optional exec options. See ExecOptions - * @returns number - */ - exec() { - return __awaiter(this, void 0, void 0, function* () { - return new Promise((resolve, reject) => { - this._debug(`exec tool: ${this.toolPath}`); - this._debug('arguments:'); - for (const arg of this.args) { - this._debug(` ${arg}`); - } - const optionsNonNull = this._cloneExecOptions(this.options); - if (!optionsNonNull.silent && optionsNonNull.outStream) { - optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL); - } - const state = new ExecState(optionsNonNull, this.toolPath); - state.on('debug', (message) => { - this._debug(message); - }); - const fileName = this._getSpawnFileName(); - const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); - const stdbuffer = ''; - if (cp.stdout) { - cp.stdout.on('data', (data) => { - if (this.options.listeners && this.options.listeners.stdout) { - this.options.listeners.stdout(data); - } - if (!optionsNonNull.silent && optionsNonNull.outStream) { - optionsNonNull.outStream.write(data); - } - this._processLineBuffer(data, stdbuffer, (line) => { - if (this.options.listeners && this.options.listeners.stdline) { - this.options.listeners.stdline(line); - } - }); - }); - } - const errbuffer = ''; - if (cp.stderr) { - cp.stderr.on('data', (data) => { - state.processStderr = true; - if (this.options.listeners && this.options.listeners.stderr) { - this.options.listeners.stderr(data); - } - if (!optionsNonNull.silent && - optionsNonNull.errStream && - optionsNonNull.outStream) { - const s = optionsNonNull.failOnStdErr - ? optionsNonNull.errStream - : optionsNonNull.outStream; - s.write(data); - } - this._processLineBuffer(data, errbuffer, (line) => { - if (this.options.listeners && this.options.listeners.errline) { - this.options.listeners.errline(line); - } - }); - }); - } - cp.on('error', (err) => { - state.processError = err.message; - state.processExited = true; - state.processClosed = true; - state.CheckComplete(); - }); - cp.on('exit', (code) => { - state.processExitCode = code; - state.processExited = true; - this._debug(`Exit code ${code} received from tool '${this.toolPath}'`); - state.CheckComplete(); - }); - cp.on('close', (code) => { - state.processExitCode = code; - state.processExited = true; - state.processClosed = true; - this._debug(`STDIO streams have closed for tool '${this.toolPath}'`); - state.CheckComplete(); - }); - state.on('done', (error, exitCode) => { - if (stdbuffer.length > 0) { - this.emit('stdline', stdbuffer); - } - if (errbuffer.length > 0) { - this.emit('errline', errbuffer); - } - cp.removeAllListeners(); - if (error) { - reject(error); - } - else { - resolve(exitCode); - } - }); - }); - }); - } + return true; + }); } -exports.ToolRunner = ToolRunner; +exports.exists = exists; +function isDirectory(fsPath, useStat = false) { + return __awaiter(this, void 0, void 0, function* () { + const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath); + return stats.isDirectory(); + }); +} +exports.isDirectory = isDirectory; /** - * Convert an arg string to an array of args. Handles escaping - * - * @param argString string of arguments - * @returns string[] array of arguments + * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: + * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). */ -function argStringToArray(argString) { - const args = []; - let inQuotes = false; - let escaped = false; - let arg = ''; - function append(c) { - // we only escape double quotes. - if (escaped && c !== '"') { - arg += '\\'; - } - arg += c; - escaped = false; +function isRooted(p) { + p = normalizeSeparators(p); + if (!p) { + throw new Error('isRooted() parameter "p" cannot be empty'); } - for (let i = 0; i < argString.length; i++) { - const c = argString.charAt(i); - if (c === '"') { - if (!escaped) { - inQuotes = !inQuotes; - } - else { - append(c); - } - continue; - } - if (c === '\\' && escaped) { - append(c); - continue; - } - if (c === '\\' && inQuotes) { - escaped = true; - continue; - } - if (c === ' ' && !inQuotes) { - if (arg.length > 0) { - args.push(arg); - arg = ''; - } - continue; - } - append(c); + if (exports.IS_WINDOWS) { + return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello + ); // e.g. C: or C:\hello } - if (arg.length > 0) { - args.push(arg.trim()); - } - return args; + return p.startsWith('/'); } -exports.argStringToArray = argStringToArray; -class ExecState extends events.EventEmitter { - constructor(options, toolPath) { - super(); - this.processClosed = false; // tracks whether the process has exited and stdio is closed - this.processError = ''; - this.processExitCode = 0; - this.processExited = false; // tracks whether the process has exited - this.processStderr = false; // tracks whether stderr was written to - this.delay = 10000; // 10 seconds - this.done = false; - this.timeout = null; - if (!toolPath) { - throw new Error('toolPath must not be empty'); - } - this.options = options; - this.toolPath = toolPath; - if (options.delay) { - this.delay = options.delay; - } - } - CheckComplete() { - if (this.done) { +exports.isRooted = isRooted; +/** + * Recursively create a directory at `fsPath`. + * + * This implementation is optimistic, meaning it attempts to create the full + * path first, and backs up the path stack from there. + * + * @param fsPath The path to create + * @param maxDepth The maximum recursion depth + * @param depth The current recursion depth + */ +function mkdirP(fsPath, maxDepth = 1000, depth = 1) { + return __awaiter(this, void 0, void 0, function* () { + assert_1.ok(fsPath, 'a path argument must be provided'); + fsPath = path.resolve(fsPath); + if (depth >= maxDepth) + return exports.mkdir(fsPath); + try { + yield exports.mkdir(fsPath); return; } - if (this.processClosed) { - this._setResult(); - } - else if (this.processExited) { - this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this); - } - } - _debug(message) { - this.emit('debug', message); - } - _setResult() { - // determine whether there is an error - let error; - if (this.processExited) { - if (this.processError) { - error = new Error(`There was an error when attempting to execute the process '${this.toolPath}'. This may indicate the process failed to start. Error: ${this.processError}`); - } - else if (this.processExitCode !== 0 && !this.options.ignoreReturnCode) { - error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`); - } - else if (this.processStderr && this.options.failOnStdErr) { - error = new Error(`The process '${this.toolPath}' failed because one or more lines were written to the STDERR stream`); - } - } - // clear the timeout - if (this.timeout) { - clearTimeout(this.timeout); - this.timeout = null; - } - this.done = true; - this.emit('done', error, this.processExitCode); - } - static HandleTimeout(state) { - if (state.done) { - return; - } - if (!state.processClosed && state.processExited) { - const message = `The STDIO streams did not close within ${state.delay / - 1000} seconds of the exit event from process '${state.toolPath}'. This may indicate a child process inherited the STDIO streams and has not yet exited.`; - state._debug(message); - } - state._setResult(); - } -} -//# sourceMappingURL=toolrunner.js.map - -/***/ }), - -/***/ 417: -/***/ (function(module) { - -module.exports = require("crypto"); - -/***/ }), - -/***/ 442: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var ERRORS_MSGS = __webpack_require__(516); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); -function postConstruct() { - return function (target, propertyKey, descriptor) { - var metadata = new metadata_1.Metadata(METADATA_KEY.POST_CONSTRUCT, propertyKey); - if (Reflect.hasOwnMetadata(METADATA_KEY.POST_CONSTRUCT, target.constructor)) { - throw new Error(ERRORS_MSGS.MULTIPLE_POST_CONSTRUCT_METHODS); - } - Reflect.defineMetadata(METADATA_KEY.POST_CONSTRUCT, metadata, target.constructor); - }; -} -exports.postConstruct = postConstruct; - - -/***/ }), - -/***/ 462: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var Plan = (function () { - function Plan(parentContext, rootRequest) { - this.parentContext = parentContext; - this.rootRequest = rootRequest; - } - return Plan; -}()); -exports.Plan = Plan; - - -/***/ }), - -/***/ 502: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var ERROR_MSGS = __webpack_require__(516); -var literal_types_1 = __webpack_require__(186); -var exceptions_1 = __webpack_require__(355); -var serialization_1 = __webpack_require__(571); -var instantiation_1 = __webpack_require__(9); -var invokeFactory = function (factoryType, serviceIdentifier, fn) { - try { - return fn(); - } - catch (error) { - if (exceptions_1.isStackOverflowExeption(error)) { - throw new Error(ERROR_MSGS.CIRCULAR_DEPENDENCY_IN_FACTORY(factoryType, serviceIdentifier.toString())); - } - else { - throw error; - } - } -}; -var _resolveRequest = function (requestScope) { - return function (request) { - request.parentContext.setCurrentRequest(request); - var bindings = request.bindings; - var childRequests = request.childRequests; - var targetIsAnArray = request.target && request.target.isArray(); - var targetParentIsNotAnArray = !request.parentRequest || - !request.parentRequest.target || - !request.target || - !request.parentRequest.target.matchesArray(request.target.serviceIdentifier); - if (targetIsAnArray && targetParentIsNotAnArray) { - return childRequests.map(function (childRequest) { - var _f = _resolveRequest(requestScope); - return _f(childRequest); - }); - } - else { - var result = null; - if (request.target.isOptional() && bindings.length === 0) { - return undefined; - } - var binding_1 = bindings[0]; - var isSingleton = binding_1.scope === literal_types_1.BindingScopeEnum.Singleton; - var isRequestSingleton = binding_1.scope === literal_types_1.BindingScopeEnum.Request; - if (isSingleton && binding_1.activated) { - return binding_1.cache; - } - if (isRequestSingleton && - requestScope !== null && - requestScope.has(binding_1.id)) { - return requestScope.get(binding_1.id); - } - if (binding_1.type === literal_types_1.BindingTypeEnum.ConstantValue) { - result = binding_1.cache; - } - else if (binding_1.type === literal_types_1.BindingTypeEnum.Function) { - result = binding_1.cache; - } - else if (binding_1.type === literal_types_1.BindingTypeEnum.Constructor) { - result = binding_1.implementationType; - } - else if (binding_1.type === literal_types_1.BindingTypeEnum.DynamicValue && binding_1.dynamicValue !== null) { - result = invokeFactory("toDynamicValue", binding_1.serviceIdentifier, function () { return binding_1.dynamicValue(request.parentContext); }); - } - else if (binding_1.type === literal_types_1.BindingTypeEnum.Factory && binding_1.factory !== null) { - result = invokeFactory("toFactory", binding_1.serviceIdentifier, function () { return binding_1.factory(request.parentContext); }); - } - else if (binding_1.type === literal_types_1.BindingTypeEnum.Provider && binding_1.provider !== null) { - result = invokeFactory("toProvider", binding_1.serviceIdentifier, function () { return binding_1.provider(request.parentContext); }); - } - else if (binding_1.type === literal_types_1.BindingTypeEnum.Instance && binding_1.implementationType !== null) { - result = instantiation_1.resolveInstance(binding_1.implementationType, childRequests, _resolveRequest(requestScope)); - } - else { - var serviceIdentifier = serialization_1.getServiceIdentifierAsString(request.serviceIdentifier); - throw new Error(ERROR_MSGS.INVALID_BINDING_TYPE + " " + serviceIdentifier); - } - if (typeof binding_1.onActivation === "function") { - result = binding_1.onActivation(request.parentContext, result); - } - if (isSingleton) { - binding_1.cache = result; - binding_1.activated = true; - } - if (isRequestSingleton && - requestScope !== null && - !requestScope.has(binding_1.id)) { - requestScope.set(binding_1.id, result); - } - return result; - } - }; -}; -function resolve(context) { - var _f = _resolveRequest(context.plan.rootRequest.requestScope); - return _f(context.plan.rootRequest); -} -exports.resolve = resolve; - - -/***/ }), - -/***/ 516: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DUPLICATED_INJECTABLE_DECORATOR = "Cannot apply @injectable decorator multiple times."; -exports.DUPLICATED_METADATA = "Metadata key was used more than once in a parameter:"; -exports.NULL_ARGUMENT = "NULL argument"; -exports.KEY_NOT_FOUND = "Key Not Found"; -exports.AMBIGUOUS_MATCH = "Ambiguous match found for serviceIdentifier:"; -exports.CANNOT_UNBIND = "Could not unbind serviceIdentifier:"; -exports.NOT_REGISTERED = "No matching bindings found for serviceIdentifier:"; -exports.MISSING_INJECTABLE_ANNOTATION = "Missing required @injectable annotation in:"; -exports.MISSING_INJECT_ANNOTATION = "Missing required @inject or @multiInject annotation in:"; -exports.UNDEFINED_INJECT_ANNOTATION = function (name) { - return "@inject called with undefined this could mean that the class " + name + " has " + - "a circular dependency problem. You can use a LazyServiceIdentifer to " + - "overcome this limitation."; -}; -exports.CIRCULAR_DEPENDENCY = "Circular dependency found:"; -exports.NOT_IMPLEMENTED = "Sorry, this feature is not fully implemented yet."; -exports.INVALID_BINDING_TYPE = "Invalid binding type:"; -exports.NO_MORE_SNAPSHOTS_AVAILABLE = "No snapshot available to restore."; -exports.INVALID_MIDDLEWARE_RETURN = "Invalid return type in middleware. Middleware must return!"; -exports.INVALID_FUNCTION_BINDING = "Value provided to function binding must be a function!"; -exports.INVALID_TO_SELF_VALUE = "The toSelf function can only be applied when a constructor is " + - "used as service identifier"; -exports.INVALID_DECORATOR_OPERATION = "The @inject @multiInject @tagged and @named decorators " + - "must be applied to the parameters of a class constructor or a class property."; -exports.ARGUMENTS_LENGTH_MISMATCH = function () { - var values = []; - for (var _i = 0; _i < arguments.length; _i++) { - values[_i] = arguments[_i]; - } - return "The number of constructor arguments in the derived class " + - (values[0] + " must be >= than the number of constructor arguments of its base class."); -}; -exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = "Invalid Container constructor argument. Container options " + - "must be an object."; -exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = "Invalid Container option. Default scope must " + - "be a string ('singleton' or 'transient')."; -exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = "Invalid Container option. Auto bind injectable must " + - "be a boolean"; -exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = "Invalid Container option. Skip base check must " + - "be a boolean"; -exports.MULTIPLE_POST_CONSTRUCT_METHODS = "Cannot apply @postConstruct decorator multiple times in the same class"; -exports.POST_CONSTRUCT_ERROR = function () { - var values = []; - for (var _i = 0; _i < arguments.length; _i++) { - values[_i] = arguments[_i]; - } - return "@postConstruct error in class " + values[0] + ": " + values[1]; -}; -exports.CIRCULAR_DEPENDENCY_IN_FACTORY = function () { - var values = []; - for (var _i = 0; _i < arguments.length; _i++) { - values[_i] = arguments[_i]; - } - return "It looks like there is a circular dependency " + - ("in one of the '" + values[0] + "' bindings. Please investigate bindings with") + - ("service identifier '" + values[1] + "'."); -}; -exports.STACK_OVERFLOW = "Maximum call stack size exceeded"; - - -/***/ }), - -/***/ 534: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var id_1 = __webpack_require__(786); -var metadata_1 = __webpack_require__(173); -var queryable_string_1 = __webpack_require__(657); -var Target = (function () { - function Target(type, name, serviceIdentifier, namedOrTagged) { - this.id = id_1.id(); - this.type = type; - this.serviceIdentifier = serviceIdentifier; - this.name = new queryable_string_1.QueryableString(name || ""); - this.metadata = new Array(); - var metadataItem = null; - if (typeof namedOrTagged === "string") { - metadataItem = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, namedOrTagged); - } - else if (namedOrTagged instanceof metadata_1.Metadata) { - metadataItem = namedOrTagged; - } - if (metadataItem !== null) { - this.metadata.push(metadataItem); - } - } - Target.prototype.hasTag = function (key) { - for (var _i = 0, _a = this.metadata; _i < _a.length; _i++) { - var m = _a[_i]; - if (m.key === key) { - return true; - } - } - return false; - }; - Target.prototype.isArray = function () { - return this.hasTag(METADATA_KEY.MULTI_INJECT_TAG); - }; - Target.prototype.matchesArray = function (name) { - return this.matchesTag(METADATA_KEY.MULTI_INJECT_TAG)(name); - }; - Target.prototype.isNamed = function () { - return this.hasTag(METADATA_KEY.NAMED_TAG); - }; - Target.prototype.isTagged = function () { - return this.metadata.some(function (m) { - return (m.key !== METADATA_KEY.INJECT_TAG) && - (m.key !== METADATA_KEY.MULTI_INJECT_TAG) && - (m.key !== METADATA_KEY.NAME_TAG) && - (m.key !== METADATA_KEY.UNMANAGED_TAG) && - (m.key !== METADATA_KEY.NAMED_TAG); - }); - }; - Target.prototype.isOptional = function () { - return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true); - }; - Target.prototype.getNamedTag = function () { - if (this.isNamed()) { - return this.metadata.filter(function (m) { return m.key === METADATA_KEY.NAMED_TAG; })[0]; - } - return null; - }; - Target.prototype.getCustomTags = function () { - if (this.isTagged()) { - return this.metadata.filter(function (m) { - return (m.key !== METADATA_KEY.INJECT_TAG) && - (m.key !== METADATA_KEY.MULTI_INJECT_TAG) && - (m.key !== METADATA_KEY.NAME_TAG) && - (m.key !== METADATA_KEY.UNMANAGED_TAG) && - (m.key !== METADATA_KEY.NAMED_TAG); - }); - } - return null; - }; - Target.prototype.matchesNamedTag = function (name) { - return this.matchesTag(METADATA_KEY.NAMED_TAG)(name); - }; - Target.prototype.matchesTag = function (key) { - var _this = this; - return function (value) { - for (var _i = 0, _a = _this.metadata; _i < _a.length; _i++) { - var m = _a[_i]; - if (m.key === key && m.value === value) { - return true; + catch (err) { + switch (err.code) { + case 'ENOENT': { + yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1); + yield exports.mkdir(fsPath); + return; + } + default: { + let stats; + try { + stats = yield exports.stat(fsPath); + } + catch (err2) { + throw err; + } + if (!stats.isDirectory()) + throw err; } } - return false; - }; - }; - return Target; -}()); -exports.Target = Target; - + } + }); +} +exports.mkdirP = mkdirP; +/** + * Best effort attempt to determine whether a file exists and is executable. + * @param filePath file path to check + * @param extensions additional file extensions to try + * @return if file exists and is executable, returns the file path. otherwise empty string. + */ +function tryGetExecutablePath(filePath, extensions) { + return __awaiter(this, void 0, void 0, function* () { + let stats = undefined; + try { + // test file exists + stats = yield exports.stat(filePath); + } + catch (err) { + if (err.code !== 'ENOENT') { + // eslint-disable-next-line no-console + console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); + } + } + if (stats && stats.isFile()) { + if (exports.IS_WINDOWS) { + // on Windows, test for valid extension + const upperExt = path.extname(filePath).toUpperCase(); + if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) { + return filePath; + } + } + else { + if (isUnixExecutable(stats)) { + return filePath; + } + } + } + // try each extension + const originalFilePath = filePath; + for (const extension of extensions) { + filePath = originalFilePath + extension; + stats = undefined; + try { + stats = yield exports.stat(filePath); + } + catch (err) { + if (err.code !== 'ENOENT') { + // eslint-disable-next-line no-console + console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); + } + } + if (stats && stats.isFile()) { + if (exports.IS_WINDOWS) { + // preserve the case of the actual file (since an extension was appended) + try { + const directory = path.dirname(filePath); + const upperName = path.basename(filePath).toUpperCase(); + for (const actualName of yield exports.readdir(directory)) { + if (upperName === actualName.toUpperCase()) { + filePath = path.join(directory, actualName); + break; + } + } + } + catch (err) { + // eslint-disable-next-line no-console + console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); + } + return filePath; + } + else { + if (isUnixExecutable(stats)) { + return filePath; + } + } + } + } + return ''; + }); +} +exports.tryGetExecutablePath = tryGetExecutablePath; +function normalizeSeparators(p) { + p = p || ''; + if (exports.IS_WINDOWS) { + // convert slashes on Windows + p = p.replace(/\//g, '\\'); + // remove redundant slashes + return p.replace(/\\\\+/g, '\\'); + } + // remove redundant slashes + return p.replace(/\/\/+/g, '/'); +} +// on Mac/Linux, test the execute bit +// R W X R W X R W X +// 256 128 64 32 16 8 4 2 1 +function isUnixExecutable(stats) { + return ((stats.mode & 1) > 0 || + ((stats.mode & 8) > 0 && stats.gid === process.getgid()) || + ((stats.mode & 64) > 0 && stats.uid === process.getuid())); +} +//# sourceMappingURL=io-util.js.map /***/ }), -/***/ 538: +/***/ 695: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var ERROR_MSGS = __webpack_require__(516); -var literal_types_1 = __webpack_require__(186); -var binding_in_when_on_syntax_1 = __webpack_require__(226); -var binding_when_on_syntax_1 = __webpack_require__(179); +var ERROR_MSGS = __webpack_require__(800); +var literal_types_1 = __webpack_require__(274); +var binding_in_when_on_syntax_1 = __webpack_require__(766); +var binding_when_on_syntax_1 = __webpack_require__(107); var BindingToSyntax = (function () { function BindingToSyntax(binding) { this._binding = binding; @@ -5496,10 +7720,793 @@ exports.BindingToSyntax = BindingToSyntax; /***/ }), -/***/ 542: +/***/ 702: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + 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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var binding_1 = __webpack_require__(773); +var ERROR_MSGS = __webpack_require__(800); +var literal_types_1 = __webpack_require__(274); +var METADATA_KEY = __webpack_require__(946); +var metadata_reader_1 = __webpack_require__(975); +var planner_1 = __webpack_require__(845); +var resolver_1 = __webpack_require__(911); +var binding_to_syntax_1 = __webpack_require__(695); +var id_1 = __webpack_require__(862); +var serialization_1 = __webpack_require__(395); +var container_snapshot_1 = __webpack_require__(15); +var lookup_1 = __webpack_require__(319); +var Container = (function () { + function Container(containerOptions) { + var options = containerOptions || {}; + if (typeof options !== "object") { + throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT); + } + if (options.defaultScope === undefined) { + options.defaultScope = literal_types_1.BindingScopeEnum.Transient; + } + else if (options.defaultScope !== literal_types_1.BindingScopeEnum.Singleton && + options.defaultScope !== literal_types_1.BindingScopeEnum.Transient && + options.defaultScope !== literal_types_1.BindingScopeEnum.Request) { + throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE); + } + if (options.autoBindInjectable === undefined) { + options.autoBindInjectable = false; + } + else if (typeof options.autoBindInjectable !== "boolean") { + throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE); + } + if (options.skipBaseClassChecks === undefined) { + options.skipBaseClassChecks = false; + } + else if (typeof options.skipBaseClassChecks !== "boolean") { + throw new Error("" + ERROR_MSGS.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK); + } + this.options = { + autoBindInjectable: options.autoBindInjectable, + defaultScope: options.defaultScope, + skipBaseClassChecks: options.skipBaseClassChecks + }; + this.id = id_1.id(); + this._bindingDictionary = new lookup_1.Lookup(); + this._snapshots = []; + this._middleware = null; + this.parent = null; + this._metadataReader = new metadata_reader_1.MetadataReader(); + } + Container.merge = function (container1, container2) { + var container = new Container(); + var bindingDictionary = planner_1.getBindingDictionary(container); + var bindingDictionary1 = planner_1.getBindingDictionary(container1); + var bindingDictionary2 = planner_1.getBindingDictionary(container2); + function copyDictionary(origin, destination) { + origin.traverse(function (key, value) { + value.forEach(function (binding) { + destination.add(binding.serviceIdentifier, binding.clone()); + }); + }); + } + copyDictionary(bindingDictionary1, bindingDictionary); + copyDictionary(bindingDictionary2, bindingDictionary); + return container; + }; + Container.prototype.load = function () { + var modules = []; + for (var _i = 0; _i < arguments.length; _i++) { + modules[_i] = arguments[_i]; + } + var getHelpers = this._getContainerModuleHelpersFactory(); + for (var _a = 0, modules_1 = modules; _a < modules_1.length; _a++) { + var currentModule = modules_1[_a]; + var containerModuleHelpers = getHelpers(currentModule.id); + currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction); + } + }; + Container.prototype.loadAsync = function () { + var modules = []; + for (var _i = 0; _i < arguments.length; _i++) { + modules[_i] = arguments[_i]; + } + return __awaiter(this, void 0, void 0, function () { + var getHelpers, _a, modules_2, currentModule, containerModuleHelpers; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + getHelpers = this._getContainerModuleHelpersFactory(); + _a = 0, modules_2 = modules; + _b.label = 1; + case 1: + if (!(_a < modules_2.length)) return [3, 4]; + currentModule = modules_2[_a]; + containerModuleHelpers = getHelpers(currentModule.id); + return [4, currentModule.registry(containerModuleHelpers.bindFunction, containerModuleHelpers.unbindFunction, containerModuleHelpers.isboundFunction, containerModuleHelpers.rebindFunction)]; + case 2: + _b.sent(); + _b.label = 3; + case 3: + _a++; + return [3, 1]; + case 4: return [2]; + } + }); + }); + }; + Container.prototype.unload = function () { + var _this = this; + var modules = []; + for (var _i = 0; _i < arguments.length; _i++) { + modules[_i] = arguments[_i]; + } + var conditionFactory = function (expected) { return function (item) { + return item.moduleId === expected; + }; }; + modules.forEach(function (module) { + var condition = conditionFactory(module.id); + _this._bindingDictionary.removeByCondition(condition); + }); + }; + Container.prototype.bind = function (serviceIdentifier) { + var scope = this.options.defaultScope || literal_types_1.BindingScopeEnum.Transient; + var binding = new binding_1.Binding(serviceIdentifier, scope); + this._bindingDictionary.add(serviceIdentifier, binding); + return new binding_to_syntax_1.BindingToSyntax(binding); + }; + Container.prototype.rebind = function (serviceIdentifier) { + this.unbind(serviceIdentifier); + return this.bind(serviceIdentifier); + }; + Container.prototype.unbind = function (serviceIdentifier) { + try { + this._bindingDictionary.remove(serviceIdentifier); + } + catch (e) { + throw new Error(ERROR_MSGS.CANNOT_UNBIND + " " + serialization_1.getServiceIdentifierAsString(serviceIdentifier)); + } + }; + Container.prototype.unbindAll = function () { + this._bindingDictionary = new lookup_1.Lookup(); + }; + Container.prototype.isBound = function (serviceIdentifier) { + var bound = this._bindingDictionary.hasKey(serviceIdentifier); + if (!bound && this.parent) { + bound = this.parent.isBound(serviceIdentifier); + } + return bound; + }; + Container.prototype.isBoundNamed = function (serviceIdentifier, named) { + return this.isBoundTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named); + }; + Container.prototype.isBoundTagged = function (serviceIdentifier, key, value) { + var bound = false; + if (this._bindingDictionary.hasKey(serviceIdentifier)) { + var bindings = this._bindingDictionary.get(serviceIdentifier); + var request_1 = planner_1.createMockRequest(this, serviceIdentifier, key, value); + bound = bindings.some(function (b) { return b.constraint(request_1); }); + } + if (!bound && this.parent) { + bound = this.parent.isBoundTagged(serviceIdentifier, key, value); + } + return bound; + }; + Container.prototype.snapshot = function () { + this._snapshots.push(container_snapshot_1.ContainerSnapshot.of(this._bindingDictionary.clone(), this._middleware)); + }; + Container.prototype.restore = function () { + var snapshot = this._snapshots.pop(); + if (snapshot === undefined) { + throw new Error(ERROR_MSGS.NO_MORE_SNAPSHOTS_AVAILABLE); + } + this._bindingDictionary = snapshot.bindings; + this._middleware = snapshot.middleware; + }; + Container.prototype.createChild = function (containerOptions) { + var child = new Container(containerOptions || this.options); + child.parent = this; + return child; + }; + Container.prototype.applyMiddleware = function () { + var middlewares = []; + for (var _i = 0; _i < arguments.length; _i++) { + middlewares[_i] = arguments[_i]; + } + var initial = (this._middleware) ? this._middleware : this._planAndResolve(); + this._middleware = middlewares.reduce(function (prev, curr) { return curr(prev); }, initial); + }; + Container.prototype.applyCustomMetadataReader = function (metadataReader) { + this._metadataReader = metadataReader; + }; + Container.prototype.get = function (serviceIdentifier) { + return this._get(false, false, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier); + }; + Container.prototype.getTagged = function (serviceIdentifier, key, value) { + return this._get(false, false, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier, key, value); + }; + Container.prototype.getNamed = function (serviceIdentifier, named) { + return this.getTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named); + }; + Container.prototype.getAll = function (serviceIdentifier) { + return this._get(true, true, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier); + }; + Container.prototype.getAllTagged = function (serviceIdentifier, key, value) { + return this._get(false, true, literal_types_1.TargetTypeEnum.Variable, serviceIdentifier, key, value); + }; + Container.prototype.getAllNamed = function (serviceIdentifier, named) { + return this.getAllTagged(serviceIdentifier, METADATA_KEY.NAMED_TAG, named); + }; + Container.prototype.resolve = function (constructorFunction) { + var tempContainer = this.createChild(); + tempContainer.bind(constructorFunction).toSelf(); + return tempContainer.get(constructorFunction); + }; + Container.prototype._getContainerModuleHelpersFactory = function () { + var _this = this; + var setModuleId = function (bindingToSyntax, moduleId) { + bindingToSyntax._binding.moduleId = moduleId; + }; + var getBindFunction = function (moduleId) { + return function (serviceIdentifier) { + var _bind = _this.bind.bind(_this); + var bindingToSyntax = _bind(serviceIdentifier); + setModuleId(bindingToSyntax, moduleId); + return bindingToSyntax; + }; + }; + var getUnbindFunction = function (moduleId) { + return function (serviceIdentifier) { + var _unbind = _this.unbind.bind(_this); + _unbind(serviceIdentifier); + }; + }; + var getIsboundFunction = function (moduleId) { + return function (serviceIdentifier) { + var _isBound = _this.isBound.bind(_this); + return _isBound(serviceIdentifier); + }; + }; + var getRebindFunction = function (moduleId) { + return function (serviceIdentifier) { + var _rebind = _this.rebind.bind(_this); + var bindingToSyntax = _rebind(serviceIdentifier); + setModuleId(bindingToSyntax, moduleId); + return bindingToSyntax; + }; + }; + return function (mId) { return ({ + bindFunction: getBindFunction(mId), + isboundFunction: getIsboundFunction(mId), + rebindFunction: getRebindFunction(mId), + unbindFunction: getUnbindFunction(mId) + }); }; + }; + Container.prototype._get = function (avoidConstraints, isMultiInject, targetType, serviceIdentifier, key, value) { + var result = null; + var defaultArgs = { + avoidConstraints: avoidConstraints, + contextInterceptor: function (context) { return context; }, + isMultiInject: isMultiInject, + key: key, + serviceIdentifier: serviceIdentifier, + targetType: targetType, + value: value + }; + if (this._middleware) { + result = this._middleware(defaultArgs); + if (result === undefined || result === null) { + throw new Error(ERROR_MSGS.INVALID_MIDDLEWARE_RETURN); + } + } + else { + result = this._planAndResolve()(defaultArgs); + } + return result; + }; + Container.prototype._planAndResolve = function () { + var _this = this; + return function (args) { + var context = planner_1.plan(_this._metadataReader, _this, args.isMultiInject, args.targetType, args.serviceIdentifier, args.key, args.value, args.avoidConstraints); + context = args.contextInterceptor(context); + var result = resolver_1.resolve(context); + return result; + }; + }; + return Container; +}()); +exports.Container = Container; + + +/***/ }), + +/***/ 708: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); +var decorator_utils_1 = __webpack_require__(309); +function multiInject(serviceIdentifier) { + return function (target, targetKey, index) { + var metadata = new metadata_1.Metadata(METADATA_KEY.MULTI_INJECT_TAG, serviceIdentifier); + if (typeof index === "number") { + decorator_utils_1.tagParameter(target, targetKey, index, metadata); + } + else { + decorator_utils_1.tagProperty(target, targetKey, metadata); + } + }; +} +exports.multiInject = multiInject; + + +/***/ }), + +/***/ 722: +/***/ (function(module) { + +/** + * Convert array of 16 byte values to UUID string format of the form: + * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX + */ +var byteToHex = []; +for (var i = 0; i < 256; ++i) { + byteToHex[i] = (i + 0x100).toString(16).substr(1); +} + +function bytesToUuid(buf, offset) { + var i = offset || 0; + var bth = byteToHex; + // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 + return ([bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], '-', + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]], + bth[buf[i++]], bth[buf[i++]]]).join(''); +} + +module.exports = bytesToUuid; + + +/***/ }), + +/***/ 729: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var Plan = (function () { + function Plan(parentContext, rootRequest) { + this.parentContext = parentContext; + this.rootRequest = rootRequest; + } + return Plan; +}()); +exports.Plan = Plan; + + +/***/ }), + +/***/ 747: +/***/ (function(module) { + +module.exports = require("fs"); + +/***/ }), + +/***/ 766: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var binding_in_syntax_1 = __webpack_require__(415); +var binding_on_syntax_1 = __webpack_require__(956); +var binding_when_syntax_1 = __webpack_require__(954); +var BindingInWhenOnSyntax = (function () { + function BindingInWhenOnSyntax(binding) { + this._binding = binding; + this._bindingWhenSyntax = new binding_when_syntax_1.BindingWhenSyntax(this._binding); + this._bindingOnSyntax = new binding_on_syntax_1.BindingOnSyntax(this._binding); + this._bindingInSyntax = new binding_in_syntax_1.BindingInSyntax(binding); + } + BindingInWhenOnSyntax.prototype.inRequestScope = function () { + return this._bindingInSyntax.inRequestScope(); + }; + BindingInWhenOnSyntax.prototype.inSingletonScope = function () { + return this._bindingInSyntax.inSingletonScope(); + }; + BindingInWhenOnSyntax.prototype.inTransientScope = function () { + return this._bindingInSyntax.inTransientScope(); + }; + BindingInWhenOnSyntax.prototype.when = function (constraint) { + return this._bindingWhenSyntax.when(constraint); + }; + BindingInWhenOnSyntax.prototype.whenTargetNamed = function (name) { + return this._bindingWhenSyntax.whenTargetNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenTargetIsDefault = function () { + return this._bindingWhenSyntax.whenTargetIsDefault(); + }; + BindingInWhenOnSyntax.prototype.whenTargetTagged = function (tag, value) { + return this._bindingWhenSyntax.whenTargetTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenInjectedInto = function (parent) { + return this._bindingWhenSyntax.whenInjectedInto(parent); + }; + BindingInWhenOnSyntax.prototype.whenParentNamed = function (name) { + return this._bindingWhenSyntax.whenParentNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenParentTagged = function (tag, value) { + return this._bindingWhenSyntax.whenParentTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenAnyAncestorIs(ancestor); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorIs = function (ancestor) { + return this._bindingWhenSyntax.whenNoAncestorIs(ancestor); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenAnyAncestorNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenAnyAncestorTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorNamed = function (name) { + return this._bindingWhenSyntax.whenNoAncestorNamed(name); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorTagged = function (tag, value) { + return this._bindingWhenSyntax.whenNoAncestorTagged(tag, value); + }; + BindingInWhenOnSyntax.prototype.whenAnyAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenAnyAncestorMatches(constraint); + }; + BindingInWhenOnSyntax.prototype.whenNoAncestorMatches = function (constraint) { + return this._bindingWhenSyntax.whenNoAncestorMatches(constraint); + }; + BindingInWhenOnSyntax.prototype.onActivation = function (handler) { + return this._bindingOnSyntax.onActivation(handler); + }; + return BindingInWhenOnSyntax; +}()); +exports.BindingInWhenOnSyntax = BindingInWhenOnSyntax; + + +/***/ }), + +/***/ 768: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +const inversify_1 = __webpack_require__(410); +const common_1 = __webpack_require__(605); +const types_1 = __webpack_require__(639); +const build_agent_1 = __webpack_require__(868); +const ioc = new inversify_1.Container(); +exports.ioc = ioc; +ioc.bind(types_1.TYPES.IVersionManager).to(common_1.VersionManager); +ioc.bind(types_1.TYPES.IBuildAgent).to(build_agent_1.BuildAgent); +ioc.bind(types_1.TYPES.IDotnetTool).to(common_1.DotnetTool); +ioc.bind(types_1.TYPES.IGitVersionTool).to(common_1.GitVersionTool); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW9jLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9EOi9Qcm9qZWN0cy9PU1MvR2l0VG9vbHMvdXNlLWdpdHZlcnNpb24vc3JjL2dpdGh1Yi9pb2MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSx5Q0FBc0M7QUFFdEMsc0NBQXVFO0FBRXZFLG9DQUFpQztBQUNqQywrQ0FBMkM7QUFFM0MsTUFBTSxHQUFHLEdBQUcsSUFBSSxxQkFBUyxFQUFFLENBQUM7QUFPbkIsa0JBQUc7QUFMWixHQUFHLENBQUMsSUFBSSxDQUFrQixhQUFLLENBQUMsZUFBZSxDQUFDLENBQUMsRUFBRSxDQUFDLHVCQUFjLENBQUMsQ0FBQztBQUNwRSxHQUFHLENBQUMsSUFBSSxDQUFjLGFBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFLENBQUMsd0JBQVUsQ0FBQyxDQUFDO0FBQ3hELEdBQUcsQ0FBQyxJQUFJLENBQWMsYUFBSyxDQUFDLFdBQVcsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxtQkFBVSxDQUFDLENBQUM7QUFDeEQsR0FBRyxDQUFDLElBQUksQ0FBa0IsYUFBSyxDQUFDLGVBQWUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyx1QkFBYyxDQUFDLENBQUMifQ== + +/***/ }), + +/***/ 773: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var literal_types_1 = __webpack_require__(274); +var id_1 = __webpack_require__(862); +var Binding = (function () { + function Binding(serviceIdentifier, scope) { + this.id = id_1.id(); + this.activated = false; + this.serviceIdentifier = serviceIdentifier; + this.scope = scope; + this.type = literal_types_1.BindingTypeEnum.Invalid; + this.constraint = function (request) { return true; }; + this.implementationType = null; + this.cache = null; + this.factory = null; + this.provider = null; + this.onActivation = null; + this.dynamicValue = null; + } + Binding.prototype.clone = function () { + var clone = new Binding(this.serviceIdentifier, this.scope); + clone.activated = false; + clone.implementationType = this.implementationType; + clone.dynamicValue = this.dynamicValue; + clone.scope = this.scope; + clone.type = this.type; + clone.factory = this.factory; + clone.provider = this.provider; + clone.constraint = this.constraint; + clone.onActivation = this.onActivation; + clone.cache = this.cache; + return clone; + }; + return Binding; +}()); +exports.Binding = Binding; + + +/***/ }), + +/***/ 778: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var inject_1 = __webpack_require__(625); +var ERROR_MSGS = __webpack_require__(800); +var literal_types_1 = __webpack_require__(274); +var METADATA_KEY = __webpack_require__(946); +var serialization_1 = __webpack_require__(395); +exports.getFunctionName = serialization_1.getFunctionName; +var target_1 = __webpack_require__(412); +function getDependencies(metadataReader, func) { + var constructorName = serialization_1.getFunctionName(func); + var targets = getTargets(metadataReader, constructorName, func, false); + return targets; +} +exports.getDependencies = getDependencies; +function getTargets(metadataReader, constructorName, func, isBaseClass) { + var metadata = metadataReader.getConstructorMetadata(func); + var serviceIdentifiers = metadata.compilerGeneratedMetadata; + if (serviceIdentifiers === undefined) { + var msg = ERROR_MSGS.MISSING_INJECTABLE_ANNOTATION + " " + constructorName + "."; + throw new Error(msg); + } + var constructorArgsMetadata = metadata.userGeneratedMetadata; + var keys = Object.keys(constructorArgsMetadata); + var hasUserDeclaredUnknownInjections = (func.length === 0 && keys.length > 0); + var iterations = (hasUserDeclaredUnknownInjections) ? keys.length : func.length; + var constructorTargets = getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations); + var propertyTargets = getClassPropsAsTargets(metadataReader, func); + var targets = constructorTargets.concat(propertyTargets); + return targets; +} +function getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata) { + var targetMetadata = constructorArgsMetadata[index.toString()] || []; + var metadata = formatTargetMetadata(targetMetadata); + var isManaged = metadata.unmanaged !== true; + var serviceIdentifier = serviceIdentifiers[index]; + var injectIdentifier = (metadata.inject || metadata.multiInject); + serviceIdentifier = (injectIdentifier) ? (injectIdentifier) : serviceIdentifier; + if (serviceIdentifier instanceof inject_1.LazyServiceIdentifer) { + serviceIdentifier = serviceIdentifier.unwrap(); + } + if (isManaged) { + var isObject = serviceIdentifier === Object; + var isFunction = serviceIdentifier === Function; + var isUndefined = serviceIdentifier === undefined; + var isUnknownType = (isObject || isFunction || isUndefined); + if (!isBaseClass && isUnknownType) { + var msg = ERROR_MSGS.MISSING_INJECT_ANNOTATION + " argument " + index + " in class " + constructorName + "."; + throw new Error(msg); + } + var target = new target_1.Target(literal_types_1.TargetTypeEnum.ConstructorArgument, metadata.targetName, serviceIdentifier); + target.metadata = targetMetadata; + return target; + } + return null; +} +function getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations) { + var targets = []; + for (var i = 0; i < iterations; i++) { + var index = i; + var target = getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata); + if (target !== null) { + targets.push(target); + } + } + return targets; +} +function getClassPropsAsTargets(metadataReader, constructorFunc) { + var classPropsMetadata = metadataReader.getPropertiesMetadata(constructorFunc); + var targets = []; + var keys = Object.keys(classPropsMetadata); + for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { + var key = keys_1[_i]; + var targetMetadata = classPropsMetadata[key]; + var metadata = formatTargetMetadata(classPropsMetadata[key]); + var targetName = metadata.targetName || key; + var serviceIdentifier = (metadata.inject || metadata.multiInject); + var target = new target_1.Target(literal_types_1.TargetTypeEnum.ClassProperty, targetName, serviceIdentifier); + target.metadata = targetMetadata; + targets.push(target); + } + var baseConstructor = Object.getPrototypeOf(constructorFunc.prototype).constructor; + if (baseConstructor !== Object) { + var baseTargets = getClassPropsAsTargets(metadataReader, baseConstructor); + targets = targets.concat(baseTargets); + } + return targets; +} +function getBaseClassDependencyCount(metadataReader, func) { + var baseConstructor = Object.getPrototypeOf(func.prototype).constructor; + if (baseConstructor !== Object) { + var baseConstructorName = serialization_1.getFunctionName(baseConstructor); + var targets = getTargets(metadataReader, baseConstructorName, baseConstructor, true); + var metadata = targets.map(function (t) { + return t.metadata.filter(function (m) { + return m.key === METADATA_KEY.UNMANAGED_TAG; + }); + }); + var unmanagedCount = [].concat.apply([], metadata).length; + var dependencyCount = targets.length - unmanagedCount; + if (dependencyCount > 0) { + return dependencyCount; + } + else { + return getBaseClassDependencyCount(metadataReader, baseConstructor); + } + } + else { + return 0; + } +} +exports.getBaseClassDependencyCount = getBaseClassDependencyCount; +function formatTargetMetadata(targetMetadata) { + var targetMetadataMap = {}; + targetMetadata.forEach(function (m) { + targetMetadataMap[m.key.toString()] = m.value; + }); + return { + inject: targetMetadataMap[METADATA_KEY.INJECT_TAG], + multiInject: targetMetadataMap[METADATA_KEY.MULTI_INJECT_TAG], + targetName: targetMetadataMap[METADATA_KEY.NAME_TAG], + unmanaged: targetMetadataMap[METADATA_KEY.UNMANAGED_TAG] + }; +} + + +/***/ }), + +/***/ 800: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +exports.DUPLICATED_INJECTABLE_DECORATOR = "Cannot apply @injectable decorator multiple times."; +exports.DUPLICATED_METADATA = "Metadata key was used more than once in a parameter:"; +exports.NULL_ARGUMENT = "NULL argument"; +exports.KEY_NOT_FOUND = "Key Not Found"; +exports.AMBIGUOUS_MATCH = "Ambiguous match found for serviceIdentifier:"; +exports.CANNOT_UNBIND = "Could not unbind serviceIdentifier:"; +exports.NOT_REGISTERED = "No matching bindings found for serviceIdentifier:"; +exports.MISSING_INJECTABLE_ANNOTATION = "Missing required @injectable annotation in:"; +exports.MISSING_INJECT_ANNOTATION = "Missing required @inject or @multiInject annotation in:"; +exports.UNDEFINED_INJECT_ANNOTATION = function (name) { + return "@inject called with undefined this could mean that the class " + name + " has " + + "a circular dependency problem. You can use a LazyServiceIdentifer to " + + "overcome this limitation."; +}; +exports.CIRCULAR_DEPENDENCY = "Circular dependency found:"; +exports.NOT_IMPLEMENTED = "Sorry, this feature is not fully implemented yet."; +exports.INVALID_BINDING_TYPE = "Invalid binding type:"; +exports.NO_MORE_SNAPSHOTS_AVAILABLE = "No snapshot available to restore."; +exports.INVALID_MIDDLEWARE_RETURN = "Invalid return type in middleware. Middleware must return!"; +exports.INVALID_FUNCTION_BINDING = "Value provided to function binding must be a function!"; +exports.INVALID_TO_SELF_VALUE = "The toSelf function can only be applied when a constructor is " + + "used as service identifier"; +exports.INVALID_DECORATOR_OPERATION = "The @inject @multiInject @tagged and @named decorators " + + "must be applied to the parameters of a class constructor or a class property."; +exports.ARGUMENTS_LENGTH_MISMATCH = function () { + var values = []; + for (var _i = 0; _i < arguments.length; _i++) { + values[_i] = arguments[_i]; + } + return "The number of constructor arguments in the derived class " + + (values[0] + " must be >= than the number of constructor arguments of its base class."); +}; +exports.CONTAINER_OPTIONS_MUST_BE_AN_OBJECT = "Invalid Container constructor argument. Container options " + + "must be an object."; +exports.CONTAINER_OPTIONS_INVALID_DEFAULT_SCOPE = "Invalid Container option. Default scope must " + + "be a string ('singleton' or 'transient')."; +exports.CONTAINER_OPTIONS_INVALID_AUTO_BIND_INJECTABLE = "Invalid Container option. Auto bind injectable must " + + "be a boolean"; +exports.CONTAINER_OPTIONS_INVALID_SKIP_BASE_CHECK = "Invalid Container option. Skip base check must " + + "be a boolean"; +exports.MULTIPLE_POST_CONSTRUCT_METHODS = "Cannot apply @postConstruct decorator multiple times in the same class"; +exports.POST_CONSTRUCT_ERROR = function () { + var values = []; + for (var _i = 0; _i < arguments.length; _i++) { + values[_i] = arguments[_i]; + } + return "@postConstruct error in class " + values[0] + ": " + values[1]; +}; +exports.CIRCULAR_DEPENDENCY_IN_FACTORY = function () { + var values = []; + for (var _i = 0; _i < arguments.length; _i++) { + values[_i] = arguments[_i]; + } + return "It looks like there is a circular dependency " + + ("in one of the '" + values[0] + "' bindings. Please investigate bindings with") + + ("service identifier '" + values[1] + "'."); +}; +exports.STACK_OVERFLOW = "Maximum call stack size exceeded"; + + +/***/ }), + +/***/ 804: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); +var decorator_utils_1 = __webpack_require__(309); +function optional() { + return function (target, targetKey, index) { + var metadata = new metadata_1.Metadata(METADATA_KEY.OPTIONAL_TAG, true); + if (typeof index === "number") { + decorator_utils_1.tagParameter(target, targetKey, index, metadata); + } + else { + decorator_utils_1.tagProperty(target, targetKey, metadata); + } + }; +} +exports.optional = optional; + + +/***/ }), + +/***/ 826: /***/ (function(module, __unusedexports, __webpack_require__) { -var rng = __webpack_require__(95); +var rng = __webpack_require__(139); var bytesToUuid = __webpack_require__(722); function v4(options, buf, offset) { @@ -5532,11 +8539,229 @@ module.exports = v4; /***/ }), -/***/ 545: +/***/ 835: +/***/ (function(module) { + +module.exports = require("url"); + +/***/ }), + +/***/ 845: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var binding_count_1 = __webpack_require__(403); +var ERROR_MSGS = __webpack_require__(800); +var literal_types_1 = __webpack_require__(274); +var METADATA_KEY = __webpack_require__(946); +var exceptions_1 = __webpack_require__(480); +var serialization_1 = __webpack_require__(395); +var context_1 = __webpack_require__(32); +var metadata_1 = __webpack_require__(355); +var plan_1 = __webpack_require__(729); +var reflection_utils_1 = __webpack_require__(778); +var request_1 = __webpack_require__(231); +var target_1 = __webpack_require__(412); +function getBindingDictionary(cntnr) { + return cntnr._bindingDictionary; +} +exports.getBindingDictionary = getBindingDictionary; +function _createTarget(isMultiInject, targetType, serviceIdentifier, name, key, value) { + var metadataKey = isMultiInject ? METADATA_KEY.MULTI_INJECT_TAG : METADATA_KEY.INJECT_TAG; + var injectMetadata = new metadata_1.Metadata(metadataKey, serviceIdentifier); + var target = new target_1.Target(targetType, name, serviceIdentifier, injectMetadata); + if (key !== undefined) { + var tagMetadata = new metadata_1.Metadata(key, value); + target.metadata.push(tagMetadata); + } + return target; +} +function _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target) { + var bindings = getBindings(context.container, target.serviceIdentifier); + var activeBindings = []; + if (bindings.length === binding_count_1.BindingCount.NoBindingsAvailable && + context.container.options.autoBindInjectable && + typeof target.serviceIdentifier === "function" && + metadataReader.getConstructorMetadata(target.serviceIdentifier).compilerGeneratedMetadata) { + context.container.bind(target.serviceIdentifier).toSelf(); + bindings = getBindings(context.container, target.serviceIdentifier); + } + if (!avoidConstraints) { + activeBindings = bindings.filter(function (binding) { + var request = new request_1.Request(binding.serviceIdentifier, context, parentRequest, binding, target); + return binding.constraint(request); + }); + } + else { + activeBindings = bindings; + } + _validateActiveBindingCount(target.serviceIdentifier, activeBindings, target, context.container); + return activeBindings; +} +function _validateActiveBindingCount(serviceIdentifier, bindings, target, container) { + switch (bindings.length) { + case binding_count_1.BindingCount.NoBindingsAvailable: + if (target.isOptional()) { + return bindings; + } + else { + var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier); + var msg = ERROR_MSGS.NOT_REGISTERED; + msg += serialization_1.listMetadataForTarget(serviceIdentifierString, target); + msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings); + throw new Error(msg); + } + case binding_count_1.BindingCount.OnlyOneBindingAvailable: + if (!target.isArray()) { + return bindings; + } + case binding_count_1.BindingCount.MultipleBindingsAvailable: + default: + if (!target.isArray()) { + var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier); + var msg = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString; + msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings); + throw new Error(msg); + } + else { + return bindings; + } + } +} +function _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, parentRequest, target) { + var activeBindings; + var childRequest; + if (parentRequest === null) { + activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, null, target); + childRequest = new request_1.Request(serviceIdentifier, context, null, activeBindings, target); + var thePlan = new plan_1.Plan(context, childRequest); + context.addPlan(thePlan); + } + else { + activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target); + childRequest = parentRequest.addChildRequest(target.serviceIdentifier, activeBindings, target); + } + activeBindings.forEach(function (binding) { + var subChildRequest = null; + if (target.isArray()) { + subChildRequest = childRequest.addChildRequest(binding.serviceIdentifier, binding, target); + } + else { + if (binding.cache) { + return; + } + subChildRequest = childRequest; + } + if (binding.type === literal_types_1.BindingTypeEnum.Instance && binding.implementationType !== null) { + var dependencies = reflection_utils_1.getDependencies(metadataReader, binding.implementationType); + if (!context.container.options.skipBaseClassChecks) { + var baseClassDependencyCount = reflection_utils_1.getBaseClassDependencyCount(metadataReader, binding.implementationType); + if (dependencies.length < baseClassDependencyCount) { + var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH(reflection_utils_1.getFunctionName(binding.implementationType)); + throw new Error(error); + } + } + dependencies.forEach(function (dependency) { + _createSubRequests(metadataReader, false, dependency.serviceIdentifier, context, subChildRequest, dependency); + }); + } + }); +} +function getBindings(container, serviceIdentifier) { + var bindings = []; + var bindingDictionary = getBindingDictionary(container); + if (bindingDictionary.hasKey(serviceIdentifier)) { + bindings = bindingDictionary.get(serviceIdentifier); + } + else if (container.parent !== null) { + bindings = getBindings(container.parent, serviceIdentifier); + } + return bindings; +} +function plan(metadataReader, container, isMultiInject, targetType, serviceIdentifier, key, value, avoidConstraints) { + if (avoidConstraints === void 0) { avoidConstraints = false; } + var context = new context_1.Context(container); + var target = _createTarget(isMultiInject, targetType, serviceIdentifier, "", key, value); + try { + _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, null, target); + return context; + } + catch (error) { + if (exceptions_1.isStackOverflowExeption(error)) { + if (context.plan) { + serialization_1.circularDependencyToException(context.plan.rootRequest); + } + } + throw error; + } +} +exports.plan = plan; +function createMockRequest(container, serviceIdentifier, key, value) { + var target = new target_1.Target(literal_types_1.TargetTypeEnum.Variable, "", serviceIdentifier, new metadata_1.Metadata(key, value)); + var context = new context_1.Context(container); + var request = new request_1.Request(serviceIdentifier, context, null, [], target); + return request; +} +exports.createMockRequest = createMockRequest; + + +/***/ }), + +/***/ 862: +/***/ (function(__unusedmodule, exports) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var idCounter = 0; +function id() { + return idCounter++; +} +exports.id = id; + + +/***/ }), + +/***/ 864: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var id_1 = __webpack_require__(862); +var ContainerModule = (function () { + function ContainerModule(registry) { + this.id = id_1.id(); + this.registry = registry; + } + return ContainerModule; +}()); +exports.ContainerModule = ContainerModule; +var AsyncContainerModule = (function () { + function AsyncContainerModule(registry) { + this.id = id_1.id(); + this.registry = registry; + } + return AsyncContainerModule; +}()); +exports.AsyncContainerModule = AsyncContainerModule; + + +/***/ }), + +/***/ 868: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; 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) { @@ -5547,31 +8772,120 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", { value: true }); -__webpack_require__(674); -const types_1 = __webpack_require__(834); -const ioc_1 = __webpack_require__(603); -const gitVersionTool = ioc_1.ioc.get(types_1.TYPES.IGitVersionTool); -const buildAgent = ioc_1.ioc.get(types_1.TYPES.IBuildAgent); -function run() { - return __awaiter(this, void 0, void 0, function* () { - try { - const version = "5.1.2"; - const includePrerelease = false; - yield gitVersionTool.install(version, includePrerelease); - buildAgent.setSucceeded("GitVersion executed successfully", true); - } - catch (error) { - buildAgent.setFailed(error.message, true); - } - }); -} -exports.run = run; -run(); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImZpbGU6Ly8vRDovUHJvamVjdHMvT1NTL0dpdFRvb2xzL3VzZS1naXR2ZXJzaW9uMi9zcmMvZ2l0aHViL21haW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7QUFBQSw0QkFBMEI7QUFHMUIsb0NBQWlDO0FBQ2pDLCtCQUE0QjtBQUU1QixNQUFNLGNBQWMsR0FBRyxTQUFHLENBQUMsR0FBRyxDQUFrQixhQUFLLENBQUMsZUFBZSxDQUFDLENBQUM7QUFDdkUsTUFBTSxVQUFVLEdBQUcsU0FBRyxDQUFDLEdBQUcsQ0FBYyxhQUFLLENBQUMsV0FBVyxDQUFDLENBQUM7QUFFM0QsU0FBc0IsR0FBRzs7UUFDckIsSUFBSTtZQUVBLE1BQU0sT0FBTyxHQUFHLE9BQU8sQ0FBQztZQUN4QixNQUFNLGlCQUFpQixHQUFHLEtBQUssQ0FBQztZQUVoQyxNQUFNLGNBQWMsQ0FBQyxPQUFPLENBQUMsT0FBTyxFQUFFLGlCQUFpQixDQUFDLENBQUM7WUFFekQsVUFBVSxDQUFDLFlBQVksQ0FBQyxrQ0FBa0MsRUFBRSxJQUFJLENBQUMsQ0FBQztTQUNyRTtRQUFDLE9BQU8sS0FBSyxFQUFFO1lBQ1osVUFBVSxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsT0FBTyxFQUFFLElBQUksQ0FBQyxDQUFDO1NBQzdDO0lBQ0wsQ0FBQztDQUFBO0FBWkQsa0JBWUM7QUFFRCxHQUFHLEVBQUUsQ0FBQyJ9 +const path = __webpack_require__(622); +const uuidV4 = __webpack_require__(826); +const core = __webpack_require__(470); +const exe = __webpack_require__(986); +const io = __webpack_require__(1); +const toolCache = __webpack_require__(533); +const inversify_1 = __webpack_require__(410); +let BuildAgent = class BuildAgent { + find(toolName, versionSpec, arch) { + return toolCache.find(toolName, versionSpec, arch); + } + cacheDir(sourceDir, tool, version, arch) { + return toolCache.cacheDir(sourceDir, tool, version, arch); + } + createTempDir() { + return __awaiter(this, void 0, void 0, function* () { + const IS_WINDOWS = process.platform === "win32"; + let tempDirectory = process.env.RUNNER_TEMP || ""; + if (!tempDirectory) { + let baseLocation; + if (IS_WINDOWS) { + // On Windows use the USERPROFILE env variable + baseLocation = process.env.USERPROFILE || "C:\\"; + } + else { + if (process.platform === "darwin") { + baseLocation = "/Users"; + } + else { + baseLocation = "/home"; + } + } + tempDirectory = path.join(baseLocation, "actions", "temp"); + } + const dest = path.join(tempDirectory, uuidV4()); + yield io.mkdirP(dest); + return dest; + }); + } + debug(message) { + core.debug(message); + } + setFailed(message, done) { + core.setFailed(message); + } + setSucceeded(message, done) { + // + } + exportVariable(name, val) { + core.exportVariable(name, val); + } + addPath(inputPath) { + core.addPath(inputPath); + } + which(tool, check) { + return io.which(tool, check); + } + exec(exec, args) { + return __awaiter(this, void 0, void 0, function* () { + const dotnetPath = yield io.which(exec, true); + let resultCode = 0; + let stdout = ""; + let stderr = ""; + resultCode = yield exe.exec(`"${dotnetPath}"`, args, { + listeners: { + stderr: (data) => { + stderr += data.toString(); + }, + stdout: (data) => { + stdout += data.toString(); + }, + }, + }); + return { + code: resultCode, + error: null, + stderr, + stdout, + }; + }); + } +}; +BuildAgent = __decorate([ + inversify_1.injectable() +], BuildAgent); +exports.B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***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var ERRORS_MSGS = __webpack_require__(800); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); +function postConstruct() { + return function (target, propertyKey, descriptor) { + var metadata = new metadata_1.Metadata(METADATA_KEY.POST_CONSTRUCT, propertyKey); + if (Reflect.hasOwnMetadata(METADATA_KEY.POST_CONSTRUCT, target.constructor)) { + throw new Error(ERRORS_MSGS.MULTIPLE_POST_CONSTRUCT_METHODS); + } + Reflect.defineMetadata(METADATA_KEY.POST_CONSTRUCT, metadata, target.constructor); + }; +} +exports.postConstruct = postConstruct; + + +/***/ }), + +/***/ 874: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; @@ -5588,7 +8902,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", { value: true }); const url = __webpack_require__(835); -const http = __webpack_require__(605); +const http = __webpack_require__(876); const https = __webpack_require__(211); let fs; let tunnel; @@ -5937,7 +9251,7 @@ class HttpClient { if (useProxy) { // If using proxy, need tunnel if (!tunnel) { - tunnel = __webpack_require__(212); + tunnel = __webpack_require__(413); } const agentOptions = { maxSockets: maxSockets, @@ -6034,570 +9348,152 @@ exports.HttpClient = HttpClient; /***/ }), -/***/ 568: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ 876: +/***/ (function(module) { -"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 }); -const core = __webpack_require__(949); -const io = __webpack_require__(957); -const fs = __webpack_require__(747); -const os = __webpack_require__(365); -const path = __webpack_require__(622); -const httpm = __webpack_require__(549); -const semver = __webpack_require__(323); -const uuidV4 = __webpack_require__(542); -const exec_1 = __webpack_require__(676); -const assert_1 = __webpack_require__(357); -class HTTPError extends Error { - constructor(httpStatusCode) { - super(`Unexpected HTTP response: ${httpStatusCode}`); - this.httpStatusCode = httpStatusCode; - Object.setPrototypeOf(this, new.target.prototype); - } -} -exports.HTTPError = HTTPError; -const IS_WINDOWS = process.platform === 'win32'; -const userAgent = 'actions/tool-cache'; -// On load grab temp directory and cache directory and remove them from env (currently don't want to expose this) -let tempDirectory = process.env['RUNNER_TEMP'] || ''; -let cacheRoot = process.env['RUNNER_TOOL_CACHE'] || ''; -// If directories not found, place them in common temp locations -if (!tempDirectory || !cacheRoot) { - let baseLocation; - if (IS_WINDOWS) { - // On windows use the USERPROFILE env variable - baseLocation = process.env['USERPROFILE'] || 'C:\\'; - } - else { - if (process.platform === 'darwin') { - baseLocation = '/Users'; - } - else { - baseLocation = '/home'; - } - } - if (!tempDirectory) { - tempDirectory = path.join(baseLocation, 'actions', 'temp'); - } - if (!cacheRoot) { - cacheRoot = path.join(baseLocation, 'actions', 'cache'); - } -} -/** - * Download a tool from an url and stream it into a file - * - * @param url url of tool to download - * @returns path to downloaded tool - */ -function downloadTool(url) { - return __awaiter(this, void 0, void 0, function* () { - // Wrap in a promise so that we can resolve from within stream callbacks - return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { - try { - const http = new httpm.HttpClient(userAgent, [], { - allowRetries: true, - maxRetries: 3 - }); - const destPath = path.join(tempDirectory, uuidV4()); - yield io.mkdirP(tempDirectory); - core.debug(`Downloading ${url}`); - core.debug(`Downloading ${destPath}`); - if (fs.existsSync(destPath)) { - throw new Error(`Destination file path ${destPath} already exists`); - } - const response = yield http.get(url); - if (response.message.statusCode !== 200) { - const err = new HTTPError(response.message.statusCode); - core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); - throw err; - } - const file = fs.createWriteStream(destPath); - file.on('open', () => __awaiter(this, void 0, void 0, function* () { - try { - const stream = response.message.pipe(file); - stream.on('close', () => { - core.debug('download complete'); - resolve(destPath); - }); - } - catch (err) { - core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`); - reject(err); - } - })); - file.on('error', err => { - file.end(); - reject(err); - }); - } - catch (err) { - reject(err); - } - })); - }); -} -exports.downloadTool = downloadTool; -/** - * Extract a .7z file - * - * @param file path to the .7z file - * @param dest destination directory. Optional. - * @param _7zPath path to 7zr.exe. Optional, for long path support. Most .7z archives do not have this - * problem. If your .7z archive contains very long paths, you can pass the path to 7zr.exe which will - * gracefully handle long paths. By default 7zdec.exe is used because it is a very small program and is - * bundled with the tool lib. However it does not support long paths. 7zr.exe is the reduced command line - * interface, it is smaller than the full command line interface, and it does support long paths. At the - * time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website. - * Be sure to check the current license agreement. If 7zr.exe is bundled with your action, then the path - * to 7zr.exe can be pass to this function. - * @returns path to the destination directory - */ -function extract7z(file, dest, _7zPath) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(IS_WINDOWS, 'extract7z() not supported on current OS'); - assert_1.ok(file, 'parameter "file" is required'); - dest = dest || (yield _createExtractFolder(dest)); - const originalCwd = process.cwd(); - process.chdir(dest); - if (_7zPath) { - try { - const args = [ - 'x', - '-bb1', - '-bd', - '-sccUTF-8', - file - ]; - const options = { - silent: true - }; - yield exec_1.exec(`"${_7zPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } - } - else { - const escapedScript = path - .join(__dirname, '..', 'scripts', 'Invoke-7zdec.ps1') - .replace(/'/g, "''") - .replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`; - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - const options = { - silent: true - }; - try { - const powershellPath = yield io.which('powershell', true); - yield exec_1.exec(`"${powershellPath}"`, args, options); - } - finally { - process.chdir(originalCwd); - } - } - return dest; - }); -} -exports.extract7z = extract7z; -/** - * Extract a tar - * - * @param file path to the tar - * @param dest destination directory. Optional. - * @param flags flags for the tar. Optional. - * @returns path to the destination directory - */ -function extractTar(file, dest, flags = 'xz') { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - dest = dest || (yield _createExtractFolder(dest)); - const tarPath = yield io.which('tar', true); - yield exec_1.exec(`"${tarPath}"`, [flags, '-C', dest, '-f', file]); - return dest; - }); -} -exports.extractTar = extractTar; -/** - * Extract a zip - * - * @param file path to the zip - * @param dest destination directory. Optional. - * @returns path to the destination directory - */ -function extractZip(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - dest = dest || (yield _createExtractFolder(dest)); - if (IS_WINDOWS) { - yield extractZipWin(file, dest); - } - else { - yield extractZipNix(file, dest); - } - return dest; - }); -} -exports.extractZip = extractZip; -function extractZipWin(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - // build the powershell command - const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines - const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, ''); - const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`; - // run powershell - const powershellPath = yield io.which('powershell'); - const args = [ - '-NoLogo', - '-Sta', - '-NoProfile', - '-NonInteractive', - '-ExecutionPolicy', - 'Unrestricted', - '-Command', - command - ]; - yield exec_1.exec(`"${powershellPath}"`, args); - }); -} -function extractZipNix(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - const unzipPath = yield io.which('unzip'); - yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest }); - }); -} -/** - * Caches a directory and installs it into the tool cacheDir - * - * @param sourceDir the directory to cache into tools - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture - */ -function cacheDir(sourceDir, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source dir: ${sourceDir}`); - if (!fs.statSync(sourceDir).isDirectory()) { - throw new Error('sourceDir is not a directory'); - } - // Create the tool dir - const destPath = yield _createToolPath(tool, version, arch); - // copy each child item. do not move. move can fail on Windows - // due to anti-virus software having an open handle on a file. - for (const itemName of fs.readdirSync(sourceDir)) { - const s = path.join(sourceDir, itemName); - yield io.cp(s, destPath, { recursive: true }); - } - // write .complete - _completeToolPath(tool, version, arch); - return destPath; - }); -} -exports.cacheDir = cacheDir; -/** - * Caches a downloaded file (GUID) and installs it - * into the tool cache with a given targetName - * - * @param sourceFile the file to cache into tools. Typically a result of downloadTool which is a guid. - * @param targetFile the name of the file name in the tools directory - * @param tool tool name - * @param version version of the tool. semver format - * @param arch architecture of the tool. Optional. Defaults to machine architecture - */ -function cacheFile(sourceFile, targetFile, tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - version = semver.clean(version) || version; - arch = arch || os.arch(); - core.debug(`Caching tool ${tool} ${version} ${arch}`); - core.debug(`source file: ${sourceFile}`); - if (!fs.statSync(sourceFile).isFile()) { - throw new Error('sourceFile is not a file'); - } - // create the tool dir - const destFolder = yield _createToolPath(tool, version, arch); - // copy instead of move. move can fail on Windows due to - // anti-virus software having an open handle on a file. - const destPath = path.join(destFolder, targetFile); - core.debug(`destination file ${destPath}`); - yield io.cp(sourceFile, destPath); - // write .complete - _completeToolPath(tool, version, arch); - return destFolder; - }); -} -exports.cacheFile = cacheFile; -/** - * Finds the path to a tool version in the local installed tool cache - * - * @param toolName name of the tool - * @param versionSpec version of the tool - * @param arch optional arch. defaults to arch of computer - */ -function find(toolName, versionSpec, arch) { - if (!toolName) { - throw new Error('toolName parameter is required'); - } - if (!versionSpec) { - throw new Error('versionSpec parameter is required'); - } - arch = arch || os.arch(); - // attempt to resolve an explicit version - if (!_isExplicitVersion(versionSpec)) { - const localVersions = findAllVersions(toolName, arch); - const match = _evaluateVersions(localVersions, versionSpec); - versionSpec = match; - } - // check for the explicit version in the cache - let toolPath = ''; - if (versionSpec) { - versionSpec = semver.clean(versionSpec) || ''; - const cachePath = path.join(cacheRoot, toolName, versionSpec, arch); - core.debug(`checking cache: ${cachePath}`); - if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) { - core.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`); - toolPath = cachePath; - } - else { - core.debug('not found'); - } - } - return toolPath; -} -exports.find = find; -/** - * Finds the paths to all versions of a tool that are installed in the local tool cache - * - * @param toolName name of the tool - * @param arch optional arch. defaults to arch of computer - */ -function findAllVersions(toolName, arch) { - const versions = []; - arch = arch || os.arch(); - const toolPath = path.join(cacheRoot, toolName); - if (fs.existsSync(toolPath)) { - const children = fs.readdirSync(toolPath); - for (const child of children) { - if (_isExplicitVersion(child)) { - const fullPath = path.join(toolPath, child, arch || ''); - if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) { - versions.push(child); - } - } - } - } - return versions; -} -exports.findAllVersions = findAllVersions; -function _createExtractFolder(dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!dest) { - // create a temp dir - dest = path.join(tempDirectory, uuidV4()); - } - yield io.mkdirP(dest); - return dest; - }); -} -function _createToolPath(tool, version, arch) { - return __awaiter(this, void 0, void 0, function* () { - const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); - core.debug(`destination ${folderPath}`); - const markerPath = `${folderPath}.complete`; - yield io.rmRF(folderPath); - yield io.rmRF(markerPath); - yield io.mkdirP(folderPath); - return folderPath; - }); -} -function _completeToolPath(tool, version, arch) { - const folderPath = path.join(cacheRoot, tool, semver.clean(version) || version, arch || ''); - const markerPath = `${folderPath}.complete`; - fs.writeFileSync(markerPath, ''); - core.debug('finished caching tool'); -} -function _isExplicitVersion(versionSpec) { - const c = semver.clean(versionSpec) || ''; - core.debug(`isExplicit: ${c}`); - const valid = semver.valid(c) != null; - core.debug(`explicit? ${valid}`); - return valid; -} -function _evaluateVersions(versions, versionSpec) { - let version = ''; - core.debug(`evaluating ${versions.length} versions`); - versions = versions.sort((a, b) => { - if (semver.gt(a, b)) { - return 1; - } - return -1; - }); - for (let i = versions.length - 1; i >= 0; i--) { - const potential = versions[i]; - const satisfied = semver.satisfies(potential, versionSpec); - if (satisfied) { - version = potential; - break; - } - } - if (version) { - core.debug(`matched: ${version}`); - } - else { - core.debug('match not found'); - } - return version; -} -//# sourceMappingURL=tool-cache.js.map +module.exports = require("http"); /***/ }), -/***/ 571: +/***/ 904: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var ERROR_MSGS = __webpack_require__(516); -function getServiceIdentifierAsString(serviceIdentifier) { - if (typeof serviceIdentifier === "function") { - var _serviceIdentifier = serviceIdentifier; - return _serviceIdentifier.name; - } - else if (typeof serviceIdentifier === "symbol") { - return serviceIdentifier.toString(); - } - else { - var _serviceIdentifier = serviceIdentifier; - return _serviceIdentifier; - } -} -exports.getServiceIdentifierAsString = getServiceIdentifierAsString; -function listRegisteredBindingsForServiceIdentifier(container, serviceIdentifier, getBindings) { - var registeredBindingsList = ""; - var registeredBindings = getBindings(container, serviceIdentifier); - if (registeredBindings.length !== 0) { - registeredBindingsList = "\nRegistered bindings:"; - registeredBindings.forEach(function (binding) { - var name = "Object"; - if (binding.implementationType !== null) { - name = getFunctionName(binding.implementationType); - } - registeredBindingsList = registeredBindingsList + "\n " + name; - if (binding.constraint.metaData) { - registeredBindingsList = registeredBindingsList + " - " + binding.constraint.metaData; - } - }); - } - return registeredBindingsList; -} -exports.listRegisteredBindingsForServiceIdentifier = listRegisteredBindingsForServiceIdentifier; -function alreadyDependencyChain(request, serviceIdentifier) { - if (request.parentRequest === null) { - return false; - } - else if (request.parentRequest.serviceIdentifier === serviceIdentifier) { - return true; - } - else { - return alreadyDependencyChain(request.parentRequest, serviceIdentifier); - } -} -function dependencyChainToString(request) { - function _createStringArr(req, result) { - if (result === void 0) { result = []; } - var serviceIdentifier = getServiceIdentifierAsString(req.serviceIdentifier); - result.push(serviceIdentifier); - if (req.parentRequest !== null) { - return _createStringArr(req.parentRequest, result); - } - return result; - } - var stringArr = _createStringArr(request); - return stringArr.reverse().join(" --> "); -} -function circularDependencyToException(request) { - request.childRequests.forEach(function (childRequest) { - if (alreadyDependencyChain(childRequest, childRequest.serviceIdentifier)) { - var services = dependencyChainToString(childRequest); - throw new Error(ERROR_MSGS.CIRCULAR_DEPENDENCY + " " + services); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); +var decorator_utils_1 = __webpack_require__(309); +function named(name) { + return function (target, targetKey, index) { + var metadata = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, name); + if (typeof index === "number") { + decorator_utils_1.tagParameter(target, targetKey, index, metadata); } else { - circularDependencyToException(childRequest); + decorator_utils_1.tagProperty(target, targetKey, metadata); } - }); + }; } -exports.circularDependencyToException = circularDependencyToException; -function listMetadataForTarget(serviceIdentifierString, target) { - if (target.isTagged() || target.isNamed()) { - var m_1 = ""; - var namedTag = target.getNamedTag(); - var otherTags = target.getCustomTags(); - if (namedTag !== null) { - m_1 += namedTag.toString() + "\n"; +exports.named = named; + + +/***/ }), + +/***/ 911: +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + +Object.defineProperty(exports, "__esModule", { value: true }); +var ERROR_MSGS = __webpack_require__(800); +var literal_types_1 = __webpack_require__(274); +var exceptions_1 = __webpack_require__(480); +var serialization_1 = __webpack_require__(395); +var instantiation_1 = __webpack_require__(124); +var invokeFactory = function (factoryType, serviceIdentifier, fn) { + try { + return fn(); + } + catch (error) { + if (exceptions_1.isStackOverflowExeption(error)) { + throw new Error(ERROR_MSGS.CIRCULAR_DEPENDENCY_IN_FACTORY(factoryType, serviceIdentifier.toString())); } - if (otherTags !== null) { - otherTags.forEach(function (tag) { - m_1 += tag.toString() + "\n"; + else { + throw error; + } + } +}; +var _resolveRequest = function (requestScope) { + return function (request) { + request.parentContext.setCurrentRequest(request); + var bindings = request.bindings; + var childRequests = request.childRequests; + var targetIsAnArray = request.target && request.target.isArray(); + var targetParentIsNotAnArray = !request.parentRequest || + !request.parentRequest.target || + !request.target || + !request.parentRequest.target.matchesArray(request.target.serviceIdentifier); + if (targetIsAnArray && targetParentIsNotAnArray) { + return childRequests.map(function (childRequest) { + var _f = _resolveRequest(requestScope); + return _f(childRequest); }); } - return " " + serviceIdentifierString + "\n " + serviceIdentifierString + " - " + m_1; - } - else { - return " " + serviceIdentifierString; - } + else { + var result = null; + if (request.target.isOptional() && bindings.length === 0) { + return undefined; + } + var binding_1 = bindings[0]; + var isSingleton = binding_1.scope === literal_types_1.BindingScopeEnum.Singleton; + var isRequestSingleton = binding_1.scope === literal_types_1.BindingScopeEnum.Request; + if (isSingleton && binding_1.activated) { + return binding_1.cache; + } + if (isRequestSingleton && + requestScope !== null && + requestScope.has(binding_1.id)) { + return requestScope.get(binding_1.id); + } + if (binding_1.type === literal_types_1.BindingTypeEnum.ConstantValue) { + result = binding_1.cache; + } + else if (binding_1.type === literal_types_1.BindingTypeEnum.Function) { + result = binding_1.cache; + } + else if (binding_1.type === literal_types_1.BindingTypeEnum.Constructor) { + result = binding_1.implementationType; + } + else if (binding_1.type === literal_types_1.BindingTypeEnum.DynamicValue && binding_1.dynamicValue !== null) { + result = invokeFactory("toDynamicValue", binding_1.serviceIdentifier, function () { return binding_1.dynamicValue(request.parentContext); }); + } + else if (binding_1.type === literal_types_1.BindingTypeEnum.Factory && binding_1.factory !== null) { + result = invokeFactory("toFactory", binding_1.serviceIdentifier, function () { return binding_1.factory(request.parentContext); }); + } + else if (binding_1.type === literal_types_1.BindingTypeEnum.Provider && binding_1.provider !== null) { + result = invokeFactory("toProvider", binding_1.serviceIdentifier, function () { return binding_1.provider(request.parentContext); }); + } + else if (binding_1.type === literal_types_1.BindingTypeEnum.Instance && binding_1.implementationType !== null) { + result = instantiation_1.resolveInstance(binding_1.implementationType, childRequests, _resolveRequest(requestScope)); + } + else { + var serviceIdentifier = serialization_1.getServiceIdentifierAsString(request.serviceIdentifier); + throw new Error(ERROR_MSGS.INVALID_BINDING_TYPE + " " + serviceIdentifier); + } + if (typeof binding_1.onActivation === "function") { + result = binding_1.onActivation(request.parentContext, result); + } + if (isSingleton) { + binding_1.cache = result; + binding_1.activated = true; + } + if (isRequestSingleton && + requestScope !== null && + !requestScope.has(binding_1.id)) { + requestScope.set(binding_1.id, result); + } + return result; + } + }; +}; +function resolve(context) { + var _f = _resolveRequest(context.plan.rootRequest.requestScope); + return _f(context.plan.rootRequest); } -exports.listMetadataForTarget = listMetadataForTarget; -function getFunctionName(v) { - if (v.name) { - return v.name; - } - else { - var name_1 = v.toString(); - var match = name_1.match(/^function\s*([^\s(]+)/); - return match ? match[1] : "Anonymous function: " + name_1; - } -} -exports.getFunctionName = getFunctionName; +exports.resolve = resolve; /***/ }), -/***/ 599: +/***/ 912: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); +var METADATA_KEY = __webpack_require__(946); +var metadata_1 = __webpack_require__(355); var traverseAncerstors = function (request, constraint) { var parent = request.parentRequest; if (parent !== null) { @@ -6638,129 +9534,35 @@ exports.typeConstraint = typeConstraint; /***/ }), -/***/ 603: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const inversify_1 = __webpack_require__(386); -const common_1 = __webpack_require__(175); -const types_1 = __webpack_require__(834); -const build_agent_1 = __webpack_require__(817); -const ioc = new inversify_1.Container(); -exports.ioc = ioc; -ioc.bind(types_1.TYPES.IVersionManager).to(common_1.VersionManager); -ioc.bind(types_1.TYPES.IBuildAgent).to(build_agent_1.BuildAgent); -ioc.bind(types_1.TYPES.IDotnetTool).to(common_1.DotnetTool); -ioc.bind(types_1.TYPES.IGitVersionTool).to(common_1.GitVersionTool); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW9jLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9EOi9Qcm9qZWN0cy9PU1MvR2l0VG9vbHMvdXNlLWdpdHZlcnNpb24yL3NyYy9naXRodWIvaW9jLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEseUNBQXNDO0FBRXRDLHNDQUF1RTtBQUV2RSxvQ0FBaUM7QUFDakMsK0NBQTJDO0FBRTNDLE1BQU0sR0FBRyxHQUFHLElBQUkscUJBQVMsRUFBRSxDQUFDO0FBT25CLGtCQUFHO0FBTFosR0FBRyxDQUFDLElBQUksQ0FBa0IsYUFBSyxDQUFDLGVBQWUsQ0FBQyxDQUFDLEVBQUUsQ0FBQyx1QkFBYyxDQUFDLENBQUM7QUFDcEUsR0FBRyxDQUFDLElBQUksQ0FBYyxhQUFLLENBQUMsV0FBVyxDQUFDLENBQUMsRUFBRSxDQUFDLHdCQUFVLENBQUMsQ0FBQztBQUN4RCxHQUFHLENBQUMsSUFBSSxDQUFjLGFBQUssQ0FBQyxXQUFXLENBQUMsQ0FBQyxFQUFFLENBQUMsbUJBQVUsQ0FBQyxDQUFDO0FBQ3hELEdBQUcsQ0FBQyxJQUFJLENBQWtCLGFBQUssQ0FBQyxlQUFlLENBQUMsQ0FBQyxFQUFFLENBQUMsdUJBQWMsQ0FBQyxDQUFDIn0= - -/***/ }), - -/***/ 605: -/***/ (function(module) { - -module.exports = require("http"); - -/***/ }), - -/***/ 614: -/***/ (function(module) { - -module.exports = require("events"); - -/***/ }), - -/***/ 622: -/***/ (function(module) { - -module.exports = require("path"); - -/***/ }), - -/***/ 631: -/***/ (function(module) { - -module.exports = require("net"); - -/***/ }), - -/***/ 638: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var id_1 = __webpack_require__(786); -var Context = (function () { - function Context(container) { - this.id = id_1.id(); - this.container = container; - } - Context.prototype.addPlan = function (plan) { - this.plan = plan; - }; - Context.prototype.setCurrentRequest = function (currentRequest) { - this.currentRequest = currentRequest; - }; - return Context; -}()); -exports.Context = Context; - - -/***/ }), - -/***/ 649: +/***/ 946: /***/ (function(__unusedmodule, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var ContainerSnapshot = (function () { - function ContainerSnapshot() { - } - ContainerSnapshot.of = function (bindings, middleware) { - var snapshot = new ContainerSnapshot(); - snapshot.bindings = bindings; - snapshot.middleware = middleware; - return snapshot; - }; - return ContainerSnapshot; -}()); -exports.ContainerSnapshot = ContainerSnapshot; +exports.NAMED_TAG = "named"; +exports.NAME_TAG = "name"; +exports.UNMANAGED_TAG = "unmanaged"; +exports.OPTIONAL_TAG = "optional"; +exports.INJECT_TAG = "inject"; +exports.MULTI_INJECT_TAG = "multi_inject"; +exports.TAGGED = "inversify:tagged"; +exports.TAGGED_PROP = "inversify:tagged_props"; +exports.PARAM_TYPES = "inversify:paramtypes"; +exports.DESIGN_PARAM_TYPES = "design:paramtypes"; +exports.POST_CONSTRUCT = "post_construct"; /***/ }), -/***/ 651: -/***/ (function(module) { - -module.exports = function cmp (a, b) { - var pa = a.split('.'); - var pb = b.split('.'); - for (var i = 0; i < 3; i++) { - var na = Number(pa[i]); - var nb = Number(pb[i]); - if (na > nb) return 1; - if (nb > na) return -1; - if (!isNaN(na) && isNaN(nb)) return 1; - if (isNaN(na) && !isNaN(nb)) return -1; - } - return 0; -}; - - -/***/ }), - -/***/ 653: +/***/ 954: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var binding_on_syntax_1 = __webpack_require__(20); -var constraint_helpers_1 = __webpack_require__(599); +var binding_on_syntax_1 = __webpack_require__(956); +var constraint_helpers_1 = __webpack_require__(912); var BindingWhenSyntax = (function () { function BindingWhenSyntax(binding) { this._binding = binding; @@ -6859,1207 +9661,58 @@ exports.BindingWhenSyntax = BindingWhenSyntax; /***/ }), -/***/ 656: +/***/ 956: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); -var decorator_utils_1 = __webpack_require__(289); -function unmanaged() { - return function (target, targetKey, index) { - var metadata = new metadata_1.Metadata(METADATA_KEY.UNMANAGED_TAG, true); - decorator_utils_1.tagParameter(target, targetKey, index, metadata); +var binding_when_syntax_1 = __webpack_require__(954); +var BindingOnSyntax = (function () { + function BindingOnSyntax(binding) { + this._binding = binding; + } + BindingOnSyntax.prototype.onActivation = function (handler) { + this._binding.onActivation = handler; + return new binding_when_syntax_1.BindingWhenSyntax(this._binding); }; -} -exports.unmanaged = unmanaged; + return BindingOnSyntax; +}()); +exports.BindingOnSyntax = BindingOnSyntax; /***/ }), -/***/ 657: -/***/ (function(__unusedmodule, exports) { +/***/ 975: +/***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var QueryableString = (function () { - function QueryableString(str) { - this.str = str; +var METADATA_KEY = __webpack_require__(946); +var MetadataReader = (function () { + function MetadataReader() { } - QueryableString.prototype.startsWith = function (searchString) { - return this.str.indexOf(searchString) === 0; - }; - QueryableString.prototype.endsWith = function (searchString) { - var reverseString = ""; - var reverseSearchString = searchString.split("").reverse().join(""); - reverseString = this.str.split("").reverse().join(""); - return this.startsWith.call({ str: reverseString }, reverseSearchString); - }; - QueryableString.prototype.contains = function (searchString) { - return (this.str.indexOf(searchString) !== -1); - }; - QueryableString.prototype.equals = function (compareString) { - return this.str === compareString; - }; - QueryableString.prototype.value = function () { - return this.str; - }; - return QueryableString; -}()); -exports.QueryableString = QueryableString; - - -/***/ }), - -/***/ 669: -/***/ (function(module) { - -module.exports = require("util"); - -/***/ }), - -/***/ 674: -/***/ (function() { - -/*! ***************************************************************************** -Copyright (C) Microsoft. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -var Reflect; -(function (Reflect) { - // Metadata Proposal - // https://rbuckton.github.io/reflect-metadata/ - (function (factory) { - var root = typeof global === "object" ? global : - typeof self === "object" ? self : - typeof this === "object" ? this : - Function("return this;")(); - var exporter = makeExporter(Reflect); - if (typeof root.Reflect === "undefined") { - root.Reflect = Reflect; - } - else { - exporter = makeExporter(root.Reflect, exporter); - } - factory(exporter); - function makeExporter(target, previous) { - return function (key, value) { - if (typeof target[key] !== "function") { - Object.defineProperty(target, key, { configurable: true, writable: true, value: value }); - } - if (previous) - previous(key, value); - }; - } - })(function (exporter) { - var hasOwn = Object.prototype.hasOwnProperty; - // feature test for Symbol support - var supportsSymbol = typeof Symbol === "function"; - var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive"; - var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator"; - var supportsCreate = typeof Object.create === "function"; // feature test for Object.create support - var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support - var downLevel = !supportsCreate && !supportsProto; - var HashMap = { - // create an object in dictionary mode (a.k.a. "slow" mode in v8) - create: supportsCreate - ? function () { return MakeDictionary(Object.create(null)); } - : supportsProto - ? function () { return MakeDictionary({ __proto__: null }); } - : function () { return MakeDictionary({}); }, - has: downLevel - ? function (map, key) { return hasOwn.call(map, key); } - : function (map, key) { return key in map; }, - get: downLevel - ? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; } - : function (map, key) { return map[key]; }, + MetadataReader.prototype.getConstructorMetadata = function (constructorFunc) { + var compilerGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.PARAM_TYPES, constructorFunc); + var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED, constructorFunc); + return { + compilerGeneratedMetadata: compilerGeneratedMetadata, + userGeneratedMetadata: userGeneratedMetadata || {} }; - // Load global or shim versions of Map, Set, and WeakMap - var functionPrototype = Object.getPrototypeOf(Function); - var usePolyfill = typeof process === "object" && process.env && process.env["REFLECT_METADATA_USE_MAP_POLYFILL"] === "true"; - var _Map = !usePolyfill && typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill(); - var _Set = !usePolyfill && typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill(); - var _WeakMap = !usePolyfill && typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill(); - // [[Metadata]] internal slot - // https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots - var Metadata = new _WeakMap(); - /** - * Applies a set of decorators to a property of a target object. - * @param decorators An array of decorators. - * @param target The target object. - * @param propertyKey (Optional) The property key to decorate. - * @param attributes (Optional) The property descriptor for the target key. - * @remarks Decorators are applied in reverse order. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * Example = Reflect.decorate(decoratorsArray, Example); - * - * // property (on constructor) - * Reflect.decorate(decoratorsArray, Example, "staticProperty"); - * - * // property (on prototype) - * Reflect.decorate(decoratorsArray, Example.prototype, "property"); - * - * // method (on constructor) - * Object.defineProperty(Example, "staticMethod", - * Reflect.decorate(decoratorsArray, Example, "staticMethod", - * Object.getOwnPropertyDescriptor(Example, "staticMethod"))); - * - * // method (on prototype) - * Object.defineProperty(Example.prototype, "method", - * Reflect.decorate(decoratorsArray, Example.prototype, "method", - * Object.getOwnPropertyDescriptor(Example.prototype, "method"))); - * - */ - function decorate(decorators, target, propertyKey, attributes) { - if (!IsUndefined(propertyKey)) { - if (!IsArray(decorators)) - throw new TypeError(); - if (!IsObject(target)) - throw new TypeError(); - if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes)) - throw new TypeError(); - if (IsNull(attributes)) - attributes = undefined; - propertyKey = ToPropertyKey(propertyKey); - return DecorateProperty(decorators, target, propertyKey, attributes); - } - else { - if (!IsArray(decorators)) - throw new TypeError(); - if (!IsConstructor(target)) - throw new TypeError(); - return DecorateConstructor(decorators, target); - } - } - exporter("decorate", decorate); - // 4.1.2 Reflect.metadata(metadataKey, metadataValue) - // https://rbuckton.github.io/reflect-metadata/#reflect.metadata - /** - * A default metadata decorator factory that can be used on a class, class member, or parameter. - * @param metadataKey The key for the metadata entry. - * @param metadataValue The value for the metadata entry. - * @returns A decorator function. - * @remarks - * If `metadataKey` is already defined for the target and target key, the - * metadataValue for that key will be overwritten. - * @example - * - * // constructor - * @Reflect.metadata(key, value) - * class Example { - * } - * - * // property (on constructor, TypeScript only) - * class Example { - * @Reflect.metadata(key, value) - * static staticProperty; - * } - * - * // property (on prototype, TypeScript only) - * class Example { - * @Reflect.metadata(key, value) - * property; - * } - * - * // method (on constructor) - * class Example { - * @Reflect.metadata(key, value) - * static staticMethod() { } - * } - * - * // method (on prototype) - * class Example { - * @Reflect.metadata(key, value) - * method() { } - * } - * - */ - function metadata(metadataKey, metadataValue) { - function decorator(target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey)) - throw new TypeError(); - OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey); - } - return decorator; - } - exporter("metadata", metadata); - /** - * Define a unique metadata entry on the target. - * @param metadataKey A key used to store and retrieve metadata. - * @param metadataValue A value that contains attached metadata. - * @param target The target object on which to define metadata. - * @param propertyKey (Optional) The property key for the target. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * Reflect.defineMetadata("custom:annotation", options, Example); - * - * // property (on constructor) - * Reflect.defineMetadata("custom:annotation", options, Example, "staticProperty"); - * - * // property (on prototype) - * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "property"); - * - * // method (on constructor) - * Reflect.defineMetadata("custom:annotation", options, Example, "staticMethod"); - * - * // method (on prototype) - * Reflect.defineMetadata("custom:annotation", options, Example.prototype, "method"); - * - * // decorator factory as metadata-producing annotation. - * function MyAnnotation(options): Decorator { - * return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key); - * } - * - */ - function defineMetadata(metadataKey, metadataValue, target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey); - } - exporter("defineMetadata", defineMetadata); - /** - * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined. - * @param metadataKey A key used to store and retrieve metadata. - * @param target The target object on which the metadata is defined. - * @param propertyKey (Optional) The property key for the target. - * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * result = Reflect.hasMetadata("custom:annotation", Example); - * - * // property (on constructor) - * result = Reflect.hasMetadata("custom:annotation", Example, "staticProperty"); - * - * // property (on prototype) - * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "property"); - * - * // method (on constructor) - * result = Reflect.hasMetadata("custom:annotation", Example, "staticMethod"); - * - * // method (on prototype) - * result = Reflect.hasMetadata("custom:annotation", Example.prototype, "method"); - * - */ - function hasMetadata(metadataKey, target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - return OrdinaryHasMetadata(metadataKey, target, propertyKey); - } - exporter("hasMetadata", hasMetadata); - /** - * Gets a value indicating whether the target object has the provided metadata key defined. - * @param metadataKey A key used to store and retrieve metadata. - * @param target The target object on which the metadata is defined. - * @param propertyKey (Optional) The property key for the target. - * @returns `true` if the metadata key was defined on the target object; otherwise, `false`. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * result = Reflect.hasOwnMetadata("custom:annotation", Example); - * - * // property (on constructor) - * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticProperty"); - * - * // property (on prototype) - * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "property"); - * - * // method (on constructor) - * result = Reflect.hasOwnMetadata("custom:annotation", Example, "staticMethod"); - * - * // method (on prototype) - * result = Reflect.hasOwnMetadata("custom:annotation", Example.prototype, "method"); - * - */ - function hasOwnMetadata(metadataKey, target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey); - } - exporter("hasOwnMetadata", hasOwnMetadata); - /** - * Gets the metadata value for the provided metadata key on the target object or its prototype chain. - * @param metadataKey A key used to store and retrieve metadata. - * @param target The target object on which the metadata is defined. - * @param propertyKey (Optional) The property key for the target. - * @returns The metadata value for the metadata key if found; otherwise, `undefined`. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * result = Reflect.getMetadata("custom:annotation", Example); - * - * // property (on constructor) - * result = Reflect.getMetadata("custom:annotation", Example, "staticProperty"); - * - * // property (on prototype) - * result = Reflect.getMetadata("custom:annotation", Example.prototype, "property"); - * - * // method (on constructor) - * result = Reflect.getMetadata("custom:annotation", Example, "staticMethod"); - * - * // method (on prototype) - * result = Reflect.getMetadata("custom:annotation", Example.prototype, "method"); - * - */ - function getMetadata(metadataKey, target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - return OrdinaryGetMetadata(metadataKey, target, propertyKey); - } - exporter("getMetadata", getMetadata); - /** - * Gets the metadata value for the provided metadata key on the target object. - * @param metadataKey A key used to store and retrieve metadata. - * @param target The target object on which the metadata is defined. - * @param propertyKey (Optional) The property key for the target. - * @returns The metadata value for the metadata key if found; otherwise, `undefined`. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * result = Reflect.getOwnMetadata("custom:annotation", Example); - * - * // property (on constructor) - * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticProperty"); - * - * // property (on prototype) - * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "property"); - * - * // method (on constructor) - * result = Reflect.getOwnMetadata("custom:annotation", Example, "staticMethod"); - * - * // method (on prototype) - * result = Reflect.getOwnMetadata("custom:annotation", Example.prototype, "method"); - * - */ - function getOwnMetadata(metadataKey, target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey); - } - exporter("getOwnMetadata", getOwnMetadata); - /** - * Gets the metadata keys defined on the target object or its prototype chain. - * @param target The target object on which the metadata is defined. - * @param propertyKey (Optional) The property key for the target. - * @returns An array of unique metadata keys. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * result = Reflect.getMetadataKeys(Example); - * - * // property (on constructor) - * result = Reflect.getMetadataKeys(Example, "staticProperty"); - * - * // property (on prototype) - * result = Reflect.getMetadataKeys(Example.prototype, "property"); - * - * // method (on constructor) - * result = Reflect.getMetadataKeys(Example, "staticMethod"); - * - * // method (on prototype) - * result = Reflect.getMetadataKeys(Example.prototype, "method"); - * - */ - function getMetadataKeys(target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - return OrdinaryMetadataKeys(target, propertyKey); - } - exporter("getMetadataKeys", getMetadataKeys); - /** - * Gets the unique metadata keys defined on the target object. - * @param target The target object on which the metadata is defined. - * @param propertyKey (Optional) The property key for the target. - * @returns An array of unique metadata keys. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * result = Reflect.getOwnMetadataKeys(Example); - * - * // property (on constructor) - * result = Reflect.getOwnMetadataKeys(Example, "staticProperty"); - * - * // property (on prototype) - * result = Reflect.getOwnMetadataKeys(Example.prototype, "property"); - * - * // method (on constructor) - * result = Reflect.getOwnMetadataKeys(Example, "staticMethod"); - * - * // method (on prototype) - * result = Reflect.getOwnMetadataKeys(Example.prototype, "method"); - * - */ - function getOwnMetadataKeys(target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - return OrdinaryOwnMetadataKeys(target, propertyKey); - } - exporter("getOwnMetadataKeys", getOwnMetadataKeys); - /** - * Deletes the metadata entry from the target object with the provided key. - * @param metadataKey A key used to store and retrieve metadata. - * @param target The target object on which the metadata is defined. - * @param propertyKey (Optional) The property key for the target. - * @returns `true` if the metadata entry was found and deleted; otherwise, false. - * @example - * - * class Example { - * // property declarations are not part of ES6, though they are valid in TypeScript: - * // static staticProperty; - * // property; - * - * constructor(p) { } - * static staticMethod(p) { } - * method(p) { } - * } - * - * // constructor - * result = Reflect.deleteMetadata("custom:annotation", Example); - * - * // property (on constructor) - * result = Reflect.deleteMetadata("custom:annotation", Example, "staticProperty"); - * - * // property (on prototype) - * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "property"); - * - * // method (on constructor) - * result = Reflect.deleteMetadata("custom:annotation", Example, "staticMethod"); - * - * // method (on prototype) - * result = Reflect.deleteMetadata("custom:annotation", Example.prototype, "method"); - * - */ - function deleteMetadata(metadataKey, target, propertyKey) { - if (!IsObject(target)) - throw new TypeError(); - if (!IsUndefined(propertyKey)) - propertyKey = ToPropertyKey(propertyKey); - var metadataMap = GetOrCreateMetadataMap(target, propertyKey, /*Create*/ false); - if (IsUndefined(metadataMap)) - return false; - if (!metadataMap.delete(metadataKey)) - return false; - if (metadataMap.size > 0) - return true; - var targetMetadata = Metadata.get(target); - targetMetadata.delete(propertyKey); - if (targetMetadata.size > 0) - return true; - Metadata.delete(target); - return true; - } - exporter("deleteMetadata", deleteMetadata); - function DecorateConstructor(decorators, target) { - for (var i = decorators.length - 1; i >= 0; --i) { - var decorator = decorators[i]; - var decorated = decorator(target); - if (!IsUndefined(decorated) && !IsNull(decorated)) { - if (!IsConstructor(decorated)) - throw new TypeError(); - target = decorated; - } - } - return target; - } - function DecorateProperty(decorators, target, propertyKey, descriptor) { - for (var i = decorators.length - 1; i >= 0; --i) { - var decorator = decorators[i]; - var decorated = decorator(target, propertyKey, descriptor); - if (!IsUndefined(decorated) && !IsNull(decorated)) { - if (!IsObject(decorated)) - throw new TypeError(); - descriptor = decorated; - } - } - return descriptor; - } - function GetOrCreateMetadataMap(O, P, Create) { - var targetMetadata = Metadata.get(O); - if (IsUndefined(targetMetadata)) { - if (!Create) - return undefined; - targetMetadata = new _Map(); - Metadata.set(O, targetMetadata); - } - var metadataMap = targetMetadata.get(P); - if (IsUndefined(metadataMap)) { - if (!Create) - return undefined; - metadataMap = new _Map(); - targetMetadata.set(P, metadataMap); - } - return metadataMap; - } - // 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P) - // https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata - function OrdinaryHasMetadata(MetadataKey, O, P) { - var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P); - if (hasOwn) - return true; - var parent = OrdinaryGetPrototypeOf(O); - if (!IsNull(parent)) - return OrdinaryHasMetadata(MetadataKey, parent, P); - return false; - } - // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P) - // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata - function OrdinaryHasOwnMetadata(MetadataKey, O, P) { - var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false); - if (IsUndefined(metadataMap)) - return false; - return ToBoolean(metadataMap.has(MetadataKey)); - } - // 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P) - // https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata - function OrdinaryGetMetadata(MetadataKey, O, P) { - var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P); - if (hasOwn) - return OrdinaryGetOwnMetadata(MetadataKey, O, P); - var parent = OrdinaryGetPrototypeOf(O); - if (!IsNull(parent)) - return OrdinaryGetMetadata(MetadataKey, parent, P); - return undefined; - } - // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P) - // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata - function OrdinaryGetOwnMetadata(MetadataKey, O, P) { - var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false); - if (IsUndefined(metadataMap)) - return undefined; - return metadataMap.get(MetadataKey); - } - // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) - // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata - function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) { - var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true); - metadataMap.set(MetadataKey, MetadataValue); - } - // 3.1.6.1 OrdinaryMetadataKeys(O, P) - // https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys - function OrdinaryMetadataKeys(O, P) { - var ownKeys = OrdinaryOwnMetadataKeys(O, P); - var parent = OrdinaryGetPrototypeOf(O); - if (parent === null) - return ownKeys; - var parentKeys = OrdinaryMetadataKeys(parent, P); - if (parentKeys.length <= 0) - return ownKeys; - if (ownKeys.length <= 0) - return parentKeys; - var set = new _Set(); - var keys = []; - for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) { - var key = ownKeys_1[_i]; - var hasKey = set.has(key); - if (!hasKey) { - set.add(key); - keys.push(key); - } - } - for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) { - var key = parentKeys_1[_a]; - var hasKey = set.has(key); - if (!hasKey) { - set.add(key); - keys.push(key); - } - } - return keys; - } - // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P) - // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys - function OrdinaryOwnMetadataKeys(O, P) { - var keys = []; - var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false); - if (IsUndefined(metadataMap)) - return keys; - var keysObj = metadataMap.keys(); - var iterator = GetIterator(keysObj); - var k = 0; - while (true) { - var next = IteratorStep(iterator); - if (!next) { - keys.length = k; - return keys; - } - var nextValue = IteratorValue(next); - try { - keys[k] = nextValue; - } - catch (e) { - try { - IteratorClose(iterator); - } - finally { - throw e; - } - } - k++; - } - } - // 6 ECMAScript Data Typ0es and Values - // https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values - function Type(x) { - if (x === null) - return 1 /* Null */; - switch (typeof x) { - case "undefined": return 0 /* Undefined */; - case "boolean": return 2 /* Boolean */; - case "string": return 3 /* String */; - case "symbol": return 4 /* Symbol */; - case "number": return 5 /* Number */; - case "object": return x === null ? 1 /* Null */ : 6 /* Object */; - default: return 6 /* Object */; - } - } - // 6.1.1 The Undefined Type - // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type - function IsUndefined(x) { - return x === undefined; - } - // 6.1.2 The Null Type - // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type - function IsNull(x) { - return x === null; - } - // 6.1.5 The Symbol Type - // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type - function IsSymbol(x) { - return typeof x === "symbol"; - } - // 6.1.7 The Object Type - // https://tc39.github.io/ecma262/#sec-object-type - function IsObject(x) { - return typeof x === "object" ? x !== null : typeof x === "function"; - } - // 7.1 Type Conversion - // https://tc39.github.io/ecma262/#sec-type-conversion - // 7.1.1 ToPrimitive(input [, PreferredType]) - // https://tc39.github.io/ecma262/#sec-toprimitive - function ToPrimitive(input, PreferredType) { - switch (Type(input)) { - case 0 /* Undefined */: return input; - case 1 /* Null */: return input; - case 2 /* Boolean */: return input; - case 3 /* String */: return input; - case 4 /* Symbol */: return input; - case 5 /* Number */: return input; - } - var hint = PreferredType === 3 /* String */ ? "string" : PreferredType === 5 /* Number */ ? "number" : "default"; - var exoticToPrim = GetMethod(input, toPrimitiveSymbol); - if (exoticToPrim !== undefined) { - var result = exoticToPrim.call(input, hint); - if (IsObject(result)) - throw new TypeError(); - return result; - } - return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint); - } - // 7.1.1.1 OrdinaryToPrimitive(O, hint) - // https://tc39.github.io/ecma262/#sec-ordinarytoprimitive - function OrdinaryToPrimitive(O, hint) { - if (hint === "string") { - var toString_1 = O.toString; - if (IsCallable(toString_1)) { - var result = toString_1.call(O); - if (!IsObject(result)) - return result; - } - var valueOf = O.valueOf; - if (IsCallable(valueOf)) { - var result = valueOf.call(O); - if (!IsObject(result)) - return result; - } - } - else { - var valueOf = O.valueOf; - if (IsCallable(valueOf)) { - var result = valueOf.call(O); - if (!IsObject(result)) - return result; - } - var toString_2 = O.toString; - if (IsCallable(toString_2)) { - var result = toString_2.call(O); - if (!IsObject(result)) - return result; - } - } - throw new TypeError(); - } - // 7.1.2 ToBoolean(argument) - // https://tc39.github.io/ecma262/2016/#sec-toboolean - function ToBoolean(argument) { - return !!argument; - } - // 7.1.12 ToString(argument) - // https://tc39.github.io/ecma262/#sec-tostring - function ToString(argument) { - return "" + argument; - } - // 7.1.14 ToPropertyKey(argument) - // https://tc39.github.io/ecma262/#sec-topropertykey - function ToPropertyKey(argument) { - var key = ToPrimitive(argument, 3 /* String */); - if (IsSymbol(key)) - return key; - return ToString(key); - } - // 7.2 Testing and Comparison Operations - // https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations - // 7.2.2 IsArray(argument) - // https://tc39.github.io/ecma262/#sec-isarray - function IsArray(argument) { - return Array.isArray - ? Array.isArray(argument) - : argument instanceof Object - ? argument instanceof Array - : Object.prototype.toString.call(argument) === "[object Array]"; - } - // 7.2.3 IsCallable(argument) - // https://tc39.github.io/ecma262/#sec-iscallable - function IsCallable(argument) { - // NOTE: This is an approximation as we cannot check for [[Call]] internal method. - return typeof argument === "function"; - } - // 7.2.4 IsConstructor(argument) - // https://tc39.github.io/ecma262/#sec-isconstructor - function IsConstructor(argument) { - // NOTE: This is an approximation as we cannot check for [[Construct]] internal method. - return typeof argument === "function"; - } - // 7.2.7 IsPropertyKey(argument) - // https://tc39.github.io/ecma262/#sec-ispropertykey - function IsPropertyKey(argument) { - switch (Type(argument)) { - case 3 /* String */: return true; - case 4 /* Symbol */: return true; - default: return false; - } - } - // 7.3 Operations on Objects - // https://tc39.github.io/ecma262/#sec-operations-on-objects - // 7.3.9 GetMethod(V, P) - // https://tc39.github.io/ecma262/#sec-getmethod - function GetMethod(V, P) { - var func = V[P]; - if (func === undefined || func === null) - return undefined; - if (!IsCallable(func)) - throw new TypeError(); - return func; - } - // 7.4 Operations on Iterator Objects - // https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects - function GetIterator(obj) { - var method = GetMethod(obj, iteratorSymbol); - if (!IsCallable(method)) - throw new TypeError(); // from Call - var iterator = method.call(obj); - if (!IsObject(iterator)) - throw new TypeError(); - return iterator; - } - // 7.4.4 IteratorValue(iterResult) - // https://tc39.github.io/ecma262/2016/#sec-iteratorvalue - function IteratorValue(iterResult) { - return iterResult.value; - } - // 7.4.5 IteratorStep(iterator) - // https://tc39.github.io/ecma262/#sec-iteratorstep - function IteratorStep(iterator) { - var result = iterator.next(); - return result.done ? false : result; - } - // 7.4.6 IteratorClose(iterator, completion) - // https://tc39.github.io/ecma262/#sec-iteratorclose - function IteratorClose(iterator) { - var f = iterator["return"]; - if (f) - f.call(iterator); - } - // 9.1 Ordinary Object Internal Methods and Internal Slots - // https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots - // 9.1.1.1 OrdinaryGetPrototypeOf(O) - // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof - function OrdinaryGetPrototypeOf(O) { - var proto = Object.getPrototypeOf(O); - if (typeof O !== "function" || O === functionPrototype) - return proto; - // TypeScript doesn't set __proto__ in ES5, as it's non-standard. - // Try to determine the superclass constructor. Compatible implementations - // must either set __proto__ on a subclass constructor to the superclass constructor, - // or ensure each class has a valid `constructor` property on its prototype that - // points back to the constructor. - // If this is not the same as Function.[[Prototype]], then this is definately inherited. - // This is the case when in ES6 or when using __proto__ in a compatible browser. - if (proto !== functionPrototype) - return proto; - // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage. - var prototype = O.prototype; - var prototypeProto = prototype && Object.getPrototypeOf(prototype); - if (prototypeProto == null || prototypeProto === Object.prototype) - return proto; - // If the constructor was not a function, then we cannot determine the heritage. - var constructor = prototypeProto.constructor; - if (typeof constructor !== "function") - return proto; - // If we have some kind of self-reference, then we cannot determine the heritage. - if (constructor === O) - return proto; - // we have a pretty good guess at the heritage. - return constructor; - } - // naive Map shim - function CreateMapPolyfill() { - var cacheSentinel = {}; - var arraySentinel = []; - var MapIterator = /** @class */ (function () { - function MapIterator(keys, values, selector) { - this._index = 0; - this._keys = keys; - this._values = values; - this._selector = selector; - } - MapIterator.prototype["@@iterator"] = function () { return this; }; - MapIterator.prototype[iteratorSymbol] = function () { return this; }; - MapIterator.prototype.next = function () { - var index = this._index; - if (index >= 0 && index < this._keys.length) { - var result = this._selector(this._keys[index], this._values[index]); - if (index + 1 >= this._keys.length) { - this._index = -1; - this._keys = arraySentinel; - this._values = arraySentinel; - } - else { - this._index++; - } - return { value: result, done: false }; - } - return { value: undefined, done: true }; - }; - MapIterator.prototype.throw = function (error) { - if (this._index >= 0) { - this._index = -1; - this._keys = arraySentinel; - this._values = arraySentinel; - } - throw error; - }; - MapIterator.prototype.return = function (value) { - if (this._index >= 0) { - this._index = -1; - this._keys = arraySentinel; - this._values = arraySentinel; - } - return { value: value, done: true }; - }; - return MapIterator; - }()); - return /** @class */ (function () { - function Map() { - this._keys = []; - this._values = []; - this._cacheKey = cacheSentinel; - this._cacheIndex = -2; - } - Object.defineProperty(Map.prototype, "size", { - get: function () { return this._keys.length; }, - enumerable: true, - configurable: true - }); - Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; }; - Map.prototype.get = function (key) { - var index = this._find(key, /*insert*/ false); - return index >= 0 ? this._values[index] : undefined; - }; - Map.prototype.set = function (key, value) { - var index = this._find(key, /*insert*/ true); - this._values[index] = value; - return this; - }; - Map.prototype.delete = function (key) { - var index = this._find(key, /*insert*/ false); - if (index >= 0) { - var size = this._keys.length; - for (var i = index + 1; i < size; i++) { - this._keys[i - 1] = this._keys[i]; - this._values[i - 1] = this._values[i]; - } - this._keys.length--; - this._values.length--; - if (key === this._cacheKey) { - this._cacheKey = cacheSentinel; - this._cacheIndex = -2; - } - return true; - } - return false; - }; - Map.prototype.clear = function () { - this._keys.length = 0; - this._values.length = 0; - this._cacheKey = cacheSentinel; - this._cacheIndex = -2; - }; - Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); }; - Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); }; - Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); }; - Map.prototype["@@iterator"] = function () { return this.entries(); }; - Map.prototype[iteratorSymbol] = function () { return this.entries(); }; - Map.prototype._find = function (key, insert) { - if (this._cacheKey !== key) { - this._cacheIndex = this._keys.indexOf(this._cacheKey = key); - } - if (this._cacheIndex < 0 && insert) { - this._cacheIndex = this._keys.length; - this._keys.push(key); - this._values.push(undefined); - } - return this._cacheIndex; - }; - return Map; - }()); - function getKey(key, _) { - return key; - } - function getValue(_, value) { - return value; - } - function getEntry(key, value) { - return [key, value]; - } - } - // naive Set shim - function CreateSetPolyfill() { - return /** @class */ (function () { - function Set() { - this._map = new _Map(); - } - Object.defineProperty(Set.prototype, "size", { - get: function () { return this._map.size; }, - enumerable: true, - configurable: true - }); - Set.prototype.has = function (value) { return this._map.has(value); }; - Set.prototype.add = function (value) { return this._map.set(value, value), this; }; - Set.prototype.delete = function (value) { return this._map.delete(value); }; - Set.prototype.clear = function () { this._map.clear(); }; - Set.prototype.keys = function () { return this._map.keys(); }; - Set.prototype.values = function () { return this._map.values(); }; - Set.prototype.entries = function () { return this._map.entries(); }; - Set.prototype["@@iterator"] = function () { return this.keys(); }; - Set.prototype[iteratorSymbol] = function () { return this.keys(); }; - return Set; - }()); - } - // naive WeakMap shim - function CreateWeakMapPolyfill() { - var UUID_SIZE = 16; - var keys = HashMap.create(); - var rootKey = CreateUniqueKey(); - return /** @class */ (function () { - function WeakMap() { - this._key = CreateUniqueKey(); - } - WeakMap.prototype.has = function (target) { - var table = GetOrCreateWeakMapTable(target, /*create*/ false); - return table !== undefined ? HashMap.has(table, this._key) : false; - }; - WeakMap.prototype.get = function (target) { - var table = GetOrCreateWeakMapTable(target, /*create*/ false); - return table !== undefined ? HashMap.get(table, this._key) : undefined; - }; - WeakMap.prototype.set = function (target, value) { - var table = GetOrCreateWeakMapTable(target, /*create*/ true); - table[this._key] = value; - return this; - }; - WeakMap.prototype.delete = function (target) { - var table = GetOrCreateWeakMapTable(target, /*create*/ false); - return table !== undefined ? delete table[this._key] : false; - }; - WeakMap.prototype.clear = function () { - // NOTE: not a real clear, just makes the previous data unreachable - this._key = CreateUniqueKey(); - }; - return WeakMap; - }()); - function CreateUniqueKey() { - var key; - do - key = "@@WeakMap@@" + CreateUUID(); - while (HashMap.has(keys, key)); - keys[key] = true; - return key; - } - function GetOrCreateWeakMapTable(target, create) { - if (!hasOwn.call(target, rootKey)) { - if (!create) - return undefined; - Object.defineProperty(target, rootKey, { value: HashMap.create() }); - } - return target[rootKey]; - } - function FillRandomBytes(buffer, size) { - for (var i = 0; i < size; ++i) - buffer[i] = Math.random() * 0xff | 0; - return buffer; - } - function GenRandomBytes(size) { - if (typeof Uint8Array === "function") { - if (typeof crypto !== "undefined") - return crypto.getRandomValues(new Uint8Array(size)); - if (typeof msCrypto !== "undefined") - return msCrypto.getRandomValues(new Uint8Array(size)); - return FillRandomBytes(new Uint8Array(size), size); - } - return FillRandomBytes(new Array(size), size); - } - function CreateUUID() { - var data = GenRandomBytes(UUID_SIZE); - // mark as random - RFC 4122 ยง 4.4 - data[6] = data[6] & 0x4f | 0x40; - data[8] = data[8] & 0xbf | 0x80; - var result = ""; - for (var offset = 0; offset < UUID_SIZE; ++offset) { - var byte = data[offset]; - if (offset === 4 || offset === 6 || offset === 8) - result += "-"; - if (byte < 16) - result += "0"; - result += byte.toString(16).toLowerCase(); - } - return result; - } - } - // uses a heuristic used by v8 and chakra to force an object into dictionary mode. - function MakeDictionary(obj) { - obj.__ = undefined; - delete obj.__; - return obj; - } - }); -})(Reflect || (Reflect = {})); + }; + MetadataReader.prototype.getPropertiesMetadata = function (constructorFunc) { + var userGeneratedMetadata = Reflect.getMetadata(METADATA_KEY.TAGGED_PROP, constructorFunc) || []; + return userGeneratedMetadata; + }; + return MetadataReader; +}()); +exports.MetadataReader = MetadataReader; /***/ }), -/***/ 676: +/***/ 986: /***/ (function(__unusedmodule, exports, __webpack_require__) { "use strict"; @@ -8074,7 +9727,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", { value: true }); -const tr = __webpack_require__(396); +const tr = __webpack_require__(9); /** * Exec a command. * Output will be streamed to the live console. @@ -8101,1659 +9754,6 @@ function exec(commandLine, args, options) { exports.exec = exec; //# sourceMappingURL=exec.js.map -/***/ }), - -/***/ 677: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -exports.NAMED_TAG = "named"; -exports.NAME_TAG = "name"; -exports.UNMANAGED_TAG = "unmanaged"; -exports.OPTIONAL_TAG = "optional"; -exports.INJECT_TAG = "inject"; -exports.MULTI_INJECT_TAG = "multi_inject"; -exports.TAGGED = "inversify:tagged"; -exports.TAGGED_PROP = "inversify:tagged_props"; -exports.PARAM_TYPES = "inversify:paramtypes"; -exports.DESIGN_PARAM_TYPES = "design:paramtypes"; -exports.POST_CONSTRUCT = "post_construct"; - - -/***/ }), - -/***/ 722: -/***/ (function(module) { - -/** - * Convert array of 16 byte values to UUID string format of the form: - * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX - */ -var byteToHex = []; -for (var i = 0; i < 256; ++i) { - byteToHex[i] = (i + 0x100).toString(16).substr(1); -} - -function bytesToUuid(buf, offset) { - var i = offset || 0; - var bth = byteToHex; - // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4 - return ([bth[buf[i++]], bth[buf[i++]], - bth[buf[i++]], bth[buf[i++]], '-', - bth[buf[i++]], bth[buf[i++]], '-', - bth[buf[i++]], bth[buf[i++]], '-', - bth[buf[i++]], bth[buf[i++]], '-', - bth[buf[i++]], bth[buf[i++]], - bth[buf[i++]], bth[buf[i++]], - bth[buf[i++]], bth[buf[i++]]]).join(''); -} - -module.exports = bytesToUuid; - - -/***/ }), - -/***/ 747: -/***/ (function(module) { - -module.exports = require("fs"); - -/***/ }), - -/***/ 752: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var id_1 = __webpack_require__(786); -var ContainerModule = (function () { - function ContainerModule(registry) { - this.id = id_1.id(); - this.registry = registry; - } - return ContainerModule; -}()); -exports.ContainerModule = ContainerModule; -var AsyncContainerModule = (function () { - function AsyncContainerModule(registry) { - this.id = id_1.id(); - this.registry = registry; - } - return AsyncContainerModule; -}()); -exports.AsyncContainerModule = AsyncContainerModule; - - -/***/ }), - -/***/ 758: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); -var decorator_utils_1 = __webpack_require__(289); -function named(name) { - return function (target, targetKey, index) { - var metadata = new metadata_1.Metadata(METADATA_KEY.NAMED_TAG, name); - if (typeof index === "number") { - decorator_utils_1.tagParameter(target, targetKey, index, metadata); - } - else { - decorator_utils_1.tagProperty(target, targetKey, metadata); - } - }; -} -exports.named = named; - - -/***/ }), - -/***/ 786: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var idCounter = 0; -function id() { - return idCounter++; -} -exports.id = id; - - -/***/ }), - -/***/ 787: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var binding_count_1 = __webpack_require__(964); -var ERROR_MSGS = __webpack_require__(516); -var literal_types_1 = __webpack_require__(186); -var METADATA_KEY = __webpack_require__(677); -var exceptions_1 = __webpack_require__(355); -var serialization_1 = __webpack_require__(571); -var context_1 = __webpack_require__(638); -var metadata_1 = __webpack_require__(173); -var plan_1 = __webpack_require__(462); -var reflection_utils_1 = __webpack_require__(839); -var request_1 = __webpack_require__(87); -var target_1 = __webpack_require__(534); -function getBindingDictionary(cntnr) { - return cntnr._bindingDictionary; -} -exports.getBindingDictionary = getBindingDictionary; -function _createTarget(isMultiInject, targetType, serviceIdentifier, name, key, value) { - var metadataKey = isMultiInject ? METADATA_KEY.MULTI_INJECT_TAG : METADATA_KEY.INJECT_TAG; - var injectMetadata = new metadata_1.Metadata(metadataKey, serviceIdentifier); - var target = new target_1.Target(targetType, name, serviceIdentifier, injectMetadata); - if (key !== undefined) { - var tagMetadata = new metadata_1.Metadata(key, value); - target.metadata.push(tagMetadata); - } - return target; -} -function _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target) { - var bindings = getBindings(context.container, target.serviceIdentifier); - var activeBindings = []; - if (bindings.length === binding_count_1.BindingCount.NoBindingsAvailable && - context.container.options.autoBindInjectable && - typeof target.serviceIdentifier === "function" && - metadataReader.getConstructorMetadata(target.serviceIdentifier).compilerGeneratedMetadata) { - context.container.bind(target.serviceIdentifier).toSelf(); - bindings = getBindings(context.container, target.serviceIdentifier); - } - if (!avoidConstraints) { - activeBindings = bindings.filter(function (binding) { - var request = new request_1.Request(binding.serviceIdentifier, context, parentRequest, binding, target); - return binding.constraint(request); - }); - } - else { - activeBindings = bindings; - } - _validateActiveBindingCount(target.serviceIdentifier, activeBindings, target, context.container); - return activeBindings; -} -function _validateActiveBindingCount(serviceIdentifier, bindings, target, container) { - switch (bindings.length) { - case binding_count_1.BindingCount.NoBindingsAvailable: - if (target.isOptional()) { - return bindings; - } - else { - var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier); - var msg = ERROR_MSGS.NOT_REGISTERED; - msg += serialization_1.listMetadataForTarget(serviceIdentifierString, target); - msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings); - throw new Error(msg); - } - case binding_count_1.BindingCount.OnlyOneBindingAvailable: - if (!target.isArray()) { - return bindings; - } - case binding_count_1.BindingCount.MultipleBindingsAvailable: - default: - if (!target.isArray()) { - var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier); - var msg = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString; - msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings); - throw new Error(msg); - } - else { - return bindings; - } - } -} -function _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, parentRequest, target) { - var activeBindings; - var childRequest; - if (parentRequest === null) { - activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, null, target); - childRequest = new request_1.Request(serviceIdentifier, context, null, activeBindings, target); - var thePlan = new plan_1.Plan(context, childRequest); - context.addPlan(thePlan); - } - else { - activeBindings = _getActiveBindings(metadataReader, avoidConstraints, context, parentRequest, target); - childRequest = parentRequest.addChildRequest(target.serviceIdentifier, activeBindings, target); - } - activeBindings.forEach(function (binding) { - var subChildRequest = null; - if (target.isArray()) { - subChildRequest = childRequest.addChildRequest(binding.serviceIdentifier, binding, target); - } - else { - if (binding.cache) { - return; - } - subChildRequest = childRequest; - } - if (binding.type === literal_types_1.BindingTypeEnum.Instance && binding.implementationType !== null) { - var dependencies = reflection_utils_1.getDependencies(metadataReader, binding.implementationType); - if (!context.container.options.skipBaseClassChecks) { - var baseClassDependencyCount = reflection_utils_1.getBaseClassDependencyCount(metadataReader, binding.implementationType); - if (dependencies.length < baseClassDependencyCount) { - var error = ERROR_MSGS.ARGUMENTS_LENGTH_MISMATCH(reflection_utils_1.getFunctionName(binding.implementationType)); - throw new Error(error); - } - } - dependencies.forEach(function (dependency) { - _createSubRequests(metadataReader, false, dependency.serviceIdentifier, context, subChildRequest, dependency); - }); - } - }); -} -function getBindings(container, serviceIdentifier) { - var bindings = []; - var bindingDictionary = getBindingDictionary(container); - if (bindingDictionary.hasKey(serviceIdentifier)) { - bindings = bindingDictionary.get(serviceIdentifier); - } - else if (container.parent !== null) { - bindings = getBindings(container.parent, serviceIdentifier); - } - return bindings; -} -function plan(metadataReader, container, isMultiInject, targetType, serviceIdentifier, key, value, avoidConstraints) { - if (avoidConstraints === void 0) { avoidConstraints = false; } - var context = new context_1.Context(container); - var target = _createTarget(isMultiInject, targetType, serviceIdentifier, "", key, value); - try { - _createSubRequests(metadataReader, avoidConstraints, serviceIdentifier, context, null, target); - return context; - } - catch (error) { - if (exceptions_1.isStackOverflowExeption(error)) { - if (context.plan) { - serialization_1.circularDependencyToException(context.plan.rootRequest); - } - } - throw error; - } -} -exports.plan = plan; -function createMockRequest(container, serviceIdentifier, key, value) { - var target = new target_1.Target(literal_types_1.TargetTypeEnum.Variable, "", serviceIdentifier, new metadata_1.Metadata(key, value)); - var context = new context_1.Context(container); - var request = new request_1.Request(serviceIdentifier, context, null, [], target); - return request; -} -exports.createMockRequest = createMockRequest; - - -/***/ }), - -/***/ 817: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -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 }); -const path = __webpack_require__(622); -const uuidV4 = __webpack_require__(542); -const core = __webpack_require__(949); -const exe = __webpack_require__(676); -const io = __webpack_require__(957); -const toolCache = __webpack_require__(568); -const inversify_1 = __webpack_require__(386); -let BuildAgent = class BuildAgent { - find(toolName, versionSpec, arch) { - return toolCache.find(toolName, versionSpec, arch); - } - cacheDir(sourceDir, tool, version, arch) { - return toolCache.cacheDir(sourceDir, tool, version, arch); - } - createTempDir() { - return __awaiter(this, void 0, void 0, function* () { - const IS_WINDOWS = process.platform === "win32"; - let tempDirectory = process.env.RUNNER_TEMP || ""; - if (!tempDirectory) { - let baseLocation; - if (IS_WINDOWS) { - // On Windows use the USERPROFILE env variable - baseLocation = process.env.USERPROFILE || "C:\\"; - } - else { - if (process.platform === "darwin") { - baseLocation = "/Users"; - } - else { - baseLocation = "/home"; - } - } - tempDirectory = path.join(baseLocation, "actions", "temp"); - } - const dest = path.join(tempDirectory, uuidV4()); - yield io.mkdirP(dest); - return dest; - }); - } - debug(message) { - core.debug(message); - } - setFailed(message, done) { - core.setFailed(message); - } - setSucceeded(message, done) { - // - } - exportVariable(name, val) { - core.exportVariable(name, val); - } - addPath(inputPath) { - core.addPath(inputPath); - } - which(tool, check) { - return io.which(tool, check); - } - exec(exec, args) { - return __awaiter(this, void 0, void 0, function* () { - const dotnetPath = yield io.which(exec, true); - let resultCode = 0; - let stdout = ""; - let stderr = ""; - resultCode = yield exe.exec(`"${dotnetPath}"`, args, { - listeners: { - stderr: (data) => { - stderr += data.toString(); - }, - stdout: (data) => { - stdout += data.toString(); - }, - }, - }); - return { - code: resultCode, - error: null, - stderr, - stdout, - }; - }); - } -}; -BuildAgent = __decorate([ - inversify_1.injectable() -], BuildAgent); -exports.BuildAgent = BuildAgent; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQtYWdlbnQ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UssQ0FBQyxJQUFJLEVBQUUsS0FBSyxDQUFDLENBQUM7SUFDakMsQ0FBQztJQUVZLElBQUksQ0FBQyxJQUFZLEVBQUUsSUFBYzs7WUFDMUMsTUFBTSxVQUFVLEdBQUcsTUFBTSxFQUFFLENBQUMsS0FBSyxDQUFDLElBQUksRUFBRSxJQUFJLENBQUMsQ0FBQztZQUM5QyxJQUFJLFVBQVUsR0FBRyxDQUFDLENBQUM7WUFDbkIsSUFBSSxNQUFNLEdBQUcsRUFBRSxDQUFDO1lBQ2hCLElBQUksTUFBTSxHQUFHLEVBQUUsQ0FBQztZQUNoQixVQUFVLEdBQUcsTUFBTSxHQUFHLENBQUMsSUFBSSxDQUN2QixJQUFJLFVBQVUsR0FBRyxFQUNqQixJQUFJLEVBQ0o7Z0JBQ0ksU0FBUyxFQUFFO29CQUNQLE1BQU0sRUFBRSxDQUFDLElBQVksRUFBRSxFQUFFO3dCQUNyQixNQUFNLElBQUksSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDO29CQUM5QixDQUFDO29CQUNELE1BQU0sRUFBRSxDQUFDLElBQVksRUFBRSxFQUFFO3dCQUNyQixNQUFNLElBQUksSUFBSSxDQUFDLFFBQVEsRUFBRSxDQUFDO29CQUM5QixDQUFDO2lCQUNKO2FBQ0osQ0FBQyxDQUFDO1lBQ1AsT0FBTztnQkFDSCxJQUFJLEVBQUUsVUFBVTtnQkFDaEIsS0FBSyxFQUFFLElBQUk7Z0JBQ1gsTUFBTTtnQkFDTixNQUFNO2FBQ1QsQ0FBQztRQUNOLENBQUM7S0FBQTtDQUNKLENBQUE7QUFuRkssVUFBVTtJQURmLHNCQUFVLEVBQUU7R0FDUCxVQUFVLENBbUZmO0FBR0csZ0NBQVUifQ== - -/***/ }), - -/***/ 834: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -const TYPES = { - IBuildAgent: Symbol.for("BuildAgent"), - IDotnetTool: Symbol.for("DotnetTool"), - IGitVersionTool: Symbol.for("GitVersionTool"), - IVersionManager: Symbol.for("VersionManager"), -}; -exports.TYPES = TYPES; -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZmlsZTovLy9EOi9Qcm9qZWN0cy9PU1MvR2l0VG9vbHMvdXNlLWdpdHZlcnNpb24yL3NyYy90eXBlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLE1BQU0sS0FBSyxHQUFHO0lBQ1YsV0FBVyxFQUFFLE1BQU0sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDO0lBQ3JDLFdBQVcsRUFBRSxNQUFNLENBQUMsR0FBRyxDQUFDLFlBQVksQ0FBQztJQUNyQyxlQUFlLEVBQUUsTUFBTSxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsQ0FBQztJQUM3QyxlQUFlLEVBQUUsTUFBTSxDQUFDLEdBQUcsQ0FBQyxnQkFBZ0IsQ0FBQztDQUNoRCxDQUFDO0FBRU8sc0JBQUsifQ== - -/***/ }), - -/***/ 835: -/***/ (function(module) { - -module.exports = require("url"); - -/***/ }), - -/***/ 839: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var inject_1 = __webpack_require__(380); -var ERROR_MSGS = __webpack_require__(516); -var literal_types_1 = __webpack_require__(186); -var METADATA_KEY = __webpack_require__(677); -var serialization_1 = __webpack_require__(571); -exports.getFunctionName = serialization_1.getFunctionName; -var target_1 = __webpack_require__(534); -function getDependencies(metadataReader, func) { - var constructorName = serialization_1.getFunctionName(func); - var targets = getTargets(metadataReader, constructorName, func, false); - return targets; -} -exports.getDependencies = getDependencies; -function getTargets(metadataReader, constructorName, func, isBaseClass) { - var metadata = metadataReader.getConstructorMetadata(func); - var serviceIdentifiers = metadata.compilerGeneratedMetadata; - if (serviceIdentifiers === undefined) { - var msg = ERROR_MSGS.MISSING_INJECTABLE_ANNOTATION + " " + constructorName + "."; - throw new Error(msg); - } - var constructorArgsMetadata = metadata.userGeneratedMetadata; - var keys = Object.keys(constructorArgsMetadata); - var hasUserDeclaredUnknownInjections = (func.length === 0 && keys.length > 0); - var iterations = (hasUserDeclaredUnknownInjections) ? keys.length : func.length; - var constructorTargets = getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations); - var propertyTargets = getClassPropsAsTargets(metadataReader, func); - var targets = constructorTargets.concat(propertyTargets); - return targets; -} -function getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata) { - var targetMetadata = constructorArgsMetadata[index.toString()] || []; - var metadata = formatTargetMetadata(targetMetadata); - var isManaged = metadata.unmanaged !== true; - var serviceIdentifier = serviceIdentifiers[index]; - var injectIdentifier = (metadata.inject || metadata.multiInject); - serviceIdentifier = (injectIdentifier) ? (injectIdentifier) : serviceIdentifier; - if (serviceIdentifier instanceof inject_1.LazyServiceIdentifer) { - serviceIdentifier = serviceIdentifier.unwrap(); - } - if (isManaged) { - var isObject = serviceIdentifier === Object; - var isFunction = serviceIdentifier === Function; - var isUndefined = serviceIdentifier === undefined; - var isUnknownType = (isObject || isFunction || isUndefined); - if (!isBaseClass && isUnknownType) { - var msg = ERROR_MSGS.MISSING_INJECT_ANNOTATION + " argument " + index + " in class " + constructorName + "."; - throw new Error(msg); - } - var target = new target_1.Target(literal_types_1.TargetTypeEnum.ConstructorArgument, metadata.targetName, serviceIdentifier); - target.metadata = targetMetadata; - return target; - } - return null; -} -function getConstructorArgsAsTargets(isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata, iterations) { - var targets = []; - for (var i = 0; i < iterations; i++) { - var index = i; - var target = getConstructorArgsAsTarget(index, isBaseClass, constructorName, serviceIdentifiers, constructorArgsMetadata); - if (target !== null) { - targets.push(target); - } - } - return targets; -} -function getClassPropsAsTargets(metadataReader, constructorFunc) { - var classPropsMetadata = metadataReader.getPropertiesMetadata(constructorFunc); - var targets = []; - var keys = Object.keys(classPropsMetadata); - for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { - var key = keys_1[_i]; - var targetMetadata = classPropsMetadata[key]; - var metadata = formatTargetMetadata(classPropsMetadata[key]); - var targetName = metadata.targetName || key; - var serviceIdentifier = (metadata.inject || metadata.multiInject); - var target = new target_1.Target(literal_types_1.TargetTypeEnum.ClassProperty, targetName, serviceIdentifier); - target.metadata = targetMetadata; - targets.push(target); - } - var baseConstructor = Object.getPrototypeOf(constructorFunc.prototype).constructor; - if (baseConstructor !== Object) { - var baseTargets = getClassPropsAsTargets(metadataReader, baseConstructor); - targets = targets.concat(baseTargets); - } - return targets; -} -function getBaseClassDependencyCount(metadataReader, func) { - var baseConstructor = Object.getPrototypeOf(func.prototype).constructor; - if (baseConstructor !== Object) { - var baseConstructorName = serialization_1.getFunctionName(baseConstructor); - var targets = getTargets(metadataReader, baseConstructorName, baseConstructor, true); - var metadata = targets.map(function (t) { - return t.metadata.filter(function (m) { - return m.key === METADATA_KEY.UNMANAGED_TAG; - }); - }); - var unmanagedCount = [].concat.apply([], metadata).length; - var dependencyCount = targets.length - unmanagedCount; - if (dependencyCount > 0) { - return dependencyCount; - } - else { - return getBaseClassDependencyCount(metadataReader, baseConstructor); - } - } - else { - return 0; - } -} -exports.getBaseClassDependencyCount = getBaseClassDependencyCount; -function formatTargetMetadata(targetMetadata) { - var targetMetadataMap = {}; - targetMetadata.forEach(function (m) { - targetMetadataMap[m.key.toString()] = m.value; - }); - return { - inject: targetMetadataMap[METADATA_KEY.INJECT_TAG], - multiInject: targetMetadataMap[METADATA_KEY.MULTI_INJECT_TAG], - targetName: targetMetadataMap[METADATA_KEY.NAME_TAG], - unmanaged: targetMetadataMap[METADATA_KEY.UNMANAGED_TAG] - }; -} - - -/***/ }), - -/***/ 851: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - - -var net = __webpack_require__(631); -var tls = __webpack_require__(16); -var http = __webpack_require__(605); -var https = __webpack_require__(211); -var events = __webpack_require__(614); -var assert = __webpack_require__(357); -var util = __webpack_require__(669); - - -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; - - -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; -} - -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - return agent; -} - -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; -} - -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - return agent; -} - - -function TunnelingAgent(options) { - var self = this; - self.options = options || {}; - self.proxyOptions = self.options.proxy || {}; - self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; - self.requests = []; - self.sockets = []; - - self.on('free', function onFree(socket, host, port, localAddress) { - var options = toOptions(host, port, localAddress); - for (var i = 0, len = self.requests.length; i < len; ++i) { - var pending = self.requests[i]; - if (pending.host === options.host && pending.port === options.port) { - // Detect the request to connect same origin server, - // reuse the connection. - self.requests.splice(i, 1); - pending.request.onSocket(socket); - return; - } - } - socket.destroy(); - self.removeSocket(socket); - }); -} -util.inherits(TunnelingAgent, events.EventEmitter); - -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); - - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; - } - - // If we are under maxSockets create a new one. - self.createSocket(options, function(socket) { - socket.on('free', onFree); - socket.on('close', onCloseOrRemove); - socket.on('agentRemove', onCloseOrRemove); - req.onSocket(socket); - - function onFree() { - self.emit('free', socket, options); - } - - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); - } - }); -}; - -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); - - var connectOptions = mergeOptions({}, self.proxyOptions, { - method: 'CONNECT', - path: options.host + ':' + options.port, - agent: false - }); - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); - } - - debug('making CONNECT request'); - var connectReq = self.request(connectOptions); - connectReq.useChunkedEncodingByDefault = false; // for v0.6 - connectReq.once('response', onResponse); // for v0.6 - connectReq.once('upgrade', onUpgrade); // for v0.6 - connectReq.once('connect', onConnect); // for v0.7 or later - connectReq.once('error', onError); - connectReq.end(); - - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; - } - - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); - } - - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); - - if (res.statusCode === 200) { - assert.equal(head.length, 0); - debug('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - cb(socket); - } else { - debug('tunneling socket could not be established, statusCode=%d', - res.statusCode); - var error = new Error('tunneling socket could not be established, ' + - 'statusCode=' + res.statusCode); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } - } - - function onError(cause) { - connectReq.removeAllListeners(); - - debug('tunneling socket could not be established, cause=%s\n', - cause.message, cause.stack); - var error = new Error('tunneling socket could not be established, ' + - 'cause=' + cause.message); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } -}; - -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; - } - this.sockets.splice(pos, 1); - - var pending = this.requests.shift(); - if (pending) { - // If we have pending requests and a socket gets closed a new one - // needs to be created to take over in the pool for the one that closed. - this.createSocket(pending, function(socket) { - pending.request.onSocket(socket); - }); - } -}; - -function createSecureSocket(options, cb) { - var self = this; - TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { - var hostHeader = options.request.getHeader('host'); - var tlsOptions = mergeOptions({}, self.options, { - socket: socket, - servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host - }); - - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); - }); -} - - -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; - } - return host; // for v0.11 or later -} - -function mergeOptions(target) { - for (var i = 1, len = arguments.length; i < len; ++i) { - var overrides = arguments[i]; - if (typeof overrides === 'object') { - var keys = Object.keys(overrides); - for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { - var k = keys[j]; - if (overrides[k] !== undefined) { - target[k] = overrides[k]; - } - } - } - } - return target; -} - - -var debug; -if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments); - if (typeof args[0] === 'string') { - args[0] = 'TUNNEL: ' + args[0]; - } else { - args.unshift('TUNNEL:'); - } - console.error.apply(console, args); - } -} else { - debug = function() {}; -} -exports.debug = debug; // for test - - -/***/ }), - -/***/ 860: -/***/ (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()); - }); -}; -var _a; -Object.defineProperty(exports, "__esModule", { value: true }); -const assert_1 = __webpack_require__(357); -const fs = __webpack_require__(747); -const path = __webpack_require__(622); -_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; -exports.IS_WINDOWS = process.platform === 'win32'; -function exists(fsPath) { - return __awaiter(this, void 0, void 0, function* () { - try { - yield exports.stat(fsPath); - } - catch (err) { - if (err.code === 'ENOENT') { - return false; - } - throw err; - } - return true; - }); -} -exports.exists = exists; -function isDirectory(fsPath, useStat = false) { - return __awaiter(this, void 0, void 0, function* () { - const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath); - return stats.isDirectory(); - }); -} -exports.isDirectory = isDirectory; -/** - * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: - * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). - */ -function isRooted(p) { - p = normalizeSeparators(p); - if (!p) { - throw new Error('isRooted() parameter "p" cannot be empty'); - } - if (exports.IS_WINDOWS) { - return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello - ); // e.g. C: or C:\hello - } - return p.startsWith('/'); -} -exports.isRooted = isRooted; -/** - * Recursively create a directory at `fsPath`. - * - * This implementation is optimistic, meaning it attempts to create the full - * path first, and backs up the path stack from there. - * - * @param fsPath The path to create - * @param maxDepth The maximum recursion depth - * @param depth The current recursion depth - */ -function mkdirP(fsPath, maxDepth = 1000, depth = 1) { - return __awaiter(this, void 0, void 0, function* () { - assert_1.ok(fsPath, 'a path argument must be provided'); - fsPath = path.resolve(fsPath); - if (depth >= maxDepth) - return exports.mkdir(fsPath); - try { - yield exports.mkdir(fsPath); - return; - } - catch (err) { - switch (err.code) { - case 'ENOENT': { - yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1); - yield exports.mkdir(fsPath); - return; - } - default: { - let stats; - try { - stats = yield exports.stat(fsPath); - } - catch (err2) { - throw err; - } - if (!stats.isDirectory()) - throw err; - } - } - } - }); -} -exports.mkdirP = mkdirP; -/** - * Best effort attempt to determine whether a file exists and is executable. - * @param filePath file path to check - * @param extensions additional file extensions to try - * @return if file exists and is executable, returns the file path. otherwise empty string. - */ -function tryGetExecutablePath(filePath, extensions) { - return __awaiter(this, void 0, void 0, function* () { - let stats = undefined; - try { - // test file exists - stats = yield exports.stat(filePath); - } - catch (err) { - if (err.code !== 'ENOENT') { - // eslint-disable-next-line no-console - console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); - } - } - if (stats && stats.isFile()) { - if (exports.IS_WINDOWS) { - // on Windows, test for valid extension - const upperExt = path.extname(filePath).toUpperCase(); - if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) { - return filePath; - } - } - else { - if (isUnixExecutable(stats)) { - return filePath; - } - } - } - // try each extension - const originalFilePath = filePath; - for (const extension of extensions) { - filePath = originalFilePath + extension; - stats = undefined; - try { - stats = yield exports.stat(filePath); - } - catch (err) { - if (err.code !== 'ENOENT') { - // eslint-disable-next-line no-console - console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); - } - } - if (stats && stats.isFile()) { - if (exports.IS_WINDOWS) { - // preserve the case of the actual file (since an extension was appended) - try { - const directory = path.dirname(filePath); - const upperName = path.basename(filePath).toUpperCase(); - for (const actualName of yield exports.readdir(directory)) { - if (upperName === actualName.toUpperCase()) { - filePath = path.join(directory, actualName); - break; - } - } - } - catch (err) { - // eslint-disable-next-line no-console - console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); - } - return filePath; - } - else { - if (isUnixExecutable(stats)) { - return filePath; - } - } - } - } - return ''; - }); -} -exports.tryGetExecutablePath = tryGetExecutablePath; -function normalizeSeparators(p) { - p = p || ''; - if (exports.IS_WINDOWS) { - // convert slashes on Windows - p = p.replace(/\//g, '\\'); - // remove redundant slashes - return p.replace(/\\\\+/g, '\\'); - } - // remove redundant slashes - return p.replace(/\/\/+/g, '/'); -} -// on Mac/Linux, test the execute bit -// R W X R W X R W X -// 256 128 64 32 16 8 4 2 1 -function isUnixExecutable(stats) { - return ((stats.mode & 1) > 0 || - ((stats.mode & 8) > 0 && stats.gid === process.getgid()) || - ((stats.mode & 64) > 0 && stats.uid === process.getuid())); -} -//# sourceMappingURL=io-util.js.map - -/***/ }), - -/***/ 891: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); -var decorator_utils_1 = __webpack_require__(289); -function multiInject(serviceIdentifier) { - return function (target, targetKey, index) { - var metadata = new metadata_1.Metadata(METADATA_KEY.MULTI_INJECT_TAG, serviceIdentifier); - if (typeof index === "number") { - decorator_utils_1.tagParameter(target, targetKey, index, metadata); - } - else { - decorator_utils_1.tagProperty(target, targetKey, metadata); - } - }; -} -exports.multiInject = multiInject; - - -/***/ }), - -/***/ 902: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var literal_types_1 = __webpack_require__(186); -var binding_when_on_syntax_1 = __webpack_require__(179); -var BindingInSyntax = (function () { - function BindingInSyntax(binding) { - this._binding = binding; - } - BindingInSyntax.prototype.inRequestScope = function () { - this._binding.scope = literal_types_1.BindingScopeEnum.Request; - return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding); - }; - BindingInSyntax.prototype.inSingletonScope = function () { - this._binding.scope = literal_types_1.BindingScopeEnum.Singleton; - return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding); - }; - BindingInSyntax.prototype.inTransientScope = function () { - this._binding.scope = literal_types_1.BindingScopeEnum.Transient; - return new binding_when_on_syntax_1.BindingWhenOnSyntax(this._binding); - }; - return BindingInSyntax; -}()); -exports.BindingInSyntax = BindingInSyntax; - - -/***/ }), - -/***/ 911: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -exports.multiBindToService = function (container) { - return function (service) { - return function () { - var types = []; - for (var _i = 0; _i < arguments.length; _i++) { - types[_i] = arguments[_i]; - } - return types.forEach(function (t) { return container.bind(t).toService(service); }); - }; - }; -}; - - -/***/ }), - -/***/ 919: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var ERRORS_MSGS = __webpack_require__(516); -var METADATA_KEY = __webpack_require__(677); -function injectable() { - return function (target) { - if (Reflect.hasOwnMetadata(METADATA_KEY.PARAM_TYPES, target)) { - throw new Error(ERRORS_MSGS.DUPLICATED_INJECTABLE_DECORATOR); - } - var types = Reflect.getMetadata(METADATA_KEY.DESIGN_PARAM_TYPES, target) || []; - Reflect.defineMetadata(METADATA_KEY.PARAM_TYPES, types, target); - return target; - }; -} -exports.injectable = injectable; - - -/***/ }), - -/***/ 949: -/***/ (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 }); -const command_1 = __webpack_require__(106); -const os = __webpack_require__(365); -const path = __webpack_require__(622); -/** - * The code to exit an action - */ -var ExitCode; -(function (ExitCode) { - /** - * A code indicating that the action was successful - */ - ExitCode[ExitCode["Success"] = 0] = "Success"; - /** - * A code indicating that the action was a failure - */ - ExitCode[ExitCode["Failure"] = 1] = "Failure"; -})(ExitCode = exports.ExitCode || (exports.ExitCode = {})); -//----------------------------------------------------------------------- -// Variables -//----------------------------------------------------------------------- -/** - * Sets env variable for this action and future actions in the job - * @param name the name of the variable to set - * @param val the value of the variable - */ -function exportVariable(name, val) { - process.env[name] = val; - command_1.issueCommand('set-env', { name }, val); -} -exports.exportVariable = exportVariable; -/** - * Registers a secret which will get masked from logs - * @param secret value of the secret - */ -function setSecret(secret) { - command_1.issueCommand('add-mask', {}, secret); -} -exports.setSecret = setSecret; -/** - * Prepends inputPath to the PATH (for this action and future actions) - * @param inputPath - */ -function addPath(inputPath) { - command_1.issueCommand('add-path', {}, inputPath); - process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; -} -exports.addPath = addPath; -/** - * Gets the value of an input. The value is also trimmed. - * - * @param name name of the input to get - * @param options optional. See InputOptions. - * @returns string - */ -function getInput(name, options) { - const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; - if (options && options.required && !val) { - throw new Error(`Input required and not supplied: ${name}`); - } - return val.trim(); -} -exports.getInput = getInput; -/** - * Sets the value of an output. - * - * @param name name of the output to set - * @param value value to store - */ -function setOutput(name, value) { - command_1.issueCommand('set-output', { name }, value); -} -exports.setOutput = setOutput; -//----------------------------------------------------------------------- -// Results -//----------------------------------------------------------------------- -/** - * Sets the action status to failed. - * When the action exits it will be with an exit code of 1 - * @param message add error issue message - */ -function setFailed(message) { - process.exitCode = ExitCode.Failure; - error(message); -} -exports.setFailed = setFailed; -//----------------------------------------------------------------------- -// Logging Commands -//----------------------------------------------------------------------- -/** - * Writes debug message to user log - * @param message debug message - */ -function debug(message) { - command_1.issueCommand('debug', {}, message); -} -exports.debug = debug; -/** - * Adds an error issue - * @param message error issue message - */ -function error(message) { - command_1.issue('error', message); -} -exports.error = error; -/** - * Adds an warning issue - * @param message warning issue message - */ -function warning(message) { - command_1.issue('warning', message); -} -exports.warning = warning; -/** - * Writes info to log with console.log. - * @param message info message - */ -function info(message) { - process.stdout.write(message + os.EOL); -} -exports.info = info; -/** - * Begin an output group. - * - * Output until the next `groupEnd` will be foldable in this group - * - * @param name The name of the output group - */ -function startGroup(name) { - command_1.issue('group', name); -} -exports.startGroup = startGroup; -/** - * End an output group. - */ -function endGroup() { - command_1.issue('endgroup'); -} -exports.endGroup = endGroup; -/** - * Wrap an asynchronous function call in a group. - * - * Returns the same type as the function itself. - * - * @param name The name of the group - * @param fn The function to wrap in the group - */ -function group(name, fn) { - return __awaiter(this, void 0, void 0, function* () { - startGroup(name); - let result; - try { - result = yield fn(); - } - finally { - endGroup(); - } - return result; - }); -} -exports.group = group; -//----------------------------------------------------------------------- -// Wrapper action state -//----------------------------------------------------------------------- -/** - * Saves state for current action, the state can only be retrieved by this action's post job execution. - * - * @param name name of the state to store - * @param value value to store - */ -function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); -} -exports.saveState = saveState; -/** - * Gets the value of an state set by this action's main execution. - * - * @param name name of the state to get - * @returns string - */ -function getState(name) { - return process.env[`STATE_${name}`] || ''; -} -exports.getState = getState; -//# sourceMappingURL=core.js.map - -/***/ }), - -/***/ 957: -/***/ (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 }); -const childProcess = __webpack_require__(129); -const path = __webpack_require__(622); -const util_1 = __webpack_require__(669); -const ioUtil = __webpack_require__(860); -const exec = util_1.promisify(childProcess.exec); -/** - * Copies a file or folder. - * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js - * - * @param source source path - * @param dest destination path - * @param options optional. See CopyOptions. - */ -function cp(source, dest, options = {}) { - return __awaiter(this, void 0, void 0, function* () { - const { force, recursive } = readCopyOptions(options); - const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null; - // Dest is an existing file, but not forcing - if (destStat && destStat.isFile() && !force) { - return; - } - // If dest is an existing directory, should copy inside. - const newDest = destStat && destStat.isDirectory() - ? path.join(dest, path.basename(source)) - : dest; - if (!(yield ioUtil.exists(source))) { - throw new Error(`no such file or directory: ${source}`); - } - const sourceStat = yield ioUtil.stat(source); - if (sourceStat.isDirectory()) { - if (!recursive) { - throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`); - } - else { - yield cpDirRecursive(source, newDest, 0, force); - } - } - else { - if (path.relative(source, newDest) === '') { - // a file cannot be copied to itself - throw new Error(`'${newDest}' and '${source}' are the same file`); - } - yield copyFile(source, newDest, force); - } - }); -} -exports.cp = cp; -/** - * Moves a path. - * - * @param source source path - * @param dest destination path - * @param options optional. See MoveOptions. - */ -function mv(source, dest, options = {}) { - return __awaiter(this, void 0, void 0, function* () { - if (yield ioUtil.exists(dest)) { - let destExists = true; - if (yield ioUtil.isDirectory(dest)) { - // If dest is directory copy src into dest - dest = path.join(dest, path.basename(source)); - destExists = yield ioUtil.exists(dest); - } - if (destExists) { - if (options.force == null || options.force) { - yield rmRF(dest); - } - else { - throw new Error('Destination already exists'); - } - } - } - yield mkdirP(path.dirname(dest)); - yield ioUtil.rename(source, dest); - }); -} -exports.mv = mv; -/** - * Remove a path recursively with force - * - * @param inputPath path to remove - */ -function rmRF(inputPath) { - return __awaiter(this, void 0, void 0, function* () { - if (ioUtil.IS_WINDOWS) { - // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another - // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del. - try { - if (yield ioUtil.isDirectory(inputPath, true)) { - yield exec(`rd /s /q "${inputPath}"`); - } - else { - yield exec(`del /f /a "${inputPath}"`); - } - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } - // Shelling out fails to remove a symlink folder with missing source, this unlink catches that - try { - yield ioUtil.unlink(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - } - } - else { - let isDir = false; - try { - isDir = yield ioUtil.isDirectory(inputPath); - } - catch (err) { - // if you try to delete a file that doesn't exist, desired result is achieved - // other errors are valid - if (err.code !== 'ENOENT') - throw err; - return; - } - if (isDir) { - yield exec(`rm -rf "${inputPath}"`); - } - else { - yield ioUtil.unlink(inputPath); - } - } - }); -} -exports.rmRF = rmRF; -/** - * Make a directory. Creates the full path with folders in between - * Will throw if it fails - * - * @param fsPath path to create - * @returns Promise - */ -function mkdirP(fsPath) { - return __awaiter(this, void 0, void 0, function* () { - yield ioUtil.mkdirP(fsPath); - }); -} -exports.mkdirP = mkdirP; -/** - * Returns path of a tool had the tool actually been invoked. Resolves via paths. - * If you check and the tool does not exist, it will throw. - * - * @param tool name of the tool - * @param check whether to check if tool exists - * @returns Promise path to tool - */ -function which(tool, check) { - return __awaiter(this, void 0, void 0, function* () { - if (!tool) { - throw new Error("parameter 'tool' is required"); - } - // recursive when check=true - if (check) { - const result = yield which(tool, false); - if (!result) { - if (ioUtil.IS_WINDOWS) { - throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); - } - else { - throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); - } - } - } - try { - // build the list of extensions to try - const extensions = []; - if (ioUtil.IS_WINDOWS && process.env.PATHEXT) { - for (const extension of process.env.PATHEXT.split(path.delimiter)) { - if (extension) { - extensions.push(extension); - } - } - } - // if it's rooted, return it if exists. otherwise return empty. - if (ioUtil.isRooted(tool)) { - const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions); - if (filePath) { - return filePath; - } - return ''; - } - // if any path separators, return empty - if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) { - return ''; - } - // build the list of directories - // - // Note, technically "where" checks the current directory on Windows. From a toolkit perspective, - // it feels like we should not do this. Checking the current directory seems like more of a use - // case of a shell, and the which() function exposed by the toolkit should strive for consistency - // across platforms. - const directories = []; - if (process.env.PATH) { - for (const p of process.env.PATH.split(path.delimiter)) { - if (p) { - directories.push(p); - } - } - } - // return the first match - for (const directory of directories) { - const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions); - if (filePath) { - return filePath; - } - } - return ''; - } - catch (err) { - throw new Error(`which failed with message ${err.message}`); - } - }); -} -exports.which = which; -function readCopyOptions(options) { - const force = options.force == null ? true : options.force; - const recursive = Boolean(options.recursive); - return { force, recursive }; -} -function cpDirRecursive(sourceDir, destDir, currentDepth, force) { - return __awaiter(this, void 0, void 0, function* () { - // Ensure there is not a run away recursive copy - if (currentDepth >= 255) - return; - currentDepth++; - yield mkdirP(destDir); - const files = yield ioUtil.readdir(sourceDir); - for (const fileName of files) { - const srcFile = `${sourceDir}/${fileName}`; - const destFile = `${destDir}/${fileName}`; - const srcFileStat = yield ioUtil.lstat(srcFile); - if (srcFileStat.isDirectory()) { - // Recurse - yield cpDirRecursive(srcFile, destFile, currentDepth, force); - } - else { - yield copyFile(srcFile, destFile, force); - } - } - // Change the mode for the newly created directory - yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode); - }); -} -// Buffered file copy -function copyFile(srcFile, destFile, force) { - return __awaiter(this, void 0, void 0, function* () { - if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) { - // unlink/re-link it - try { - yield ioUtil.lstat(destFile); - yield ioUtil.unlink(destFile); - } - catch (e) { - // Try to override file permission - if (e.code === 'EPERM') { - yield ioUtil.chmod(destFile, '0666'); - yield ioUtil.unlink(destFile); - } - // other errors = it doesn't exist, no work to do - } - // Copy over symlink - const symlinkFull = yield ioUtil.readlink(srcFile); - yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null); - } - else if (!(yield ioUtil.exists(destFile)) || force) { - yield ioUtil.copyFile(srcFile, destFile); - } - }); -} -//# sourceMappingURL=io.js.map - -/***/ }), - -/***/ 964: -/***/ (function(__unusedmodule, exports) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var BindingCount = { - MultipleBindingsAvailable: 2, - NoBindingsAvailable: 0, - OnlyOneBindingAvailable: 1 -}; -exports.BindingCount = BindingCount; - - -/***/ }), - -/***/ 996: -/***/ (function(__unusedmodule, exports, __webpack_require__) { - -"use strict"; - -Object.defineProperty(exports, "__esModule", { value: true }); -var METADATA_KEY = __webpack_require__(677); -var metadata_1 = __webpack_require__(173); -var decorator_utils_1 = __webpack_require__(289); -function optional() { - return function (target, targetKey, index) { - var metadata = new metadata_1.Metadata(METADATA_KEY.OPTIONAL_TAG, true); - if (typeof index === "number") { - decorator_utils_1.tagParameter(target, targetKey, index, metadata); - } - else { - decorator_utils_1.tagProperty(target, targetKey, metadata); - } - }; -} -exports.optional = optional; - - /***/ }) /******/ }); \ No newline at end of file diff --git a/package.json b/package.json index 0104ddc..add8638 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "main": "main.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "package-github": "ncc build src/github/main.ts -o dist/github/setup" }, "author": "GitTools", "contributors": [