mirror of
https://github.com/tj-actions/changed-files
synced 2024-12-17 03:47:20 +00:00
8c9ee56d01
Co-authored-by: GitHub Action <action@github.com>
9904 lines
No EOL
311 KiB
JavaScript
Generated
9904 lines
No EOL
311 KiB
JavaScript
Generated
require('./sourcemap-register.js');/******/ (() => { // webpackBootstrap
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
/***/ 7358:
|
|
/***/ (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;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.getDiffFiles = exports.getRenamedFiles = void 0;
|
|
const path = __importStar(__nccwpck_require__(1017));
|
|
const utils_1 = __nccwpck_require__(918);
|
|
const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const renamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
|
cwd: workingDirectory,
|
|
sha1: diffResult.previousSha,
|
|
sha2: diffResult.currentSha,
|
|
diff: diffResult.diff,
|
|
oldNewSeparator: inputs.oldNewSeparator
|
|
});
|
|
if (hasSubmodule) {
|
|
for (const submodulePath of submodulePaths) {
|
|
const submoduleShaResult = yield (0, utils_1.gitSubmoduleDiffSHA)({
|
|
cwd: workingDirectory,
|
|
parentSha1: diffResult.previousSha,
|
|
parentSha2: diffResult.currentSha,
|
|
submodulePath,
|
|
diff: diffResult.diff
|
|
});
|
|
const submoduleWorkingDirectory = path.join(workingDirectory, submodulePath);
|
|
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
|
const submoduleRenamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
|
cwd: submoduleWorkingDirectory,
|
|
sha1: submoduleShaResult.previousSha,
|
|
sha2: submoduleShaResult.currentSha,
|
|
diff: diffResult.diff,
|
|
oldNewSeparator: inputs.oldNewSeparator,
|
|
isSubmodule: true,
|
|
parentDir: submodulePath
|
|
});
|
|
renamedFiles.push(...submoduleRenamedFiles);
|
|
}
|
|
}
|
|
}
|
|
if (inputs.json) {
|
|
return (0, utils_1.jsonOutput)({ value: renamedFiles, shouldEscape: inputs.escapeJson });
|
|
}
|
|
return renamedFiles.join(inputs.oldNewFilesSeparator);
|
|
});
|
|
exports.getRenamedFiles = getRenamedFiles;
|
|
const getDiffFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, diffFilter, filePatterns = [], submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
let files = yield (0, utils_1.gitDiff)({
|
|
cwd: workingDirectory,
|
|
sha1: diffResult.previousSha,
|
|
sha2: diffResult.currentSha,
|
|
diff: diffResult.diff,
|
|
diffFilter,
|
|
filePatterns
|
|
});
|
|
if (hasSubmodule) {
|
|
for (const submodulePath of submodulePaths) {
|
|
const submoduleShaResult = yield (0, utils_1.gitSubmoduleDiffSHA)({
|
|
cwd: workingDirectory,
|
|
parentSha1: diffResult.previousSha,
|
|
parentSha2: diffResult.currentSha,
|
|
submodulePath,
|
|
diff: diffResult.diff
|
|
});
|
|
const submoduleWorkingDirectory = path.join(workingDirectory, submodulePath);
|
|
if (submoduleShaResult.currentSha && submoduleShaResult.previousSha) {
|
|
const submoduleFiles = yield (0, utils_1.gitDiff)({
|
|
cwd: submoduleWorkingDirectory,
|
|
sha1: submoduleShaResult.previousSha,
|
|
sha2: submoduleShaResult.currentSha,
|
|
diff: diffResult.diff,
|
|
diffFilter,
|
|
isSubmodule: true,
|
|
filePatterns,
|
|
parentDir: submodulePath
|
|
});
|
|
files.push(...submoduleFiles);
|
|
}
|
|
}
|
|
}
|
|
if (inputs.dirNames) {
|
|
files = files.map(file => (0, utils_1.getDirnameMaxDepth)({
|
|
pathStr: file,
|
|
dirNamesMaxDepth: inputs.dirNamesMaxDepth,
|
|
excludeRoot: inputs.dirNamesExcludeRoot
|
|
}));
|
|
files = [...new Set(files)];
|
|
}
|
|
if (inputs.json) {
|
|
return (0, utils_1.jsonOutput)({ value: files, shouldEscape: inputs.escapeJson });
|
|
}
|
|
return files.join(inputs.separator);
|
|
});
|
|
exports.getDiffFiles = getDiffFiles;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8613:
|
|
/***/ (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;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.getSHAForPullRequestEvent = exports.getSHAForPushEvent = void 0;
|
|
const core = __importStar(__nccwpck_require__(2186));
|
|
const utils_1 = __nccwpck_require__(918);
|
|
const getCurrentSHA = ({ inputs, workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
let currentSha = inputs.sha;
|
|
core.debug('Getting current SHA...');
|
|
if (inputs.until) {
|
|
core.debug(`Getting base SHA for '${inputs.until}'...`);
|
|
try {
|
|
currentSha = yield (0, utils_1.gitLog)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
'--format=%H',
|
|
'-n',
|
|
'1',
|
|
'--date',
|
|
'local',
|
|
'--until',
|
|
inputs.until
|
|
]
|
|
});
|
|
}
|
|
catch (error) {
|
|
core.error(`Invalid until date: ${inputs.until}. ${error.message}`);
|
|
throw error;
|
|
}
|
|
}
|
|
else {
|
|
if (!currentSha) {
|
|
currentSha = yield (0, utils_1.getHeadSha)({ cwd: workingDirectory });
|
|
}
|
|
}
|
|
yield (0, utils_1.verifyCommitSha)({ sha: currentSha, cwd: workingDirectory });
|
|
core.debug(`Current SHA: ${currentSha}`);
|
|
return currentSha;
|
|
});
|
|
const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs, isTag) => __awaiter(void 0, void 0, void 0, function* () {
|
|
let targetBranch = env.GITHUB_REF_NAME;
|
|
const currentBranch = targetBranch;
|
|
let initialCommit = false;
|
|
if (isShallow) {
|
|
core.info('Repository is shallow, fetching more history...');
|
|
if (isTag) {
|
|
const sourceBranch = env.GITHUB_EVENT_BASE_REF.replace('refs/heads/', '') ||
|
|
env.GITHUB_EVENT_RELEASE_TARGET_COMMITISH;
|
|
yield (0, utils_1.gitFetch)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
`--deepen=${inputs.fetchDepth}`,
|
|
'origin',
|
|
`+refs/heads/${sourceBranch}:refs/remotes/origin/${sourceBranch}`
|
|
]
|
|
});
|
|
}
|
|
else {
|
|
yield (0, utils_1.gitFetch)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
`--deepen=${inputs.fetchDepth}`,
|
|
'origin',
|
|
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
|
]
|
|
});
|
|
}
|
|
if (hasSubmodule) {
|
|
yield (0, utils_1.gitFetchSubmodules)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
`--deepen=${inputs.fetchDepth}`
|
|
]
|
|
});
|
|
}
|
|
}
|
|
const currentSha = yield getCurrentSHA({ inputs, workingDirectory });
|
|
let previousSha = inputs.baseSha;
|
|
const diff = '..';
|
|
if (previousSha && currentSha && currentBranch && targetBranch) {
|
|
if (previousSha === currentSha) {
|
|
core.error(`Similar commit hashes detected: previous sha: ${previousSha} is equivalent to the current sha: ${currentSha}.`);
|
|
core.error(`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`);
|
|
throw new Error('Similar commit hashes detected.');
|
|
}
|
|
yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory });
|
|
core.debug(`Previous SHA: ${previousSha}`);
|
|
return {
|
|
previousSha,
|
|
currentSha,
|
|
currentBranch,
|
|
targetBranch,
|
|
diff
|
|
};
|
|
}
|
|
if (!previousSha) {
|
|
core.debug('Getting previous SHA...');
|
|
if (inputs.since) {
|
|
core.debug(`Getting base SHA for '${inputs.since}'...`);
|
|
try {
|
|
const allCommitsFrom = yield (0, utils_1.gitLog)({
|
|
cwd: workingDirectory,
|
|
args: ['--format=%H', '--date', 'local', '--since', inputs.since]
|
|
});
|
|
if (allCommitsFrom) {
|
|
const allCommitsFromArray = allCommitsFrom.split('\n');
|
|
previousSha = allCommitsFromArray[allCommitsFromArray.length - 1];
|
|
}
|
|
}
|
|
catch (error) {
|
|
core.error(`Invalid since date: ${inputs.since}. ${error.message}`);
|
|
throw error;
|
|
}
|
|
}
|
|
else if (isTag) {
|
|
core.debug('Getting previous SHA for tag...');
|
|
const { sha, tag } = yield (0, utils_1.getPreviousGitTag)({ cwd: workingDirectory });
|
|
previousSha = sha;
|
|
targetBranch = tag;
|
|
}
|
|
else {
|
|
core.debug('Getting previous SHA for last remote commit...');
|
|
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
|
|
previousSha = env.GITHUB_EVENT_BEFORE;
|
|
}
|
|
if (!previousSha ||
|
|
previousSha === '0000000000000000000000000000000000000000') {
|
|
previousSha = yield (0, utils_1.getParentSha)({
|
|
cwd: workingDirectory
|
|
});
|
|
}
|
|
else if ((yield (0, utils_1.verifyCommitSha)({
|
|
sha: previousSha,
|
|
cwd: workingDirectory,
|
|
showAsErrorMessage: false
|
|
})) !== 0) {
|
|
core.warning(`Previous commit ${previousSha} is not valid. Using parent commit.`);
|
|
previousSha = yield (0, utils_1.getParentSha)({
|
|
cwd: workingDirectory
|
|
});
|
|
}
|
|
if (!previousSha || previousSha === currentSha) {
|
|
previousSha = yield (0, utils_1.getParentSha)({
|
|
cwd: workingDirectory
|
|
});
|
|
if (!previousSha) {
|
|
core.warning('Initial commit detected no previous commit found.');
|
|
initialCommit = true;
|
|
previousSha = currentSha;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory });
|
|
core.debug(`Previous SHA: ${previousSha}`);
|
|
core.debug(`Target branch: ${targetBranch}`);
|
|
core.debug(`Current branch: ${currentBranch}`);
|
|
if (!initialCommit && previousSha === currentSha) {
|
|
core.error(`Similar commit hashes detected: previous sha: ${previousSha} is equivalent to the current sha: ${currentSha}.`);
|
|
core.error(`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`);
|
|
throw new Error('Similar commit hashes detected.');
|
|
}
|
|
return {
|
|
previousSha,
|
|
currentSha,
|
|
currentBranch,
|
|
targetBranch,
|
|
diff,
|
|
initialCommit
|
|
};
|
|
});
|
|
exports.getSHAForPushEvent = getSHAForPushEvent;
|
|
const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
let targetBranch = env.GITHUB_EVENT_PULL_REQUEST_BASE_REF;
|
|
const currentBranch = env.GITHUB_EVENT_PULL_REQUEST_HEAD_REF;
|
|
if (inputs.sinceLastRemoteCommit) {
|
|
targetBranch = currentBranch;
|
|
}
|
|
if (isShallow) {
|
|
core.info('Repository is shallow, fetching more history...');
|
|
let prFetchExitCode = yield (0, utils_1.gitFetch)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
'origin',
|
|
`pull/${env.GITHUB_EVENT_PULL_REQUEST_NUMBER}/head:${currentBranch}`
|
|
]
|
|
});
|
|
if (prFetchExitCode !== 0) {
|
|
prFetchExitCode = yield (0, utils_1.gitFetch)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
`--deepen=${inputs.fetchDepth}`,
|
|
'origin',
|
|
`+refs/heads/${currentBranch}*:refs/remotes/origin/${currentBranch}*`
|
|
]
|
|
});
|
|
}
|
|
if (prFetchExitCode !== 0) {
|
|
throw new Error('Failed to fetch pull request branch. Please ensure "persist-credentials" is set to "true" when checking out the repository. See: https://github.com/actions/checkout#usage');
|
|
}
|
|
if (!inputs.sinceLastRemoteCommit) {
|
|
core.debug('Fetching target branch...');
|
|
yield (0, utils_1.gitFetch)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
`--deepen=${inputs.fetchDepth}`,
|
|
'origin',
|
|
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
|
]
|
|
});
|
|
if (hasSubmodule) {
|
|
yield (0, utils_1.gitFetchSubmodules)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
`--deepen=${inputs.fetchDepth}`
|
|
]
|
|
});
|
|
}
|
|
}
|
|
core.info('Completed fetching more history.');
|
|
}
|
|
const currentSha = yield getCurrentSHA({ inputs, workingDirectory });
|
|
let previousSha = inputs.baseSha;
|
|
let diff = '...';
|
|
if (previousSha && currentSha && currentBranch && targetBranch) {
|
|
if (previousSha === currentSha) {
|
|
core.error(`Similar commit hashes detected: previous sha: ${previousSha} is equivalent to the current sha: ${currentSha}.`);
|
|
core.error(`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`);
|
|
throw new Error('Similar commit hashes detected.');
|
|
}
|
|
yield (0, utils_1.verifyCommitSha)({ sha: currentSha, cwd: workingDirectory });
|
|
core.debug(`Previous SHA: ${previousSha}`);
|
|
return {
|
|
previousSha,
|
|
currentSha,
|
|
currentBranch,
|
|
targetBranch,
|
|
diff
|
|
};
|
|
}
|
|
if (!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF ||
|
|
env.GITHUB_EVENT_HEAD_REPO_FORK === 'true') {
|
|
diff = '..';
|
|
}
|
|
if (!previousSha) {
|
|
if (inputs.sinceLastRemoteCommit) {
|
|
previousSha = env.GITHUB_EVENT_BEFORE;
|
|
if (!previousSha) {
|
|
previousSha = yield (0, utils_1.getRemoteBranchHeadSha)({
|
|
cwd: workingDirectory,
|
|
branch: currentBranch
|
|
});
|
|
}
|
|
if ((yield (0, utils_1.verifyCommitSha)({
|
|
sha: previousSha,
|
|
cwd: workingDirectory,
|
|
showAsErrorMessage: false
|
|
})) !== 0) {
|
|
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
|
}
|
|
}
|
|
else {
|
|
previousSha = yield (0, utils_1.getRemoteBranchHeadSha)({
|
|
cwd: workingDirectory,
|
|
branch: targetBranch
|
|
});
|
|
if (!previousSha) {
|
|
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
|
}
|
|
if (isShallow) {
|
|
if (yield (0, utils_1.canDiffCommits)({
|
|
cwd: workingDirectory,
|
|
sha1: previousSha,
|
|
sha2: currentSha,
|
|
diff
|
|
})) {
|
|
core.debug('Merge base is not in the local history, fetching remote target branch...');
|
|
for (let i = 1; i <= 10; i++) {
|
|
yield (0, utils_1.gitFetch)({
|
|
cwd: workingDirectory,
|
|
args: [
|
|
...gitExtraArgs,
|
|
'-u',
|
|
'--progress',
|
|
`--deepen=${inputs.fetchDepth}`,
|
|
'origin',
|
|
`+refs/heads/${targetBranch}:refs/remotes/origin/${targetBranch}`
|
|
]
|
|
});
|
|
if (yield (0, utils_1.canDiffCommits)({
|
|
cwd: workingDirectory,
|
|
sha1: previousSha,
|
|
sha2: currentSha,
|
|
diff
|
|
})) {
|
|
break;
|
|
}
|
|
core.debug('Merge base is not in the local history, fetching remote target branch again...');
|
|
core.debug(`Attempt ${i}/10`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!previousSha || previousSha === currentSha) {
|
|
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
|
}
|
|
}
|
|
if (!(yield (0, utils_1.canDiffCommits)({
|
|
cwd: workingDirectory,
|
|
sha1: previousSha,
|
|
sha2: currentSha,
|
|
diff
|
|
}))) {
|
|
diff = '..';
|
|
}
|
|
yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory });
|
|
core.debug(`Previous SHA: ${previousSha}`);
|
|
if (!(yield (0, utils_1.canDiffCommits)({
|
|
cwd: workingDirectory,
|
|
sha1: previousSha,
|
|
sha2: currentSha,
|
|
diff
|
|
}))) {
|
|
throw new Error(`Unable to determine a difference between ${previousSha}${diff}${currentSha}`);
|
|
}
|
|
if (previousSha === currentSha) {
|
|
core.error(`Similar commit hashes detected: previous sha: ${previousSha} is equivalent to the current sha: ${currentSha}.`);
|
|
core.error(`Please verify that both commits are valid, and increase the fetch_depth to a number higher than ${inputs.fetchDepth}.`);
|
|
throw new Error('Similar commit hashes detected.');
|
|
}
|
|
return {
|
|
previousSha,
|
|
currentSha,
|
|
currentBranch,
|
|
targetBranch,
|
|
diff
|
|
};
|
|
});
|
|
exports.getSHAForPullRequestEvent = getSHAForPullRequestEvent;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9763:
|
|
/***/ (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;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.getEnv = void 0;
|
|
const fs_1 = __nccwpck_require__(7147);
|
|
const core = __importStar(__nccwpck_require__(2186));
|
|
const getEnv = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
const eventPath = process.env.GITHUB_EVENT_PATH;
|
|
let eventJson = {};
|
|
if (eventPath) {
|
|
eventJson = JSON.parse(yield fs_1.promises.readFile(eventPath, { encoding: 'utf8' }));
|
|
}
|
|
core.debug(`Env: ${JSON.stringify(process.env, null, 2)}`);
|
|
core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`);
|
|
return {
|
|
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ((_b = (_a = eventJson.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.ref) || '',
|
|
GITHUB_EVENT_PULL_REQUEST_BASE_REF: ((_d = (_c = eventJson.pull_request) === null || _c === void 0 ? void 0 : _c.base) === null || _d === void 0 ? void 0 : _d.ref) || '',
|
|
GITHUB_EVENT_BEFORE: eventJson.before || '',
|
|
GITHUB_EVENT_BASE_REF: eventJson.base_ref || '',
|
|
GITHUB_EVENT_RELEASE_TARGET_COMMITISH: ((_e = eventJson.release) === null || _e === void 0 ? void 0 : _e.target_commitish) || '',
|
|
GITHUB_EVENT_HEAD_REPO_FORK: ((_f = eventJson.head_repo) === null || _f === void 0 ? void 0 : _f.fork) || '',
|
|
GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_g = eventJson.pull_request) === null || _g === void 0 ? void 0 : _g.number) || '',
|
|
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_j = (_h = eventJson.pull_request) === null || _h === void 0 ? void 0 : _h.base) === null || _j === void 0 ? void 0 : _j.sha) || '',
|
|
GITHUB_EVENT_FORCED: eventJson.forced || '',
|
|
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
|
|
GITHUB_REF: process.env.GITHUB_REF || '',
|
|
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
|
|
};
|
|
});
|
|
exports.getEnv = getEnv;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6180:
|
|
/***/ (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;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.getInputs = void 0;
|
|
const core = __importStar(__nccwpck_require__(2186));
|
|
const getInputs = () => {
|
|
const files = core.getInput('files', { required: false });
|
|
const filesSeparator = core.getInput('files_separator', {
|
|
required: false,
|
|
trimWhitespace: false
|
|
});
|
|
const filesIgnore = core.getInput('files_ignore', { required: false });
|
|
const filesIgnoreSeparator = core.getInput('files_ignore_separator', {
|
|
required: false,
|
|
trimWhitespace: false
|
|
});
|
|
const filesFromSourceFile = core.getInput('files_from_source_file', {
|
|
required: false
|
|
});
|
|
const filesFromSourceFileSeparator = core.getInput('files_from_source_file_separator', {
|
|
required: false,
|
|
trimWhitespace: false
|
|
});
|
|
const filesIgnoreFromSourceFile = core.getInput('files_ignore_from_source_file', { required: false });
|
|
const filesIgnoreFromSourceFileSeparator = core.getInput('files_ignore_from_source_file_separator', {
|
|
required: false,
|
|
trimWhitespace: false
|
|
});
|
|
const separator = core.getInput('separator', {
|
|
required: true,
|
|
trimWhitespace: false
|
|
});
|
|
const includeAllOldNewRenamedFiles = core.getBooleanInput('include_all_old_new_renamed_files', { required: false });
|
|
const oldNewSeparator = core.getInput('old_new_separator', {
|
|
required: true,
|
|
trimWhitespace: false
|
|
});
|
|
const oldNewFilesSeparator = core.getInput('old_new_files_separator', {
|
|
required: true,
|
|
trimWhitespace: false
|
|
});
|
|
const sha = core.getInput('sha', { required: false });
|
|
const baseSha = core.getInput('base_sha', { required: false });
|
|
const since = core.getInput('since', { required: false });
|
|
const until = core.getInput('until', { required: false });
|
|
const path = core.getInput('path', { required: false });
|
|
const quotePath = core.getBooleanInput('quotepath', { required: false });
|
|
const diffRelative = core.getBooleanInput('diff_relative', { required: false });
|
|
const dirNames = core.getBooleanInput('dir_names', { required: false });
|
|
const dirNamesMaxDepth = core.getInput('dir_names_max_depth', {
|
|
required: false
|
|
});
|
|
const dirNamesExcludeRoot = core.getBooleanInput('dir_names_exclude_root', {
|
|
required: false
|
|
});
|
|
const json = core.getBooleanInput('json', { required: false });
|
|
const escapeJson = core.getBooleanInput('escape_json', { required: false });
|
|
const fetchDepth = core.getInput('fetch_depth', { required: false });
|
|
const sinceLastRemoteCommit = core.getBooleanInput('since_last_remote_commit', { required: false });
|
|
const writeOutputFiles = core.getBooleanInput('write_output_files', {
|
|
required: false
|
|
});
|
|
const outputDir = core.getInput('output_dir', { required: false });
|
|
const inputs = {
|
|
files,
|
|
filesSeparator,
|
|
filesFromSourceFile,
|
|
filesFromSourceFileSeparator,
|
|
filesIgnore,
|
|
filesIgnoreSeparator,
|
|
filesIgnoreFromSourceFile,
|
|
filesIgnoreFromSourceFileSeparator,
|
|
separator,
|
|
includeAllOldNewRenamedFiles,
|
|
oldNewSeparator,
|
|
oldNewFilesSeparator,
|
|
sha,
|
|
baseSha,
|
|
since,
|
|
until,
|
|
path,
|
|
quotePath,
|
|
diffRelative,
|
|
dirNames,
|
|
dirNamesExcludeRoot,
|
|
json,
|
|
escapeJson,
|
|
sinceLastRemoteCommit,
|
|
writeOutputFiles,
|
|
outputDir
|
|
};
|
|
if (fetchDepth) {
|
|
inputs.fetchDepth = Math.max(parseInt(fetchDepth, 10), 2);
|
|
}
|
|
if (dirNamesMaxDepth) {
|
|
inputs.dirNamesMaxDepth = parseInt(dirNamesMaxDepth, 10);
|
|
}
|
|
return inputs;
|
|
};
|
|
exports.getInputs = getInputs;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 3109:
|
|
/***/ (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;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.run = void 0;
|
|
const core = __importStar(__nccwpck_require__(2186));
|
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
|
const changedFiles_1 = __nccwpck_require__(7358);
|
|
const commitSha_1 = __nccwpck_require__(8613);
|
|
const env_1 = __nccwpck_require__(9763);
|
|
const inputs_1 = __nccwpck_require__(6180);
|
|
const utils_1 = __nccwpck_require__(918);
|
|
function run() {
|
|
var _a;
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
core.startGroup('changed-files');
|
|
const env = yield (0, env_1.getEnv)();
|
|
core.debug(`Env: ${JSON.stringify(env, null, 2)}`);
|
|
const inputs = (0, inputs_1.getInputs)();
|
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`);
|
|
yield (0, utils_1.verifyMinimumGitVersion)();
|
|
let quotePathValue = 'on';
|
|
if (!inputs.quotePath) {
|
|
quotePathValue = 'off';
|
|
}
|
|
yield (0, utils_1.updateGitGlobalConfig)({
|
|
name: 'core.quotepath',
|
|
value: quotePathValue
|
|
});
|
|
if (inputs.diffRelative) {
|
|
yield (0, utils_1.updateGitGlobalConfig)({
|
|
name: 'diff.relative',
|
|
value: 'true'
|
|
});
|
|
}
|
|
const workingDirectory = path_1.default.resolve(env.GITHUB_WORKSPACE || process.cwd(), inputs.path);
|
|
const isShallow = yield (0, utils_1.isRepoShallow)({ cwd: workingDirectory });
|
|
const hasSubmodule = yield (0, utils_1.submoduleExists)({ cwd: workingDirectory });
|
|
let gitExtraArgs = ['--no-tags', '--prune', '--recurse-submodules'];
|
|
const isTag = (_a = env.GITHUB_REF) === null || _a === void 0 ? void 0 : _a.startsWith('refs/tags/');
|
|
let submodulePaths = [];
|
|
if (hasSubmodule) {
|
|
submodulePaths = yield (0, utils_1.getSubmodulePath)({ cwd: workingDirectory });
|
|
}
|
|
if (isTag) {
|
|
gitExtraArgs = ['--prune', '--no-recurse-submodules'];
|
|
}
|
|
let diffResult;
|
|
if (!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF) {
|
|
core.info('Running on a push event...');
|
|
diffResult = yield (0, commitSha_1.getSHAForPushEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs, isTag);
|
|
}
|
|
else {
|
|
core.info('Running on a pull request event...');
|
|
diffResult = yield (0, commitSha_1.getSHAForPullRequestEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitExtraArgs);
|
|
}
|
|
if (diffResult.initialCommit) {
|
|
core.info('This is the first commit for this repository; exiting...');
|
|
core.endGroup();
|
|
return;
|
|
}
|
|
core.info(`Retrieving changes between ${diffResult.previousSha} (${diffResult.targetBranch}) → ${diffResult.currentSha} (${diffResult.currentBranch})`);
|
|
const filePatterns = yield (0, utils_1.getFilePatterns)({
|
|
inputs,
|
|
workingDirectory
|
|
});
|
|
const addedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'A',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Added files: ${addedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'added_files',
|
|
value: addedFiles,
|
|
inputs
|
|
});
|
|
const copiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'C',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Copied files: ${copiedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'copied_files',
|
|
value: copiedFiles,
|
|
inputs
|
|
});
|
|
const modifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'M',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Modified files: ${modifiedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'modified_files',
|
|
value: modifiedFiles,
|
|
inputs
|
|
});
|
|
const renamedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'R',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Renamed files: ${renamedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'renamed_files',
|
|
value: renamedFiles,
|
|
inputs
|
|
});
|
|
const typeChangedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'T',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Type changed files: ${typeChangedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'type_changed_files',
|
|
value: typeChangedFiles,
|
|
inputs
|
|
});
|
|
const unmergedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'U',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Unmerged files: ${unmergedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'unmerged_files',
|
|
value: unmergedFiles,
|
|
inputs
|
|
});
|
|
const unknownFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'X',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Unknown files: ${unknownFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'unknown_files',
|
|
value: unknownFiles,
|
|
inputs
|
|
});
|
|
const allChangedAndModifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'ACDMRTUX',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'all_changed_and_modified_files',
|
|
value: allChangedAndModifiedFiles,
|
|
inputs
|
|
});
|
|
const allChangedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'ACMR',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`All changed files: ${allChangedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'all_changed_files',
|
|
value: allChangedFiles,
|
|
inputs
|
|
});
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'any_changed',
|
|
value: allChangedFiles.length > 0 && filePatterns.length > 0,
|
|
inputs
|
|
});
|
|
const allOtherChangedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'ACMR',
|
|
submodulePaths
|
|
});
|
|
core.debug(`All other changed files: ${allOtherChangedFiles}`);
|
|
const otherChangedFiles = allOtherChangedFiles
|
|
.split(inputs.separator)
|
|
.filter(filePath => !allChangedFiles.split(inputs.separator).includes(filePath));
|
|
const onlyChanged = otherChangedFiles.length === 0 && allChangedFiles.length > 0;
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'only_changed',
|
|
value: onlyChanged,
|
|
inputs
|
|
});
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'other_changed_files',
|
|
value: otherChangedFiles.join(inputs.separator),
|
|
inputs
|
|
});
|
|
const allModifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'ACMRD',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`All modified files: ${allModifiedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'all_modified_files',
|
|
value: allModifiedFiles,
|
|
inputs
|
|
});
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'any_modified',
|
|
value: allModifiedFiles.length > 0 && filePatterns.length > 0,
|
|
inputs
|
|
});
|
|
const allOtherModifiedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'ACMRD',
|
|
submodulePaths
|
|
});
|
|
const otherModifiedFiles = allOtherModifiedFiles
|
|
.split(inputs.separator)
|
|
.filter(filePath => !allModifiedFiles.split(inputs.separator).includes(filePath));
|
|
const onlyModified = otherModifiedFiles.length === 0 && allModifiedFiles.length > 0;
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'only_modified',
|
|
value: onlyModified,
|
|
inputs
|
|
});
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'other_modified_files',
|
|
value: otherModifiedFiles.join(inputs.separator),
|
|
inputs
|
|
});
|
|
const deletedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'D',
|
|
filePatterns,
|
|
submodulePaths
|
|
});
|
|
core.debug(`Deleted files: ${deletedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'deleted_files',
|
|
value: deletedFiles,
|
|
inputs
|
|
});
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'any_deleted',
|
|
value: deletedFiles.length > 0 && filePatterns.length > 0,
|
|
inputs
|
|
});
|
|
const allOtherDeletedFiles = yield (0, changedFiles_1.getDiffFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
diffFilter: 'D',
|
|
submodulePaths
|
|
});
|
|
const otherDeletedFiles = allOtherDeletedFiles
|
|
.split(inputs.separator)
|
|
.filter(filePath => !deletedFiles.split(inputs.separator).includes(filePath));
|
|
const onlyDeleted = otherDeletedFiles.length === 0 && deletedFiles.length > 0;
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'only_deleted',
|
|
value: onlyDeleted,
|
|
inputs
|
|
});
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'other_deleted_files',
|
|
value: otherDeletedFiles.join(inputs.separator),
|
|
inputs
|
|
});
|
|
if (inputs.includeAllOldNewRenamedFiles) {
|
|
const allOldNewRenamedFiles = yield (0, changedFiles_1.getRenamedFiles)({
|
|
inputs,
|
|
workingDirectory,
|
|
hasSubmodule,
|
|
diffResult,
|
|
submodulePaths
|
|
});
|
|
core.debug(`All old new renamed files: ${allOldNewRenamedFiles}`);
|
|
yield (0, utils_1.setOutput)({
|
|
key: 'all_old_new_renamed_files',
|
|
value: allOldNewRenamedFiles,
|
|
inputs
|
|
});
|
|
}
|
|
core.info('All Done!');
|
|
core.endGroup();
|
|
});
|
|
}
|
|
exports.run = run;
|
|
/* istanbul ignore if */
|
|
if (!process.env.TESTING) {
|
|
// eslint-disable-next-line github/no-then
|
|
run().catch(e => {
|
|
core.setFailed(e.message || e);
|
|
});
|
|
}
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 918:
|
|
/***/ (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;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
var m = o[Symbol.asyncIterator], i;
|
|
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
};
|
|
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
function fulfill(value) { resume("next", value); }
|
|
function reject(value) { resume("throw", value); }
|
|
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
};
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.setOutput = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.getHeadSha = exports.gitLog = exports.gitDiff = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
|
/*global AsyncIterableIterator*/
|
|
const core = __importStar(__nccwpck_require__(2186));
|
|
const exec = __importStar(__nccwpck_require__(1514));
|
|
const fs_1 = __nccwpck_require__(7147);
|
|
const micromatch_1 = __importDefault(__nccwpck_require__(6228));
|
|
const path = __importStar(__nccwpck_require__(1017));
|
|
const readline_1 = __nccwpck_require__(4521);
|
|
const IS_WINDOWS = process.platform === 'win32';
|
|
const MINIMUM_GIT_VERSION = '2.18.0';
|
|
/**
|
|
* Normalize file path separators to '/' on Windows and Linux/macOS
|
|
* @param p file path
|
|
* @returns file path with normalized separators
|
|
*/
|
|
const normalizeSeparators = (p) => {
|
|
// Windows
|
|
if (IS_WINDOWS) {
|
|
// Convert slashes on Windows
|
|
p = p.replace(/\//g, '\\');
|
|
// Remove redundant slashes
|
|
const isUnc = /^\\\\+[^\\]/.test(p); // e.g. \\hello
|
|
return (isUnc ? '\\' : '') + p.replace(/\\\\+/g, '\\'); // preserve leading \\ for UNC
|
|
}
|
|
// Remove redundant slashes
|
|
return p.replace(/\/\/+/g, '/');
|
|
};
|
|
/**
|
|
* Trims unnecessary trailing slash from file path
|
|
* @param p file path
|
|
* @returns file path without unnecessary trailing slash
|
|
*/
|
|
const safeTrimTrailingSeparator = (p) => {
|
|
// Empty path
|
|
if (!p) {
|
|
return '';
|
|
}
|
|
// Normalize separators
|
|
p = normalizeSeparators(p);
|
|
// No trailing slash
|
|
if (!p.endsWith(path.sep)) {
|
|
return p;
|
|
}
|
|
// Check '/' on Linux/macOS and '\' on Windows
|
|
if (p === path.sep) {
|
|
return p;
|
|
}
|
|
// On Windows, avoid trimming the drive root, e.g. C:\ or \\hello
|
|
if (IS_WINDOWS && /^[A-Z]:\\$/i.test(p)) {
|
|
return p;
|
|
}
|
|
// Trim trailing slash
|
|
return p.substring(0, p.length - 1);
|
|
};
|
|
const dirname = (p) => {
|
|
// Normalize slashes and trim unnecessary trailing slash
|
|
p = safeTrimTrailingSeparator(p);
|
|
// Windows UNC root, e.g. \\hello or \\hello\world
|
|
if (IS_WINDOWS && /^\\\\[^\\]+(\\[^\\]+)?$/.test(p)) {
|
|
return p;
|
|
}
|
|
// Get dirname
|
|
let result = path.dirname(p);
|
|
// Trim trailing slash for Windows UNC root, e.g. \\hello\world\
|
|
if (IS_WINDOWS && /^\\\\[^\\]+\\[^\\]+\\$/.test(result)) {
|
|
result = safeTrimTrailingSeparator(result);
|
|
}
|
|
return result;
|
|
};
|
|
const versionToNumber = (version) => {
|
|
const [major, minor, patch] = version.split('.').map(Number);
|
|
return major * 1000000 + minor * 1000 + patch;
|
|
};
|
|
const verifyMinimumGitVersion = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['--version'], { silent: process.env.RUNNER_DEBUG !== '1' });
|
|
if (exitCode !== 0) {
|
|
throw new Error(stderr || 'An unexpected error occurred');
|
|
}
|
|
const gitVersion = stdout.trim();
|
|
if (versionToNumber(gitVersion) < versionToNumber(MINIMUM_GIT_VERSION)) {
|
|
throw new Error(`Minimum required git version is ${MINIMUM_GIT_VERSION}, your version is ${gitVersion}`);
|
|
}
|
|
});
|
|
exports.verifyMinimumGitVersion = verifyMinimumGitVersion;
|
|
const exists = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
try {
|
|
yield fs_1.promises.access(filePath);
|
|
return true;
|
|
}
|
|
catch (_a) {
|
|
return false;
|
|
}
|
|
});
|
|
function lineOfFileGenerator({ filePath, excludedFiles }) {
|
|
return __asyncGenerator(this, arguments, function* lineOfFileGenerator_1() {
|
|
var _a, e_1, _b, _c;
|
|
const fileStream = (0, fs_1.createReadStream)(filePath);
|
|
/* istanbul ignore next */
|
|
fileStream.on('error', error => {
|
|
throw error;
|
|
});
|
|
const rl = (0, readline_1.createInterface)({
|
|
input: fileStream,
|
|
crlfDelay: Infinity
|
|
});
|
|
try {
|
|
for (var _d = true, rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield __await(rl_1.next()), _a = rl_1_1.done, !_a;) {
|
|
_c = rl_1_1.value;
|
|
_d = false;
|
|
try {
|
|
const line = _c;
|
|
if (!line.startsWith('#') && line !== '') {
|
|
if (excludedFiles) {
|
|
if (line.startsWith('!')) {
|
|
yield yield __await(line);
|
|
}
|
|
else {
|
|
yield yield __await(`!${line}`);
|
|
}
|
|
}
|
|
else {
|
|
yield yield __await(line);
|
|
}
|
|
}
|
|
}
|
|
finally {
|
|
_d = true;
|
|
}
|
|
}
|
|
}
|
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
finally {
|
|
try {
|
|
if (!_d && !_a && (_b = rl_1.return)) yield __await(_b.call(rl_1));
|
|
}
|
|
finally { if (e_1) throw e_1.error; }
|
|
}
|
|
});
|
|
}
|
|
const getFilesFromSourceFile = ({ filePaths, excludedFiles = false }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
var _b, e_2, _c, _d;
|
|
const lines = [];
|
|
for (const filePath of filePaths) {
|
|
try {
|
|
for (var _e = true, _f = (e_2 = void 0, __asyncValues(lineOfFileGenerator({ filePath, excludedFiles }))), _g; _g = yield _f.next(), _b = _g.done, !_b;) {
|
|
_d = _g.value;
|
|
_e = false;
|
|
try {
|
|
const line = _d;
|
|
lines.push(line);
|
|
}
|
|
finally {
|
|
_e = true;
|
|
}
|
|
}
|
|
}
|
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
finally {
|
|
try {
|
|
if (!_e && !_b && (_c = _f.return)) yield _c.call(_f);
|
|
}
|
|
finally { if (e_2) throw e_2.error; }
|
|
}
|
|
}
|
|
return lines;
|
|
});
|
|
const updateGitGlobalConfig = ({ name, value }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stderr } = yield exec.getExecOutput('git', ['config', '--global', name, value], {
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
/* istanbul ignore if */
|
|
if (exitCode !== 0 || stderr) {
|
|
core.warning(stderr || `Couldn't update git global config ${name}`);
|
|
}
|
|
});
|
|
exports.updateGitGlobalConfig = updateGitGlobalConfig;
|
|
const isRepoShallow = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', '--is-shallow-repository'], {
|
|
cwd,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
return stdout.trim() === 'true';
|
|
});
|
|
exports.isRepoShallow = isRepoShallow;
|
|
const submoduleExists = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { stdout, exitCode } = yield exec.getExecOutput('git', ['submodule', 'status'], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
if (exitCode !== 0) {
|
|
return false;
|
|
}
|
|
return stdout.trim() !== '';
|
|
});
|
|
exports.submoduleExists = submoduleExists;
|
|
const gitFetch = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode } = yield exec.getExecOutput('git', ['fetch', '-q', ...args], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
return exitCode;
|
|
});
|
|
exports.gitFetch = gitFetch;
|
|
const gitFetchSubmodules = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stderr } = yield exec.getExecOutput('git', ['submodule', 'foreach', 'git', 'fetch', '-q', ...args], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
/* istanbul ignore if */
|
|
if (exitCode !== 0) {
|
|
core.warning(stderr || "Couldn't fetch submodules");
|
|
}
|
|
});
|
|
exports.gitFetchSubmodules = gitFetchSubmodules;
|
|
const normalizePath = (p) => {
|
|
return p.replace(/\\/g, '/');
|
|
};
|
|
const getSubmodulePath = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', ['submodule', 'status'], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
if (exitCode !== 0) {
|
|
core.warning(stderr || "Couldn't get submodule names");
|
|
return [];
|
|
}
|
|
return stdout
|
|
.trim()
|
|
.split('\n')
|
|
.map(line => normalizePath(line.split(' ')[1]));
|
|
});
|
|
exports.getSubmodulePath = getSubmodulePath;
|
|
const gitSubmoduleDiffSHA = ({ cwd, parentSha1, parentSha2, submodulePath, diff }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
var _h, _j, _k, _l;
|
|
const { stdout } = yield exec.getExecOutput('git', ['diff', parentSha1, parentSha2, '--', submodulePath], {
|
|
cwd,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
const subprojectCommitPreRegex = /^(?<preCommit>-)Subproject commit (?<commitHash>.+)$/m;
|
|
const subprojectCommitCurRegex = /^(?<curCommit>\+)Subproject commit (?<commitHash>.+)$/m;
|
|
const previousSha = ((_j = (_h = subprojectCommitPreRegex.exec(stdout)) === null || _h === void 0 ? void 0 : _h.groups) === null || _j === void 0 ? void 0 : _j.commitHash) ||
|
|
'4b825dc642cb6eb9a060e54bf8d69288fbee4904';
|
|
const currentSha = (_l = (_k = subprojectCommitCurRegex.exec(stdout)) === null || _k === void 0 ? void 0 : _k.groups) === null || _l === void 0 ? void 0 : _l.commitHash;
|
|
if (currentSha) {
|
|
return { previousSha, currentSha };
|
|
}
|
|
core.debug(`No submodule commit found for ${submodulePath} between ${parentSha1}${diff}${parentSha2}`);
|
|
return {};
|
|
});
|
|
exports.gitSubmoduleDiffSHA = gitSubmoduleDiffSHA;
|
|
const gitRenamedFiles = ({ cwd, sha1, sha2, diff, oldNewSeparator, isSubmodule = false, parentDir = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stderr, stdout } = yield exec.getExecOutput('git', [
|
|
'diff',
|
|
'--name-status',
|
|
'--ignore-submodules=all',
|
|
'--diff-filter=R',
|
|
`${sha1}${diff}${sha2}`
|
|
], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
if (exitCode !== 0) {
|
|
if (isSubmodule) {
|
|
core.warning(stderr ||
|
|
`Failed to get renamed files for submodule between: ${sha1}${diff}${sha2}`);
|
|
core.warning('Please ensure that submodules are initialized and up to date. See: https://github.com/actions/checkout#usage');
|
|
}
|
|
else {
|
|
core.error(stderr || `Failed to get renamed files between: ${sha1}${diff}${sha2}`);
|
|
throw new Error('Unable to get renamed files');
|
|
}
|
|
return [];
|
|
}
|
|
return stdout
|
|
.trim()
|
|
.split('\n')
|
|
.filter(Boolean)
|
|
.map(line => {
|
|
core.debug(`Renamed file: ${line}`);
|
|
const [, oldPath, newPath] = line.split('\t');
|
|
if (isSubmodule) {
|
|
return `${normalizePath(path.join(parentDir, oldPath))}${oldNewSeparator}${normalizePath(path.join(parentDir, newPath))}`;
|
|
}
|
|
return `${normalizePath(oldPath)}${oldNewSeparator}${normalizePath(newPath)}`;
|
|
});
|
|
});
|
|
exports.gitRenamedFiles = gitRenamedFiles;
|
|
const gitDiff = ({ cwd, sha1, sha2, diff, diffFilter, filePatterns = [], isSubmodule = false, parentDir = '' }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stdout, stderr } = yield exec.getExecOutput('git', [
|
|
'diff',
|
|
'--name-only',
|
|
'--ignore-submodules=all',
|
|
`--diff-filter=${diffFilter}`,
|
|
`${sha1}${diff}${sha2}`
|
|
], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
if (exitCode !== 0) {
|
|
if (isSubmodule) {
|
|
core.warning(stderr ||
|
|
`Failed to get changed files for submodule between: ${sha1}${diff}${sha2}`);
|
|
core.warning('Please ensure that submodules are initialized and up to date. See: https://github.com/actions/checkout#usage');
|
|
}
|
|
else {
|
|
core.warning(stderr || `Failed to get changed files between: ${sha1}${diff}${sha2}`);
|
|
}
|
|
return [];
|
|
}
|
|
const files = stdout
|
|
.split('\n')
|
|
.filter(Boolean)
|
|
.map(p => {
|
|
if (isSubmodule) {
|
|
return normalizePath(path.join(parentDir, p));
|
|
}
|
|
return normalizePath(p);
|
|
});
|
|
if (filePatterns.length === 0) {
|
|
return files;
|
|
}
|
|
return (0, micromatch_1.default)(files, filePatterns, {
|
|
dot: true,
|
|
windows: IS_WINDOWS,
|
|
noext: true
|
|
});
|
|
});
|
|
exports.gitDiff = gitDiff;
|
|
const gitLog = ({ args, cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { stdout } = yield exec.getExecOutput('git', ['log', ...args], {
|
|
cwd,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
return stdout.trim();
|
|
});
|
|
exports.gitLog = gitLog;
|
|
const getHeadSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', 'HEAD'], {
|
|
cwd,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
return stdout.trim();
|
|
});
|
|
exports.getHeadSha = getHeadSha;
|
|
const getRemoteBranchHeadSha = ({ cwd, branch }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { stdout } = yield exec.getExecOutput('git', ['rev-parse', `origin/${branch}`], {
|
|
cwd,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
return stdout.trim();
|
|
});
|
|
exports.getRemoteBranchHeadSha = getRemoteBranchHeadSha;
|
|
const getParentSha = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { stdout, exitCode } = yield exec.getExecOutput('git', ['rev-list', '-n', '1', 'HEAD^'], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
if (exitCode !== 0) {
|
|
return '';
|
|
}
|
|
return stdout.trim();
|
|
});
|
|
exports.getParentSha = getParentSha;
|
|
const verifyCommitSha = ({ sha, cwd, showAsErrorMessage = true }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stderr } = yield exec.getExecOutput('git', ['rev-parse', '--verify', `${sha}^{commit}`], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
if (exitCode !== 0) {
|
|
if (showAsErrorMessage) {
|
|
core.error(`Unable to locate the commit sha: ${sha}`);
|
|
core.error("Please verify that the commit sha is correct, and increase the 'fetch_depth' input if needed");
|
|
core.debug(stderr);
|
|
}
|
|
else {
|
|
core.warning(`Unable to locate the commit sha: ${sha}`);
|
|
core.debug(stderr);
|
|
}
|
|
}
|
|
return exitCode;
|
|
});
|
|
exports.verifyCommitSha = verifyCommitSha;
|
|
const getPreviousGitTag = ({ cwd }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { stdout } = yield exec.getExecOutput('git', ['tag', '--sort=-version:refname'], {
|
|
cwd,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
const tags = stdout.trim().split('\n');
|
|
if (tags.length < 2) {
|
|
core.warning('No previous tag found');
|
|
return { tag: '', sha: '' };
|
|
}
|
|
const previousTag = tags[1];
|
|
const { stdout: stdout2 } = yield exec.getExecOutput('git', ['rev-parse', previousTag], {
|
|
cwd,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
const sha = stdout2.trim();
|
|
return { tag: previousTag, sha };
|
|
});
|
|
exports.getPreviousGitTag = getPreviousGitTag;
|
|
const canDiffCommits = ({ cwd, sha1, sha2, diff }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const { exitCode, stderr } = yield exec.getExecOutput('git', ['diff', '--name-only', '--ignore-submodules=all', `${sha1}${diff}${sha2}`], {
|
|
cwd,
|
|
ignoreReturnCode: true,
|
|
silent: process.env.RUNNER_DEBUG !== '1'
|
|
});
|
|
if (exitCode !== 0) {
|
|
core.warning(stderr || `Unable find merge base between ${sha1} and ${sha2}`);
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
exports.canDiffCommits = canDiffCommits;
|
|
const getDirnameMaxDepth = ({ pathStr, dirNamesMaxDepth, excludeRoot }) => {
|
|
const pathArr = dirname(pathStr).split(path.sep);
|
|
const maxDepth = Math.min(dirNamesMaxDepth || pathArr.length, pathArr.length);
|
|
let output = pathArr[0];
|
|
for (let i = 1; i < maxDepth; i++) {
|
|
output = path.join(output, pathArr[i]);
|
|
}
|
|
if (excludeRoot && output === '.') {
|
|
return '';
|
|
}
|
|
return normalizePath(output);
|
|
};
|
|
exports.getDirnameMaxDepth = getDirnameMaxDepth;
|
|
const jsonOutput = ({ value, shouldEscape }) => {
|
|
const result = JSON.stringify(value);
|
|
return shouldEscape ? result.replace(/"/g, '\\"') : result;
|
|
};
|
|
exports.jsonOutput = jsonOutput;
|
|
const getFilePatterns = ({ inputs, workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
let filePatterns = inputs.files
|
|
.split(inputs.filesSeparator)
|
|
.filter(p => p !== '')
|
|
.join('\n');
|
|
if (inputs.filesFromSourceFile !== '') {
|
|
const inputFilesFromSourceFile = inputs.filesFromSourceFile
|
|
.split(inputs.filesFromSourceFileSeparator)
|
|
.filter(p => p !== '')
|
|
.map(p => path.join(workingDirectory, p));
|
|
core.debug(`files from source file: ${inputFilesFromSourceFile}`);
|
|
const filesFromSourceFiles = (yield getFilesFromSourceFile({ filePaths: inputFilesFromSourceFile })).join('\n');
|
|
core.debug(`files from source files patterns: ${filesFromSourceFiles}`);
|
|
filePatterns = filePatterns.concat('\n', filesFromSourceFiles);
|
|
}
|
|
if (inputs.filesIgnore) {
|
|
const filesIgnorePatterns = inputs.filesIgnore
|
|
.split(inputs.filesIgnoreSeparator)
|
|
.filter(p => p !== '')
|
|
.map(p => {
|
|
if (!p.startsWith('!')) {
|
|
p = `!${p}`;
|
|
}
|
|
return p;
|
|
})
|
|
.join('\n');
|
|
core.debug(`files ignore patterns: ${filesIgnorePatterns}`);
|
|
filePatterns = filePatterns.concat('\n', filesIgnorePatterns);
|
|
}
|
|
if (inputs.filesIgnoreFromSourceFile) {
|
|
const inputFilesIgnoreFromSourceFile = inputs.filesIgnoreFromSourceFile
|
|
.split(inputs.filesIgnoreFromSourceFileSeparator)
|
|
.filter(p => p !== '')
|
|
.map(p => path.join(workingDirectory, p));
|
|
core.debug(`files ignore from source file: ${inputFilesIgnoreFromSourceFile}`);
|
|
const filesIgnoreFromSourceFiles = (yield getFilesFromSourceFile({
|
|
filePaths: inputFilesIgnoreFromSourceFile,
|
|
excludedFiles: true
|
|
})).join('\n');
|
|
core.debug(`files ignore from source files patterns: ${filesIgnoreFromSourceFiles}`);
|
|
filePatterns = filePatterns.concat('\n', filesIgnoreFromSourceFiles);
|
|
}
|
|
if (IS_WINDOWS) {
|
|
filePatterns = filePatterns.replace(/\r\n/g, '\n');
|
|
filePatterns = filePatterns.replace(/\r/g, '\n');
|
|
}
|
|
core.debug(`file patterns: ${filePatterns}`);
|
|
return filePatterns
|
|
.trim()
|
|
.split('\n')
|
|
.filter(Boolean)
|
|
.map(pattern => {
|
|
if (pattern.endsWith('/')) {
|
|
return `${pattern}**`;
|
|
}
|
|
else {
|
|
const pathParts = pattern.split('/');
|
|
const lastPart = pathParts[pathParts.length - 1];
|
|
if (!lastPart.includes('.')) {
|
|
return `${pattern}/**`;
|
|
}
|
|
else {
|
|
return pattern;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
exports.getFilePatterns = getFilePatterns;
|
|
const setOutput = ({ key, value, inputs }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const cleanedValue = value.toString().trim();
|
|
core.setOutput(key, cleanedValue);
|
|
if (inputs.writeOutputFiles) {
|
|
const outputDir = inputs.outputDir || '.github/outputs';
|
|
const extension = inputs.json ? 'json' : 'txt';
|
|
const outputFilePath = path.join(outputDir, `${key}.${extension}`);
|
|
if (!(yield exists(outputDir))) {
|
|
yield fs_1.promises.mkdir(outputDir, { recursive: true });
|
|
}
|
|
yield fs_1.promises.writeFile(outputFilePath, cleanedValue.replace(/\\"/g, '"'));
|
|
}
|
|
});
|
|
exports.setOutput = setOutput;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 7351:
|
|
/***/ (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;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.issue = exports.issueCommand = void 0;
|
|
const os = __importStar(__nccwpck_require__(2037));
|
|
const utils_1 = __nccwpck_require__(5278);
|
|
/**
|
|
* Commands
|
|
*
|
|
* Command Format:
|
|
* ::name key=value,key=value::message
|
|
*
|
|
* Examples:
|
|
* ::warning::This is the message
|
|
* ::set-env name=MY_VAR::some value
|
|
*/
|
|
function issueCommand(command, properties, message) {
|
|
const cmd = new Command(command, properties, message);
|
|
process.stdout.write(cmd.toString() + os.EOL);
|
|
}
|
|
exports.issueCommand = issueCommand;
|
|
function issue(name, message = '') {
|
|
issueCommand(name, {}, message);
|
|
}
|
|
exports.issue = issue;
|
|
const CMD_STRING = '::';
|
|
class Command {
|
|
constructor(command, properties, message) {
|
|
if (!command) {
|
|
command = 'missing.command';
|
|
}
|
|
this.command = command;
|
|
this.properties = properties;
|
|
this.message = message;
|
|
}
|
|
toString() {
|
|
let cmdStr = CMD_STRING + this.command;
|
|
if (this.properties && Object.keys(this.properties).length > 0) {
|
|
cmdStr += ' ';
|
|
let first = true;
|
|
for (const key in this.properties) {
|
|
if (this.properties.hasOwnProperty(key)) {
|
|
const val = this.properties[key];
|
|
if (val) {
|
|
if (first) {
|
|
first = false;
|
|
}
|
|
else {
|
|
cmdStr += ',';
|
|
}
|
|
cmdStr += `${key}=${escapeProperty(val)}`;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
|
|
return cmdStr;
|
|
}
|
|
}
|
|
function escapeData(s) {
|
|
return utils_1.toCommandValue(s)
|
|
.replace(/%/g, '%25')
|
|
.replace(/\r/g, '%0D')
|
|
.replace(/\n/g, '%0A');
|
|
}
|
|
function escapeProperty(s) {
|
|
return utils_1.toCommandValue(s)
|
|
.replace(/%/g, '%25')
|
|
.replace(/\r/g, '%0D')
|
|
.replace(/\n/g, '%0A')
|
|
.replace(/:/g, '%3A')
|
|
.replace(/,/g, '%2C');
|
|
}
|
|
//# sourceMappingURL=command.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2186:
|
|
/***/ (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) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
|
const command_1 = __nccwpck_require__(7351);
|
|
const file_command_1 = __nccwpck_require__(717);
|
|
const utils_1 = __nccwpck_require__(5278);
|
|
const os = __importStar(__nccwpck_require__(2037));
|
|
const path = __importStar(__nccwpck_require__(1017));
|
|
const oidc_utils_1 = __nccwpck_require__(8041);
|
|
/**
|
|
* 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. Non-string values will be converted to a string via JSON.stringify
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
function exportVariable(name, val) {
|
|
const convertedVal = utils_1.toCommandValue(val);
|
|
process.env[name] = convertedVal;
|
|
const filePath = process.env['GITHUB_ENV'] || '';
|
|
if (filePath) {
|
|
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
|
|
}
|
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
|
}
|
|
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) {
|
|
const filePath = process.env['GITHUB_PATH'] || '';
|
|
if (filePath) {
|
|
file_command_1.issueFileCommand('PATH', inputPath);
|
|
}
|
|
else {
|
|
command_1.issueCommand('add-path', {}, inputPath);
|
|
}
|
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
|
}
|
|
exports.addPath = addPath;
|
|
/**
|
|
* Gets the value of an input.
|
|
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
|
|
* Returns an empty string if the value is not defined.
|
|
*
|
|
* @param name name of the input to get
|
|
* @param options optional. See InputOptions.
|
|
* @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}`);
|
|
}
|
|
if (options && options.trimWhitespace === false) {
|
|
return val;
|
|
}
|
|
return val.trim();
|
|
}
|
|
exports.getInput = getInput;
|
|
/**
|
|
* Gets the values of an multiline input. Each value is also trimmed.
|
|
*
|
|
* @param name name of the input to get
|
|
* @param options optional. See InputOptions.
|
|
* @returns string[]
|
|
*
|
|
*/
|
|
function getMultilineInput(name, options) {
|
|
const inputs = getInput(name, options)
|
|
.split('\n')
|
|
.filter(x => x !== '');
|
|
if (options && options.trimWhitespace === false) {
|
|
return inputs;
|
|
}
|
|
return inputs.map(input => input.trim());
|
|
}
|
|
exports.getMultilineInput = getMultilineInput;
|
|
/**
|
|
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
|
|
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
|
|
* The return value is also in boolean type.
|
|
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
|
|
*
|
|
* @param name name of the input to get
|
|
* @param options optional. See InputOptions.
|
|
* @returns boolean
|
|
*/
|
|
function getBooleanInput(name, options) {
|
|
const trueValue = ['true', 'True', 'TRUE'];
|
|
const falseValue = ['false', 'False', 'FALSE'];
|
|
const val = getInput(name, options);
|
|
if (trueValue.includes(val))
|
|
return true;
|
|
if (falseValue.includes(val))
|
|
return false;
|
|
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
|
|
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
|
}
|
|
exports.getBooleanInput = getBooleanInput;
|
|
/**
|
|
* Sets the value of an output.
|
|
*
|
|
* @param name name of the output to set
|
|
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
function setOutput(name, value) {
|
|
const filePath = process.env['GITHUB_OUTPUT'] || '';
|
|
if (filePath) {
|
|
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
|
|
}
|
|
process.stdout.write(os.EOL);
|
|
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
|
|
}
|
|
exports.setOutput = setOutput;
|
|
/**
|
|
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
|
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
|
*
|
|
*/
|
|
function setCommandEcho(enabled) {
|
|
command_1.issue('echo', enabled ? 'on' : 'off');
|
|
}
|
|
exports.setCommandEcho = setCommandEcho;
|
|
//-----------------------------------------------------------------------
|
|
// 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
|
|
//-----------------------------------------------------------------------
|
|
/**
|
|
* Gets whether Actions Step Debug is on or not
|
|
*/
|
|
function isDebug() {
|
|
return process.env['RUNNER_DEBUG'] === '1';
|
|
}
|
|
exports.isDebug = isDebug;
|
|
/**
|
|
* 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. Errors will be converted to string via toString()
|
|
* @param properties optional properties to add to the annotation.
|
|
*/
|
|
function error(message, properties = {}) {
|
|
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
|
}
|
|
exports.error = error;
|
|
/**
|
|
* Adds a warning issue
|
|
* @param message warning issue message. Errors will be converted to string via toString()
|
|
* @param properties optional properties to add to the annotation.
|
|
*/
|
|
function warning(message, properties = {}) {
|
|
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
|
}
|
|
exports.warning = warning;
|
|
/**
|
|
* Adds a notice issue
|
|
* @param message notice issue message. Errors will be converted to string via toString()
|
|
* @param properties optional properties to add to the annotation.
|
|
*/
|
|
function notice(message, properties = {}) {
|
|
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
|
}
|
|
exports.notice = notice;
|
|
/**
|
|
* Writes info to log with console.log.
|
|
* @param message info message
|
|
*/
|
|
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. Non-string values will be converted to a string via JSON.stringify
|
|
*/
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
function saveState(name, value) {
|
|
const filePath = process.env['GITHUB_STATE'] || '';
|
|
if (filePath) {
|
|
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
|
|
}
|
|
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
|
|
}
|
|
exports.saveState = saveState;
|
|
/**
|
|
* 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;
|
|
function getIDToken(aud) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
|
});
|
|
}
|
|
exports.getIDToken = getIDToken;
|
|
/**
|
|
* Summary exports
|
|
*/
|
|
var summary_1 = __nccwpck_require__(1327);
|
|
Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } }));
|
|
/**
|
|
* @deprecated use core.summary
|
|
*/
|
|
var summary_2 = __nccwpck_require__(1327);
|
|
Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } }));
|
|
/**
|
|
* Path exports
|
|
*/
|
|
var path_utils_1 = __nccwpck_require__(2981);
|
|
Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } }));
|
|
Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } }));
|
|
Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } }));
|
|
//# sourceMappingURL=core.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 717:
|
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
|
|
"use strict";
|
|
|
|
// For internal use, subject to change.
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
|
|
// We use any as a valid input type
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
const fs = __importStar(__nccwpck_require__(7147));
|
|
const os = __importStar(__nccwpck_require__(2037));
|
|
const uuid_1 = __nccwpck_require__(5840);
|
|
const utils_1 = __nccwpck_require__(5278);
|
|
function issueFileCommand(command, message) {
|
|
const filePath = process.env[`GITHUB_${command}`];
|
|
if (!filePath) {
|
|
throw new Error(`Unable to find environment variable for file command ${command}`);
|
|
}
|
|
if (!fs.existsSync(filePath)) {
|
|
throw new Error(`Missing file at path: ${filePath}`);
|
|
}
|
|
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
|
|
encoding: 'utf8'
|
|
});
|
|
}
|
|
exports.issueFileCommand = issueFileCommand;
|
|
function prepareKeyValueMessage(key, value) {
|
|
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
|
|
const convertedValue = utils_1.toCommandValue(value);
|
|
// These should realistically never happen, but just in case someone finds a
|
|
// way to exploit uuid generation let's not allow keys or values that contain
|
|
// the delimiter.
|
|
if (key.includes(delimiter)) {
|
|
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
|
|
}
|
|
if (convertedValue.includes(delimiter)) {
|
|
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
|
|
}
|
|
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
|
|
}
|
|
exports.prepareKeyValueMessage = prepareKeyValueMessage;
|
|
//# sourceMappingURL=file-command.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8041:
|
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.OidcClient = void 0;
|
|
const http_client_1 = __nccwpck_require__(6255);
|
|
const auth_1 = __nccwpck_require__(5526);
|
|
const core_1 = __nccwpck_require__(2186);
|
|
class OidcClient {
|
|
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
|
const requestOptions = {
|
|
allowRetries: allowRetry,
|
|
maxRetries: maxRetry
|
|
};
|
|
return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
|
|
}
|
|
static getRequestToken() {
|
|
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
|
|
if (!token) {
|
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
|
|
}
|
|
return token;
|
|
}
|
|
static getIDTokenUrl() {
|
|
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
|
|
if (!runtimeUrl) {
|
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
|
|
}
|
|
return runtimeUrl;
|
|
}
|
|
static getCall(id_token_url) {
|
|
var _a;
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const httpclient = OidcClient.createHttpClient();
|
|
const res = yield httpclient
|
|
.getJson(id_token_url)
|
|
.catch(error => {
|
|
throw new Error(`Failed to get ID Token. \n
|
|
Error Code : ${error.statusCode}\n
|
|
Error Message: ${error.result.message}`);
|
|
});
|
|
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
|
if (!id_token) {
|
|
throw new Error('Response json body do not have ID Token field');
|
|
}
|
|
return id_token;
|
|
});
|
|
}
|
|
static getIDToken(audience) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
try {
|
|
// New ID Token is requested from action service
|
|
let id_token_url = OidcClient.getIDTokenUrl();
|
|
if (audience) {
|
|
const encodedAudience = encodeURIComponent(audience);
|
|
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
|
|
}
|
|
core_1.debug(`ID token url is ${id_token_url}`);
|
|
const id_token = yield OidcClient.getCall(id_token_url);
|
|
core_1.setSecret(id_token);
|
|
return id_token;
|
|
}
|
|
catch (error) {
|
|
throw new Error(`Error message: ${error.message}`);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
exports.OidcClient = OidcClient;
|
|
//# sourceMappingURL=oidc-utils.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2981:
|
|
/***/ (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;
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0;
|
|
const path = __importStar(__nccwpck_require__(1017));
|
|
/**
|
|
* toPosixPath converts the given path to the posix form. On Windows, \\ will be
|
|
* replaced with /.
|
|
*
|
|
* @param pth. Path to transform.
|
|
* @return string Posix path.
|
|
*/
|
|
function toPosixPath(pth) {
|
|
return pth.replace(/[\\]/g, '/');
|
|
}
|
|
exports.toPosixPath = toPosixPath;
|
|
/**
|
|
* toWin32Path converts the given path to the win32 form. On Linux, / will be
|
|
* replaced with \\.
|
|
*
|
|
* @param pth. Path to transform.
|
|
* @return string Win32 path.
|
|
*/
|
|
function toWin32Path(pth) {
|
|
return pth.replace(/[/]/g, '\\');
|
|
}
|
|
exports.toWin32Path = toWin32Path;
|
|
/**
|
|
* toPlatformPath converts the given path to a platform-specific path. It does
|
|
* this by replacing instances of / and \ with the platform-specific path
|
|
* separator.
|
|
*
|
|
* @param pth The path to platformize.
|
|
* @return string The platform-specific path.
|
|
*/
|
|
function toPlatformPath(pth) {
|
|
return pth.replace(/[/\\]/g, path.sep);
|
|
}
|
|
exports.toPlatformPath = toPlatformPath;
|
|
//# sourceMappingURL=path-utils.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1327:
|
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0;
|
|
const os_1 = __nccwpck_require__(2037);
|
|
const fs_1 = __nccwpck_require__(7147);
|
|
const { access, appendFile, writeFile } = fs_1.promises;
|
|
exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY';
|
|
exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary';
|
|
class Summary {
|
|
constructor() {
|
|
this._buffer = '';
|
|
}
|
|
/**
|
|
* Finds the summary file path from the environment, rejects if env var is not found or file does not exist
|
|
* Also checks r/w permissions.
|
|
*
|
|
* @returns step summary file path
|
|
*/
|
|
filePath() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (this._filePath) {
|
|
return this._filePath;
|
|
}
|
|
const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR];
|
|
if (!pathFromEnv) {
|
|
throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`);
|
|
}
|
|
try {
|
|
yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK);
|
|
}
|
|
catch (_a) {
|
|
throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`);
|
|
}
|
|
this._filePath = pathFromEnv;
|
|
return this._filePath;
|
|
});
|
|
}
|
|
/**
|
|
* Wraps content in an HTML tag, adding any HTML attributes
|
|
*
|
|
* @param {string} tag HTML tag to wrap
|
|
* @param {string | null} content content within the tag
|
|
* @param {[attribute: string]: string} attrs key-value list of HTML attributes to add
|
|
*
|
|
* @returns {string} content wrapped in HTML element
|
|
*/
|
|
wrap(tag, content, attrs = {}) {
|
|
const htmlAttrs = Object.entries(attrs)
|
|
.map(([key, value]) => ` ${key}="${value}"`)
|
|
.join('');
|
|
if (!content) {
|
|
return `<${tag}${htmlAttrs}>`;
|
|
}
|
|
return `<${tag}${htmlAttrs}>${content}</${tag}>`;
|
|
}
|
|
/**
|
|
* Writes text in the buffer to the summary buffer file and empties buffer. Will append by default.
|
|
*
|
|
* @param {SummaryWriteOptions} [options] (optional) options for write operation
|
|
*
|
|
* @returns {Promise<Summary>} summary instance
|
|
*/
|
|
write(options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const overwrite = !!(options === null || options === void 0 ? void 0 : options.overwrite);
|
|
const filePath = yield this.filePath();
|
|
const writeFunc = overwrite ? writeFile : appendFile;
|
|
yield writeFunc(filePath, this._buffer, { encoding: 'utf8' });
|
|
return this.emptyBuffer();
|
|
});
|
|
}
|
|
/**
|
|
* Clears the summary buffer and wipes the summary file
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
clear() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.emptyBuffer().write({ overwrite: true });
|
|
});
|
|
}
|
|
/**
|
|
* Returns the current summary buffer as a string
|
|
*
|
|
* @returns {string} string of summary buffer
|
|
*/
|
|
stringify() {
|
|
return this._buffer;
|
|
}
|
|
/**
|
|
* If the summary buffer is empty
|
|
*
|
|
* @returns {boolen} true if the buffer is empty
|
|
*/
|
|
isEmptyBuffer() {
|
|
return this._buffer.length === 0;
|
|
}
|
|
/**
|
|
* Resets the summary buffer without writing to summary file
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
emptyBuffer() {
|
|
this._buffer = '';
|
|
return this;
|
|
}
|
|
/**
|
|
* Adds raw text to the summary buffer
|
|
*
|
|
* @param {string} text content to add
|
|
* @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false)
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addRaw(text, addEOL = false) {
|
|
this._buffer += text;
|
|
return addEOL ? this.addEOL() : this;
|
|
}
|
|
/**
|
|
* Adds the operating system-specific end-of-line marker to the buffer
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addEOL() {
|
|
return this.addRaw(os_1.EOL);
|
|
}
|
|
/**
|
|
* Adds an HTML codeblock to the summary buffer
|
|
*
|
|
* @param {string} code content to render within fenced code block
|
|
* @param {string} lang (optional) language to syntax highlight code
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addCodeBlock(code, lang) {
|
|
const attrs = Object.assign({}, (lang && { lang }));
|
|
const element = this.wrap('pre', this.wrap('code', code), attrs);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML list to the summary buffer
|
|
*
|
|
* @param {string[]} items list of items to render
|
|
* @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false)
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addList(items, ordered = false) {
|
|
const tag = ordered ? 'ol' : 'ul';
|
|
const listItems = items.map(item => this.wrap('li', item)).join('');
|
|
const element = this.wrap(tag, listItems);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML table to the summary buffer
|
|
*
|
|
* @param {SummaryTableCell[]} rows table rows
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addTable(rows) {
|
|
const tableBody = rows
|
|
.map(row => {
|
|
const cells = row
|
|
.map(cell => {
|
|
if (typeof cell === 'string') {
|
|
return this.wrap('td', cell);
|
|
}
|
|
const { header, data, colspan, rowspan } = cell;
|
|
const tag = header ? 'th' : 'td';
|
|
const attrs = Object.assign(Object.assign({}, (colspan && { colspan })), (rowspan && { rowspan }));
|
|
return this.wrap(tag, data, attrs);
|
|
})
|
|
.join('');
|
|
return this.wrap('tr', cells);
|
|
})
|
|
.join('');
|
|
const element = this.wrap('table', tableBody);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds a collapsable HTML details element to the summary buffer
|
|
*
|
|
* @param {string} label text for the closed state
|
|
* @param {string} content collapsable content
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addDetails(label, content) {
|
|
const element = this.wrap('details', this.wrap('summary', label) + content);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML image tag to the summary buffer
|
|
*
|
|
* @param {string} src path to the image you to embed
|
|
* @param {string} alt text description of the image
|
|
* @param {SummaryImageOptions} options (optional) addition image attributes
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addImage(src, alt, options) {
|
|
const { width, height } = options || {};
|
|
const attrs = Object.assign(Object.assign({}, (width && { width })), (height && { height }));
|
|
const element = this.wrap('img', null, Object.assign({ src, alt }, attrs));
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML section heading element
|
|
*
|
|
* @param {string} text heading text
|
|
* @param {number | string} [level=1] (optional) the heading level, default: 1
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addHeading(text, level) {
|
|
const tag = `h${level}`;
|
|
const allowedTag = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(tag)
|
|
? tag
|
|
: 'h1';
|
|
const element = this.wrap(allowedTag, text);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML thematic break (<hr>) to the summary buffer
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addSeparator() {
|
|
const element = this.wrap('hr', null);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML line break (<br>) to the summary buffer
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addBreak() {
|
|
const element = this.wrap('br', null);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML blockquote to the summary buffer
|
|
*
|
|
* @param {string} text quote text
|
|
* @param {string} cite (optional) citation url
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addQuote(text, cite) {
|
|
const attrs = Object.assign({}, (cite && { cite }));
|
|
const element = this.wrap('blockquote', text, attrs);
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
/**
|
|
* Adds an HTML anchor tag to the summary buffer
|
|
*
|
|
* @param {string} text link text/content
|
|
* @param {string} href hyperlink
|
|
*
|
|
* @returns {Summary} summary instance
|
|
*/
|
|
addLink(text, href) {
|
|
const element = this.wrap('a', text, { href });
|
|
return this.addRaw(element).addEOL();
|
|
}
|
|
}
|
|
const _summary = new Summary();
|
|
/**
|
|
* @deprecated use `core.summary`
|
|
*/
|
|
exports.markdownSummary = _summary;
|
|
exports.summary = _summary;
|
|
//# sourceMappingURL=summary.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5278:
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
"use strict";
|
|
|
|
// We use any as a valid input type
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.toCommandProperties = exports.toCommandValue = void 0;
|
|
/**
|
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
|
* @param input input to sanitize into a string
|
|
*/
|
|
function toCommandValue(input) {
|
|
if (input === null || input === undefined) {
|
|
return '';
|
|
}
|
|
else if (typeof input === 'string' || input instanceof String) {
|
|
return input;
|
|
}
|
|
return JSON.stringify(input);
|
|
}
|
|
exports.toCommandValue = toCommandValue;
|
|
/**
|
|
*
|
|
* @param annotationProperties
|
|
* @returns The command properties to send with the actual annotation command
|
|
* See IssueCommandProperties: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionCommandManager.cs#L646
|
|
*/
|
|
function toCommandProperties(annotationProperties) {
|
|
if (!Object.keys(annotationProperties).length) {
|
|
return {};
|
|
}
|
|
return {
|
|
title: annotationProperties.title,
|
|
file: annotationProperties.file,
|
|
line: annotationProperties.startLine,
|
|
endLine: annotationProperties.endLine,
|
|
col: annotationProperties.startColumn,
|
|
endColumn: annotationProperties.endColumn
|
|
};
|
|
}
|
|
exports.toCommandProperties = toCommandProperties;
|
|
//# sourceMappingURL=utils.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1514:
|
|
/***/ (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) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.getExecOutput = exports.exec = void 0;
|
|
const string_decoder_1 = __nccwpck_require__(1576);
|
|
const tr = __importStar(__nccwpck_require__(8159));
|
|
/**
|
|
* Exec a command.
|
|
* Output will be streamed to the live console.
|
|
* Returns promise with return code
|
|
*
|
|
* @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<number> exit code
|
|
*/
|
|
function exec(commandLine, args, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const commandArgs = tr.argStringToArray(commandLine);
|
|
if (commandArgs.length === 0) {
|
|
throw new Error(`Parameter 'commandLine' cannot be null or empty.`);
|
|
}
|
|
// Path to tool to execute should be first arg
|
|
const toolPath = commandArgs[0];
|
|
args = commandArgs.slice(1).concat(args || []);
|
|
const runner = new tr.ToolRunner(toolPath, args, options);
|
|
return runner.exec();
|
|
});
|
|
}
|
|
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<ExecOutput> 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
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8159:
|
|
/***/ (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) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.argStringToArray = exports.ToolRunner = void 0;
|
|
const os = __importStar(__nccwpck_require__(2037));
|
|
const events = __importStar(__nccwpck_require__(2361));
|
|
const child = __importStar(__nccwpck_require__(2081));
|
|
const path = __importStar(__nccwpck_require__(1017));
|
|
const io = __importStar(__nccwpck_require__(7436));
|
|
const ioUtil = __importStar(__nccwpck_require__(1962));
|
|
const timers_1 = __nccwpck_require__(9512);
|
|
/* 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);
|
|
}
|
|
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() {
|
|
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* () {
|
|
// root the tool path if it is unrooted and contains relative pathing
|
|
if (!ioUtil.isRooted(this.toolPath) &&
|
|
(this.toolPath.includes('/') ||
|
|
(IS_WINDOWS && this.toolPath.includes('\\')))) {
|
|
// prefer options.cwd if it is specified, however options.cwd may also need to be rooted
|
|
this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath);
|
|
}
|
|
// 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) => __awaiter(this, void 0, void 0, function* () {
|
|
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);
|
|
});
|
|
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));
|
|
let 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);
|
|
}
|
|
stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
|
|
if (this.options.listeners && this.options.listeners.stdline) {
|
|
this.options.listeners.stdline(line);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
let 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);
|
|
}
|
|
errbuffer = 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);
|
|
}
|
|
});
|
|
if (this.options.input) {
|
|
if (!cp.stdin) {
|
|
throw new Error('child process missing stdin');
|
|
}
|
|
cp.stdin.end(this.options.input);
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
}
|
|
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 = timers_1.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
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5526:
|
|
/***/ (function(__unused_webpack_module, exports) {
|
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
|
class BasicCredentialHandler {
|
|
constructor(username, password) {
|
|
this.username = username;
|
|
this.password = password;
|
|
}
|
|
prepareRequest(options) {
|
|
if (!options.headers) {
|
|
throw Error('The request has no headers');
|
|
}
|
|
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
|
}
|
|
// This handler cannot handle 401
|
|
canHandleAuthentication() {
|
|
return false;
|
|
}
|
|
handleAuthentication() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
throw new Error('not implemented');
|
|
});
|
|
}
|
|
}
|
|
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
class BearerCredentialHandler {
|
|
constructor(token) {
|
|
this.token = token;
|
|
}
|
|
// currently implements pre-authorization
|
|
// TODO: support preAuth = false where it hooks on 401
|
|
prepareRequest(options) {
|
|
if (!options.headers) {
|
|
throw Error('The request has no headers');
|
|
}
|
|
options.headers['Authorization'] = `Bearer ${this.token}`;
|
|
}
|
|
// This handler cannot handle 401
|
|
canHandleAuthentication() {
|
|
return false;
|
|
}
|
|
handleAuthentication() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
throw new Error('not implemented');
|
|
});
|
|
}
|
|
}
|
|
exports.BearerCredentialHandler = BearerCredentialHandler;
|
|
class PersonalAccessTokenCredentialHandler {
|
|
constructor(token) {
|
|
this.token = token;
|
|
}
|
|
// currently implements pre-authorization
|
|
// TODO: support preAuth = false where it hooks on 401
|
|
prepareRequest(options) {
|
|
if (!options.headers) {
|
|
throw Error('The request has no headers');
|
|
}
|
|
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
|
}
|
|
// This handler cannot handle 401
|
|
canHandleAuthentication() {
|
|
return false;
|
|
}
|
|
handleAuthentication() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
throw new Error('not implemented');
|
|
});
|
|
}
|
|
}
|
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
|
//# sourceMappingURL=auth.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6255:
|
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
|
|
"use strict";
|
|
|
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
|
const http = __importStar(__nccwpck_require__(3685));
|
|
const https = __importStar(__nccwpck_require__(5687));
|
|
const pm = __importStar(__nccwpck_require__(9835));
|
|
const tunnel = __importStar(__nccwpck_require__(4294));
|
|
var HttpCodes;
|
|
(function (HttpCodes) {
|
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
|
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
var Headers;
|
|
(function (Headers) {
|
|
Headers["Accept"] = "accept";
|
|
Headers["ContentType"] = "content-type";
|
|
})(Headers = exports.Headers || (exports.Headers = {}));
|
|
var MediaTypes;
|
|
(function (MediaTypes) {
|
|
MediaTypes["ApplicationJson"] = "application/json";
|
|
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
|
/**
|
|
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
*/
|
|
function getProxyUrl(serverUrl) {
|
|
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
|
return proxyUrl ? proxyUrl.href : '';
|
|
}
|
|
exports.getProxyUrl = getProxyUrl;
|
|
const HttpRedirectCodes = [
|
|
HttpCodes.MovedPermanently,
|
|
HttpCodes.ResourceMoved,
|
|
HttpCodes.SeeOther,
|
|
HttpCodes.TemporaryRedirect,
|
|
HttpCodes.PermanentRedirect
|
|
];
|
|
const HttpResponseRetryCodes = [
|
|
HttpCodes.BadGateway,
|
|
HttpCodes.ServiceUnavailable,
|
|
HttpCodes.GatewayTimeout
|
|
];
|
|
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
const ExponentialBackoffCeiling = 10;
|
|
const ExponentialBackoffTimeSlice = 5;
|
|
class HttpClientError extends Error {
|
|
constructor(message, statusCode) {
|
|
super(message);
|
|
this.name = 'HttpClientError';
|
|
this.statusCode = statusCode;
|
|
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
}
|
|
}
|
|
exports.HttpClientError = HttpClientError;
|
|
class HttpClientResponse {
|
|
constructor(message) {
|
|
this.message = message;
|
|
}
|
|
readBody() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
let output = Buffer.alloc(0);
|
|
this.message.on('data', (chunk) => {
|
|
output = Buffer.concat([output, chunk]);
|
|
});
|
|
this.message.on('end', () => {
|
|
resolve(output.toString());
|
|
});
|
|
}));
|
|
});
|
|
}
|
|
}
|
|
exports.HttpClientResponse = HttpClientResponse;
|
|
function isHttps(requestUrl) {
|
|
const parsedUrl = new URL(requestUrl);
|
|
return parsedUrl.protocol === 'https:';
|
|
}
|
|
exports.isHttps = isHttps;
|
|
class HttpClient {
|
|
constructor(userAgent, handlers, requestOptions) {
|
|
this._ignoreSslError = false;
|
|
this._allowRedirects = true;
|
|
this._allowRedirectDowngrade = false;
|
|
this._maxRedirects = 50;
|
|
this._allowRetries = false;
|
|
this._maxRetries = 1;
|
|
this._keepAlive = false;
|
|
this._disposed = false;
|
|
this.userAgent = userAgent;
|
|
this.handlers = handlers || [];
|
|
this.requestOptions = requestOptions;
|
|
if (requestOptions) {
|
|
if (requestOptions.ignoreSslError != null) {
|
|
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
}
|
|
this._socketTimeout = requestOptions.socketTimeout;
|
|
if (requestOptions.allowRedirects != null) {
|
|
this._allowRedirects = requestOptions.allowRedirects;
|
|
}
|
|
if (requestOptions.allowRedirectDowngrade != null) {
|
|
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
}
|
|
if (requestOptions.maxRedirects != null) {
|
|
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
}
|
|
if (requestOptions.keepAlive != null) {
|
|
this._keepAlive = requestOptions.keepAlive;
|
|
}
|
|
if (requestOptions.allowRetries != null) {
|
|
this._allowRetries = requestOptions.allowRetries;
|
|
}
|
|
if (requestOptions.maxRetries != null) {
|
|
this._maxRetries = requestOptions.maxRetries;
|
|
}
|
|
}
|
|
}
|
|
options(requestUrl, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
});
|
|
}
|
|
get(requestUrl, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
});
|
|
}
|
|
del(requestUrl, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
});
|
|
}
|
|
post(requestUrl, data, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
});
|
|
}
|
|
patch(requestUrl, data, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
});
|
|
}
|
|
put(requestUrl, data, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
});
|
|
}
|
|
head(requestUrl, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
});
|
|
}
|
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
});
|
|
}
|
|
/**
|
|
* Gets a typed object from an endpoint
|
|
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
|
*/
|
|
getJson(requestUrl, additionalHeaders = {}) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
const res = yield this.get(requestUrl, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
});
|
|
}
|
|
postJson(requestUrl, obj, additionalHeaders = {}) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const data = JSON.stringify(obj, null, 2);
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
const res = yield this.post(requestUrl, data, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
});
|
|
}
|
|
putJson(requestUrl, obj, additionalHeaders = {}) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const data = JSON.stringify(obj, null, 2);
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
const res = yield this.put(requestUrl, data, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
});
|
|
}
|
|
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
const data = JSON.stringify(obj, null, 2);
|
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
|
return this._processResponse(res, this.requestOptions);
|
|
});
|
|
}
|
|
/**
|
|
* Makes a raw http request.
|
|
* All other methods such as get, post, patch, and request ultimately call this.
|
|
* Prefer get, del, post and patch
|
|
*/
|
|
request(verb, requestUrl, data, headers) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (this._disposed) {
|
|
throw new Error('Client has already been disposed.');
|
|
}
|
|
const parsedUrl = new URL(requestUrl);
|
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
// Only perform retries on reads since writes may not be idempotent.
|
|
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
|
? this._maxRetries + 1
|
|
: 1;
|
|
let numTries = 0;
|
|
let response;
|
|
do {
|
|
response = yield this.requestRaw(info, data);
|
|
// Check if it's an authentication challenge
|
|
if (response &&
|
|
response.message &&
|
|
response.message.statusCode === HttpCodes.Unauthorized) {
|
|
let authenticationHandler;
|
|
for (const handler of this.handlers) {
|
|
if (handler.canHandleAuthentication(response)) {
|
|
authenticationHandler = handler;
|
|
break;
|
|
}
|
|
}
|
|
if (authenticationHandler) {
|
|
return authenticationHandler.handleAuthentication(this, info, data);
|
|
}
|
|
else {
|
|
// We have received an unauthorized response but have no handlers to handle it.
|
|
// Let the response return to the caller.
|
|
return response;
|
|
}
|
|
}
|
|
let redirectsRemaining = this._maxRedirects;
|
|
while (response.message.statusCode &&
|
|
HttpRedirectCodes.includes(response.message.statusCode) &&
|
|
this._allowRedirects &&
|
|
redirectsRemaining > 0) {
|
|
const redirectUrl = response.message.headers['location'];
|
|
if (!redirectUrl) {
|
|
// if there's no location to redirect to, we won't
|
|
break;
|
|
}
|
|
const parsedRedirectUrl = new URL(redirectUrl);
|
|
if (parsedUrl.protocol === 'https:' &&
|
|
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
|
!this._allowRedirectDowngrade) {
|
|
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
|
|
}
|
|
// we need to finish reading the response before reassigning response
|
|
// which will leak the open socket.
|
|
yield response.readBody();
|
|
// strip authorization header if redirected to a different hostname
|
|
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
|
for (const header in headers) {
|
|
// header names are case insensitive
|
|
if (header.toLowerCase() === 'authorization') {
|
|
delete headers[header];
|
|
}
|
|
}
|
|
}
|
|
// let's make the request with the new redirectUrl
|
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
response = yield this.requestRaw(info, data);
|
|
redirectsRemaining--;
|
|
}
|
|
if (!response.message.statusCode ||
|
|
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
|
// If not a retry code, return immediately instead of retrying
|
|
return response;
|
|
}
|
|
numTries += 1;
|
|
if (numTries < maxTries) {
|
|
yield response.readBody();
|
|
yield this._performExponentialBackoff(numTries);
|
|
}
|
|
} while (numTries < maxTries);
|
|
return response;
|
|
});
|
|
}
|
|
/**
|
|
* Needs to be called if keepAlive is set to true in request options.
|
|
*/
|
|
dispose() {
|
|
if (this._agent) {
|
|
this._agent.destroy();
|
|
}
|
|
this._disposed = true;
|
|
}
|
|
/**
|
|
* Raw request.
|
|
* @param info
|
|
* @param data
|
|
*/
|
|
requestRaw(info, data) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return new Promise((resolve, reject) => {
|
|
function callbackForResult(err, res) {
|
|
if (err) {
|
|
reject(err);
|
|
}
|
|
else if (!res) {
|
|
// If `err` is not passed, then `res` must be passed.
|
|
reject(new Error('Unknown error'));
|
|
}
|
|
else {
|
|
resolve(res);
|
|
}
|
|
}
|
|
this.requestRawWithCallback(info, data, callbackForResult);
|
|
});
|
|
});
|
|
}
|
|
/**
|
|
* Raw request with callback.
|
|
* @param info
|
|
* @param data
|
|
* @param onResult
|
|
*/
|
|
requestRawWithCallback(info, data, onResult) {
|
|
if (typeof data === 'string') {
|
|
if (!info.options.headers) {
|
|
info.options.headers = {};
|
|
}
|
|
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
}
|
|
let callbackCalled = false;
|
|
function handleResult(err, res) {
|
|
if (!callbackCalled) {
|
|
callbackCalled = true;
|
|
onResult(err, res);
|
|
}
|
|
}
|
|
const req = info.httpModule.request(info.options, (msg) => {
|
|
const res = new HttpClientResponse(msg);
|
|
handleResult(undefined, res);
|
|
});
|
|
let socket;
|
|
req.on('socket', sock => {
|
|
socket = sock;
|
|
});
|
|
// If we ever get disconnected, we want the socket to timeout eventually
|
|
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
if (socket) {
|
|
socket.end();
|
|
}
|
|
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
|
});
|
|
req.on('error', function (err) {
|
|
// err has statusCode property
|
|
// res should have headers
|
|
handleResult(err);
|
|
});
|
|
if (data && typeof data === 'string') {
|
|
req.write(data, 'utf8');
|
|
}
|
|
if (data && typeof data !== 'string') {
|
|
data.on('close', function () {
|
|
req.end();
|
|
});
|
|
data.pipe(req);
|
|
}
|
|
else {
|
|
req.end();
|
|
}
|
|
}
|
|
/**
|
|
* Gets an http agent. This function is useful when you need an http agent that handles
|
|
* routing through a proxy server - depending upon the url and proxy environment variables.
|
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
*/
|
|
getAgent(serverUrl) {
|
|
const parsedUrl = new URL(serverUrl);
|
|
return this._getAgent(parsedUrl);
|
|
}
|
|
_prepareRequest(method, requestUrl, headers) {
|
|
const info = {};
|
|
info.parsedUrl = requestUrl;
|
|
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
info.httpModule = usingSsl ? https : http;
|
|
const defaultPort = usingSsl ? 443 : 80;
|
|
info.options = {};
|
|
info.options.host = info.parsedUrl.hostname;
|
|
info.options.port = info.parsedUrl.port
|
|
? parseInt(info.parsedUrl.port)
|
|
: defaultPort;
|
|
info.options.path =
|
|
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
info.options.method = method;
|
|
info.options.headers = this._mergeHeaders(headers);
|
|
if (this.userAgent != null) {
|
|
info.options.headers['user-agent'] = this.userAgent;
|
|
}
|
|
info.options.agent = this._getAgent(info.parsedUrl);
|
|
// gives handlers an opportunity to participate
|
|
if (this.handlers) {
|
|
for (const handler of this.handlers) {
|
|
handler.prepareRequest(info.options);
|
|
}
|
|
}
|
|
return info;
|
|
}
|
|
_mergeHeaders(headers) {
|
|
if (this.requestOptions && this.requestOptions.headers) {
|
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
|
}
|
|
return lowercaseKeys(headers || {});
|
|
}
|
|
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
|
let clientHeader;
|
|
if (this.requestOptions && this.requestOptions.headers) {
|
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
|
}
|
|
return additionalHeaders[header] || clientHeader || _default;
|
|
}
|
|
_getAgent(parsedUrl) {
|
|
let agent;
|
|
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
|
const useProxy = proxyUrl && proxyUrl.hostname;
|
|
if (this._keepAlive && useProxy) {
|
|
agent = this._proxyAgent;
|
|
}
|
|
if (this._keepAlive && !useProxy) {
|
|
agent = this._agent;
|
|
}
|
|
// if agent is already assigned use that agent.
|
|
if (agent) {
|
|
return agent;
|
|
}
|
|
const usingSsl = parsedUrl.protocol === 'https:';
|
|
let maxSockets = 100;
|
|
if (this.requestOptions) {
|
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
}
|
|
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
|
if (proxyUrl && proxyUrl.hostname) {
|
|
const agentOptions = {
|
|
maxSockets,
|
|
keepAlive: this._keepAlive,
|
|
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
|
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
|
};
|
|
let tunnelAgent;
|
|
const overHttps = proxyUrl.protocol === 'https:';
|
|
if (usingSsl) {
|
|
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
}
|
|
else {
|
|
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
}
|
|
agent = tunnelAgent(agentOptions);
|
|
this._proxyAgent = agent;
|
|
}
|
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
if (this._keepAlive && !agent) {
|
|
const options = { keepAlive: this._keepAlive, maxSockets };
|
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
this._agent = agent;
|
|
}
|
|
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
if (!agent) {
|
|
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
}
|
|
if (usingSsl && this._ignoreSslError) {
|
|
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
// we have to cast it to any and change it directly
|
|
agent.options = Object.assign(agent.options || {}, {
|
|
rejectUnauthorized: false
|
|
});
|
|
}
|
|
return agent;
|
|
}
|
|
_performExponentialBackoff(retryNumber) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
});
|
|
}
|
|
_processResponse(res, options) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
const statusCode = res.message.statusCode || 0;
|
|
const response = {
|
|
statusCode,
|
|
result: null,
|
|
headers: {}
|
|
};
|
|
// not found leads to null obj returned
|
|
if (statusCode === HttpCodes.NotFound) {
|
|
resolve(response);
|
|
}
|
|
// get the result from the body
|
|
function dateTimeDeserializer(key, value) {
|
|
if (typeof value === 'string') {
|
|
const a = new Date(value);
|
|
if (!isNaN(a.valueOf())) {
|
|
return a;
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
let obj;
|
|
let contents;
|
|
try {
|
|
contents = yield res.readBody();
|
|
if (contents && contents.length > 0) {
|
|
if (options && options.deserializeDates) {
|
|
obj = JSON.parse(contents, dateTimeDeserializer);
|
|
}
|
|
else {
|
|
obj = JSON.parse(contents);
|
|
}
|
|
response.result = obj;
|
|
}
|
|
response.headers = res.message.headers;
|
|
}
|
|
catch (err) {
|
|
// Invalid resource (contents not json); leaving result obj null
|
|
}
|
|
// note that 3xx redirects are handled by the http layer.
|
|
if (statusCode > 299) {
|
|
let msg;
|
|
// if exception/error in body, attempt to get better error
|
|
if (obj && obj.message) {
|
|
msg = obj.message;
|
|
}
|
|
else if (contents && contents.length > 0) {
|
|
// it may be the case that the exception is in the body message as string
|
|
msg = contents;
|
|
}
|
|
else {
|
|
msg = `Failed request: (${statusCode})`;
|
|
}
|
|
const err = new HttpClientError(msg, statusCode);
|
|
err.result = response.result;
|
|
reject(err);
|
|
}
|
|
else {
|
|
resolve(response);
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
}
|
|
exports.HttpClient = HttpClient;
|
|
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
//# sourceMappingURL=index.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9835:
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.checkBypass = exports.getProxyUrl = void 0;
|
|
function getProxyUrl(reqUrl) {
|
|
const usingSsl = reqUrl.protocol === 'https:';
|
|
if (checkBypass(reqUrl)) {
|
|
return undefined;
|
|
}
|
|
const proxyVar = (() => {
|
|
if (usingSsl) {
|
|
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
|
}
|
|
else {
|
|
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
|
}
|
|
})();
|
|
if (proxyVar) {
|
|
return new URL(proxyVar);
|
|
}
|
|
else {
|
|
return undefined;
|
|
}
|
|
}
|
|
exports.getProxyUrl = getProxyUrl;
|
|
function checkBypass(reqUrl) {
|
|
if (!reqUrl.hostname) {
|
|
return false;
|
|
}
|
|
const reqHost = reqUrl.hostname;
|
|
if (isLoopbackAddress(reqHost)) {
|
|
return true;
|
|
}
|
|
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
|
if (!noProxy) {
|
|
return false;
|
|
}
|
|
// Determine the request port
|
|
let reqPort;
|
|
if (reqUrl.port) {
|
|
reqPort = Number(reqUrl.port);
|
|
}
|
|
else if (reqUrl.protocol === 'http:') {
|
|
reqPort = 80;
|
|
}
|
|
else if (reqUrl.protocol === 'https:') {
|
|
reqPort = 443;
|
|
}
|
|
// Format the request hostname and hostname with port
|
|
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
|
if (typeof reqPort === 'number') {
|
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
|
}
|
|
// Compare request host against noproxy
|
|
for (const upperNoProxyItem of noProxy
|
|
.split(',')
|
|
.map(x => x.trim().toUpperCase())
|
|
.filter(x => x)) {
|
|
if (upperNoProxyItem === '*' ||
|
|
upperReqHosts.some(x => x === upperNoProxyItem ||
|
|
x.endsWith(`.${upperNoProxyItem}`) ||
|
|
(upperNoProxyItem.startsWith('.') &&
|
|
x.endsWith(`${upperNoProxyItem}`)))) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
exports.checkBypass = checkBypass;
|
|
function isLoopbackAddress(host) {
|
|
const hostLower = host.toLowerCase();
|
|
return (hostLower === 'localhost' ||
|
|
hostLower.startsWith('127.') ||
|
|
hostLower.startsWith('[::1]') ||
|
|
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
|
|
}
|
|
//# sourceMappingURL=proxy.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1962:
|
|
/***/ (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) {
|
|
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 }));
|
|
exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.READONLY = exports.UV_FS_O_EXLOCK = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rm = exports.rename = exports.readlink = exports.readdir = exports.open = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
|
|
const fs = __importStar(__nccwpck_require__(7147));
|
|
const path = __importStar(__nccwpck_require__(1017));
|
|
_a = fs.promises
|
|
// export const {open} = 'fs'
|
|
, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.open = _a.open, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rm = _a.rm, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
|
|
// export const {open} = 'fs'
|
|
exports.IS_WINDOWS = process.platform === 'win32';
|
|
// See https://github.com/nodejs/node/blob/d0153aee367422d0858105abec186da4dff0a0c5/deps/uv/include/uv/win.h#L691
|
|
exports.UV_FS_O_EXLOCK = 0x10000000;
|
|
exports.READONLY = fs.constants.O_RDONLY;
|
|
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;
|
|
/**
|
|
* 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()));
|
|
}
|
|
// Get the path of cmd.exe in windows
|
|
function getCmdPath() {
|
|
var _a;
|
|
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
|
|
}
|
|
exports.getCmdPath = getCmdPath;
|
|
//# sourceMappingURL=io-util.js.map
|
|
|
|
/***/ }),
|
|
|
|
/***/ 7436:
|
|
/***/ (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) {
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
|
|
const assert_1 = __nccwpck_require__(9491);
|
|
const path = __importStar(__nccwpck_require__(1017));
|
|
const ioUtil = __importStar(__nccwpck_require__(1962));
|
|
/**
|
|
* 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, copySourceDirectory } = 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() && copySourceDirectory
|
|
? 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) {
|
|
// Check for invalid characters
|
|
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
|
if (/[*"<>|]/.test(inputPath)) {
|
|
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
|
|
}
|
|
}
|
|
try {
|
|
// note if path does not exist, error is silent
|
|
yield ioUtil.rm(inputPath, {
|
|
force: true,
|
|
maxRetries: 3,
|
|
recursive: true,
|
|
retryDelay: 300
|
|
});
|
|
}
|
|
catch (err) {
|
|
throw new Error(`File was unable to be removed ${err}`);
|
|
}
|
|
});
|
|
}
|
|
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<void>
|
|
*/
|
|
function mkdirP(fsPath) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
assert_1.ok(fsPath, 'a path argument must be provided');
|
|
yield ioUtil.mkdir(fsPath, { recursive: true });
|
|
});
|
|
}
|
|
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<string> 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.`);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
const matches = yield findInPath(tool);
|
|
if (matches && matches.length > 0) {
|
|
return matches[0];
|
|
}
|
|
return '';
|
|
});
|
|
}
|
|
exports.which = which;
|
|
/**
|
|
* Returns a list of all occurrences of the given tool on the system path.
|
|
*
|
|
* @returns Promise<string[]> the paths of the tool
|
|
*/
|
|
function findInPath(tool) {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (!tool) {
|
|
throw new Error("parameter 'tool' is required");
|
|
}
|
|
// 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(path.sep)) {
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
// find all matches
|
|
const matches = [];
|
|
for (const directory of directories) {
|
|
const filePath = yield ioUtil.tryGetExecutablePath(path.join(directory, tool), extensions);
|
|
if (filePath) {
|
|
matches.push(filePath);
|
|
}
|
|
}
|
|
return matches;
|
|
});
|
|
}
|
|
exports.findInPath = findInPath;
|
|
function readCopyOptions(options) {
|
|
const force = options.force == null ? true : options.force;
|
|
const recursive = Boolean(options.recursive);
|
|
const copySourceDirectory = options.copySourceDirectory == null
|
|
? true
|
|
: Boolean(options.copySourceDirectory);
|
|
return { force, recursive, copySourceDirectory };
|
|
}
|
|
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
|
|
|
|
/***/ }),
|
|
|
|
/***/ 610:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const stringify = __nccwpck_require__(8750);
|
|
const compile = __nccwpck_require__(9434);
|
|
const expand = __nccwpck_require__(5873);
|
|
const parse = __nccwpck_require__(6477);
|
|
|
|
/**
|
|
* Expand the given pattern or create a regex-compatible string.
|
|
*
|
|
* ```js
|
|
* const braces = require('braces');
|
|
* console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
|
|
* console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
|
|
* ```
|
|
* @param {String} `str`
|
|
* @param {Object} `options`
|
|
* @return {String}
|
|
* @api public
|
|
*/
|
|
|
|
const braces = (input, options = {}) => {
|
|
let output = [];
|
|
|
|
if (Array.isArray(input)) {
|
|
for (let pattern of input) {
|
|
let result = braces.create(pattern, options);
|
|
if (Array.isArray(result)) {
|
|
output.push(...result);
|
|
} else {
|
|
output.push(result);
|
|
}
|
|
}
|
|
} else {
|
|
output = [].concat(braces.create(input, options));
|
|
}
|
|
|
|
if (options && options.expand === true && options.nodupes === true) {
|
|
output = [...new Set(output)];
|
|
}
|
|
return output;
|
|
};
|
|
|
|
/**
|
|
* Parse the given `str` with the given `options`.
|
|
*
|
|
* ```js
|
|
* // braces.parse(pattern, [, options]);
|
|
* const ast = braces.parse('a/{b,c}/d');
|
|
* console.log(ast);
|
|
* ```
|
|
* @param {String} pattern Brace pattern to parse
|
|
* @param {Object} options
|
|
* @return {Object} Returns an AST
|
|
* @api public
|
|
*/
|
|
|
|
braces.parse = (input, options = {}) => parse(input, options);
|
|
|
|
/**
|
|
* Creates a braces string from an AST, or an AST node.
|
|
*
|
|
* ```js
|
|
* const braces = require('braces');
|
|
* let ast = braces.parse('foo/{a,b}/bar');
|
|
* console.log(stringify(ast.nodes[2])); //=> '{a,b}'
|
|
* ```
|
|
* @param {String} `input` Brace pattern or AST.
|
|
* @param {Object} `options`
|
|
* @return {Array} Returns an array of expanded values.
|
|
* @api public
|
|
*/
|
|
|
|
braces.stringify = (input, options = {}) => {
|
|
if (typeof input === 'string') {
|
|
return stringify(braces.parse(input, options), options);
|
|
}
|
|
return stringify(input, options);
|
|
};
|
|
|
|
/**
|
|
* Compiles a brace pattern into a regex-compatible, optimized string.
|
|
* This method is called by the main [braces](#braces) function by default.
|
|
*
|
|
* ```js
|
|
* const braces = require('braces');
|
|
* console.log(braces.compile('a/{b,c}/d'));
|
|
* //=> ['a/(b|c)/d']
|
|
* ```
|
|
* @param {String} `input` Brace pattern or AST.
|
|
* @param {Object} `options`
|
|
* @return {Array} Returns an array of expanded values.
|
|
* @api public
|
|
*/
|
|
|
|
braces.compile = (input, options = {}) => {
|
|
if (typeof input === 'string') {
|
|
input = braces.parse(input, options);
|
|
}
|
|
return compile(input, options);
|
|
};
|
|
|
|
/**
|
|
* Expands a brace pattern into an array. This method is called by the
|
|
* main [braces](#braces) function when `options.expand` is true. Before
|
|
* using this method it's recommended that you read the [performance notes](#performance))
|
|
* and advantages of using [.compile](#compile) instead.
|
|
*
|
|
* ```js
|
|
* const braces = require('braces');
|
|
* console.log(braces.expand('a/{b,c}/d'));
|
|
* //=> ['a/b/d', 'a/c/d'];
|
|
* ```
|
|
* @param {String} `pattern` Brace pattern
|
|
* @param {Object} `options`
|
|
* @return {Array} Returns an array of expanded values.
|
|
* @api public
|
|
*/
|
|
|
|
braces.expand = (input, options = {}) => {
|
|
if (typeof input === 'string') {
|
|
input = braces.parse(input, options);
|
|
}
|
|
|
|
let result = expand(input, options);
|
|
|
|
// filter out empty strings if specified
|
|
if (options.noempty === true) {
|
|
result = result.filter(Boolean);
|
|
}
|
|
|
|
// filter out duplicates if specified
|
|
if (options.nodupes === true) {
|
|
result = [...new Set(result)];
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
/**
|
|
* Processes a brace pattern and returns either an expanded array
|
|
* (if `options.expand` is true), a highly optimized regex-compatible string.
|
|
* This method is called by the main [braces](#braces) function.
|
|
*
|
|
* ```js
|
|
* const braces = require('braces');
|
|
* console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
|
|
* //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
|
|
* ```
|
|
* @param {String} `pattern` Brace pattern
|
|
* @param {Object} `options`
|
|
* @return {Array} Returns an array of expanded values.
|
|
* @api public
|
|
*/
|
|
|
|
braces.create = (input, options = {}) => {
|
|
if (input === '' || input.length < 3) {
|
|
return [input];
|
|
}
|
|
|
|
return options.expand !== true
|
|
? braces.compile(input, options)
|
|
: braces.expand(input, options);
|
|
};
|
|
|
|
/**
|
|
* Expose "braces"
|
|
*/
|
|
|
|
module.exports = braces;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9434:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const fill = __nccwpck_require__(6330);
|
|
const utils = __nccwpck_require__(5207);
|
|
|
|
const compile = (ast, options = {}) => {
|
|
let walk = (node, parent = {}) => {
|
|
let invalidBlock = utils.isInvalidBrace(parent);
|
|
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
let invalid = invalidBlock === true || invalidNode === true;
|
|
let prefix = options.escapeInvalid === true ? '\\' : '';
|
|
let output = '';
|
|
|
|
if (node.isOpen === true) {
|
|
return prefix + node.value;
|
|
}
|
|
if (node.isClose === true) {
|
|
return prefix + node.value;
|
|
}
|
|
|
|
if (node.type === 'open') {
|
|
return invalid ? (prefix + node.value) : '(';
|
|
}
|
|
|
|
if (node.type === 'close') {
|
|
return invalid ? (prefix + node.value) : ')';
|
|
}
|
|
|
|
if (node.type === 'comma') {
|
|
return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
|
|
}
|
|
|
|
if (node.value) {
|
|
return node.value;
|
|
}
|
|
|
|
if (node.nodes && node.ranges > 0) {
|
|
let args = utils.reduce(node.nodes);
|
|
let range = fill(...args, { ...options, wrap: false, toRegex: true });
|
|
|
|
if (range.length !== 0) {
|
|
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
|
}
|
|
}
|
|
|
|
if (node.nodes) {
|
|
for (let child of node.nodes) {
|
|
output += walk(child, node);
|
|
}
|
|
}
|
|
return output;
|
|
};
|
|
|
|
return walk(ast);
|
|
};
|
|
|
|
module.exports = compile;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8774:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = {
|
|
MAX_LENGTH: 1024 * 64,
|
|
|
|
// Digits
|
|
CHAR_0: '0', /* 0 */
|
|
CHAR_9: '9', /* 9 */
|
|
|
|
// Alphabet chars.
|
|
CHAR_UPPERCASE_A: 'A', /* A */
|
|
CHAR_LOWERCASE_A: 'a', /* a */
|
|
CHAR_UPPERCASE_Z: 'Z', /* Z */
|
|
CHAR_LOWERCASE_Z: 'z', /* z */
|
|
|
|
CHAR_LEFT_PARENTHESES: '(', /* ( */
|
|
CHAR_RIGHT_PARENTHESES: ')', /* ) */
|
|
|
|
CHAR_ASTERISK: '*', /* * */
|
|
|
|
// Non-alphabetic chars.
|
|
CHAR_AMPERSAND: '&', /* & */
|
|
CHAR_AT: '@', /* @ */
|
|
CHAR_BACKSLASH: '\\', /* \ */
|
|
CHAR_BACKTICK: '`', /* ` */
|
|
CHAR_CARRIAGE_RETURN: '\r', /* \r */
|
|
CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
|
|
CHAR_COLON: ':', /* : */
|
|
CHAR_COMMA: ',', /* , */
|
|
CHAR_DOLLAR: '$', /* . */
|
|
CHAR_DOT: '.', /* . */
|
|
CHAR_DOUBLE_QUOTE: '"', /* " */
|
|
CHAR_EQUAL: '=', /* = */
|
|
CHAR_EXCLAMATION_MARK: '!', /* ! */
|
|
CHAR_FORM_FEED: '\f', /* \f */
|
|
CHAR_FORWARD_SLASH: '/', /* / */
|
|
CHAR_HASH: '#', /* # */
|
|
CHAR_HYPHEN_MINUS: '-', /* - */
|
|
CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
|
|
CHAR_LEFT_CURLY_BRACE: '{', /* { */
|
|
CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */
|
|
CHAR_LINE_FEED: '\n', /* \n */
|
|
CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */
|
|
CHAR_PERCENT: '%', /* % */
|
|
CHAR_PLUS: '+', /* + */
|
|
CHAR_QUESTION_MARK: '?', /* ? */
|
|
CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */
|
|
CHAR_RIGHT_CURLY_BRACE: '}', /* } */
|
|
CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */
|
|
CHAR_SEMICOLON: ';', /* ; */
|
|
CHAR_SINGLE_QUOTE: '\'', /* ' */
|
|
CHAR_SPACE: ' ', /* */
|
|
CHAR_TAB: '\t', /* \t */
|
|
CHAR_UNDERSCORE: '_', /* _ */
|
|
CHAR_VERTICAL_LINE: '|', /* | */
|
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5873:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const fill = __nccwpck_require__(6330);
|
|
const stringify = __nccwpck_require__(8750);
|
|
const utils = __nccwpck_require__(5207);
|
|
|
|
const append = (queue = '', stash = '', enclose = false) => {
|
|
let result = [];
|
|
|
|
queue = [].concat(queue);
|
|
stash = [].concat(stash);
|
|
|
|
if (!stash.length) return queue;
|
|
if (!queue.length) {
|
|
return enclose ? utils.flatten(stash).map(ele => `{${ele}}`) : stash;
|
|
}
|
|
|
|
for (let item of queue) {
|
|
if (Array.isArray(item)) {
|
|
for (let value of item) {
|
|
result.push(append(value, stash, enclose));
|
|
}
|
|
} else {
|
|
for (let ele of stash) {
|
|
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
|
result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
|
|
}
|
|
}
|
|
}
|
|
return utils.flatten(result);
|
|
};
|
|
|
|
const expand = (ast, options = {}) => {
|
|
let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
|
|
|
|
let walk = (node, parent = {}) => {
|
|
node.queue = [];
|
|
|
|
let p = parent;
|
|
let q = parent.queue;
|
|
|
|
while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
|
|
p = p.parent;
|
|
q = p.queue;
|
|
}
|
|
|
|
if (node.invalid || node.dollar) {
|
|
q.push(append(q.pop(), stringify(node, options)));
|
|
return;
|
|
}
|
|
|
|
if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
|
|
q.push(append(q.pop(), ['{}']));
|
|
return;
|
|
}
|
|
|
|
if (node.nodes && node.ranges > 0) {
|
|
let args = utils.reduce(node.nodes);
|
|
|
|
if (utils.exceedsLimit(...args, options.step, rangeLimit)) {
|
|
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
|
}
|
|
|
|
let range = fill(...args, options);
|
|
if (range.length === 0) {
|
|
range = stringify(node, options);
|
|
}
|
|
|
|
q.push(append(q.pop(), range));
|
|
node.nodes = [];
|
|
return;
|
|
}
|
|
|
|
let enclose = utils.encloseBrace(node);
|
|
let queue = node.queue;
|
|
let block = node;
|
|
|
|
while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
|
|
block = block.parent;
|
|
queue = block.queue;
|
|
}
|
|
|
|
for (let i = 0; i < node.nodes.length; i++) {
|
|
let child = node.nodes[i];
|
|
|
|
if (child.type === 'comma' && node.type === 'brace') {
|
|
if (i === 1) queue.push('');
|
|
queue.push('');
|
|
continue;
|
|
}
|
|
|
|
if (child.type === 'close') {
|
|
q.push(append(q.pop(), queue, enclose));
|
|
continue;
|
|
}
|
|
|
|
if (child.value && child.type !== 'open') {
|
|
queue.push(append(queue.pop(), child.value));
|
|
continue;
|
|
}
|
|
|
|
if (child.nodes) {
|
|
walk(child, node);
|
|
}
|
|
}
|
|
|
|
return queue;
|
|
};
|
|
|
|
return utils.flatten(walk(ast));
|
|
};
|
|
|
|
module.exports = expand;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6477:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const stringify = __nccwpck_require__(8750);
|
|
|
|
/**
|
|
* Constants
|
|
*/
|
|
|
|
const {
|
|
MAX_LENGTH,
|
|
CHAR_BACKSLASH, /* \ */
|
|
CHAR_BACKTICK, /* ` */
|
|
CHAR_COMMA, /* , */
|
|
CHAR_DOT, /* . */
|
|
CHAR_LEFT_PARENTHESES, /* ( */
|
|
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
CHAR_RIGHT_SQUARE_BRACKET, /* ] */
|
|
CHAR_DOUBLE_QUOTE, /* " */
|
|
CHAR_SINGLE_QUOTE, /* ' */
|
|
CHAR_NO_BREAK_SPACE,
|
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE
|
|
} = __nccwpck_require__(8774);
|
|
|
|
/**
|
|
* parse
|
|
*/
|
|
|
|
const parse = (input, options = {}) => {
|
|
if (typeof input !== 'string') {
|
|
throw new TypeError('Expected a string');
|
|
}
|
|
|
|
let opts = options || {};
|
|
let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
if (input.length > max) {
|
|
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
|
}
|
|
|
|
let ast = { type: 'root', input, nodes: [] };
|
|
let stack = [ast];
|
|
let block = ast;
|
|
let prev = ast;
|
|
let brackets = 0;
|
|
let length = input.length;
|
|
let index = 0;
|
|
let depth = 0;
|
|
let value;
|
|
let memo = {};
|
|
|
|
/**
|
|
* Helpers
|
|
*/
|
|
|
|
const advance = () => input[index++];
|
|
const push = node => {
|
|
if (node.type === 'text' && prev.type === 'dot') {
|
|
prev.type = 'text';
|
|
}
|
|
|
|
if (prev && prev.type === 'text' && node.type === 'text') {
|
|
prev.value += node.value;
|
|
return;
|
|
}
|
|
|
|
block.nodes.push(node);
|
|
node.parent = block;
|
|
node.prev = prev;
|
|
prev = node;
|
|
return node;
|
|
};
|
|
|
|
push({ type: 'bos' });
|
|
|
|
while (index < length) {
|
|
block = stack[stack.length - 1];
|
|
value = advance();
|
|
|
|
/**
|
|
* Invalid chars
|
|
*/
|
|
|
|
if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Escaped chars
|
|
*/
|
|
|
|
if (value === CHAR_BACKSLASH) {
|
|
push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Right square bracket (literal): ']'
|
|
*/
|
|
|
|
if (value === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
push({ type: 'text', value: '\\' + value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Left square bracket: '['
|
|
*/
|
|
|
|
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
|
brackets++;
|
|
|
|
let closed = true;
|
|
let next;
|
|
|
|
while (index < length && (next = advance())) {
|
|
value += next;
|
|
|
|
if (next === CHAR_LEFT_SQUARE_BRACKET) {
|
|
brackets++;
|
|
continue;
|
|
}
|
|
|
|
if (next === CHAR_BACKSLASH) {
|
|
value += advance();
|
|
continue;
|
|
}
|
|
|
|
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
brackets--;
|
|
|
|
if (brackets === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Parentheses
|
|
*/
|
|
|
|
if (value === CHAR_LEFT_PARENTHESES) {
|
|
block = push({ type: 'paren', nodes: [] });
|
|
stack.push(block);
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
if (value === CHAR_RIGHT_PARENTHESES) {
|
|
if (block.type !== 'paren') {
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
block = stack.pop();
|
|
push({ type: 'text', value });
|
|
block = stack[stack.length - 1];
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Quotes: '|"|`
|
|
*/
|
|
|
|
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
|
let open = value;
|
|
let next;
|
|
|
|
if (options.keepQuotes !== true) {
|
|
value = '';
|
|
}
|
|
|
|
while (index < length && (next = advance())) {
|
|
if (next === CHAR_BACKSLASH) {
|
|
value += next + advance();
|
|
continue;
|
|
}
|
|
|
|
if (next === open) {
|
|
if (options.keepQuotes === true) value += next;
|
|
break;
|
|
}
|
|
|
|
value += next;
|
|
}
|
|
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Left curly brace: '{'
|
|
*/
|
|
|
|
if (value === CHAR_LEFT_CURLY_BRACE) {
|
|
depth++;
|
|
|
|
let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
|
let brace = {
|
|
type: 'brace',
|
|
open: true,
|
|
close: false,
|
|
dollar,
|
|
depth,
|
|
commas: 0,
|
|
ranges: 0,
|
|
nodes: []
|
|
};
|
|
|
|
block = push(brace);
|
|
stack.push(block);
|
|
push({ type: 'open', value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Right curly brace: '}'
|
|
*/
|
|
|
|
if (value === CHAR_RIGHT_CURLY_BRACE) {
|
|
if (block.type !== 'brace') {
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
let type = 'close';
|
|
block = stack.pop();
|
|
block.close = true;
|
|
|
|
push({ type, value });
|
|
depth--;
|
|
|
|
block = stack[stack.length - 1];
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Comma: ','
|
|
*/
|
|
|
|
if (value === CHAR_COMMA && depth > 0) {
|
|
if (block.ranges > 0) {
|
|
block.ranges = 0;
|
|
let open = block.nodes.shift();
|
|
block.nodes = [open, { type: 'text', value: stringify(block) }];
|
|
}
|
|
|
|
push({ type: 'comma', value });
|
|
block.commas++;
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Dot: '.'
|
|
*/
|
|
|
|
if (value === CHAR_DOT && depth > 0 && block.commas === 0) {
|
|
let siblings = block.nodes;
|
|
|
|
if (depth === 0 || siblings.length === 0) {
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
if (prev.type === 'dot') {
|
|
block.range = [];
|
|
prev.value += value;
|
|
prev.type = 'range';
|
|
|
|
if (block.nodes.length !== 3 && block.nodes.length !== 5) {
|
|
block.invalid = true;
|
|
block.ranges = 0;
|
|
prev.type = 'text';
|
|
continue;
|
|
}
|
|
|
|
block.ranges++;
|
|
block.args = [];
|
|
continue;
|
|
}
|
|
|
|
if (prev.type === 'range') {
|
|
siblings.pop();
|
|
|
|
let before = siblings[siblings.length - 1];
|
|
before.value += prev.value + value;
|
|
prev = before;
|
|
block.ranges--;
|
|
continue;
|
|
}
|
|
|
|
push({ type: 'dot', value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Text
|
|
*/
|
|
|
|
push({ type: 'text', value });
|
|
}
|
|
|
|
// Mark imbalanced braces and brackets as invalid
|
|
do {
|
|
block = stack.pop();
|
|
|
|
if (block.type !== 'root') {
|
|
block.nodes.forEach(node => {
|
|
if (!node.nodes) {
|
|
if (node.type === 'open') node.isOpen = true;
|
|
if (node.type === 'close') node.isClose = true;
|
|
if (!node.nodes) node.type = 'text';
|
|
node.invalid = true;
|
|
}
|
|
});
|
|
|
|
// get the location of the block on parent.nodes (block's siblings)
|
|
let parent = stack[stack.length - 1];
|
|
let index = parent.nodes.indexOf(block);
|
|
// replace the (invalid) block with it's nodes
|
|
parent.nodes.splice(index, 1, ...block.nodes);
|
|
}
|
|
} while (stack.length > 0);
|
|
|
|
push({ type: 'eos' });
|
|
return ast;
|
|
};
|
|
|
|
module.exports = parse;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8750:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const utils = __nccwpck_require__(5207);
|
|
|
|
module.exports = (ast, options = {}) => {
|
|
let stringify = (node, parent = {}) => {
|
|
let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
|
let invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
let output = '';
|
|
|
|
if (node.value) {
|
|
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
|
|
return '\\' + node.value;
|
|
}
|
|
return node.value;
|
|
}
|
|
|
|
if (node.value) {
|
|
return node.value;
|
|
}
|
|
|
|
if (node.nodes) {
|
|
for (let child of node.nodes) {
|
|
output += stringify(child);
|
|
}
|
|
}
|
|
return output;
|
|
};
|
|
|
|
return stringify(ast);
|
|
};
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5207:
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
exports.isInteger = num => {
|
|
if (typeof num === 'number') {
|
|
return Number.isInteger(num);
|
|
}
|
|
if (typeof num === 'string' && num.trim() !== '') {
|
|
return Number.isInteger(Number(num));
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Find a node of the given type
|
|
*/
|
|
|
|
exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
|
|
|
/**
|
|
* Find a node of the given type
|
|
*/
|
|
|
|
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
|
if (limit === false) return false;
|
|
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
|
return ((Number(max) - Number(min)) / Number(step)) >= limit;
|
|
};
|
|
|
|
/**
|
|
* Escape the given node with '\\' before node.value
|
|
*/
|
|
|
|
exports.escapeNode = (block, n = 0, type) => {
|
|
let node = block.nodes[n];
|
|
if (!node) return;
|
|
|
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
|
if (node.escaped !== true) {
|
|
node.value = '\\' + node.value;
|
|
node.escaped = true;
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns true if the given brace node should be enclosed in literal braces
|
|
*/
|
|
|
|
exports.encloseBrace = node => {
|
|
if (node.type !== 'brace') return false;
|
|
if ((node.commas >> 0 + node.ranges >> 0) === 0) {
|
|
node.invalid = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Returns true if a brace node is invalid.
|
|
*/
|
|
|
|
exports.isInvalidBrace = block => {
|
|
if (block.type !== 'brace') return false;
|
|
if (block.invalid === true || block.dollar) return true;
|
|
if ((block.commas >> 0 + block.ranges >> 0) === 0) {
|
|
block.invalid = true;
|
|
return true;
|
|
}
|
|
if (block.open !== true || block.close !== true) {
|
|
block.invalid = true;
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Returns true if a node is an open or close node
|
|
*/
|
|
|
|
exports.isOpenOrClose = node => {
|
|
if (node.type === 'open' || node.type === 'close') {
|
|
return true;
|
|
}
|
|
return node.open === true || node.close === true;
|
|
};
|
|
|
|
/**
|
|
* Reduce an array of text nodes.
|
|
*/
|
|
|
|
exports.reduce = nodes => nodes.reduce((acc, node) => {
|
|
if (node.type === 'text') acc.push(node.value);
|
|
if (node.type === 'range') node.type = 'text';
|
|
return acc;
|
|
}, []);
|
|
|
|
/**
|
|
* Flatten an array
|
|
*/
|
|
|
|
exports.flatten = (...args) => {
|
|
const result = [];
|
|
const flat = arr => {
|
|
for (let i = 0; i < arr.length; i++) {
|
|
let ele = arr[i];
|
|
Array.isArray(ele) ? flat(ele, result) : ele !== void 0 && result.push(ele);
|
|
}
|
|
return result;
|
|
};
|
|
flat(args);
|
|
return result;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6330:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
/*!
|
|
* fill-range <https://github.com/jonschlinkert/fill-range>
|
|
*
|
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
* Licensed under the MIT License.
|
|
*/
|
|
|
|
|
|
|
|
const util = __nccwpck_require__(3837);
|
|
const toRegexRange = __nccwpck_require__(1861);
|
|
|
|
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
|
|
const transform = toNumber => {
|
|
return value => toNumber === true ? Number(value) : String(value);
|
|
};
|
|
|
|
const isValidValue = value => {
|
|
return typeof value === 'number' || (typeof value === 'string' && value !== '');
|
|
};
|
|
|
|
const isNumber = num => Number.isInteger(+num);
|
|
|
|
const zeros = input => {
|
|
let value = `${input}`;
|
|
let index = -1;
|
|
if (value[0] === '-') value = value.slice(1);
|
|
if (value === '0') return false;
|
|
while (value[++index] === '0');
|
|
return index > 0;
|
|
};
|
|
|
|
const stringify = (start, end, options) => {
|
|
if (typeof start === 'string' || typeof end === 'string') {
|
|
return true;
|
|
}
|
|
return options.stringify === true;
|
|
};
|
|
|
|
const pad = (input, maxLength, toNumber) => {
|
|
if (maxLength > 0) {
|
|
let dash = input[0] === '-' ? '-' : '';
|
|
if (dash) input = input.slice(1);
|
|
input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0'));
|
|
}
|
|
if (toNumber === false) {
|
|
return String(input);
|
|
}
|
|
return input;
|
|
};
|
|
|
|
const toMaxLen = (input, maxLength) => {
|
|
let negative = input[0] === '-' ? '-' : '';
|
|
if (negative) {
|
|
input = input.slice(1);
|
|
maxLength--;
|
|
}
|
|
while (input.length < maxLength) input = '0' + input;
|
|
return negative ? ('-' + input) : input;
|
|
};
|
|
|
|
const toSequence = (parts, options) => {
|
|
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
|
|
let prefix = options.capture ? '' : '?:';
|
|
let positives = '';
|
|
let negatives = '';
|
|
let result;
|
|
|
|
if (parts.positives.length) {
|
|
positives = parts.positives.join('|');
|
|
}
|
|
|
|
if (parts.negatives.length) {
|
|
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
|
}
|
|
|
|
if (positives && negatives) {
|
|
result = `${positives}|${negatives}`;
|
|
} else {
|
|
result = positives || negatives;
|
|
}
|
|
|
|
if (options.wrap) {
|
|
return `(${prefix}${result})`;
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
const toRange = (a, b, isNumbers, options) => {
|
|
if (isNumbers) {
|
|
return toRegexRange(a, b, { wrap: false, ...options });
|
|
}
|
|
|
|
let start = String.fromCharCode(a);
|
|
if (a === b) return start;
|
|
|
|
let stop = String.fromCharCode(b);
|
|
return `[${start}-${stop}]`;
|
|
};
|
|
|
|
const toRegex = (start, end, options) => {
|
|
if (Array.isArray(start)) {
|
|
let wrap = options.wrap === true;
|
|
let prefix = options.capture ? '' : '?:';
|
|
return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
|
|
}
|
|
return toRegexRange(start, end, options);
|
|
};
|
|
|
|
const rangeError = (...args) => {
|
|
return new RangeError('Invalid range arguments: ' + util.inspect(...args));
|
|
};
|
|
|
|
const invalidRange = (start, end, options) => {
|
|
if (options.strictRanges === true) throw rangeError([start, end]);
|
|
return [];
|
|
};
|
|
|
|
const invalidStep = (step, options) => {
|
|
if (options.strictRanges === true) {
|
|
throw new TypeError(`Expected step "${step}" to be a number`);
|
|
}
|
|
return [];
|
|
};
|
|
|
|
const fillNumbers = (start, end, step = 1, options = {}) => {
|
|
let a = Number(start);
|
|
let b = Number(end);
|
|
|
|
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
if (options.strictRanges === true) throw rangeError([start, end]);
|
|
return [];
|
|
}
|
|
|
|
// fix negative zero
|
|
if (a === 0) a = 0;
|
|
if (b === 0) b = 0;
|
|
|
|
let descending = a > b;
|
|
let startString = String(start);
|
|
let endString = String(end);
|
|
let stepString = String(step);
|
|
step = Math.max(Math.abs(step), 1);
|
|
|
|
let padded = zeros(startString) || zeros(endString) || zeros(stepString);
|
|
let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
|
|
let toNumber = padded === false && stringify(start, end, options) === false;
|
|
let format = options.transform || transform(toNumber);
|
|
|
|
if (options.toRegex && step === 1) {
|
|
return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
|
|
}
|
|
|
|
let parts = { negatives: [], positives: [] };
|
|
let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
|
|
let range = [];
|
|
let index = 0;
|
|
|
|
while (descending ? a >= b : a <= b) {
|
|
if (options.toRegex === true && step > 1) {
|
|
push(a);
|
|
} else {
|
|
range.push(pad(format(a, index), maxLen, toNumber));
|
|
}
|
|
a = descending ? a - step : a + step;
|
|
index++;
|
|
}
|
|
|
|
if (options.toRegex === true) {
|
|
return step > 1
|
|
? toSequence(parts, options)
|
|
: toRegex(range, null, { wrap: false, ...options });
|
|
}
|
|
|
|
return range;
|
|
};
|
|
|
|
const fillLetters = (start, end, step = 1, options = {}) => {
|
|
if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
|
|
return invalidRange(start, end, options);
|
|
}
|
|
|
|
|
|
let format = options.transform || (val => String.fromCharCode(val));
|
|
let a = `${start}`.charCodeAt(0);
|
|
let b = `${end}`.charCodeAt(0);
|
|
|
|
let descending = a > b;
|
|
let min = Math.min(a, b);
|
|
let max = Math.max(a, b);
|
|
|
|
if (options.toRegex && step === 1) {
|
|
return toRange(min, max, false, options);
|
|
}
|
|
|
|
let range = [];
|
|
let index = 0;
|
|
|
|
while (descending ? a >= b : a <= b) {
|
|
range.push(format(a, index));
|
|
a = descending ? a - step : a + step;
|
|
index++;
|
|
}
|
|
|
|
if (options.toRegex === true) {
|
|
return toRegex(range, null, { wrap: false, options });
|
|
}
|
|
|
|
return range;
|
|
};
|
|
|
|
const fill = (start, end, step, options = {}) => {
|
|
if (end == null && isValidValue(start)) {
|
|
return [start];
|
|
}
|
|
|
|
if (!isValidValue(start) || !isValidValue(end)) {
|
|
return invalidRange(start, end, options);
|
|
}
|
|
|
|
if (typeof step === 'function') {
|
|
return fill(start, end, 1, { transform: step });
|
|
}
|
|
|
|
if (isObject(step)) {
|
|
return fill(start, end, 0, step);
|
|
}
|
|
|
|
let opts = { ...options };
|
|
if (opts.capture === true) opts.wrap = true;
|
|
step = step || opts.step || 1;
|
|
|
|
if (!isNumber(step)) {
|
|
if (step != null && !isObject(step)) return invalidStep(step, opts);
|
|
return fill(start, end, 1, step);
|
|
}
|
|
|
|
if (isNumber(start) && isNumber(end)) {
|
|
return fillNumbers(start, end, step, opts);
|
|
}
|
|
|
|
return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
|
|
};
|
|
|
|
module.exports = fill;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5680:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
/*!
|
|
* is-number <https://github.com/jonschlinkert/is-number>
|
|
*
|
|
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
* Released under the MIT License.
|
|
*/
|
|
|
|
|
|
|
|
module.exports = function(num) {
|
|
if (typeof num === 'number') {
|
|
return num - num === 0;
|
|
}
|
|
if (typeof num === 'string' && num.trim() !== '') {
|
|
return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6228:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const util = __nccwpck_require__(3837);
|
|
const braces = __nccwpck_require__(610);
|
|
const picomatch = __nccwpck_require__(8569);
|
|
const utils = __nccwpck_require__(479);
|
|
const isEmptyString = val => val === '' || val === './';
|
|
|
|
/**
|
|
* Returns an array of strings that match one or more glob patterns.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm(list, patterns[, options]);
|
|
*
|
|
* console.log(mm(['a.js', 'a.txt'], ['*.js']));
|
|
* //=> [ 'a.js' ]
|
|
* ```
|
|
* @param {String|Array<string>} `list` List of strings to match.
|
|
* @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
|
|
* @param {Object} `options` See available [options](#options)
|
|
* @return {Array} Returns an array of matches
|
|
* @summary false
|
|
* @api public
|
|
*/
|
|
|
|
const micromatch = (list, patterns, options) => {
|
|
patterns = [].concat(patterns);
|
|
list = [].concat(list);
|
|
|
|
let omit = new Set();
|
|
let keep = new Set();
|
|
let items = new Set();
|
|
let negatives = 0;
|
|
|
|
let onResult = state => {
|
|
items.add(state.output);
|
|
if (options && options.onResult) {
|
|
options.onResult(state);
|
|
}
|
|
};
|
|
|
|
for (let i = 0; i < patterns.length; i++) {
|
|
let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
|
|
let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
|
|
if (negated) negatives++;
|
|
|
|
for (let item of list) {
|
|
let matched = isMatch(item, true);
|
|
|
|
let match = negated ? !matched.isMatch : matched.isMatch;
|
|
if (!match) continue;
|
|
|
|
if (negated) {
|
|
omit.add(matched.output);
|
|
} else {
|
|
omit.delete(matched.output);
|
|
keep.add(matched.output);
|
|
}
|
|
}
|
|
}
|
|
|
|
let result = negatives === patterns.length ? [...items] : [...keep];
|
|
let matches = result.filter(item => !omit.has(item));
|
|
|
|
if (options && matches.length === 0) {
|
|
if (options.failglob === true) {
|
|
throw new Error(`No matches found for "${patterns.join(', ')}"`);
|
|
}
|
|
|
|
if (options.nonull === true || options.nullglob === true) {
|
|
return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
|
|
}
|
|
}
|
|
|
|
return matches;
|
|
};
|
|
|
|
/**
|
|
* Backwards compatibility
|
|
*/
|
|
|
|
micromatch.match = micromatch;
|
|
|
|
/**
|
|
* Returns a matcher function from the given glob `pattern` and `options`.
|
|
* The returned function takes a string to match as its only argument and returns
|
|
* true if the string is a match.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.matcher(pattern[, options]);
|
|
*
|
|
* const isMatch = mm.matcher('*.!(*a)');
|
|
* console.log(isMatch('a.a')); //=> false
|
|
* console.log(isMatch('a.b')); //=> true
|
|
* ```
|
|
* @param {String} `pattern` Glob pattern
|
|
* @param {Object} `options`
|
|
* @return {Function} Returns a matcher function.
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.matcher = (pattern, options) => picomatch(pattern, options);
|
|
|
|
/**
|
|
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.isMatch(string, patterns[, options]);
|
|
*
|
|
* console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
* console.log(mm.isMatch('a.a', 'b.*')); //=> false
|
|
* ```
|
|
* @param {String} `str` The string to test.
|
|
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
|
* @param {Object} `[options]` See available [options](#options).
|
|
* @return {Boolean} Returns true if any patterns match `str`
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
|
|
/**
|
|
* Backwards compatibility
|
|
*/
|
|
|
|
micromatch.any = micromatch.isMatch;
|
|
|
|
/**
|
|
* Returns a list of strings that _**do not match any**_ of the given `patterns`.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.not(list, patterns[, options]);
|
|
*
|
|
* console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
|
|
* //=> ['b.b', 'c.c']
|
|
* ```
|
|
* @param {Array} `list` Array of strings to match.
|
|
* @param {String|Array} `patterns` One or more glob pattern to use for matching.
|
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
|
* @return {Array} Returns an array of strings that **do not match** the given patterns.
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.not = (list, patterns, options = {}) => {
|
|
patterns = [].concat(patterns).map(String);
|
|
let result = new Set();
|
|
let items = [];
|
|
|
|
let onResult = state => {
|
|
if (options.onResult) options.onResult(state);
|
|
items.push(state.output);
|
|
};
|
|
|
|
let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
|
|
|
|
for (let item of items) {
|
|
if (!matches.has(item)) {
|
|
result.add(item);
|
|
}
|
|
}
|
|
return [...result];
|
|
};
|
|
|
|
/**
|
|
* Returns true if the given `string` contains the given pattern. Similar
|
|
* to [.isMatch](#isMatch) but the pattern can match any part of the string.
|
|
*
|
|
* ```js
|
|
* var mm = require('micromatch');
|
|
* // mm.contains(string, pattern[, options]);
|
|
*
|
|
* console.log(mm.contains('aa/bb/cc', '*b'));
|
|
* //=> true
|
|
* console.log(mm.contains('aa/bb/cc', '*d'));
|
|
* //=> false
|
|
* ```
|
|
* @param {String} `str` The string to match.
|
|
* @param {String|Array} `patterns` Glob pattern to use for matching.
|
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
|
* @return {Boolean} Returns true if any of the patterns matches any part of `str`.
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.contains = (str, pattern, options) => {
|
|
if (typeof str !== 'string') {
|
|
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
|
|
}
|
|
|
|
if (Array.isArray(pattern)) {
|
|
return pattern.some(p => micromatch.contains(str, p, options));
|
|
}
|
|
|
|
if (typeof pattern === 'string') {
|
|
if (isEmptyString(str) || isEmptyString(pattern)) {
|
|
return false;
|
|
}
|
|
|
|
if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return micromatch.isMatch(str, pattern, { ...options, contains: true });
|
|
};
|
|
|
|
/**
|
|
* Filter the keys of the given object with the given `glob` pattern
|
|
* and `options`. Does not attempt to match nested keys. If you need this feature,
|
|
* use [glob-object][] instead.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.matchKeys(object, patterns[, options]);
|
|
*
|
|
* const obj = { aa: 'a', ab: 'b', ac: 'c' };
|
|
* console.log(mm.matchKeys(obj, '*b'));
|
|
* //=> { ab: 'b' }
|
|
* ```
|
|
* @param {Object} `object` The object with keys to filter.
|
|
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
|
* @return {Object} Returns an object with only keys that match the given patterns.
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.matchKeys = (obj, patterns, options) => {
|
|
if (!utils.isObject(obj)) {
|
|
throw new TypeError('Expected the first argument to be an object');
|
|
}
|
|
let keys = micromatch(Object.keys(obj), patterns, options);
|
|
let res = {};
|
|
for (let key of keys) res[key] = obj[key];
|
|
return res;
|
|
};
|
|
|
|
/**
|
|
* Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.some(list, patterns[, options]);
|
|
*
|
|
* console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
|
|
* // true
|
|
* console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
|
|
* // false
|
|
* ```
|
|
* @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
|
|
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
|
* @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.some = (list, patterns, options) => {
|
|
let items = [].concat(list);
|
|
|
|
for (let pattern of [].concat(patterns)) {
|
|
let isMatch = picomatch(String(pattern), options);
|
|
if (items.some(item => isMatch(item))) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Returns true if every string in the given `list` matches
|
|
* any of the given glob `patterns`.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.every(list, patterns[, options]);
|
|
*
|
|
* console.log(mm.every('foo.js', ['foo.js']));
|
|
* // true
|
|
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
|
|
* // true
|
|
* console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
|
|
* // false
|
|
* console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
|
|
* // false
|
|
* ```
|
|
* @param {String|Array} `list` The string or array of strings to test.
|
|
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
|
* @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.every = (list, patterns, options) => {
|
|
let items = [].concat(list);
|
|
|
|
for (let pattern of [].concat(patterns)) {
|
|
let isMatch = picomatch(String(pattern), options);
|
|
if (!items.every(item => isMatch(item))) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
/**
|
|
* Returns true if **all** of the given `patterns` match
|
|
* the specified string.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.all(string, patterns[, options]);
|
|
*
|
|
* console.log(mm.all('foo.js', ['foo.js']));
|
|
* // true
|
|
*
|
|
* console.log(mm.all('foo.js', ['*.js', '!foo.js']));
|
|
* // false
|
|
*
|
|
* console.log(mm.all('foo.js', ['*.js', 'foo.js']));
|
|
* // true
|
|
*
|
|
* console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
|
|
* // true
|
|
* ```
|
|
* @param {String|Array} `str` The string to test.
|
|
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
|
* @return {Boolean} Returns true if any patterns match `str`
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.all = (str, patterns, options) => {
|
|
if (typeof str !== 'string') {
|
|
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
|
|
}
|
|
|
|
return [].concat(patterns).every(p => picomatch(p, options)(str));
|
|
};
|
|
|
|
/**
|
|
* Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.capture(pattern, string[, options]);
|
|
*
|
|
* console.log(mm.capture('test/*.js', 'test/foo.js'));
|
|
* //=> ['foo']
|
|
* console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
|
* //=> null
|
|
* ```
|
|
* @param {String} `glob` Glob pattern to use for matching.
|
|
* @param {String} `input` String to match
|
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
|
* @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.capture = (glob, input, options) => {
|
|
let posix = utils.isWindows(options);
|
|
let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
|
|
let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
|
|
|
|
if (match) {
|
|
return match.slice(1).map(v => v === void 0 ? '' : v);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Create a regular expression from the given glob `pattern`.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* // mm.makeRe(pattern[, options]);
|
|
*
|
|
* console.log(mm.makeRe('*.js'));
|
|
* //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
|
|
* ```
|
|
* @param {String} `pattern` A glob pattern to convert to regex.
|
|
* @param {Object} `options`
|
|
* @return {RegExp} Returns a regex created from the given pattern.
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.makeRe = (...args) => picomatch.makeRe(...args);
|
|
|
|
/**
|
|
* Scan a glob pattern to separate the pattern into segments. Used
|
|
* by the [split](#split) method.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* const state = mm.scan(pattern[, options]);
|
|
* ```
|
|
* @param {String} `pattern`
|
|
* @param {Object} `options`
|
|
* @return {Object} Returns an object with
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.scan = (...args) => picomatch.scan(...args);
|
|
|
|
/**
|
|
* Parse a glob pattern to create the source string for a regular
|
|
* expression.
|
|
*
|
|
* ```js
|
|
* const mm = require('micromatch');
|
|
* const state = mm.parse(pattern[, options]);
|
|
* ```
|
|
* @param {String} `glob`
|
|
* @param {Object} `options`
|
|
* @return {Object} Returns an object with useful properties and output to be used as regex source string.
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.parse = (patterns, options) => {
|
|
let res = [];
|
|
for (let pattern of [].concat(patterns || [])) {
|
|
for (let str of braces(String(pattern), options)) {
|
|
res.push(picomatch.parse(str, options));
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
|
|
/**
|
|
* Process the given brace `pattern`.
|
|
*
|
|
* ```js
|
|
* const { braces } = require('micromatch');
|
|
* console.log(braces('foo/{a,b,c}/bar'));
|
|
* //=> [ 'foo/(a|b|c)/bar' ]
|
|
*
|
|
* console.log(braces('foo/{a,b,c}/bar', { expand: true }));
|
|
* //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
|
|
* ```
|
|
* @param {String} `pattern` String with brace pattern to process.
|
|
* @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
|
|
* @return {Array}
|
|
* @api public
|
|
*/
|
|
|
|
micromatch.braces = (pattern, options) => {
|
|
if (typeof pattern !== 'string') throw new TypeError('Expected a string');
|
|
if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
|
|
return [pattern];
|
|
}
|
|
return braces(pattern, options);
|
|
};
|
|
|
|
/**
|
|
* Expand braces
|
|
*/
|
|
|
|
micromatch.braceExpand = (pattern, options) => {
|
|
if (typeof pattern !== 'string') throw new TypeError('Expected a string');
|
|
return micromatch.braces(pattern, { ...options, expand: true });
|
|
};
|
|
|
|
/**
|
|
* Expose micromatch
|
|
*/
|
|
|
|
module.exports = micromatch;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8569:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
module.exports = __nccwpck_require__(3322);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6099:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const path = __nccwpck_require__(1017);
|
|
const WIN_SLASH = '\\\\/';
|
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
|
|
/**
|
|
* Posix glob regex
|
|
*/
|
|
|
|
const DOT_LITERAL = '\\.';
|
|
const PLUS_LITERAL = '\\+';
|
|
const QMARK_LITERAL = '\\?';
|
|
const SLASH_LITERAL = '\\/';
|
|
const ONE_CHAR = '(?=.)';
|
|
const QMARK = '[^/]';
|
|
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
const STAR = `${QMARK}*?`;
|
|
|
|
const POSIX_CHARS = {
|
|
DOT_LITERAL,
|
|
PLUS_LITERAL,
|
|
QMARK_LITERAL,
|
|
SLASH_LITERAL,
|
|
ONE_CHAR,
|
|
QMARK,
|
|
END_ANCHOR,
|
|
DOTS_SLASH,
|
|
NO_DOT,
|
|
NO_DOTS,
|
|
NO_DOT_SLASH,
|
|
NO_DOTS_SLASH,
|
|
QMARK_NO_DOT,
|
|
STAR,
|
|
START_ANCHOR
|
|
};
|
|
|
|
/**
|
|
* Windows glob regex
|
|
*/
|
|
|
|
const WINDOWS_CHARS = {
|
|
...POSIX_CHARS,
|
|
|
|
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
QMARK: WIN_NO_SLASH,
|
|
STAR: `${WIN_NO_SLASH}*?`,
|
|
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
};
|
|
|
|
/**
|
|
* POSIX Bracket Regex
|
|
*/
|
|
|
|
const POSIX_REGEX_SOURCE = {
|
|
alnum: 'a-zA-Z0-9',
|
|
alpha: 'a-zA-Z',
|
|
ascii: '\\x00-\\x7F',
|
|
blank: ' \\t',
|
|
cntrl: '\\x00-\\x1F\\x7F',
|
|
digit: '0-9',
|
|
graph: '\\x21-\\x7E',
|
|
lower: 'a-z',
|
|
print: '\\x20-\\x7E ',
|
|
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
space: ' \\t\\r\\n\\v\\f',
|
|
upper: 'A-Z',
|
|
word: 'A-Za-z0-9_',
|
|
xdigit: 'A-Fa-f0-9'
|
|
};
|
|
|
|
module.exports = {
|
|
MAX_LENGTH: 1024 * 64,
|
|
POSIX_REGEX_SOURCE,
|
|
|
|
// regular expressions
|
|
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
|
|
// Replace globs with equivalent patterns to reduce parsing time.
|
|
REPLACEMENTS: {
|
|
'***': '*',
|
|
'**/**': '**',
|
|
'**/**/**': '**'
|
|
},
|
|
|
|
// Digits
|
|
CHAR_0: 48, /* 0 */
|
|
CHAR_9: 57, /* 9 */
|
|
|
|
// Alphabet chars.
|
|
CHAR_UPPERCASE_A: 65, /* A */
|
|
CHAR_LOWERCASE_A: 97, /* a */
|
|
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
CHAR_LOWERCASE_Z: 122, /* z */
|
|
|
|
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
|
|
CHAR_ASTERISK: 42, /* * */
|
|
|
|
// Non-alphabetic chars.
|
|
CHAR_AMPERSAND: 38, /* & */
|
|
CHAR_AT: 64, /* @ */
|
|
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
CHAR_COLON: 58, /* : */
|
|
CHAR_COMMA: 44, /* , */
|
|
CHAR_DOT: 46, /* . */
|
|
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
CHAR_EQUAL: 61, /* = */
|
|
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
CHAR_FORM_FEED: 12, /* \f */
|
|
CHAR_FORWARD_SLASH: 47, /* / */
|
|
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
CHAR_HASH: 35, /* # */
|
|
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
CHAR_LINE_FEED: 10, /* \n */
|
|
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
CHAR_PERCENT: 37, /* % */
|
|
CHAR_PLUS: 43, /* + */
|
|
CHAR_QUESTION_MARK: 63, /* ? */
|
|
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
CHAR_SEMICOLON: 59, /* ; */
|
|
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
CHAR_SPACE: 32, /* */
|
|
CHAR_TAB: 9, /* \t */
|
|
CHAR_UNDERSCORE: 95, /* _ */
|
|
CHAR_VERTICAL_LINE: 124, /* | */
|
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
|
|
SEP: path.sep,
|
|
|
|
/**
|
|
* Create EXTGLOB_CHARS
|
|
*/
|
|
|
|
extglobChars(chars) {
|
|
return {
|
|
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
'@': { type: 'at', open: '(?:', close: ')' }
|
|
};
|
|
},
|
|
|
|
/**
|
|
* Create GLOB_CHARS
|
|
*/
|
|
|
|
globChars(win32) {
|
|
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
}
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2139:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const constants = __nccwpck_require__(6099);
|
|
const utils = __nccwpck_require__(479);
|
|
|
|
/**
|
|
* Constants
|
|
*/
|
|
|
|
const {
|
|
MAX_LENGTH,
|
|
POSIX_REGEX_SOURCE,
|
|
REGEX_NON_SPECIAL_CHARS,
|
|
REGEX_SPECIAL_CHARS_BACKREF,
|
|
REPLACEMENTS
|
|
} = constants;
|
|
|
|
/**
|
|
* Helpers
|
|
*/
|
|
|
|
const expandRange = (args, options) => {
|
|
if (typeof options.expandRange === 'function') {
|
|
return options.expandRange(...args, options);
|
|
}
|
|
|
|
args.sort();
|
|
const value = `[${args.join('-')}]`;
|
|
|
|
try {
|
|
/* eslint-disable-next-line no-new */
|
|
new RegExp(value);
|
|
} catch (ex) {
|
|
return args.map(v => utils.escapeRegex(v)).join('..');
|
|
}
|
|
|
|
return value;
|
|
};
|
|
|
|
/**
|
|
* Create the message for a syntax error
|
|
*/
|
|
|
|
const syntaxError = (type, char) => {
|
|
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
};
|
|
|
|
/**
|
|
* Parse the given input string.
|
|
* @param {String} input
|
|
* @param {Object} options
|
|
* @return {Object}
|
|
*/
|
|
|
|
const parse = (input, options) => {
|
|
if (typeof input !== 'string') {
|
|
throw new TypeError('Expected a string');
|
|
}
|
|
|
|
input = REPLACEMENTS[input] || input;
|
|
|
|
const opts = { ...options };
|
|
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
|
|
let len = input.length;
|
|
if (len > max) {
|
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
}
|
|
|
|
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
const tokens = [bos];
|
|
|
|
const capture = opts.capture ? '' : '?:';
|
|
const win32 = utils.isWindows(options);
|
|
|
|
// create constants based on platform, for windows or posix
|
|
const PLATFORM_CHARS = constants.globChars(win32);
|
|
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
|
|
const {
|
|
DOT_LITERAL,
|
|
PLUS_LITERAL,
|
|
SLASH_LITERAL,
|
|
ONE_CHAR,
|
|
DOTS_SLASH,
|
|
NO_DOT,
|
|
NO_DOT_SLASH,
|
|
NO_DOTS_SLASH,
|
|
QMARK,
|
|
QMARK_NO_DOT,
|
|
STAR,
|
|
START_ANCHOR
|
|
} = PLATFORM_CHARS;
|
|
|
|
const globstar = opts => {
|
|
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
};
|
|
|
|
const nodot = opts.dot ? '' : NO_DOT;
|
|
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
|
|
if (opts.capture) {
|
|
star = `(${star})`;
|
|
}
|
|
|
|
// minimatch options support
|
|
if (typeof opts.noext === 'boolean') {
|
|
opts.noextglob = opts.noext;
|
|
}
|
|
|
|
const state = {
|
|
input,
|
|
index: -1,
|
|
start: 0,
|
|
dot: opts.dot === true,
|
|
consumed: '',
|
|
output: '',
|
|
prefix: '',
|
|
backtrack: false,
|
|
negated: false,
|
|
brackets: 0,
|
|
braces: 0,
|
|
parens: 0,
|
|
quotes: 0,
|
|
globstar: false,
|
|
tokens
|
|
};
|
|
|
|
input = utils.removePrefix(input, state);
|
|
len = input.length;
|
|
|
|
const extglobs = [];
|
|
const braces = [];
|
|
const stack = [];
|
|
let prev = bos;
|
|
let value;
|
|
|
|
/**
|
|
* Tokenizing helpers
|
|
*/
|
|
|
|
const eos = () => state.index === len - 1;
|
|
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
const advance = state.advance = () => input[++state.index] || '';
|
|
const remaining = () => input.slice(state.index + 1);
|
|
const consume = (value = '', num = 0) => {
|
|
state.consumed += value;
|
|
state.index += num;
|
|
};
|
|
|
|
const append = token => {
|
|
state.output += token.output != null ? token.output : token.value;
|
|
consume(token.value);
|
|
};
|
|
|
|
const negate = () => {
|
|
let count = 1;
|
|
|
|
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
advance();
|
|
state.start++;
|
|
count++;
|
|
}
|
|
|
|
if (count % 2 === 0) {
|
|
return false;
|
|
}
|
|
|
|
state.negated = true;
|
|
state.start++;
|
|
return true;
|
|
};
|
|
|
|
const increment = type => {
|
|
state[type]++;
|
|
stack.push(type);
|
|
};
|
|
|
|
const decrement = type => {
|
|
state[type]--;
|
|
stack.pop();
|
|
};
|
|
|
|
/**
|
|
* Push tokens onto the tokens array. This helper speeds up
|
|
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
* and 2) helping us avoid creating extra tokens when consecutive
|
|
* characters are plain text. This improves performance and simplifies
|
|
* lookbehinds.
|
|
*/
|
|
|
|
const push = tok => {
|
|
if (prev.type === 'globstar') {
|
|
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
|
|
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
state.output = state.output.slice(0, -prev.output.length);
|
|
prev.type = 'star';
|
|
prev.value = '*';
|
|
prev.output = star;
|
|
state.output += prev.output;
|
|
}
|
|
}
|
|
|
|
if (extglobs.length && tok.type !== 'paren') {
|
|
extglobs[extglobs.length - 1].inner += tok.value;
|
|
}
|
|
|
|
if (tok.value || tok.output) append(tok);
|
|
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
prev.value += tok.value;
|
|
prev.output = (prev.output || '') + tok.value;
|
|
return;
|
|
}
|
|
|
|
tok.prev = prev;
|
|
tokens.push(tok);
|
|
prev = tok;
|
|
};
|
|
|
|
const extglobOpen = (type, value) => {
|
|
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
|
|
token.prev = prev;
|
|
token.parens = state.parens;
|
|
token.output = state.output;
|
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
|
|
increment('parens');
|
|
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
extglobs.push(token);
|
|
};
|
|
|
|
const extglobClose = token => {
|
|
let output = token.close + (opts.capture ? ')' : '');
|
|
let rest;
|
|
|
|
if (token.type === 'negate') {
|
|
let extglobStar = star;
|
|
|
|
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
extglobStar = globstar(opts);
|
|
}
|
|
|
|
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
output = token.close = `)$))${extglobStar}`;
|
|
}
|
|
|
|
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
//
|
|
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
|
|
output = token.close = `)${expression})${extglobStar})`;
|
|
}
|
|
|
|
if (token.prev.type === 'bos') {
|
|
state.negatedExtglob = true;
|
|
}
|
|
}
|
|
|
|
push({ type: 'paren', extglob: true, value, output });
|
|
decrement('parens');
|
|
};
|
|
|
|
/**
|
|
* Fast paths
|
|
*/
|
|
|
|
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
let backslashes = false;
|
|
|
|
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
if (first === '\\') {
|
|
backslashes = true;
|
|
return m;
|
|
}
|
|
|
|
if (first === '?') {
|
|
if (esc) {
|
|
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
}
|
|
if (index === 0) {
|
|
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
}
|
|
return QMARK.repeat(chars.length);
|
|
}
|
|
|
|
if (first === '.') {
|
|
return DOT_LITERAL.repeat(chars.length);
|
|
}
|
|
|
|
if (first === '*') {
|
|
if (esc) {
|
|
return esc + first + (rest ? star : '');
|
|
}
|
|
return star;
|
|
}
|
|
return esc ? m : `\\${m}`;
|
|
});
|
|
|
|
if (backslashes === true) {
|
|
if (opts.unescape === true) {
|
|
output = output.replace(/\\/g, '');
|
|
} else {
|
|
output = output.replace(/\\+/g, m => {
|
|
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
});
|
|
}
|
|
}
|
|
|
|
if (output === input && opts.contains === true) {
|
|
state.output = input;
|
|
return state;
|
|
}
|
|
|
|
state.output = utils.wrapOutput(output, state, options);
|
|
return state;
|
|
}
|
|
|
|
/**
|
|
* Tokenize input until we reach end-of-string
|
|
*/
|
|
|
|
while (!eos()) {
|
|
value = advance();
|
|
|
|
if (value === '\u0000') {
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Escaped characters
|
|
*/
|
|
|
|
if (value === '\\') {
|
|
const next = peek();
|
|
|
|
if (next === '/' && opts.bash !== true) {
|
|
continue;
|
|
}
|
|
|
|
if (next === '.' || next === ';') {
|
|
continue;
|
|
}
|
|
|
|
if (!next) {
|
|
value += '\\';
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
// collapse slashes to reduce potential for exploits
|
|
const match = /^\\+/.exec(remaining());
|
|
let slashes = 0;
|
|
|
|
if (match && match[0].length > 2) {
|
|
slashes = match[0].length;
|
|
state.index += slashes;
|
|
if (slashes % 2 !== 0) {
|
|
value += '\\';
|
|
}
|
|
}
|
|
|
|
if (opts.unescape === true) {
|
|
value = advance();
|
|
} else {
|
|
value += advance();
|
|
}
|
|
|
|
if (state.brackets === 0) {
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* If we're inside a regex character class, continue
|
|
* until we reach the closing bracket.
|
|
*/
|
|
|
|
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
if (opts.posix !== false && value === ':') {
|
|
const inner = prev.value.slice(1);
|
|
if (inner.includes('[')) {
|
|
prev.posix = true;
|
|
|
|
if (inner.includes(':')) {
|
|
const idx = prev.value.lastIndexOf('[');
|
|
const pre = prev.value.slice(0, idx);
|
|
const rest = prev.value.slice(idx + 2);
|
|
const posix = POSIX_REGEX_SOURCE[rest];
|
|
if (posix) {
|
|
prev.value = pre + posix;
|
|
state.backtrack = true;
|
|
advance();
|
|
|
|
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
bos.output = ONE_CHAR;
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
value = `\\${value}`;
|
|
}
|
|
|
|
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
value = `\\${value}`;
|
|
}
|
|
|
|
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
value = '^';
|
|
}
|
|
|
|
prev.value += value;
|
|
append({ value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* If we're inside a quoted string, continue
|
|
* until we reach the closing double quote.
|
|
*/
|
|
|
|
if (state.quotes === 1 && value !== '"') {
|
|
value = utils.escapeRegex(value);
|
|
prev.value += value;
|
|
append({ value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Double quotes
|
|
*/
|
|
|
|
if (value === '"') {
|
|
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
if (opts.keepQuotes === true) {
|
|
push({ type: 'text', value });
|
|
}
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Parentheses
|
|
*/
|
|
|
|
if (value === '(') {
|
|
increment('parens');
|
|
push({ type: 'paren', value });
|
|
continue;
|
|
}
|
|
|
|
if (value === ')') {
|
|
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
throw new SyntaxError(syntaxError('opening', '('));
|
|
}
|
|
|
|
const extglob = extglobs[extglobs.length - 1];
|
|
if (extglob && state.parens === extglob.parens + 1) {
|
|
extglobClose(extglobs.pop());
|
|
continue;
|
|
}
|
|
|
|
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
decrement('parens');
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Square brackets
|
|
*/
|
|
|
|
if (value === '[') {
|
|
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
throw new SyntaxError(syntaxError('closing', ']'));
|
|
}
|
|
|
|
value = `\\${value}`;
|
|
} else {
|
|
increment('brackets');
|
|
}
|
|
|
|
push({ type: 'bracket', value });
|
|
continue;
|
|
}
|
|
|
|
if (value === ']') {
|
|
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
push({ type: 'text', value, output: `\\${value}` });
|
|
continue;
|
|
}
|
|
|
|
if (state.brackets === 0) {
|
|
if (opts.strictBrackets === true) {
|
|
throw new SyntaxError(syntaxError('opening', '['));
|
|
}
|
|
|
|
push({ type: 'text', value, output: `\\${value}` });
|
|
continue;
|
|
}
|
|
|
|
decrement('brackets');
|
|
|
|
const prevValue = prev.value.slice(1);
|
|
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
value = `/${value}`;
|
|
}
|
|
|
|
prev.value += value;
|
|
append({ value });
|
|
|
|
// when literal brackets are explicitly disabled
|
|
// assume we should match with a regex character class
|
|
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
continue;
|
|
}
|
|
|
|
const escaped = utils.escapeRegex(prev.value);
|
|
state.output = state.output.slice(0, -prev.value.length);
|
|
|
|
// when literal brackets are explicitly enabled
|
|
// assume we should escape the brackets to match literal characters
|
|
if (opts.literalBrackets === true) {
|
|
state.output += escaped;
|
|
prev.value = escaped;
|
|
continue;
|
|
}
|
|
|
|
// when the user specifies nothing, try to match both
|
|
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
state.output += prev.value;
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Braces
|
|
*/
|
|
|
|
if (value === '{' && opts.nobrace !== true) {
|
|
increment('braces');
|
|
|
|
const open = {
|
|
type: 'brace',
|
|
value,
|
|
output: '(',
|
|
outputIndex: state.output.length,
|
|
tokensIndex: state.tokens.length
|
|
};
|
|
|
|
braces.push(open);
|
|
push(open);
|
|
continue;
|
|
}
|
|
|
|
if (value === '}') {
|
|
const brace = braces[braces.length - 1];
|
|
|
|
if (opts.nobrace === true || !brace) {
|
|
push({ type: 'text', value, output: value });
|
|
continue;
|
|
}
|
|
|
|
let output = ')';
|
|
|
|
if (brace.dots === true) {
|
|
const arr = tokens.slice();
|
|
const range = [];
|
|
|
|
for (let i = arr.length - 1; i >= 0; i--) {
|
|
tokens.pop();
|
|
if (arr[i].type === 'brace') {
|
|
break;
|
|
}
|
|
if (arr[i].type !== 'dots') {
|
|
range.unshift(arr[i].value);
|
|
}
|
|
}
|
|
|
|
output = expandRange(range, opts);
|
|
state.backtrack = true;
|
|
}
|
|
|
|
if (brace.comma !== true && brace.dots !== true) {
|
|
const out = state.output.slice(0, brace.outputIndex);
|
|
const toks = state.tokens.slice(brace.tokensIndex);
|
|
brace.value = brace.output = '\\{';
|
|
value = output = '\\}';
|
|
state.output = out;
|
|
for (const t of toks) {
|
|
state.output += (t.output || t.value);
|
|
}
|
|
}
|
|
|
|
push({ type: 'brace', value, output });
|
|
decrement('braces');
|
|
braces.pop();
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Pipes
|
|
*/
|
|
|
|
if (value === '|') {
|
|
if (extglobs.length > 0) {
|
|
extglobs[extglobs.length - 1].conditions++;
|
|
}
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Commas
|
|
*/
|
|
|
|
if (value === ',') {
|
|
let output = value;
|
|
|
|
const brace = braces[braces.length - 1];
|
|
if (brace && stack[stack.length - 1] === 'braces') {
|
|
brace.comma = true;
|
|
output = '|';
|
|
}
|
|
|
|
push({ type: 'comma', value, output });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Slashes
|
|
*/
|
|
|
|
if (value === '/') {
|
|
// if the beginning of the glob is "./", advance the start
|
|
// to the current index, and don't add the "./" characters
|
|
// to the state. This greatly simplifies lookbehinds when
|
|
// checking for BOS characters like "!" and "." (not "./")
|
|
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
state.start = state.index + 1;
|
|
state.consumed = '';
|
|
state.output = '';
|
|
tokens.pop();
|
|
prev = bos; // reset "prev" to the first token
|
|
continue;
|
|
}
|
|
|
|
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Dots
|
|
*/
|
|
|
|
if (value === '.') {
|
|
if (state.braces > 0 && prev.type === 'dot') {
|
|
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
const brace = braces[braces.length - 1];
|
|
prev.type = 'dots';
|
|
prev.output += value;
|
|
prev.value += value;
|
|
brace.dots = true;
|
|
continue;
|
|
}
|
|
|
|
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
push({ type: 'text', value, output: DOT_LITERAL });
|
|
continue;
|
|
}
|
|
|
|
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Question marks
|
|
*/
|
|
|
|
if (value === '?') {
|
|
const isGroup = prev && prev.value === '(';
|
|
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
extglobOpen('qmark', value);
|
|
continue;
|
|
}
|
|
|
|
if (prev && prev.type === 'paren') {
|
|
const next = peek();
|
|
let output = value;
|
|
|
|
if (next === '<' && !utils.supportsLookbehinds()) {
|
|
throw new Error('Node.js v10 or higher is required for regex lookbehinds');
|
|
}
|
|
|
|
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
|
output = `\\${value}`;
|
|
}
|
|
|
|
push({ type: 'text', value, output });
|
|
continue;
|
|
}
|
|
|
|
if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
|
push({ type: 'qmark', value, output: QMARK_NO_DOT });
|
|
continue;
|
|
}
|
|
|
|
push({ type: 'qmark', value, output: QMARK });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Exclamation
|
|
*/
|
|
|
|
if (value === '!') {
|
|
if (opts.noextglob !== true && peek() === '(') {
|
|
if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
|
extglobOpen('negate', value);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (opts.nonegate !== true && state.index === 0) {
|
|
negate();
|
|
continue;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Plus
|
|
*/
|
|
|
|
if (value === '+') {
|
|
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
extglobOpen('plus', value);
|
|
continue;
|
|
}
|
|
|
|
if ((prev && prev.value === '(') || opts.regex === false) {
|
|
push({ type: 'plus', value, output: PLUS_LITERAL });
|
|
continue;
|
|
}
|
|
|
|
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
|
push({ type: 'plus', value });
|
|
continue;
|
|
}
|
|
|
|
push({ type: 'plus', value: PLUS_LITERAL });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Plain text
|
|
*/
|
|
|
|
if (value === '@') {
|
|
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
push({ type: 'at', extglob: true, value, output: '' });
|
|
continue;
|
|
}
|
|
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Plain text
|
|
*/
|
|
|
|
if (value !== '*') {
|
|
if (value === '$' || value === '^') {
|
|
value = `\\${value}`;
|
|
}
|
|
|
|
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
if (match) {
|
|
value += match[0];
|
|
state.index += match[0].length;
|
|
}
|
|
|
|
push({ type: 'text', value });
|
|
continue;
|
|
}
|
|
|
|
/**
|
|
* Stars
|
|
*/
|
|
|
|
if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
|
prev.type = 'star';
|
|
prev.star = true;
|
|
prev.value += value;
|
|
prev.output = star;
|
|
state.backtrack = true;
|
|
state.globstar = true;
|
|
consume(value);
|
|
continue;
|
|
}
|
|
|
|
let rest = remaining();
|
|
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
extglobOpen('star', value);
|
|
continue;
|
|
}
|
|
|
|
if (prev.type === 'star') {
|
|
if (opts.noglobstar === true) {
|
|
consume(value);
|
|
continue;
|
|
}
|
|
|
|
const prior = prev.prev;
|
|
const before = prior.prev;
|
|
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
|
|
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
push({ type: 'star', value, output: '' });
|
|
continue;
|
|
}
|
|
|
|
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
push({ type: 'star', value, output: '' });
|
|
continue;
|
|
}
|
|
|
|
// strip consecutive `/**/`
|
|
while (rest.slice(0, 3) === '/**') {
|
|
const after = input[state.index + 4];
|
|
if (after && after !== '/') {
|
|
break;
|
|
}
|
|
rest = rest.slice(3);
|
|
consume('/**', 3);
|
|
}
|
|
|
|
if (prior.type === 'bos' && eos()) {
|
|
prev.type = 'globstar';
|
|
prev.value += value;
|
|
prev.output = globstar(opts);
|
|
state.output = prev.output;
|
|
state.globstar = true;
|
|
consume(value);
|
|
continue;
|
|
}
|
|
|
|
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
prior.output = `(?:${prior.output}`;
|
|
|
|
prev.type = 'globstar';
|
|
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
prev.value += value;
|
|
state.globstar = true;
|
|
state.output += prior.output + prev.output;
|
|
consume(value);
|
|
continue;
|
|
}
|
|
|
|
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
const end = rest[1] !== void 0 ? '|$' : '';
|
|
|
|
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
prior.output = `(?:${prior.output}`;
|
|
|
|
prev.type = 'globstar';
|
|
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
prev.value += value;
|
|
|
|
state.output += prior.output + prev.output;
|
|
state.globstar = true;
|
|
|
|
consume(value + advance());
|
|
|
|
push({ type: 'slash', value: '/', output: '' });
|
|
continue;
|
|
}
|
|
|
|
if (prior.type === 'bos' && rest[0] === '/') {
|
|
prev.type = 'globstar';
|
|
prev.value += value;
|
|
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
state.output = prev.output;
|
|
state.globstar = true;
|
|
consume(value + advance());
|
|
push({ type: 'slash', value: '/', output: '' });
|
|
continue;
|
|
}
|
|
|
|
// remove single star from output
|
|
state.output = state.output.slice(0, -prev.output.length);
|
|
|
|
// reset previous token to globstar
|
|
prev.type = 'globstar';
|
|
prev.output = globstar(opts);
|
|
prev.value += value;
|
|
|
|
// reset output with globstar
|
|
state.output += prev.output;
|
|
state.globstar = true;
|
|
consume(value);
|
|
continue;
|
|
}
|
|
|
|
const token = { type: 'star', value, output: star };
|
|
|
|
if (opts.bash === true) {
|
|
token.output = '.*?';
|
|
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
token.output = nodot + token.output;
|
|
}
|
|
push(token);
|
|
continue;
|
|
}
|
|
|
|
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
token.output = value;
|
|
push(token);
|
|
continue;
|
|
}
|
|
|
|
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
if (prev.type === 'dot') {
|
|
state.output += NO_DOT_SLASH;
|
|
prev.output += NO_DOT_SLASH;
|
|
|
|
} else if (opts.dot === true) {
|
|
state.output += NO_DOTS_SLASH;
|
|
prev.output += NO_DOTS_SLASH;
|
|
|
|
} else {
|
|
state.output += nodot;
|
|
prev.output += nodot;
|
|
}
|
|
|
|
if (peek() !== '*') {
|
|
state.output += ONE_CHAR;
|
|
prev.output += ONE_CHAR;
|
|
}
|
|
}
|
|
|
|
push(token);
|
|
}
|
|
|
|
while (state.brackets > 0) {
|
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
state.output = utils.escapeLast(state.output, '[');
|
|
decrement('brackets');
|
|
}
|
|
|
|
while (state.parens > 0) {
|
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
|
state.output = utils.escapeLast(state.output, '(');
|
|
decrement('parens');
|
|
}
|
|
|
|
while (state.braces > 0) {
|
|
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
|
state.output = utils.escapeLast(state.output, '{');
|
|
decrement('braces');
|
|
}
|
|
|
|
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
}
|
|
|
|
// rebuild the output if we had to backtrack at any point
|
|
if (state.backtrack === true) {
|
|
state.output = '';
|
|
|
|
for (const token of state.tokens) {
|
|
state.output += token.output != null ? token.output : token.value;
|
|
|
|
if (token.suffix) {
|
|
state.output += token.suffix;
|
|
}
|
|
}
|
|
}
|
|
|
|
return state;
|
|
};
|
|
|
|
/**
|
|
* Fast paths for creating regular expressions for common glob patterns.
|
|
* This can significantly speed up processing and has very little downside
|
|
* impact when none of the fast paths match.
|
|
*/
|
|
|
|
parse.fastpaths = (input, options) => {
|
|
const opts = { ...options };
|
|
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
const len = input.length;
|
|
if (len > max) {
|
|
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
}
|
|
|
|
input = REPLACEMENTS[input] || input;
|
|
const win32 = utils.isWindows(options);
|
|
|
|
// create constants based on platform, for windows or posix
|
|
const {
|
|
DOT_LITERAL,
|
|
SLASH_LITERAL,
|
|
ONE_CHAR,
|
|
DOTS_SLASH,
|
|
NO_DOT,
|
|
NO_DOTS,
|
|
NO_DOTS_SLASH,
|
|
STAR,
|
|
START_ANCHOR
|
|
} = constants.globChars(win32);
|
|
|
|
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
const capture = opts.capture ? '' : '?:';
|
|
const state = { negated: false, prefix: '' };
|
|
let star = opts.bash === true ? '.*?' : STAR;
|
|
|
|
if (opts.capture) {
|
|
star = `(${star})`;
|
|
}
|
|
|
|
const globstar = opts => {
|
|
if (opts.noglobstar === true) return star;
|
|
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
};
|
|
|
|
const create = str => {
|
|
switch (str) {
|
|
case '*':
|
|
return `${nodot}${ONE_CHAR}${star}`;
|
|
|
|
case '.*':
|
|
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
|
|
case '*.*':
|
|
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
|
|
case '*/*':
|
|
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
|
|
case '**':
|
|
return nodot + globstar(opts);
|
|
|
|
case '**/*':
|
|
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
|
|
case '**/*.*':
|
|
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
|
|
case '**/.*':
|
|
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
|
|
default: {
|
|
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
if (!match) return;
|
|
|
|
const source = create(match[1]);
|
|
if (!source) return;
|
|
|
|
return source + DOT_LITERAL + match[2];
|
|
}
|
|
}
|
|
};
|
|
|
|
const output = utils.removePrefix(input, state);
|
|
let source = create(output);
|
|
|
|
if (source && opts.strictSlashes !== true) {
|
|
source += `${SLASH_LITERAL}?`;
|
|
}
|
|
|
|
return source;
|
|
};
|
|
|
|
module.exports = parse;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 3322:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const path = __nccwpck_require__(1017);
|
|
const scan = __nccwpck_require__(2429);
|
|
const parse = __nccwpck_require__(2139);
|
|
const utils = __nccwpck_require__(479);
|
|
const constants = __nccwpck_require__(6099);
|
|
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
|
|
/**
|
|
* Creates a matcher function from one or more glob patterns. The
|
|
* returned function takes a string to match as its first argument,
|
|
* and returns true if the string is a match. The returned matcher
|
|
* function also takes a boolean as the second argument that, when true,
|
|
* returns an object with additional information.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* // picomatch(glob[, options]);
|
|
*
|
|
* const isMatch = picomatch('*.!(*a)');
|
|
* console.log(isMatch('a.a')); //=> false
|
|
* console.log(isMatch('a.b')); //=> true
|
|
* ```
|
|
* @name picomatch
|
|
* @param {String|Array} `globs` One or more glob patterns.
|
|
* @param {Object=} `options`
|
|
* @return {Function=} Returns a matcher function.
|
|
* @api public
|
|
*/
|
|
|
|
const picomatch = (glob, options, returnState = false) => {
|
|
if (Array.isArray(glob)) {
|
|
const fns = glob.map(input => picomatch(input, options, returnState));
|
|
const arrayMatcher = str => {
|
|
for (const isMatch of fns) {
|
|
const state = isMatch(str);
|
|
if (state) return state;
|
|
}
|
|
return false;
|
|
};
|
|
return arrayMatcher;
|
|
}
|
|
|
|
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
|
|
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
throw new TypeError('Expected pattern to be a non-empty string');
|
|
}
|
|
|
|
const opts = options || {};
|
|
const posix = utils.isWindows(options);
|
|
const regex = isState
|
|
? picomatch.compileRe(glob, options)
|
|
: picomatch.makeRe(glob, options, false, true);
|
|
|
|
const state = regex.state;
|
|
delete regex.state;
|
|
|
|
let isIgnored = () => false;
|
|
if (opts.ignore) {
|
|
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
}
|
|
|
|
const matcher = (input, returnObject = false) => {
|
|
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
|
|
if (typeof opts.onResult === 'function') {
|
|
opts.onResult(result);
|
|
}
|
|
|
|
if (isMatch === false) {
|
|
result.isMatch = false;
|
|
return returnObject ? result : false;
|
|
}
|
|
|
|
if (isIgnored(input)) {
|
|
if (typeof opts.onIgnore === 'function') {
|
|
opts.onIgnore(result);
|
|
}
|
|
result.isMatch = false;
|
|
return returnObject ? result : false;
|
|
}
|
|
|
|
if (typeof opts.onMatch === 'function') {
|
|
opts.onMatch(result);
|
|
}
|
|
return returnObject ? result : true;
|
|
};
|
|
|
|
if (returnState) {
|
|
matcher.state = state;
|
|
}
|
|
|
|
return matcher;
|
|
};
|
|
|
|
/**
|
|
* Test `input` with the given `regex`. This is used by the main
|
|
* `picomatch()` function to test the input string.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* // picomatch.test(input, regex[, options]);
|
|
*
|
|
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
* ```
|
|
* @param {String} `input` String to test.
|
|
* @param {RegExp} `regex`
|
|
* @return {Object} Returns an object with matching info.
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
if (typeof input !== 'string') {
|
|
throw new TypeError('Expected input to be a string');
|
|
}
|
|
|
|
if (input === '') {
|
|
return { isMatch: false, output: '' };
|
|
}
|
|
|
|
const opts = options || {};
|
|
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
let match = input === glob;
|
|
let output = (match && format) ? format(input) : input;
|
|
|
|
if (match === false) {
|
|
output = format ? format(input) : input;
|
|
match = output === glob;
|
|
}
|
|
|
|
if (match === false || opts.capture === true) {
|
|
if (opts.matchBase === true || opts.basename === true) {
|
|
match = picomatch.matchBase(input, regex, options, posix);
|
|
} else {
|
|
match = regex.exec(output);
|
|
}
|
|
}
|
|
|
|
return { isMatch: Boolean(match), match, output };
|
|
};
|
|
|
|
/**
|
|
* Match the basename of a filepath.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* // picomatch.matchBase(input, glob[, options]);
|
|
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
* ```
|
|
* @param {String} `input` String to test.
|
|
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
* @return {Boolean}
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
return regex.test(path.basename(input));
|
|
};
|
|
|
|
/**
|
|
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* // picomatch.isMatch(string, patterns[, options]);
|
|
*
|
|
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
* ```
|
|
* @param {String|Array} str The string to test.
|
|
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
* @param {Object} [options] See available [options](#options).
|
|
* @return {Boolean} Returns true if any patterns match `str`
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
|
|
/**
|
|
* Parse a glob pattern to create the source string for a regular
|
|
* expression.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* const result = picomatch.parse(pattern[, options]);
|
|
* ```
|
|
* @param {String} `pattern`
|
|
* @param {Object} `options`
|
|
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.parse = (pattern, options) => {
|
|
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
|
return parse(pattern, { ...options, fastpaths: false });
|
|
};
|
|
|
|
/**
|
|
* Scan a glob pattern to separate the pattern into segments.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* // picomatch.scan(input[, options]);
|
|
*
|
|
* const result = picomatch.scan('!./foo/*.js');
|
|
* console.log(result);
|
|
* { prefix: '!./',
|
|
* input: '!./foo/*.js',
|
|
* start: 3,
|
|
* base: 'foo',
|
|
* glob: '*.js',
|
|
* isBrace: false,
|
|
* isBracket: false,
|
|
* isGlob: true,
|
|
* isExtglob: false,
|
|
* isGlobstar: false,
|
|
* negated: true }
|
|
* ```
|
|
* @param {String} `input` Glob pattern to scan.
|
|
* @param {Object} `options`
|
|
* @return {Object} Returns an object with
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.scan = (input, options) => scan(input, options);
|
|
|
|
/**
|
|
* Compile a regular expression from the `state` object returned by the
|
|
* [parse()](#parse) method.
|
|
*
|
|
* @param {Object} `state`
|
|
* @param {Object} `options`
|
|
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
* @return {RegExp}
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
if (returnOutput === true) {
|
|
return state.output;
|
|
}
|
|
|
|
const opts = options || {};
|
|
const prepend = opts.contains ? '' : '^';
|
|
const append = opts.contains ? '' : '$';
|
|
|
|
let source = `${prepend}(?:${state.output})${append}`;
|
|
if (state && state.negated === true) {
|
|
source = `^(?!${source}).*$`;
|
|
}
|
|
|
|
const regex = picomatch.toRegex(source, options);
|
|
if (returnState === true) {
|
|
regex.state = state;
|
|
}
|
|
|
|
return regex;
|
|
};
|
|
|
|
/**
|
|
* Create a regular expression from a parsed glob pattern.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* const state = picomatch.parse('*.js');
|
|
* // picomatch.compileRe(state[, options]);
|
|
*
|
|
* console.log(picomatch.compileRe(state));
|
|
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
* ```
|
|
* @param {String} `state` The object returned from the `.parse` method.
|
|
* @param {Object} `options`
|
|
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
* @return {RegExp} Returns a regex created from the given pattern.
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
if (!input || typeof input !== 'string') {
|
|
throw new TypeError('Expected a non-empty string');
|
|
}
|
|
|
|
let parsed = { negated: false, fastpaths: true };
|
|
|
|
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
parsed.output = parse.fastpaths(input, options);
|
|
}
|
|
|
|
if (!parsed.output) {
|
|
parsed = parse(input, options);
|
|
}
|
|
|
|
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
};
|
|
|
|
/**
|
|
* Create a regular expression from the given regex source string.
|
|
*
|
|
* ```js
|
|
* const picomatch = require('picomatch');
|
|
* // picomatch.toRegex(source[, options]);
|
|
*
|
|
* const { output } = picomatch.parse('*.js');
|
|
* console.log(picomatch.toRegex(output));
|
|
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
* ```
|
|
* @param {String} `source` Regular expression source string.
|
|
* @param {Object} `options`
|
|
* @return {RegExp}
|
|
* @api public
|
|
*/
|
|
|
|
picomatch.toRegex = (source, options) => {
|
|
try {
|
|
const opts = options || {};
|
|
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
} catch (err) {
|
|
if (options && options.debug === true) throw err;
|
|
return /$^/;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Picomatch constants.
|
|
* @return {Object}
|
|
*/
|
|
|
|
picomatch.constants = constants;
|
|
|
|
/**
|
|
* Expose "picomatch"
|
|
*/
|
|
|
|
module.exports = picomatch;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2429:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const utils = __nccwpck_require__(479);
|
|
const {
|
|
CHAR_ASTERISK, /* * */
|
|
CHAR_AT, /* @ */
|
|
CHAR_BACKWARD_SLASH, /* \ */
|
|
CHAR_COMMA, /* , */
|
|
CHAR_DOT, /* . */
|
|
CHAR_EXCLAMATION_MARK, /* ! */
|
|
CHAR_FORWARD_SLASH, /* / */
|
|
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
CHAR_LEFT_PARENTHESES, /* ( */
|
|
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
CHAR_PLUS, /* + */
|
|
CHAR_QUESTION_MARK, /* ? */
|
|
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
} = __nccwpck_require__(6099);
|
|
|
|
const isPathSeparator = code => {
|
|
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
};
|
|
|
|
const depth = token => {
|
|
if (token.isPrefix !== true) {
|
|
token.depth = token.isGlobstar ? Infinity : 1;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Quickly scans a glob pattern and returns an object with a handful of
|
|
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
*
|
|
* ```js
|
|
* const pm = require('picomatch');
|
|
* console.log(pm.scan('foo/bar/*.js'));
|
|
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
* ```
|
|
* @param {String} `str`
|
|
* @param {Object} `options`
|
|
* @return {Object} Returns an object with tokens and regex source string.
|
|
* @api public
|
|
*/
|
|
|
|
const scan = (input, options) => {
|
|
const opts = options || {};
|
|
|
|
const length = input.length - 1;
|
|
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
const slashes = [];
|
|
const tokens = [];
|
|
const parts = [];
|
|
|
|
let str = input;
|
|
let index = -1;
|
|
let start = 0;
|
|
let lastIndex = 0;
|
|
let isBrace = false;
|
|
let isBracket = false;
|
|
let isGlob = false;
|
|
let isExtglob = false;
|
|
let isGlobstar = false;
|
|
let braceEscaped = false;
|
|
let backslashes = false;
|
|
let negated = false;
|
|
let negatedExtglob = false;
|
|
let finished = false;
|
|
let braces = 0;
|
|
let prev;
|
|
let code;
|
|
let token = { value: '', depth: 0, isGlob: false };
|
|
|
|
const eos = () => index >= length;
|
|
const peek = () => str.charCodeAt(index + 1);
|
|
const advance = () => {
|
|
prev = code;
|
|
return str.charCodeAt(++index);
|
|
};
|
|
|
|
while (index < length) {
|
|
code = advance();
|
|
let next;
|
|
|
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
backslashes = token.backslashes = true;
|
|
code = advance();
|
|
|
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
braceEscaped = true;
|
|
}
|
|
continue;
|
|
}
|
|
|
|
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
braces++;
|
|
|
|
while (eos() !== true && (code = advance())) {
|
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
backslashes = token.backslashes = true;
|
|
advance();
|
|
continue;
|
|
}
|
|
|
|
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
braces++;
|
|
continue;
|
|
}
|
|
|
|
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
isBrace = token.isBrace = true;
|
|
isGlob = token.isGlob = true;
|
|
finished = true;
|
|
|
|
if (scanToEnd === true) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
isBrace = token.isBrace = true;
|
|
isGlob = token.isGlob = true;
|
|
finished = true;
|
|
|
|
if (scanToEnd === true) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
braces--;
|
|
|
|
if (braces === 0) {
|
|
braceEscaped = false;
|
|
isBrace = token.isBrace = true;
|
|
finished = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (scanToEnd === true) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if (code === CHAR_FORWARD_SLASH) {
|
|
slashes.push(index);
|
|
tokens.push(token);
|
|
token = { value: '', depth: 0, isGlob: false };
|
|
|
|
if (finished === true) continue;
|
|
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
start += 2;
|
|
continue;
|
|
}
|
|
|
|
lastIndex = index + 1;
|
|
continue;
|
|
}
|
|
|
|
if (opts.noext !== true) {
|
|
const isExtglobChar = code === CHAR_PLUS
|
|
|| code === CHAR_AT
|
|
|| code === CHAR_ASTERISK
|
|
|| code === CHAR_QUESTION_MARK
|
|
|| code === CHAR_EXCLAMATION_MARK;
|
|
|
|
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
isGlob = token.isGlob = true;
|
|
isExtglob = token.isExtglob = true;
|
|
finished = true;
|
|
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
negatedExtglob = true;
|
|
}
|
|
|
|
if (scanToEnd === true) {
|
|
while (eos() !== true && (code = advance())) {
|
|
if (code === CHAR_BACKWARD_SLASH) {
|
|
backslashes = token.backslashes = true;
|
|
code = advance();
|
|
continue;
|
|
}
|
|
|
|
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
isGlob = token.isGlob = true;
|
|
finished = true;
|
|
break;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (code === CHAR_ASTERISK) {
|
|
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
isGlob = token.isGlob = true;
|
|
finished = true;
|
|
|
|
if (scanToEnd === true) {
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (code === CHAR_QUESTION_MARK) {
|
|
isGlob = token.isGlob = true;
|
|
finished = true;
|
|
|
|
if (scanToEnd === true) {
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
while (eos() !== true && (next = advance())) {
|
|
if (next === CHAR_BACKWARD_SLASH) {
|
|
backslashes = token.backslashes = true;
|
|
advance();
|
|
continue;
|
|
}
|
|
|
|
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
isBracket = token.isBracket = true;
|
|
isGlob = token.isGlob = true;
|
|
finished = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (scanToEnd === true) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
negated = token.negated = true;
|
|
start++;
|
|
continue;
|
|
}
|
|
|
|
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
isGlob = token.isGlob = true;
|
|
|
|
if (scanToEnd === true) {
|
|
while (eos() !== true && (code = advance())) {
|
|
if (code === CHAR_LEFT_PARENTHESES) {
|
|
backslashes = token.backslashes = true;
|
|
code = advance();
|
|
continue;
|
|
}
|
|
|
|
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
finished = true;
|
|
break;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (isGlob === true) {
|
|
finished = true;
|
|
|
|
if (scanToEnd === true) {
|
|
continue;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (opts.noext === true) {
|
|
isExtglob = false;
|
|
isGlob = false;
|
|
}
|
|
|
|
let base = str;
|
|
let prefix = '';
|
|
let glob = '';
|
|
|
|
if (start > 0) {
|
|
prefix = str.slice(0, start);
|
|
str = str.slice(start);
|
|
lastIndex -= start;
|
|
}
|
|
|
|
if (base && isGlob === true && lastIndex > 0) {
|
|
base = str.slice(0, lastIndex);
|
|
glob = str.slice(lastIndex);
|
|
} else if (isGlob === true) {
|
|
base = '';
|
|
glob = str;
|
|
} else {
|
|
base = str;
|
|
}
|
|
|
|
if (base && base !== '' && base !== '/' && base !== str) {
|
|
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
base = base.slice(0, -1);
|
|
}
|
|
}
|
|
|
|
if (opts.unescape === true) {
|
|
if (glob) glob = utils.removeBackslashes(glob);
|
|
|
|
if (base && backslashes === true) {
|
|
base = utils.removeBackslashes(base);
|
|
}
|
|
}
|
|
|
|
const state = {
|
|
prefix,
|
|
input,
|
|
start,
|
|
base,
|
|
glob,
|
|
isBrace,
|
|
isBracket,
|
|
isGlob,
|
|
isExtglob,
|
|
isGlobstar,
|
|
negated,
|
|
negatedExtglob
|
|
};
|
|
|
|
if (opts.tokens === true) {
|
|
state.maxDepth = 0;
|
|
if (!isPathSeparator(code)) {
|
|
tokens.push(token);
|
|
}
|
|
state.tokens = tokens;
|
|
}
|
|
|
|
if (opts.parts === true || opts.tokens === true) {
|
|
let prevIndex;
|
|
|
|
for (let idx = 0; idx < slashes.length; idx++) {
|
|
const n = prevIndex ? prevIndex + 1 : start;
|
|
const i = slashes[idx];
|
|
const value = input.slice(n, i);
|
|
if (opts.tokens) {
|
|
if (idx === 0 && start !== 0) {
|
|
tokens[idx].isPrefix = true;
|
|
tokens[idx].value = prefix;
|
|
} else {
|
|
tokens[idx].value = value;
|
|
}
|
|
depth(tokens[idx]);
|
|
state.maxDepth += tokens[idx].depth;
|
|
}
|
|
if (idx !== 0 || value !== '') {
|
|
parts.push(value);
|
|
}
|
|
prevIndex = i;
|
|
}
|
|
|
|
if (prevIndex && prevIndex + 1 < input.length) {
|
|
const value = input.slice(prevIndex + 1);
|
|
parts.push(value);
|
|
|
|
if (opts.tokens) {
|
|
tokens[tokens.length - 1].value = value;
|
|
depth(tokens[tokens.length - 1]);
|
|
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
}
|
|
}
|
|
|
|
state.slashes = slashes;
|
|
state.parts = parts;
|
|
}
|
|
|
|
return state;
|
|
};
|
|
|
|
module.exports = scan;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 479:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
const path = __nccwpck_require__(1017);
|
|
const win32 = process.platform === 'win32';
|
|
const {
|
|
REGEX_BACKSLASH,
|
|
REGEX_REMOVE_BACKSLASH,
|
|
REGEX_SPECIAL_CHARS,
|
|
REGEX_SPECIAL_CHARS_GLOBAL
|
|
} = __nccwpck_require__(6099);
|
|
|
|
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
|
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
|
|
exports.removeBackslashes = str => {
|
|
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
return match === '\\' ? '' : match;
|
|
});
|
|
};
|
|
|
|
exports.supportsLookbehinds = () => {
|
|
const segs = process.version.slice(1).split('.').map(Number);
|
|
if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
exports.isWindows = options => {
|
|
if (options && typeof options.windows === 'boolean') {
|
|
return options.windows;
|
|
}
|
|
return win32 === true || path.sep === '\\';
|
|
};
|
|
|
|
exports.escapeLast = (input, char, lastIdx) => {
|
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
if (idx === -1) return input;
|
|
if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
|
|
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
};
|
|
|
|
exports.removePrefix = (input, state = {}) => {
|
|
let output = input;
|
|
if (output.startsWith('./')) {
|
|
output = output.slice(2);
|
|
state.prefix = './';
|
|
}
|
|
return output;
|
|
};
|
|
|
|
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
const prepend = options.contains ? '' : '^';
|
|
const append = options.contains ? '' : '$';
|
|
|
|
let output = `${prepend}(?:${input})${append}`;
|
|
if (state.negated === true) {
|
|
output = `(?:^(?!${output}).*$)`;
|
|
}
|
|
return output;
|
|
};
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1861:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
/*!
|
|
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
|
*
|
|
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
* Released under the MIT License.
|
|
*/
|
|
|
|
|
|
|
|
const isNumber = __nccwpck_require__(5680);
|
|
|
|
const toRegexRange = (min, max, options) => {
|
|
if (isNumber(min) === false) {
|
|
throw new TypeError('toRegexRange: expected the first argument to be a number');
|
|
}
|
|
|
|
if (max === void 0 || min === max) {
|
|
return String(min);
|
|
}
|
|
|
|
if (isNumber(max) === false) {
|
|
throw new TypeError('toRegexRange: expected the second argument to be a number.');
|
|
}
|
|
|
|
let opts = { relaxZeros: true, ...options };
|
|
if (typeof opts.strictZeros === 'boolean') {
|
|
opts.relaxZeros = opts.strictZeros === false;
|
|
}
|
|
|
|
let relax = String(opts.relaxZeros);
|
|
let shorthand = String(opts.shorthand);
|
|
let capture = String(opts.capture);
|
|
let wrap = String(opts.wrap);
|
|
let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
|
|
|
|
if (toRegexRange.cache.hasOwnProperty(cacheKey)) {
|
|
return toRegexRange.cache[cacheKey].result;
|
|
}
|
|
|
|
let a = Math.min(min, max);
|
|
let b = Math.max(min, max);
|
|
|
|
if (Math.abs(a - b) === 1) {
|
|
let result = min + '|' + max;
|
|
if (opts.capture) {
|
|
return `(${result})`;
|
|
}
|
|
if (opts.wrap === false) {
|
|
return result;
|
|
}
|
|
return `(?:${result})`;
|
|
}
|
|
|
|
let isPadded = hasPadding(min) || hasPadding(max);
|
|
let state = { min, max, a, b };
|
|
let positives = [];
|
|
let negatives = [];
|
|
|
|
if (isPadded) {
|
|
state.isPadded = isPadded;
|
|
state.maxLen = String(state.max).length;
|
|
}
|
|
|
|
if (a < 0) {
|
|
let newMin = b < 0 ? Math.abs(b) : 1;
|
|
negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
|
|
a = state.a = 0;
|
|
}
|
|
|
|
if (b >= 0) {
|
|
positives = splitToPatterns(a, b, state, opts);
|
|
}
|
|
|
|
state.negatives = negatives;
|
|
state.positives = positives;
|
|
state.result = collatePatterns(negatives, positives, opts);
|
|
|
|
if (opts.capture === true) {
|
|
state.result = `(${state.result})`;
|
|
} else if (opts.wrap !== false && (positives.length + negatives.length) > 1) {
|
|
state.result = `(?:${state.result})`;
|
|
}
|
|
|
|
toRegexRange.cache[cacheKey] = state;
|
|
return state.result;
|
|
};
|
|
|
|
function collatePatterns(neg, pos, options) {
|
|
let onlyNegative = filterPatterns(neg, pos, '-', false, options) || [];
|
|
let onlyPositive = filterPatterns(pos, neg, '', false, options) || [];
|
|
let intersected = filterPatterns(neg, pos, '-?', true, options) || [];
|
|
let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
|
|
return subpatterns.join('|');
|
|
}
|
|
|
|
function splitToRanges(min, max) {
|
|
let nines = 1;
|
|
let zeros = 1;
|
|
|
|
let stop = countNines(min, nines);
|
|
let stops = new Set([max]);
|
|
|
|
while (min <= stop && stop <= max) {
|
|
stops.add(stop);
|
|
nines += 1;
|
|
stop = countNines(min, nines);
|
|
}
|
|
|
|
stop = countZeros(max + 1, zeros) - 1;
|
|
|
|
while (min < stop && stop <= max) {
|
|
stops.add(stop);
|
|
zeros += 1;
|
|
stop = countZeros(max + 1, zeros) - 1;
|
|
}
|
|
|
|
stops = [...stops];
|
|
stops.sort(compare);
|
|
return stops;
|
|
}
|
|
|
|
/**
|
|
* Convert a range to a regex pattern
|
|
* @param {Number} `start`
|
|
* @param {Number} `stop`
|
|
* @return {String}
|
|
*/
|
|
|
|
function rangeToPattern(start, stop, options) {
|
|
if (start === stop) {
|
|
return { pattern: start, count: [], digits: 0 };
|
|
}
|
|
|
|
let zipped = zip(start, stop);
|
|
let digits = zipped.length;
|
|
let pattern = '';
|
|
let count = 0;
|
|
|
|
for (let i = 0; i < digits; i++) {
|
|
let [startDigit, stopDigit] = zipped[i];
|
|
|
|
if (startDigit === stopDigit) {
|
|
pattern += startDigit;
|
|
|
|
} else if (startDigit !== '0' || stopDigit !== '9') {
|
|
pattern += toCharacterClass(startDigit, stopDigit, options);
|
|
|
|
} else {
|
|
count++;
|
|
}
|
|
}
|
|
|
|
if (count) {
|
|
pattern += options.shorthand === true ? '\\d' : '[0-9]';
|
|
}
|
|
|
|
return { pattern, count: [count], digits };
|
|
}
|
|
|
|
function splitToPatterns(min, max, tok, options) {
|
|
let ranges = splitToRanges(min, max);
|
|
let tokens = [];
|
|
let start = min;
|
|
let prev;
|
|
|
|
for (let i = 0; i < ranges.length; i++) {
|
|
let max = ranges[i];
|
|
let obj = rangeToPattern(String(start), String(max), options);
|
|
let zeros = '';
|
|
|
|
if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
|
|
if (prev.count.length > 1) {
|
|
prev.count.pop();
|
|
}
|
|
|
|
prev.count.push(obj.count[0]);
|
|
prev.string = prev.pattern + toQuantifier(prev.count);
|
|
start = max + 1;
|
|
continue;
|
|
}
|
|
|
|
if (tok.isPadded) {
|
|
zeros = padZeros(max, tok, options);
|
|
}
|
|
|
|
obj.string = zeros + obj.pattern + toQuantifier(obj.count);
|
|
tokens.push(obj);
|
|
start = max + 1;
|
|
prev = obj;
|
|
}
|
|
|
|
return tokens;
|
|
}
|
|
|
|
function filterPatterns(arr, comparison, prefix, intersection, options) {
|
|
let result = [];
|
|
|
|
for (let ele of arr) {
|
|
let { string } = ele;
|
|
|
|
// only push if _both_ are negative...
|
|
if (!intersection && !contains(comparison, 'string', string)) {
|
|
result.push(prefix + string);
|
|
}
|
|
|
|
// or _both_ are positive
|
|
if (intersection && contains(comparison, 'string', string)) {
|
|
result.push(prefix + string);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Zip strings
|
|
*/
|
|
|
|
function zip(a, b) {
|
|
let arr = [];
|
|
for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
|
|
return arr;
|
|
}
|
|
|
|
function compare(a, b) {
|
|
return a > b ? 1 : b > a ? -1 : 0;
|
|
}
|
|
|
|
function contains(arr, key, val) {
|
|
return arr.some(ele => ele[key] === val);
|
|
}
|
|
|
|
function countNines(min, len) {
|
|
return Number(String(min).slice(0, -len) + '9'.repeat(len));
|
|
}
|
|
|
|
function countZeros(integer, zeros) {
|
|
return integer - (integer % Math.pow(10, zeros));
|
|
}
|
|
|
|
function toQuantifier(digits) {
|
|
let [start = 0, stop = ''] = digits;
|
|
if (stop || start > 1) {
|
|
return `{${start + (stop ? ',' + stop : '')}}`;
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function toCharacterClass(a, b, options) {
|
|
return `[${a}${(b - a === 1) ? '' : '-'}${b}]`;
|
|
}
|
|
|
|
function hasPadding(str) {
|
|
return /^-?(0+)\d/.test(str);
|
|
}
|
|
|
|
function padZeros(value, tok, options) {
|
|
if (!tok.isPadded) {
|
|
return value;
|
|
}
|
|
|
|
let diff = Math.abs(tok.maxLen - String(value).length);
|
|
let relax = options.relaxZeros !== false;
|
|
|
|
switch (diff) {
|
|
case 0:
|
|
return '';
|
|
case 1:
|
|
return relax ? '0?' : '0';
|
|
case 2:
|
|
return relax ? '0{0,2}' : '00';
|
|
default: {
|
|
return relax ? `0{0,${diff}}` : `0{${diff}}`;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Cache
|
|
*/
|
|
|
|
toRegexRange.cache = {};
|
|
toRegexRange.clearCache = () => (toRegexRange.cache = {});
|
|
|
|
/**
|
|
* Expose `toRegexRange`
|
|
*/
|
|
|
|
module.exports = toRegexRange;
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 4294:
|
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
|
|
module.exports = __nccwpck_require__(4219);
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 4219:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
var net = __nccwpck_require__(1808);
|
|
var tls = __nccwpck_require__(4404);
|
|
var http = __nccwpck_require__(3685);
|
|
var https = __nccwpck_require__(5687);
|
|
var events = __nccwpck_require__(2361);
|
|
var assert = __nccwpck_require__(9491);
|
|
var util = __nccwpck_require__(3837);
|
|
|
|
|
|
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;
|
|
agent.defaultPort = 443;
|
|
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;
|
|
agent.defaultPort = 443;
|
|
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,
|
|
headers: {
|
|
host: options.host + ':' + options.port
|
|
}
|
|
});
|
|
if (options.localAddress) {
|
|
connectOptions.localAddress = options.localAddress;
|
|
}
|
|
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) {
|
|
debug('tunneling socket could not be established, statusCode=%d',
|
|
res.statusCode);
|
|
socket.destroy();
|
|
var error = new Error('tunneling socket could not be established, ' +
|
|
'statusCode=' + res.statusCode);
|
|
error.code = 'ECONNRESET';
|
|
options.request.emit('error', error);
|
|
self.removeSocket(placeholder);
|
|
return;
|
|
}
|
|
if (head.length > 0) {
|
|
debug('got illegal response body from proxy');
|
|
socket.destroy();
|
|
var error = new Error('got illegal response body from proxy');
|
|
error.code = 'ECONNRESET';
|
|
options.request.emit('error', error);
|
|
self.removeSocket(placeholder);
|
|
return;
|
|
}
|
|
debug('tunneling connection has established');
|
|
self.sockets[self.sockets.indexOf(placeholder)] = socket;
|
|
return cb(socket);
|
|
}
|
|
|
|
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
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5840:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
Object.defineProperty(exports, "v1", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _v.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "v3", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _v2.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "v4", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _v3.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "v5", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _v4.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "NIL", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _nil.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "version", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _version.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "validate", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _validate.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "stringify", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _stringify.default;
|
|
}
|
|
}));
|
|
Object.defineProperty(exports, "parse", ({
|
|
enumerable: true,
|
|
get: function () {
|
|
return _parse.default;
|
|
}
|
|
}));
|
|
|
|
var _v = _interopRequireDefault(__nccwpck_require__(8628));
|
|
|
|
var _v2 = _interopRequireDefault(__nccwpck_require__(6409));
|
|
|
|
var _v3 = _interopRequireDefault(__nccwpck_require__(5122));
|
|
|
|
var _v4 = _interopRequireDefault(__nccwpck_require__(9120));
|
|
|
|
var _nil = _interopRequireDefault(__nccwpck_require__(5332));
|
|
|
|
var _version = _interopRequireDefault(__nccwpck_require__(1595));
|
|
|
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
|
|
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
|
|
|
var _parse = _interopRequireDefault(__nccwpck_require__(2746));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/***/ }),
|
|
|
|
/***/ 4569:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _crypto = _interopRequireDefault(__nccwpck_require__(6113));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function md5(bytes) {
|
|
if (Array.isArray(bytes)) {
|
|
bytes = Buffer.from(bytes);
|
|
} else if (typeof bytes === 'string') {
|
|
bytes = Buffer.from(bytes, 'utf8');
|
|
}
|
|
|
|
return _crypto.default.createHash('md5').update(bytes).digest();
|
|
}
|
|
|
|
var _default = md5;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5332:
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
var _default = '00000000-0000-0000-0000-000000000000';
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2746:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function parse(uuid) {
|
|
if (!(0, _validate.default)(uuid)) {
|
|
throw TypeError('Invalid UUID');
|
|
}
|
|
|
|
let v;
|
|
const arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
|
|
|
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
arr[1] = v >>> 16 & 0xff;
|
|
arr[2] = v >>> 8 & 0xff;
|
|
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
|
|
|
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
|
|
|
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
|
|
|
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
|
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
|
|
|
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
|
arr[11] = v / 0x100000000 & 0xff;
|
|
arr[12] = v >>> 24 & 0xff;
|
|
arr[13] = v >>> 16 & 0xff;
|
|
arr[14] = v >>> 8 & 0xff;
|
|
arr[15] = v & 0xff;
|
|
return arr;
|
|
}
|
|
|
|
var _default = parse;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 814:
|
|
/***/ ((__unused_webpack_module, exports) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 807:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = rng;
|
|
|
|
var _crypto = _interopRequireDefault(__nccwpck_require__(6113));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate
|
|
|
|
let poolPtr = rnds8Pool.length;
|
|
|
|
function rng() {
|
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
_crypto.default.randomFillSync(rnds8Pool);
|
|
|
|
poolPtr = 0;
|
|
}
|
|
|
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5274:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _crypto = _interopRequireDefault(__nccwpck_require__(6113));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function sha1(bytes) {
|
|
if (Array.isArray(bytes)) {
|
|
bytes = Buffer.from(bytes);
|
|
} else if (typeof bytes === 'string') {
|
|
bytes = Buffer.from(bytes, 'utf8');
|
|
}
|
|
|
|
return _crypto.default.createHash('sha1').update(bytes).digest();
|
|
}
|
|
|
|
var _default = sha1;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8950:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Convert array of 16 byte values to UUID string format of the form:
|
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
*/
|
|
const byteToHex = [];
|
|
|
|
for (let i = 0; i < 256; ++i) {
|
|
byteToHex.push((i + 0x100).toString(16).substr(1));
|
|
}
|
|
|
|
function stringify(arr, offset = 0) {
|
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
// of the following:
|
|
// - One or more input array values don't map to a hex octet (leading to
|
|
// "undefined" in the uuid)
|
|
// - Invalid input values for the RFC `version` or `variant` fields
|
|
|
|
if (!(0, _validate.default)(uuid)) {
|
|
throw TypeError('Stringified UUID is invalid');
|
|
}
|
|
|
|
return uuid;
|
|
}
|
|
|
|
var _default = stringify;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 8628:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _rng = _interopRequireDefault(__nccwpck_require__(807));
|
|
|
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
// **`v1()` - Generate time-based UUID**
|
|
//
|
|
// Inspired by https://github.com/LiosK/UUID.js
|
|
// and http://docs.python.org/library/uuid.html
|
|
let _nodeId;
|
|
|
|
let _clockseq; // Previous uuid creation time
|
|
|
|
|
|
let _lastMSecs = 0;
|
|
let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
|
|
|
|
function v1(options, buf, offset) {
|
|
let i = buf && offset || 0;
|
|
const b = buf || new Array(16);
|
|
options = options || {};
|
|
let node = options.node || _nodeId;
|
|
let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
|
|
// specified. We do this lazily to minimize issues related to insufficient
|
|
// system entropy. See #189
|
|
|
|
if (node == null || clockseq == null) {
|
|
const seedBytes = options.random || (options.rng || _rng.default)();
|
|
|
|
if (node == null) {
|
|
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
|
node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
|
|
}
|
|
|
|
if (clockseq == null) {
|
|
// Per 4.2.2, randomize (14 bit) clockseq
|
|
clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
|
|
}
|
|
} // UUID timestamps are 100 nano-second units since the Gregorian epoch,
|
|
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
|
|
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
|
|
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
|
|
|
|
let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
|
|
// cycle to simulate higher resolution clock
|
|
|
|
let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
|
|
|
|
const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
|
|
|
|
if (dt < 0 && options.clockseq === undefined) {
|
|
clockseq = clockseq + 1 & 0x3fff;
|
|
} // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
|
|
// time interval
|
|
|
|
|
|
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
|
|
nsecs = 0;
|
|
} // Per 4.2.1.2 Throw error if too many uuids are requested
|
|
|
|
|
|
if (nsecs >= 10000) {
|
|
throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
|
|
}
|
|
|
|
_lastMSecs = msecs;
|
|
_lastNSecs = nsecs;
|
|
_clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
|
|
|
|
msecs += 12219292800000; // `time_low`
|
|
|
|
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
|
b[i++] = tl >>> 24 & 0xff;
|
|
b[i++] = tl >>> 16 & 0xff;
|
|
b[i++] = tl >>> 8 & 0xff;
|
|
b[i++] = tl & 0xff; // `time_mid`
|
|
|
|
const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
|
|
b[i++] = tmh >>> 8 & 0xff;
|
|
b[i++] = tmh & 0xff; // `time_high_and_version`
|
|
|
|
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
|
|
|
|
b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
|
|
|
|
b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
|
|
|
|
b[i++] = clockseq & 0xff; // `node`
|
|
|
|
for (let n = 0; n < 6; ++n) {
|
|
b[i + n] = node[n];
|
|
}
|
|
|
|
return buf || (0, _stringify.default)(b);
|
|
}
|
|
|
|
var _default = v1;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6409:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _v = _interopRequireDefault(__nccwpck_require__(5998));
|
|
|
|
var _md = _interopRequireDefault(__nccwpck_require__(4569));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const v3 = (0, _v.default)('v3', 0x30, _md.default);
|
|
var _default = v3;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5998:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = _default;
|
|
exports.URL = exports.DNS = void 0;
|
|
|
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
|
|
|
var _parse = _interopRequireDefault(__nccwpck_require__(2746));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function stringToBytes(str) {
|
|
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
|
|
const bytes = [];
|
|
|
|
for (let i = 0; i < str.length; ++i) {
|
|
bytes.push(str.charCodeAt(i));
|
|
}
|
|
|
|
return bytes;
|
|
}
|
|
|
|
const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
exports.DNS = DNS;
|
|
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
exports.URL = URL;
|
|
|
|
function _default(name, version, hashfunc) {
|
|
function generateUUID(value, namespace, buf, offset) {
|
|
if (typeof value === 'string') {
|
|
value = stringToBytes(value);
|
|
}
|
|
|
|
if (typeof namespace === 'string') {
|
|
namespace = (0, _parse.default)(namespace);
|
|
}
|
|
|
|
if (namespace.length !== 16) {
|
|
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
} // Compute hash of namespace and value, Per 4.3
|
|
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
// hashfunc([...namespace, ... value])`
|
|
|
|
|
|
let bytes = new Uint8Array(16 + value.length);
|
|
bytes.set(namespace);
|
|
bytes.set(value, namespace.length);
|
|
bytes = hashfunc(bytes);
|
|
bytes[6] = bytes[6] & 0x0f | version;
|
|
bytes[8] = bytes[8] & 0x3f | 0x80;
|
|
|
|
if (buf) {
|
|
offset = offset || 0;
|
|
|
|
for (let i = 0; i < 16; ++i) {
|
|
buf[offset + i] = bytes[i];
|
|
}
|
|
|
|
return buf;
|
|
}
|
|
|
|
return (0, _stringify.default)(bytes);
|
|
} // Function#name is not settable on some platforms (#270)
|
|
|
|
|
|
try {
|
|
generateUUID.name = name; // eslint-disable-next-line no-empty
|
|
} catch (err) {} // For CommonJS default export support
|
|
|
|
|
|
generateUUID.DNS = DNS;
|
|
generateUUID.URL = URL;
|
|
return generateUUID;
|
|
}
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5122:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _rng = _interopRequireDefault(__nccwpck_require__(807));
|
|
|
|
var _stringify = _interopRequireDefault(__nccwpck_require__(8950));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function v4(options, buf, offset) {
|
|
options = options || {};
|
|
|
|
const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
|
|
|
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
|
|
if (buf) {
|
|
offset = offset || 0;
|
|
|
|
for (let i = 0; i < 16; ++i) {
|
|
buf[offset + i] = rnds[i];
|
|
}
|
|
|
|
return buf;
|
|
}
|
|
|
|
return (0, _stringify.default)(rnds);
|
|
}
|
|
|
|
var _default = v4;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9120:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _v = _interopRequireDefault(__nccwpck_require__(5998));
|
|
|
|
var _sha = _interopRequireDefault(__nccwpck_require__(5274));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
const v5 = (0, _v.default)('v5', 0x50, _sha.default);
|
|
var _default = v5;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6900:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _regex = _interopRequireDefault(__nccwpck_require__(814));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function validate(uuid) {
|
|
return typeof uuid === 'string' && _regex.default.test(uuid);
|
|
}
|
|
|
|
var _default = validate;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1595:
|
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
|
|
"use strict";
|
|
|
|
|
|
Object.defineProperty(exports, "__esModule", ({
|
|
value: true
|
|
}));
|
|
exports["default"] = void 0;
|
|
|
|
var _validate = _interopRequireDefault(__nccwpck_require__(6900));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
function version(uuid) {
|
|
if (!(0, _validate.default)(uuid)) {
|
|
throw TypeError('Invalid UUID');
|
|
}
|
|
|
|
return parseInt(uuid.substr(14, 1), 16);
|
|
}
|
|
|
|
var _default = version;
|
|
exports["default"] = _default;
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9491:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("assert");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2081:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("child_process");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 6113:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("crypto");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2361:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("events");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 7147:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("fs");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 3685:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("http");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 5687:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("https");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1808:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("net");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 2037:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("os");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1017:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("path");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 4521:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("readline");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 1576:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("string_decoder");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 9512:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("timers");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 4404:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("tls");
|
|
|
|
/***/ }),
|
|
|
|
/***/ 3837:
|
|
/***/ ((module) => {
|
|
|
|
"use strict";
|
|
module.exports = require("util");
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
/************************************************************************/
|
|
/******/ // The module cache
|
|
/******/ var __webpack_module_cache__ = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __nccwpck_require__(moduleId) {
|
|
/******/ // Check if module is in cache
|
|
/******/ 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] = {
|
|
/******/ // no module.id needed
|
|
/******/ // no module.loaded needed
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ var threw = true;
|
|
/******/ try {
|
|
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__);
|
|
/******/ threw = false;
|
|
/******/ } finally {
|
|
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
/******/ }
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/************************************************************************/
|
|
/******/ /* webpack/runtime/compat */
|
|
/******/
|
|
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
|
/******/
|
|
/************************************************************************/
|
|
/******/
|
|
/******/ // startup
|
|
/******/ // Load entry module and return exports
|
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
/******/ var __webpack_exports__ = __nccwpck_require__(3109);
|
|
/******/ module.exports = __webpack_exports__;
|
|
/******/
|
|
/******/ })()
|
|
;
|
|
//# sourceMappingURL=index.js.map
|