diff --git a/dist/index.js b/dist/index.js index 9c15a5d..b4c4e40 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,8 +1,7 @@ -module.exports = /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 241: +/***/ 914: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -15,8 +14,8 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -const os = __importStar(__nccwpck_require__(87)); -const utils_1 = __nccwpck_require__(278); +const os = __importStar(__nccwpck_require__(857)); +const utils_1 = __nccwpck_require__(302); /** * Commands * @@ -88,7 +87,7 @@ function escapeProperty(s) { /***/ }), -/***/ 186: +/***/ 484: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -110,11 +109,11 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", ({ value: true })); -const command_1 = __nccwpck_require__(241); -const file_command_1 = __nccwpck_require__(717); -const utils_1 = __nccwpck_require__(278); -const os = __importStar(__nccwpck_require__(87)); -const path = __importStar(__nccwpck_require__(622)); +const command_1 = __nccwpck_require__(914); +const file_command_1 = __nccwpck_require__(753); +const utils_1 = __nccwpck_require__(302); +const os = __importStar(__nccwpck_require__(857)); +const path = __importStar(__nccwpck_require__(928)); /** * The code to exit an action */ @@ -333,7 +332,7 @@ exports.getState = getState; /***/ }), -/***/ 717: +/***/ 753: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -349,9 +348,9 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ -const fs = __importStar(__nccwpck_require__(747)); -const os = __importStar(__nccwpck_require__(87)); -const utils_1 = __nccwpck_require__(278); +const fs = __importStar(__nccwpck_require__(896)); +const os = __importStar(__nccwpck_require__(857)); +const utils_1 = __nccwpck_require__(302); function issueCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { @@ -369,7 +368,7 @@ exports.issueCommand = issueCommand; /***/ }), -/***/ 278: +/***/ 302: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -395,11 +394,30 @@ exports.toCommandValue = toCommandValue; /***/ }), -/***/ 514: +/***/ 236: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -409,15 +427,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -const tr = __importStar(__nccwpck_require__(159)); +exports.getExecOutput = exports.exec = void 0; +const string_decoder_1 = __nccwpck_require__(193); +const tr = __importStar(__nccwpck_require__(665)); /** * Exec a command. * Output will be streamed to the live console. @@ -442,15 +455,79 @@ function exec(commandLine, args, options) { }); } exports.exec = exec; +/** + * Exec a command and get the output. + * Output will be streamed to the live console. + * Returns promise with the exit code and collected stdout and stderr + * + * @param commandLine command to execute (can include additional args). Must be correctly escaped. + * @param args optional arguments for tool. Escaping is handled by the lib. + * @param options optional exec options. See ExecOptions + * @returns Promise exit code, stdout, and stderr + */ +function getExecOutput(commandLine, args, options) { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + let stdout = ''; + let stderr = ''; + //Using string decoder covers the case where a mult-byte character is split + const stdoutDecoder = new string_decoder_1.StringDecoder('utf8'); + const stderrDecoder = new string_decoder_1.StringDecoder('utf8'); + const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout; + const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr; + const stdErrListener = (data) => { + stderr += stderrDecoder.write(data); + if (originalStdErrListener) { + originalStdErrListener(data); + } + }; + const stdOutListener = (data) => { + stdout += stdoutDecoder.write(data); + if (originalStdoutListener) { + originalStdoutListener(data); + } + }; + const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener }); + const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners })); + //flush any remaining characters + stdout += stdoutDecoder.end(); + stderr += stderrDecoder.end(); + return { + exitCode, + stdout, + stderr + }; + }); +} +exports.getExecOutput = getExecOutput; //# sourceMappingURL=exec.js.map /***/ }), -/***/ 159: +/***/ 665: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -460,20 +537,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", ({ value: true })); -const os = __importStar(__nccwpck_require__(87)); -const events = __importStar(__nccwpck_require__(614)); -const child = __importStar(__nccwpck_require__(129)); -const path = __importStar(__nccwpck_require__(622)); -const io = __importStar(__nccwpck_require__(436)); -const ioUtil = __importStar(__nccwpck_require__(962)); +exports.argStringToArray = exports.ToolRunner = void 0; +const os = __importStar(__nccwpck_require__(857)); +const events = __importStar(__nccwpck_require__(434)); +const child = __importStar(__nccwpck_require__(317)); +const path = __importStar(__nccwpck_require__(928)); +const io = __importStar(__nccwpck_require__(994)); +const ioUtil = __importStar(__nccwpck_require__(207)); +const timers_1 = __nccwpck_require__(557); /* eslint-disable @typescript-eslint/unbound-method */ const IS_WINDOWS = process.platform === 'win32'; /* @@ -543,11 +615,12 @@ class ToolRunner extends events.EventEmitter { s = s.substring(n + os.EOL.length); n = s.indexOf(os.EOL); } - strBuffer = s; + return s; } catch (err) { // streaming lines to console is best effort. Don't fail a build. this._debug(`error processing line. Failed with error ${err}`); + return ''; } } _getSpawnFileName() { @@ -829,7 +902,7 @@ class ToolRunner extends events.EventEmitter { // if the tool is only a file name, then resolve it from the PATH // otherwise verify it exists (add extension on Windows if necessary) this.toolPath = yield io.which(this.toolPath, true); - return new Promise((resolve, reject) => { + return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { this._debug(`exec tool: ${this.toolPath}`); this._debug('arguments:'); for (const arg of this.args) { @@ -843,9 +916,12 @@ class ToolRunner extends events.EventEmitter { state.on('debug', (message) => { this._debug(message); }); + if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) { + return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`)); + } const fileName = this._getSpawnFileName(); const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName)); - const stdbuffer = ''; + let stdbuffer = ''; if (cp.stdout) { cp.stdout.on('data', (data) => { if (this.options.listeners && this.options.listeners.stdout) { @@ -854,14 +930,14 @@ class ToolRunner extends events.EventEmitter { if (!optionsNonNull.silent && optionsNonNull.outStream) { optionsNonNull.outStream.write(data); } - this._processLineBuffer(data, stdbuffer, (line) => { + stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => { if (this.options.listeners && this.options.listeners.stdline) { this.options.listeners.stdline(line); } }); }); } - const errbuffer = ''; + let errbuffer = ''; if (cp.stderr) { cp.stderr.on('data', (data) => { state.processStderr = true; @@ -876,7 +952,7 @@ class ToolRunner extends events.EventEmitter { : optionsNonNull.outStream; s.write(data); } - this._processLineBuffer(data, errbuffer, (line) => { + errbuffer = this._processLineBuffer(data, errbuffer, (line) => { if (this.options.listeners && this.options.listeners.errline) { this.options.listeners.errline(line); } @@ -923,7 +999,7 @@ class ToolRunner extends events.EventEmitter { } cp.stdin.end(this.options.input); } - }); + })); }); } } @@ -1009,7 +1085,7 @@ class ExecState extends events.EventEmitter { this._setResult(); } else if (this.processExited) { - this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this); + this.timeout = timers_1.setTimeout(ExecState.HandleTimeout, this.delay, this); } } _debug(message) { @@ -1053,7 +1129,7 @@ class ExecState extends events.EventEmitter { /***/ }), -/***/ 962: +/***/ 207: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1069,9 +1145,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; var _a; Object.defineProperty(exports, "__esModule", ({ value: true })); -const assert_1 = __nccwpck_require__(357); -const fs = __nccwpck_require__(747); -const path = __nccwpck_require__(622); +const assert_1 = __nccwpck_require__(613); +const fs = __nccwpck_require__(896); +const path = __nccwpck_require__(928); _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) { @@ -1255,7 +1331,7 @@ function isUnixExecutable(stats) { /***/ }), -/***/ 436: +/***/ 994: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1270,10 +1346,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", ({ value: true })); -const childProcess = __nccwpck_require__(129); -const path = __nccwpck_require__(622); -const util_1 = __nccwpck_require__(669); -const ioUtil = __nccwpck_require__(962); +const childProcess = __nccwpck_require__(317); +const path = __nccwpck_require__(928); +const util_1 = __nccwpck_require__(23); +const ioUtil = __nccwpck_require__(207); const exec = util_1.promisify(childProcess.exec); /** * Copies a file or folder. @@ -1552,15 +1628,15 @@ function copyFile(srcFile, destFile, force) { /***/ }), -/***/ 88: +/***/ 163: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const debug = __nccwpck_require__(427) -const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(293) -const { re, t } = __nccwpck_require__(523) +const debug = __nccwpck_require__(159) +const { MAX_LENGTH, MAX_SAFE_INTEGER } = __nccwpck_require__(101) +const { safeRe: re, t } = __nccwpck_require__(471) -const parseOptions = __nccwpck_require__(785) -const { compareIdentifiers } = __nccwpck_require__(463) +const parseOptions = __nccwpck_require__(356) +const { compareIdentifiers } = __nccwpck_require__(348) class SemVer { constructor (version, options) { options = parseOptions(options) @@ -1573,7 +1649,7 @@ class SemVer { version = version.version } } else if (typeof version !== 'string') { - throw new TypeError(`Invalid Version: ${version}`) + throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`) } if (version.length > MAX_LENGTH) { @@ -1715,7 +1791,7 @@ class SemVer { do { const a = this.build[i] const b = other.build[i] - debug('prerelease compare', i, a, b) + debug('build compare', i, a, b) if (a === undefined && b === undefined) { return 0 } else if (b === undefined) { @@ -1732,36 +1808,36 @@ class SemVer { // preminor will bump the version up to the next minor release, and immediately // down to pre-release. premajor and prepatch work the same way. - inc (release, identifier) { + inc (release, identifier, identifierBase) { switch (release) { case 'premajor': this.prerelease.length = 0 this.patch = 0 this.minor = 0 this.major++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'preminor': this.prerelease.length = 0 this.patch = 0 this.minor++ - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'prepatch': // If this is already a prerelease, it will bump to the next version // drop any prereleases that might already exist, since they are not // relevant at this point. this.prerelease.length = 0 - this.inc('patch', identifier) - this.inc('pre', identifier) + this.inc('patch', identifier, identifierBase) + this.inc('pre', identifier, identifierBase) break // If the input is a non-prerelease version, this acts the same as // prepatch. case 'prerelease': if (this.prerelease.length === 0) { - this.inc('patch', identifier) + this.inc('patch', identifier, identifierBase) } - this.inc('pre', identifier) + this.inc('pre', identifier, identifierBase) break case 'major': @@ -1803,9 +1879,15 @@ class SemVer { break // This probably shouldn't be used publicly. // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction. - case 'pre': + case 'pre': { + const base = Number(identifierBase) ? 1 : 0 + + if (!identifier && identifierBase === false) { + throw new Error('invalid increment argument: identifier is empty') + } + if (this.prerelease.length === 0) { - this.prerelease = [0] + this.prerelease = [base] } else { let i = this.prerelease.length while (--i >= 0) { @@ -1816,27 +1898,36 @@ class SemVer { } if (i === -1) { // didn't increment anything - this.prerelease.push(0) + if (identifier === this.prerelease.join('.') && identifierBase === false) { + throw new Error('invalid increment argument: identifier already exists') + } + this.prerelease.push(base) } } if (identifier) { // 1.2.0-beta.1 bumps to 1.2.0-beta.2, // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0 - if (this.prerelease[0] === identifier) { + let prerelease = [identifier, base] + if (identifierBase === false) { + prerelease = [identifier] + } + if (compareIdentifiers(this.prerelease[0], identifier) === 0) { if (isNaN(this.prerelease[1])) { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } else { - this.prerelease = [identifier, 0] + this.prerelease = prerelease } } break - + } default: throw new Error(`invalid increment argument: ${release}`) } - this.format() - this.raw = this.version + this.raw = this.format() + if (this.build.length) { + this.raw += `+${this.build.join('.')}` + } return this } } @@ -1846,12 +1937,12 @@ module.exports = SemVer /***/ }), -/***/ 466: +/***/ 385: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const SemVer = __nccwpck_require__(88) -const parse = __nccwpck_require__(925) -const {re, t} = __nccwpck_require__(523) +const SemVer = __nccwpck_require__(163) +const parse = __nccwpck_require__(353) +const { safeRe: re, t } = __nccwpck_require__(471) const coerce = (version, options) => { if (version instanceof SemVer) { @@ -1870,82 +1961,74 @@ const coerce = (version, options) => { let match = null if (!options.rtl) { - match = version.match(re[t.COERCE]) + match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]) } else { // Find the right-most coercible string that does not share // a terminus with a more left-ward coercible string. // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4' + // With includePrerelease option set, '1.2.3.4-rc' wants to coerce '2.3.4-rc', not '2.3.4' // // Walk through the string checking with a /g regexp // Manually set the index so as to pick up overlapping matches. // Stop when we get a match that ends at the string end, since no // coercible string can be more right-ward without the same terminus. + const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL] let next - while ((next = re[t.COERCERTL].exec(version)) && + while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length) ) { if (!match || next.index + next[0].length !== match.index + match[0].length) { match = next } - re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length + coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length } // leave it in a clean state - re[t.COERCERTL].lastIndex = -1 + coerceRtlRegex.lastIndex = -1 } - if (match === null) + if (match === null) { return null + } - return parse(`${match[2]}.${match[3] || '0'}.${match[4] || '0'}`, options) + const major = match[2] + const minor = match[3] || '0' + const patch = match[4] || '0' + const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : '' + const build = options.includePrerelease && match[6] ? `+${match[6]}` : '' + + return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options) } module.exports = coerce /***/ }), -/***/ 688: +/***/ 511: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const SemVer = __nccwpck_require__(88) +const SemVer = __nccwpck_require__(163) const major = (a, loose) => new SemVer(a, loose).major module.exports = major /***/ }), -/***/ 925: +/***/ 353: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const {MAX_LENGTH} = __nccwpck_require__(293) -const { re, t } = __nccwpck_require__(523) -const SemVer = __nccwpck_require__(88) - -const parseOptions = __nccwpck_require__(785) -const parse = (version, options) => { - options = parseOptions(options) - +const SemVer = __nccwpck_require__(163) +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { return version } - - if (typeof version !== 'string') { - return null - } - - if (version.length > MAX_LENGTH) { - return null - } - - const r = options.loose ? re[t.LOOSE] : re[t.FULL] - if (!r.test(version)) { - return null - } - try { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } @@ -1954,7 +2037,7 @@ module.exports = parse /***/ }), -/***/ 293: +/***/ 101: /***/ ((module) => { // Note: this is the semver.org version of the spec that it implements @@ -1963,22 +2046,40 @@ const SEMVER_SPEC_VERSION = '2.0.0' const MAX_LENGTH = 256 const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || - /* istanbul ignore next */ 9007199254740991 +/* istanbul ignore next */ 9007199254740991 // Max safe segment length for coercion. const MAX_SAFE_COMPONENT_LENGTH = 16 +// Max safe length for a build identifier. The max length minus 6 characters for +// the shortest version with a build 0.0.0+BUILD. +const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6 + +const RELEASE_TYPES = [ + 'major', + 'premajor', + 'minor', + 'preminor', + 'patch', + 'prepatch', + 'prerelease', +] + module.exports = { - SEMVER_SPEC_VERSION, MAX_LENGTH, + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, MAX_SAFE_INTEGER, - MAX_SAFE_COMPONENT_LENGTH + RELEASE_TYPES, + SEMVER_SPEC_VERSION, + FLAG_INCLUDE_PRERELEASE: 0b001, + FLAG_LOOSE: 0b010, } /***/ }), -/***/ 427: +/***/ 159: /***/ ((module) => { const debug = ( @@ -1994,7 +2095,7 @@ module.exports = debug /***/ }), -/***/ 463: +/***/ 348: /***/ ((module) => { const numeric = /^[0-9]+$/ @@ -2018,49 +2119,83 @@ const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, - rcompareIdentifiers + rcompareIdentifiers, } /***/ }), -/***/ 785: +/***/ 356: /***/ ((module) => { -// parse out just the options we care about so we always get a consistent -// obj with keys in a consistent order. -const opts = ['includePrerelease', 'loose', 'rtl'] -const parseOptions = options => - !options ? {} - : typeof options !== 'object' ? { loose: true } - : opts.filter(k => options[k]).reduce((options, k) => { - options[k] = true - return options - }, {}) +// parse out just the options we care about +const looseOption = Object.freeze({ loose: true }) +const emptyOpts = Object.freeze({ }) +const parseOptions = options => { + if (!options) { + return emptyOpts + } + + if (typeof options !== 'object') { + return looseOption + } + + return options +} module.exports = parseOptions /***/ }), -/***/ 523: +/***/ 471: /***/ ((module, exports, __nccwpck_require__) => { -const { MAX_SAFE_COMPONENT_LENGTH } = __nccwpck_require__(293) -const debug = __nccwpck_require__(427) +const { + MAX_SAFE_COMPONENT_LENGTH, + MAX_SAFE_BUILD_LENGTH, + MAX_LENGTH, +} = __nccwpck_require__(101) +const debug = __nccwpck_require__(159) exports = module.exports = {} // The actual regexps go on exports.re const re = exports.re = [] +const safeRe = exports.safeRe = [] const src = exports.src = [] const t = exports.t = {} let R = 0 +const LETTERDASHNUMBER = '[a-zA-Z0-9-]' + +// Replace some greedy regex tokens to prevent regex dos issues. These regex are +// used internally via the safeRe object since all inputs in this library get +// normalized first to trim and collapse all extra whitespace. The original +// regexes are exported for userland consumption and lower level usage. A +// future breaking change could export the safer regex only with a note that +// all input should have extra whitespace removed. +const safeRegexReplacements = [ + ['\\s', 1], + ['\\d', MAX_LENGTH], + [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH], +] + +const makeSafeRegex = (value) => { + for (const [token, max] of safeRegexReplacements) { + value = value + .split(`${token}*`).join(`${token}{0,${max}}`) + .split(`${token}+`).join(`${token}{1,${max}}`) + } + return value +} + const createToken = (name, value, isGlobal) => { + const safe = makeSafeRegex(value) const index = R++ - debug(index, value) + debug(name, index, value) t[name] = index src[index] = value re[index] = new RegExp(value, isGlobal ? 'g' : undefined) + safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined) } // The following Regular Expressions can be used for tokenizing, @@ -2070,13 +2205,13 @@ const createToken = (name, value, isGlobal) => { // A single `0`, or a non-zero digit followed by zero or more digits. createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*') -createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+') +createToken('NUMERICIDENTIFIERLOOSE', '\\d+') // ## Non-numeric Identifier // Zero or more digits, followed by a letter or hyphen, and then zero or // more letters, digits, or hyphens. -createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*') +createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`) // ## Main Version // Three dot-separated numeric identifiers. @@ -2111,7 +2246,7 @@ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE] // ## Build Metadata Identifier // Any combination of digits, letters, or hyphens. -createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+') +createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`) // ## Build Metadata // Plus sign, followed by one or more period-separated build metadata @@ -2171,12 +2306,17 @@ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) // Coercion. // Extract anything that could conceivably be a part of a valid semver -createToken('COERCE', `${'(^|[^\\d])' + +createToken('COERCEPLAIN', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`) +createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`) +createToken('COERCEFULL', src[t.COERCEPLAIN] + + `(?:${src[t.PRERELEASE]})?` + + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`) createToken('COERCERTL', src[t.COERCE], true) +createToken('COERCERTLFULL', src[t.COERCEFULL], true) // Tilde ranges. // Meaning is "reasonably at or greater than" @@ -2225,90 +2365,19 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + // Star ranges basically just allow anything at all. createToken('STAR', '(<|>)?=?\\s*\\*') // >=0.0.0 is like a star -createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$') -createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$') - - -/***/ }), - -/***/ 351: -/***/ ((__unused_webpack_module, __unused_webpack_exports, __nccwpck_require__) => { - -const core = __nccwpck_require__(186); -const exec = __nccwpck_require__(514); -const utils = __nccwpck_require__ (608) - -async function doScript() { - // taken from actions/checkout - let githubWorkspacePath = process.env['GITHUB_WORKSPACE'] - if (!githubWorkspacePath) { - throw new Error('GITHUB_WORKSPACE not defined') - } - githubWorkspacePath = utils.resolvePath(githubWorkspacePath) - - const drupalVersion = core.getInput('version', { - required: true, - }); - const drupalPath = utils.resolvePath(core.getInput('path') || '~/drupal'); - const extraDependencies = core.getInput('dependencies') - const allowPlugins = utils.stringToArray(core.getInput('allow_plugins')) - - await exec.exec('composer', [ - 'create-project', - `drupal/recommended-project:${drupalVersion}`, - drupalPath, - '--no-interaction' - ]); - - const commands = [ - ['config', 'minimum-stability', 'dev'], - ['config', 'prefer-stable', 'true'], - ['config', 'preferred-install', 'dist'], - ['require', '--dev', `drupal/core-dev:${drupalVersion}`], - ['config', 'repositories.0', `{"type": "path", "url": "${githubWorkspacePath}", "options": {"symlink": false}}`], - ['config', 'repositories.1', 'composer', 'https://packages.drupal.org/8'], - ]; - - if (utils.getMajorVersionFromConstraint(drupalVersion) === 8) { - commands.push(['config', '--no-plugins', 'allow-plugins.drupal/core-composer-scaffold', 'true']); - commands.push(['config', '--no-plugins', 'allow-plugins.drupal/core-project-message', 'true']); - } - commands.push(['config', '--no-plugins', 'allow-plugins.composer/installers', 'true']); - commands.push(['config', '--no-plugins', 'allow-plugins.dealerdirect/phpcodesniffer-composer-installer', 'true']); - commands.push(['config', '--no-plugins', 'allow-plugins.phpstan/extension-installer', 'true']); - - allowPlugins.forEach(package => { - commands.push(['config', '--no-plugins', 'allow-plugins.' + package, 'true']); - }); - - if (utils.getMajorVersionFromConstraint(drupalVersion) > 8) { - commands.push(['require', '--dev', '--with-all-dependencies', 'phpspec/prophecy-phpunit:^2']); - } - - if (extraDependencies) { - commands.push(['require', extraDependencies]); - } - - for (command of commands) { - core.debug(`Executing: composer ${command}`) - await exec.exec('composer', command, { - cwd: drupalPath, - }); - } -} - -doScript().catch(error => core.setFailed(error.message)); +createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$') +createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$') /***/ }), -/***/ 608: +/***/ 804: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -const path = __nccwpck_require__(622); -const semverMajor = __nccwpck_require__(688) -const smeverCoerce = __nccwpck_require__(466); -const { access } = __nccwpck_require__(747); +const path = __nccwpck_require__(928); +const semverMajor = __nccwpck_require__(511) +const smeverCoerce = __nccwpck_require__(385); +const { access } = __nccwpck_require__(896); function resolvePath(filepath) { if (filepath[0] === '~') { @@ -2340,59 +2409,75 @@ module.exports = { /***/ }), -/***/ 357: +/***/ 613: +/***/ ((module) => { + +"use strict"; +module.exports = require("assert"); + +/***/ }), + +/***/ 317: +/***/ ((module) => { + +"use strict"; +module.exports = require("child_process"); + +/***/ }), + +/***/ 434: /***/ ((module) => { "use strict"; -module.exports = require("assert");; +module.exports = require("events"); /***/ }), -/***/ 129: +/***/ 896: /***/ ((module) => { "use strict"; -module.exports = require("child_process");; +module.exports = require("fs"); /***/ }), -/***/ 614: +/***/ 857: /***/ ((module) => { "use strict"; -module.exports = require("events");; +module.exports = require("os"); /***/ }), -/***/ 747: +/***/ 928: /***/ ((module) => { "use strict"; -module.exports = require("fs");; +module.exports = require("path"); /***/ }), -/***/ 87: +/***/ 193: /***/ ((module) => { "use strict"; -module.exports = require("os");; +module.exports = require("string_decoder"); /***/ }), -/***/ 622: +/***/ 557: /***/ ((module) => { "use strict"; -module.exports = require("path");; +module.exports = require("timers"); /***/ }), -/***/ 669: +/***/ 23: /***/ ((module) => { "use strict"; -module.exports = require("util");; +module.exports = require("util"); /***/ }) @@ -2404,8 +2489,9 @@ module.exports = require("util");; /******/ // The require function /******/ function __nccwpck_require__(moduleId) { /******/ // Check if module is in cache -/******/ if(__webpack_module_cache__[moduleId]) { -/******/ return __webpack_module_cache__[moduleId].exports; +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { @@ -2430,10 +2516,75 @@ module.exports = require("util");; /************************************************************************/ /******/ /* webpack/runtime/compat */ /******/ -/******/ __nccwpck_require__.ab = __dirname + "/";/************************************************************************/ -/******/ // module exports must be returned from runtime so entry inlining is disabled -/******/ // startup -/******/ // Load entry module and return exports -/******/ return __nccwpck_require__(351); +/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/"; +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +const core = __nccwpck_require__(484); +const exec = __nccwpck_require__(236); +const utils = __nccwpck_require__ (804) + +async function doScript() { + // taken from actions/checkout + let githubWorkspacePath = process.env['GITHUB_WORKSPACE'] + if (!githubWorkspacePath) { + throw new Error('GITHUB_WORKSPACE not defined') + } + githubWorkspacePath = utils.resolvePath(githubWorkspacePath) + + const drupalVersion = core.getInput('version', { + required: true, + }); + const drupalPath = utils.resolvePath(core.getInput('path') || '~/drupal'); + const extraDependencies = core.getInput('dependencies') + const allowPlugins = utils.stringToArray(core.getInput('allow_plugins')) + + await exec.exec('composer', [ + 'create-project', + `drupal/recommended-project:${drupalVersion}`, + drupalPath, + '--no-interaction' + ]); + + const commands = [ + ['config', 'minimum-stability', 'dev'], + ['config', 'prefer-stable', 'true'], + ['config', 'preferred-install', 'dist'], + ['require', '--dev', `drupal/core-dev:${drupalVersion}`, '--with-all-dependencies'], + ['config', 'repositories.0', `{"type": "path", "url": "${githubWorkspacePath}", "options": {"symlink": false}}`], + ['config', 'repositories.1', 'composer', 'https://packages.drupal.org/8'], + ]; + + if (utils.getMajorVersionFromConstraint(drupalVersion) === 8) { + commands.push(['config', '--no-plugins', 'allow-plugins.drupal/core-composer-scaffold', 'true']); + commands.push(['config', '--no-plugins', 'allow-plugins.drupal/core-project-message', 'true']); + } + commands.push(['config', '--no-plugins', 'allow-plugins.composer/installers', 'true']); + commands.push(['config', '--no-plugins', 'allow-plugins.dealerdirect/phpcodesniffer-composer-installer', 'true']); + commands.push(['config', '--no-plugins', 'allow-plugins.phpstan/extension-installer', 'true']); + + allowPlugins.forEach(package => { + commands.push(['config', '--no-plugins', 'allow-plugins.' + package, 'true']); + }); + + if (utils.getMajorVersionFromConstraint(drupalVersion) > 8) { + commands.push(['require', '--dev', '--with-all-dependencies', 'phpspec/prophecy-phpunit:^2']); + } + + if (extraDependencies) { + commands.push(['require', extraDependencies]); + } + + for (command of commands) { + core.debug(`Executing: composer ${command}`) + await exec.exec('composer', command, { + cwd: drupalPath, + }); + } +} + +doScript().catch(error => core.setFailed(error.message)); + +module.exports = __webpack_exports__; /******/ })() ; \ No newline at end of file diff --git a/dist/licenses.txt b/dist/licenses.txt index d421754..0d81bf5 100644 --- a/dist/licenses.txt +++ b/dist/licenses.txt @@ -12,6 +12,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI @actions/exec MIT +The MIT License (MIT) + +Copyright 2019 GitHub + +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. @actions/io MIT diff --git a/src/index.js b/src/index.js index b2add72..d6651d4 100644 --- a/src/index.js +++ b/src/index.js @@ -28,7 +28,7 @@ async function doScript() { ['config', 'minimum-stability', 'dev'], ['config', 'prefer-stable', 'true'], ['config', 'preferred-install', 'dist'], - ['require', '--dev', `drupal/core-dev:${drupalVersion}`], + ['require', '--dev', `drupal/core-dev:${drupalVersion}`, '--with-all-dependencies'], ['config', 'repositories.0', `{"type": "path", "url": "${githubWorkspacePath}", "options": {"symlink": false}}`], ['config', 'repositories.1', 'composer', 'https://packages.drupal.org/8'], ];