Compare commits
27 Commits
+28
-29
@@ -1,42 +1,41 @@
|
||||
root: true
|
||||
parser: "@typescript-eslint/parser"
|
||||
parser: '@typescript-eslint/parser'
|
||||
parserOptions:
|
||||
project: tsconfig.json
|
||||
plugins:
|
||||
- "@typescript-eslint"
|
||||
- '@typescript-eslint'
|
||||
- prettier
|
||||
extends:
|
||||
- eslint:recommended
|
||||
- plugin:@typescript-eslint/eslint-recommended
|
||||
- plugin:@typescript-eslint/recommended
|
||||
- plugin:@typescript-eslint/recommended-requiring-type-checking
|
||||
- prettier/@typescript-eslint
|
||||
- plugin:prettier/recommended
|
||||
rules:
|
||||
"prettier/prettier":
|
||||
'prettier/prettier': [1]
|
||||
'@typescript-eslint/array-type': [1, { default: array-simple }]
|
||||
'@typescript-eslint/explicit-function-return-type':
|
||||
- 2
|
||||
- allowExpressions: true
|
||||
'@typescript-eslint/no-extraneous-class':
|
||||
- 1
|
||||
- singleQuote: true
|
||||
trailingComma: all
|
||||
tabWidth: 4
|
||||
endOfLine: lf
|
||||
printWidth: 160
|
||||
- usePrettierrc: false
|
||||
"@typescript-eslint/array-type": [1, { default: array-simple }]
|
||||
"@typescript-eslint/explicit-function-return-type":
|
||||
[2, { allowExpressions: true }]
|
||||
"@typescript-eslint/no-extra-non-null-assertion": [2]
|
||||
"@typescript-eslint/no-extraneous-class": [1, { allowWithDecorator: true, allowStaticOnly: true }]
|
||||
"@typescript-eslint/no-floating-promises": [1]
|
||||
"@typescript-eslint/no-parameter-properties":
|
||||
- allowWithDecorator: true
|
||||
allowStaticOnly: true
|
||||
'@typescript-eslint/no-parameter-properties':
|
||||
- 1
|
||||
- allows:
|
||||
- protected readonly
|
||||
- private readonly
|
||||
- public readonly
|
||||
- readonly
|
||||
"@typescript-eslint/no-throw-literal": [2]
|
||||
"no-unused-vars": [0]
|
||||
"@typescript-eslint/prefer-for-of": [1]
|
||||
"@typescript-eslint/prefer-function-type": [1]
|
||||
"@typescript-eslint/prefer-nullish-coalescing": [1]
|
||||
"@typescript-eslint/prefer-optional-chain": [1]
|
||||
- allows: [protected readonly, private readonly, public readonly, readonly]
|
||||
'@typescript-eslint/no-throw-literal': [2]
|
||||
'no-unused-vars': [0]
|
||||
'@typescript-eslint/no-unused-vars':
|
||||
- 1
|
||||
- varsIgnorePattern: ^_
|
||||
argsIgnorePattern: ^_
|
||||
'@typescript-eslint/prefer-for-of': [1]
|
||||
'@typescript-eslint/prefer-function-type': [1]
|
||||
'@typescript-eslint/prefer-nullish-coalescing': [1]
|
||||
'@typescript-eslint/prefer-optional-chain': [1]
|
||||
'@typescript-eslint/ban-types':
|
||||
- 1
|
||||
- types:
|
||||
object: false
|
||||
no-void: [1, { allowAsStatement: true }]
|
||||
eqeqeq: [1, smart]
|
||||
|
||||
@@ -18,10 +18,11 @@ jobs:
|
||||
run: yarn test
|
||||
- name: release
|
||||
run: yarn release
|
||||
- name: "check for uncommitted changes"
|
||||
- name: 'check for uncommitted changes'
|
||||
# Ensure no changes
|
||||
run: |
|
||||
git add . && git diff --exit-code --stat \
|
||||
|| (echo "##[error] found changed files after build. please 'yarn build && npm run format'" \
|
||||
"and check in all changes" \
|
||||
&& exit 1)
|
||||
git add .
|
||||
if ! git diff --cached --color=always --exit-code -- . ':!node_modules'; then
|
||||
echo "::error::Found changed files after build. Please run 'yarn release' and check in all changes."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
singleQuote: true
|
||||
trailingComma: all
|
||||
tabWidth: 2
|
||||
endOfLine: lf
|
||||
printWidth: 120
|
||||
overrides:
|
||||
- files:
|
||||
- '*.js'
|
||||
- '*.ts'
|
||||
options:
|
||||
tabWidth: 4
|
||||
Vendored
+2
-8
@@ -1,12 +1,6 @@
|
||||
{
|
||||
"npm.packageManager": "yarn",
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"vue"
|
||||
],
|
||||
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"],
|
||||
"eslint.enable": true,
|
||||
"files.autoSave": "off",
|
||||
"eslint.format.enable": true,
|
||||
@@ -22,4 +16,4 @@
|
||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||
},
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# GitHub Action - Setup xmake
|
||||
|
||||
[](https://github.com/xmake-io/github-action-setup-xmake/actions)
|
||||
[](https://github.com/marketplace/actions/setup-xmake)
|
||||
|
||||
@@ -23,7 +24,7 @@ Use specified version:
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '2.3.1'
|
||||
xmake-version: '2.5.3'
|
||||
```
|
||||
|
||||
Use specified branch:
|
||||
@@ -39,5 +40,5 @@ Use semver:
|
||||
```yml
|
||||
uses: xmake-io/github-action-setup-xmake@v1
|
||||
with:
|
||||
xmake-version: '>=2.2.6 <=2.3.1'
|
||||
xmake-version: '>=2.2.6 <=2.5.3'
|
||||
```
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.0.x | :white_check_mark: |
|
||||
|
||||
<!--
|
||||
| 5.0.x | :x: |
|
||||
| 4.0.x | :white_check_mark: |
|
||||
| < 4.0 | :x: |
|
||||
-->
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Use github issues to report a vulnerability.
|
||||
+1
-2
@@ -9,9 +9,8 @@ inputs:
|
||||
xmake-version:
|
||||
required: true
|
||||
default: latest
|
||||
description: The version to use. Should be a semver range or 'latest'. Or use branch@{branch_name} to select a branch.
|
||||
description: The version to use. Should be a semver range or 'latest'. Or use [{repository}#]branch@{branch_name} to select a branch.
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
|
||||
Vendored
+6
-5
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cleanup = exports.create = exports.lsRemote = void 0;
|
||||
const exec_1 = require("@actions/exec");
|
||||
const io = require("@actions/io");
|
||||
const os = require("os");
|
||||
@@ -7,9 +8,10 @@ const path = require("path");
|
||||
function makeOpt(ref) {
|
||||
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
|
||||
}
|
||||
async function lsRemote() {
|
||||
const repoUrl = (repo) => `https://github.com/${repo}.git`;
|
||||
async function lsRemote(repo) {
|
||||
let out = '';
|
||||
await exec_1.exec('git', ['ls-remote', 'https://github.com/xmake-io/xmake.git'], {
|
||||
await exec_1.exec('git', ['ls-remote', repoUrl(repo)], {
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: (d) => (out += d.toString()),
|
||||
@@ -20,7 +22,6 @@ async function lsRemote() {
|
||||
const [ref, tag] = line.trim().split('\t');
|
||||
if (ref && tag && tag.startsWith('refs/')) {
|
||||
const tagPath = tag.split('/').splice(1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let ldata = data;
|
||||
for (let i = 0; i < tagPath.length - 1; i++) {
|
||||
const seg = tagPath[i];
|
||||
@@ -37,12 +38,12 @@ async function lsRemote() {
|
||||
return data;
|
||||
}
|
||||
exports.lsRemote = lsRemote;
|
||||
async function create(ref) {
|
||||
async function create(repo, ref) {
|
||||
const opt = makeOpt(ref);
|
||||
await io.rmRF(opt.cwd);
|
||||
await io.mkdirP(opt.cwd);
|
||||
await exec_1.exec('git', ['init'], opt);
|
||||
await exec_1.exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt);
|
||||
await exec_1.exec('git', ['remote', 'add', 'origin', repoUrl(repo)], opt);
|
||||
await exec_1.exec('git', ['fetch', 'origin', '+refs/pull/*:refs/remotes/origin/pull/*', '+refs/heads/*:refs/remotes/origin/*'], opt);
|
||||
await exec_1.exec('git', ['checkout', ref], opt);
|
||||
await exec_1.exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
||||
|
||||
Vendored
+2
-1
@@ -16,7 +16,8 @@ async function run() {
|
||||
await exec_1.exec('xmake --version');
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
const ex = error;
|
||||
core.setFailed(ex.message);
|
||||
}
|
||||
}
|
||||
run().catch((e) => core.error(e));
|
||||
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Repo = exports.Sha = void 0;
|
||||
function Sha(sha) {
|
||||
sha = sha.trim().toLowerCase();
|
||||
if (!/^[a-f0-9]{40}$/g.test(sha))
|
||||
throw new Error(`Invalid sha value ${sha}`);
|
||||
return sha;
|
||||
}
|
||||
exports.Sha = Sha;
|
||||
function Repo(repo) {
|
||||
repo = repo.trim();
|
||||
if (!/^([^/#]+\/[^/#]+)$/g.test(repo))
|
||||
throw new Error(`Invalid repo value ${repo}`);
|
||||
return repo;
|
||||
}
|
||||
exports.Repo = Repo;
|
||||
Vendored
+28
-15
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.unixInstall = void 0;
|
||||
const core = require("@actions/core");
|
||||
const exec_1 = require("@actions/exec");
|
||||
const io = require("@actions/io");
|
||||
@@ -8,27 +9,39 @@ const os = require("os");
|
||||
const path = require("path");
|
||||
const semver = require("semver");
|
||||
const git = require("./git");
|
||||
async function install(sourceDir, binDir) {
|
||||
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
||||
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||
}
|
||||
async function unixInstall(version) {
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core.group(`download xmake ${version}`, () => git.create(version.sha));
|
||||
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
let toolDir;
|
||||
if (version.type !== 'local') {
|
||||
const ver = version.version;
|
||||
toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha));
|
||||
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
await install(sourceDir, binDir);
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
toolDir = await core.group(`install local xmake at '${version.path}'`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${Date.now()}`);
|
||||
await install(version.path, binDir);
|
||||
return binDir;
|
||||
});
|
||||
}
|
||||
// for versions 2.3.2 and above, xmake will be installed directly into the bin directory, and no script will be used to wrap it.
|
||||
if (version.type !== 'tags' || semver.gt(ver, '2.3.1')) {
|
||||
if (version.type !== 'tags' || semver.gt(version.version, '2.3.1')) {
|
||||
core.addPath(path.join(toolDir, 'bin'));
|
||||
}
|
||||
else {
|
||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||
core.addPath(path.join(toolDir, 'share', 'xmake'));
|
||||
}
|
||||
}
|
||||
exports.unixInstall = unixInstall;
|
||||
|
||||
Vendored
+71
-39
@@ -14,17 +14,25 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
||||
};
|
||||
var _string;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.selectVersion = void 0;
|
||||
const core = require("@actions/core");
|
||||
const semver = require("semver");
|
||||
const git_1 = require("./git");
|
||||
let VERSIONS;
|
||||
async function getVersions() {
|
||||
if (VERSIONS)
|
||||
return VERSIONS;
|
||||
return (VERSIONS = await git_1.lsRemote());
|
||||
const interfaces_1 = require("./interfaces");
|
||||
const p = require("path");
|
||||
const DEFAULT_REPO = interfaces_1.Repo('xmake-io/xmake');
|
||||
const VERSIONS = new Map();
|
||||
async function getVersions(repo) {
|
||||
const cache = VERSIONS.get(repo);
|
||||
if (cache)
|
||||
return cache;
|
||||
const result = await git_1.lsRemote(repo);
|
||||
VERSIONS.set(repo, result);
|
||||
return result;
|
||||
}
|
||||
class VersionImpl {
|
||||
constructor(version, sha, type, toString) {
|
||||
class GitVersionImpl {
|
||||
constructor(repo, version, sha, type, toString) {
|
||||
this.repo = repo;
|
||||
this.version = version;
|
||||
this.sha = sha;
|
||||
this.type = type;
|
||||
@@ -36,88 +44,112 @@ class VersionImpl {
|
||||
}
|
||||
}
|
||||
_string = new WeakMap();
|
||||
async function selectBranch(branch) {
|
||||
const versions = await getVersions();
|
||||
class LocalVersionImpl {
|
||||
constructor(path) {
|
||||
this.path = path;
|
||||
this.type = 'local';
|
||||
this.path = p.resolve(path);
|
||||
}
|
||||
}
|
||||
async function selectBranch(repo, branch) {
|
||||
const versions = await getVersions(repo);
|
||||
if (branch in versions.heads) {
|
||||
return new VersionImpl(branch, versions.heads[branch], 'heads', `branch ${branch}`);
|
||||
return new GitVersionImpl(repo, branch, versions.heads[branch], 'heads', `branch ${branch}`);
|
||||
}
|
||||
throw new Error(`Branch ${branch} not found`);
|
||||
}
|
||||
async function selectPr(pr) {
|
||||
async function selectPr(repo, pr) {
|
||||
var _a;
|
||||
const versions = await getVersions();
|
||||
const versions = await getVersions(repo);
|
||||
if (pr in versions.pull) {
|
||||
const prheads = versions.pull[pr];
|
||||
const sha = (_a = prheads.merge) !== null && _a !== void 0 ? _a : prheads.head;
|
||||
const prHeads = versions.pull[pr];
|
||||
const sha = (_a = prHeads.merge) !== null && _a !== void 0 ? _a : prHeads.head;
|
||||
if (sha) {
|
||||
return new VersionImpl(`pr#${pr}`, sha, 'pull', `pull request #${pr}`);
|
||||
return new GitVersionImpl(repo, `pr#${pr}`, sha, 'pull', `pull request #${pr}`);
|
||||
}
|
||||
}
|
||||
throw new Error(`Pull requrest #${pr} not found`);
|
||||
}
|
||||
async function selectSemver(version) {
|
||||
// check version valid
|
||||
async function selectSemver(repo, version) {
|
||||
const v = new semver.Range(version);
|
||||
if (!v) {
|
||||
throw new Error(`Invalid semver`);
|
||||
}
|
||||
const versions = await getVersions();
|
||||
const versions = await getVersions(repo);
|
||||
const ver = semver.maxSatisfying(Object.keys(versions.tags), v);
|
||||
if (!ver) {
|
||||
throw new Error(`No matched releases of xmake-version ${v.format()}`);
|
||||
}
|
||||
const sha = versions.tags[ver];
|
||||
return new VersionImpl(ver, sha, 'tags', ver);
|
||||
return new GitVersionImpl(repo, ver, sha, 'tags', ver);
|
||||
}
|
||||
async function selectSha(sha) {
|
||||
sha = sha.toLowerCase();
|
||||
if (!/^[a-f0-9]{40}$/gi.test(sha))
|
||||
throw new Error(`Invalid sha value ${sha}`);
|
||||
const versions = await getVersions();
|
||||
async function selectSha(repo, sha) {
|
||||
var _a;
|
||||
const shaValue = interfaces_1.Sha(sha);
|
||||
const versions = await getVersions(repo);
|
||||
for (const branch in versions.heads) {
|
||||
if (versions.heads[branch] === sha) {
|
||||
return selectBranch(branch);
|
||||
if (versions.heads[branch] === shaValue) {
|
||||
return selectBranch(repo, branch);
|
||||
}
|
||||
}
|
||||
for (const tag in versions.tags) {
|
||||
if (versions.tags[tag] === sha) {
|
||||
return selectSemver(tag);
|
||||
if (versions.tags[tag] === shaValue) {
|
||||
return selectSemver(repo, tag);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(new VersionImpl(`sha#${sha}`, sha, 'sha', `commit ${sha.substr(0, 8)}`));
|
||||
for (const pr in versions.pull) {
|
||||
const prData = versions.pull[pr];
|
||||
if (((_a = prData.merge) !== null && _a !== void 0 ? _a : prData.head) === shaValue) {
|
||||
return selectPr(repo, Number.parseInt(pr));
|
||||
}
|
||||
}
|
||||
return Promise.resolve(new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`));
|
||||
}
|
||||
async function selectVersion(version) {
|
||||
// get version string
|
||||
version = (version !== null && version !== void 0 ? version : core.getInput('xmake-version')) || 'latest';
|
||||
if (version.toLowerCase() === 'latest')
|
||||
version = '';
|
||||
let repo = DEFAULT_REPO;
|
||||
let ret;
|
||||
// select branch
|
||||
if (version.startsWith('local#')) {
|
||||
const path = version.slice('local#'.length);
|
||||
ret = new LocalVersionImpl(path);
|
||||
}
|
||||
{
|
||||
const match = /^([^/#]+\/[^/#]+)#(.+)$/.exec(version);
|
||||
if (match) {
|
||||
repo = interfaces_1.Repo(match[1]);
|
||||
version = match[2];
|
||||
}
|
||||
}
|
||||
if (version.startsWith('branch@')) {
|
||||
const branch = version.substr('branch@'.length);
|
||||
ret = await selectBranch(branch);
|
||||
ret = await selectBranch(repo, branch);
|
||||
}
|
||||
// select pr
|
||||
if (version.startsWith('pr@')) {
|
||||
const pr = Number.parseInt(version.substr('pr@'.length));
|
||||
if (Number.isNaN(pr) || pr <= 0) {
|
||||
throw new Error(`Invalid pull requrest ${version.substr('pr@'.length)}, should be a positive integer`);
|
||||
}
|
||||
ret = await selectPr(pr);
|
||||
ret = await selectPr(repo, pr);
|
||||
}
|
||||
// select sha
|
||||
if (version.startsWith('sha@')) {
|
||||
const sha = version.substr('sha@'.length);
|
||||
ret = await selectSha(sha);
|
||||
ret = await selectSha(repo, sha);
|
||||
}
|
||||
// select version
|
||||
if (semver.validRange(version)) {
|
||||
ret = await selectSemver(version);
|
||||
ret = await selectSemver(repo, version);
|
||||
}
|
||||
if (!ret) {
|
||||
throw new Error(`Invalid input xmake-version ${core.getInput('xmake-version')}`);
|
||||
}
|
||||
core.info(`Selected xmake ${ret} (commit: ${ret.sha.substr(0, 8)})`);
|
||||
if (ret.type === 'local') {
|
||||
core.info(`Use local xmake at '${ret.path}'`);
|
||||
}
|
||||
else {
|
||||
core.info(`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` +
|
||||
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
exports.selectVersion = selectVersion;
|
||||
|
||||
Vendored
+11
-7
@@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.winInstall = void 0;
|
||||
const core = require("@actions/core");
|
||||
const exec_1 = require("@actions/exec");
|
||||
const io = require("@actions/io");
|
||||
@@ -11,7 +12,6 @@ function getInstallerUrl(version) {
|
||||
const ver = version.version;
|
||||
switch (version.type) {
|
||||
case 'heads': {
|
||||
// we only use appveyor ci artifacts for branch version
|
||||
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
||||
return `https://ci.appveyor.com/api/projects/waruqi/xmake/artifacts/xmake-installer.exe?branch=${ver}&pr=false&job=Image%3A+Visual+Studio+2017%3B+Platform%3A+${arch}`;
|
||||
}
|
||||
@@ -22,34 +22,38 @@ function getInstallerUrl(version) {
|
||||
throw new Error('Sha builds for windows is not supported');
|
||||
}
|
||||
case 'tags': {
|
||||
// we cannot use appveyor ci artifacts, the old version links may be broken.
|
||||
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
|
||||
return semver.gt(ver, '2.2.6')
|
||||
? `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.${arch}.exe`
|
||||
: `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.exe`;
|
||||
}
|
||||
default: {
|
||||
// check that we have tested all types
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const _ = version.type;
|
||||
throw new Error('Unknown version type');
|
||||
}
|
||||
}
|
||||
}
|
||||
async function winInstall(version) {
|
||||
if (version.type === 'local') {
|
||||
throw new Error('Local builds for windows is not supported');
|
||||
}
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const installer = await core.group(`download xmake ${version}`, async () => {
|
||||
const installer = await core.group(`download xmake ${String(version)}`, async () => {
|
||||
const url = getInstallerUrl(version);
|
||||
core.info(`downloading from ${url}`);
|
||||
const file = await toolCache.downloadTool(url);
|
||||
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
|
||||
const exe = path.format({
|
||||
...path.parse(file),
|
||||
ext: '.exe',
|
||||
base: undefined,
|
||||
});
|
||||
await io.mv(file, exe);
|
||||
core.info(`downloaded to ${exe}`);
|
||||
return exe;
|
||||
});
|
||||
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
core.info(`installing to ${binDir}`);
|
||||
await exec_1.exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
};
|
||||
|
||||
+462
-390
File diff suppressed because it is too large
Load Diff
+9
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+58
-2
@@ -62,10 +62,10 @@ catch (err) {
|
||||
// setFailed logs the message and sets a failing exit code
|
||||
core.setFailed(`Action failed with error ${err}`);
|
||||
}
|
||||
```
|
||||
|
||||
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
|
||||
|
||||
```
|
||||
|
||||
#### Logging
|
||||
|
||||
@@ -89,6 +89,7 @@ try {
|
||||
}
|
||||
|
||||
// Do stuff
|
||||
core.info('Output to the actions build log')
|
||||
}
|
||||
catch (err) {
|
||||
core.error(`Error ${err}, action may still succeed though`);
|
||||
@@ -112,6 +113,61 @@ const result = await core.group('Do something async', async () => {
|
||||
})
|
||||
```
|
||||
|
||||
#### Styling output
|
||||
|
||||
Colored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.
|
||||
|
||||
Foreground colors:
|
||||
```js
|
||||
// 3/4 bit
|
||||
core.info('\u001b[35mThis foreground will be magenta')
|
||||
|
||||
// 8 bit
|
||||
core.info('\u001b[38;5;6mThis foreground will be cyan')
|
||||
|
||||
// 24 bit
|
||||
core.info('\u001b[38;2;255;0;0mThis foreground will be bright red')
|
||||
```
|
||||
|
||||
Background colors:
|
||||
```js
|
||||
// 3/4 bit
|
||||
core.info('\u001b[43mThis background will be yellow');
|
||||
|
||||
// 8 bit
|
||||
core.info('\u001b[48;5;6mThis background will be cyan')
|
||||
|
||||
// 24 bit
|
||||
core.info('\u001b[48;2;255;0;0mThis background will be bright red')
|
||||
```
|
||||
|
||||
Special styles:
|
||||
|
||||
```js
|
||||
core.info('\u001b[1mBold text')
|
||||
core.info('\u001b[3mItalic text')
|
||||
core.info('\u001b[4mUnderlined text')
|
||||
```
|
||||
|
||||
ANSI escape codes can be combined with one another:
|
||||
|
||||
```js
|
||||
core.info('\u001b[31;46mRed foreground with a cyan background and \u001b[1mbold text at the end');
|
||||
```
|
||||
|
||||
> Note: Escape codes reset at the start of each line
|
||||
```js
|
||||
core.info('\u001b[35mThis foreground will be magenta')
|
||||
core.info('This foreground will reset to the default')
|
||||
```
|
||||
|
||||
Manually typing escape codes can be a little difficult, but you can use third party modules such as [ansi-styles](https://github.com/chalk/ansi-styles).
|
||||
|
||||
```js
|
||||
const style = require('ansi-styles');
|
||||
core.info(style.color.ansi16m.hex('#abcdef') + 'Hello world!')
|
||||
```
|
||||
|
||||
#### Action state
|
||||
|
||||
You can use this library to save state and get state for sharing information between a given wrapper action:
|
||||
@@ -143,4 +199,4 @@ const core = require('@actions/core');
|
||||
var pid = core.getState("pidToKill");
|
||||
|
||||
process.kill(pid);
|
||||
```
|
||||
```
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
interface CommandProperties {
|
||||
[key: string]: string;
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
* Commands
|
||||
@@ -11,6 +11,6 @@ interface CommandProperties {
|
||||
* ::warning::This is the message
|
||||
* ::set-env name=MY_VAR::some value
|
||||
*/
|
||||
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
|
||||
export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
|
||||
export declare function issue(name: string, message?: string): void;
|
||||
export {};
|
||||
|
||||
+3
-2
@@ -8,6 +8,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = __importStar(require("os"));
|
||||
const utils_1 = require("./utils");
|
||||
/**
|
||||
* Commands
|
||||
*
|
||||
@@ -62,13 +63,13 @@ class Command {
|
||||
}
|
||||
}
|
||||
function escapeData(s) {
|
||||
return (s || '')
|
||||
return utils_1.toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A');
|
||||
}
|
||||
function escapeProperty(s) {
|
||||
return (s || '')
|
||||
return utils_1.toCommandValue(s)
|
||||
.replace(/%/g, '%25')
|
||||
.replace(/\r/g, '%0D')
|
||||
.replace(/\n/g, '%0A')
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAwB;AAQxB;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAC1B,OAAe,EACf,UAA6B,EAC7B,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;IACrD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAC/C,CAAC;AAPD,oCAOC;AAED,SAAgB,KAAK,CAAC,IAAY,EAAE,UAAkB,EAAE;IACtD,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAFD,sBAEC;AAED,MAAM,UAAU,GAAG,IAAI,CAAA;AAEvB,MAAM,OAAO;IAKX,YAAY,OAAe,EAAE,UAA6B,EAAE,OAAe;QACzE,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,iBAAiB,CAAA;SAC5B;QAED,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,QAAQ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UAAU,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;oBACvC,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;oBAChC,IAAI,GAAG,EAAE;wBACP,IAAI,KAAK,EAAE;4BACT,KAAK,GAAG,KAAK,CAAA;yBACd;6BAAM;4BACL,MAAM,IAAI,GAAG,CAAA;yBACd;wBAED,MAAM,IAAI,GAAG,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,EAAE,CAAA;qBAC1C;iBACF;aACF;SACF;QAED,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAA;QACpD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,UAAU,CAAC,CAAM;IACxB,OAAO,sBAAc,CAAC,CAAC,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED,SAAS,cAAc,CAAC,CAAM;IAC5B,OAAO,sBAAc,CAAC,CAAC,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;SACpB,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;AACzB,CAAC"}
|
||||
+17
-11
@@ -21,9 +21,9 @@ export declare enum ExitCode {
|
||||
/**
|
||||
* 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
|
||||
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
export declare function exportVariable(name: string, val: string): void;
|
||||
export declare function exportVariable(name: string, val: any): void;
|
||||
/**
|
||||
* Registers a secret which will get masked from logs
|
||||
* @param secret value of the secret
|
||||
@@ -46,15 +46,21 @@ export declare function getInput(name: string, options?: InputOptions): string;
|
||||
* Sets the value of an output.
|
||||
*
|
||||
* @param name name of the output to set
|
||||
* @param value value to store
|
||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
export declare function setOutput(name: string, value: string): void;
|
||||
export declare function setOutput(name: string, value: any): void;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
export declare function setCommandEcho(enabled: boolean): void;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
export declare function setFailed(message: string): void;
|
||||
export declare function setFailed(message: string | Error): void;
|
||||
/**
|
||||
* Gets whether Actions Step Debug is on or not
|
||||
*/
|
||||
@@ -66,14 +72,14 @@ export declare function isDebug(): boolean;
|
||||
export declare function debug(message: string): void;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message
|
||||
* @param message error issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
export declare function error(message: string): void;
|
||||
export declare function error(message: string | Error): void;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* @param message warning issue message
|
||||
* @param message warning issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
export declare function warning(message: string): void;
|
||||
export declare function warning(message: string | Error): void;
|
||||
/**
|
||||
* Writes info to log with console.log.
|
||||
* @param message info message
|
||||
@@ -104,9 +110,9 @@ export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>
|
||||
* 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
|
||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
||||
*/
|
||||
export declare function saveState(name: string, value: string): void;
|
||||
export declare function saveState(name: string, value: any): void;
|
||||
/**
|
||||
* Gets the value of an state set by this action's main execution.
|
||||
*
|
||||
|
||||
+40
-10
@@ -17,6 +17,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const command_1 = require("./command");
|
||||
const file_command_1 = require("./file-command");
|
||||
const utils_1 = require("./utils");
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
/**
|
||||
@@ -39,11 +41,21 @@ var ExitCode;
|
||||
/**
|
||||
* 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
|
||||
* @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) {
|
||||
process.env[name] = val;
|
||||
command_1.issueCommand('set-env', { name }, val);
|
||||
const convertedVal = utils_1.toCommandValue(val);
|
||||
process.env[name] = convertedVal;
|
||||
const filePath = process.env['GITHUB_ENV'] || '';
|
||||
if (filePath) {
|
||||
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||
file_command_1.issueCommand('ENV', commandValue);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||
}
|
||||
}
|
||||
exports.exportVariable = exportVariable;
|
||||
/**
|
||||
@@ -59,7 +71,13 @@ exports.setSecret = setSecret;
|
||||
* @param inputPath
|
||||
*/
|
||||
function addPath(inputPath) {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
const filePath = process.env['GITHUB_PATH'] || '';
|
||||
if (filePath) {
|
||||
file_command_1.issueCommand('PATH', inputPath);
|
||||
}
|
||||
else {
|
||||
command_1.issueCommand('add-path', {}, inputPath);
|
||||
}
|
||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||
}
|
||||
exports.addPath = addPath;
|
||||
@@ -82,12 +100,23 @@ exports.getInput = getInput;
|
||||
* Sets the value of an output.
|
||||
*
|
||||
* @param name name of the output to set
|
||||
* @param value value 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 setOutput(name, value) {
|
||||
process.stdout.write(os.EOL);
|
||||
command_1.issueCommand('set-output', { name }, 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
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -121,18 +150,18 @@ function debug(message) {
|
||||
exports.debug = debug;
|
||||
/**
|
||||
* Adds an error issue
|
||||
* @param message error issue message
|
||||
* @param message error issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
function error(message) {
|
||||
command_1.issue('error', message);
|
||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.error = error;
|
||||
/**
|
||||
* Adds an warning issue
|
||||
* @param message warning issue message
|
||||
* @param message warning issue message. Errors will be converted to string via toString()
|
||||
*/
|
||||
function warning(message) {
|
||||
command_1.issue('warning', message);
|
||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
||||
}
|
||||
exports.warning = warning;
|
||||
/**
|
||||
@@ -190,8 +219,9 @@ exports.group = group;
|
||||
* 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
|
||||
* @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) {
|
||||
command_1.issueCommand('save-state', { name }, value);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAA6C;AAE7C,uCAAwB;AACxB,2CAA4B;AAU5B;;GAEG;AACH,IAAY,QAUX;AAVD,WAAY,QAAQ;IAClB;;OAEG;IACH,6CAAW,CAAA;IAEX;;OAEG;IACH,6CAAW,CAAA;AACb,CAAC,EAVW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAUnB;AAED,yEAAyE;AACzE,YAAY;AACZ,yEAAyE;AAEzE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACvB,sBAAY,CAAC,SAAS,EAAE,EAAC,IAAI,EAAC,EAAE,GAAG,CAAC,CAAA;AACtC,CAAC;AAHD,wCAGC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,MAAc;IACtC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;AACtC,CAAC;AAFD,8BAEC;AAED;;;GAGG;AACH,SAAgB,OAAO,CAAC,SAAiB;IACvC,sBAAY,CAAC,UAAU,EAAE,EAAE,EAAE,SAAS,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,SAAS,GAAG,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;AAC7E,CAAC;AAHD,0BAGC;AAED;;;;;;GAMG;AACH,SAAgB,QAAQ,CAAC,IAAY,EAAE,OAAsB;IAC3D,MAAM,GAAG,GACP,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,WAAW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,SAAS,CAAC,IAAY,EAAE,KAAU;IAChD,sBAAY,CAAC,YAAY,EAAE,EAAC,IAAI,EAAC,EAAE,KAAK,CAAC,CAAA;AAC3C,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,EAAE,CAAA;AAC3C,CAAC;AAFD,4BAEC"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export declare function issueCommand(command: string, message: any): void;
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
// For internal use, subject to change.
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// We use any as a valid input type
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const utils_1 = require("./utils");
|
||||
function issueCommand(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.issueCommand = issueCommand;
|
||||
//# sourceMappingURL=file-command.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"file-command.js","sourceRoot":"","sources":["../src/file-command.ts"],"names":[],"mappings":";AAAA,uCAAuC;;;;;;;;;AAEvC,mCAAmC;AACnC,uDAAuD;AAEvD,uCAAwB;AACxB,uCAAwB;AACxB,mCAAsC;AAEtC,SAAgB,YAAY,CAAC,OAAe,EAAE,OAAY;IACxD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAA;IACjD,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,IAAI,KAAK,CACb,wDAAwD,OAAO,EAAE,CAClE,CAAA;KACF;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,EAAE,CAAC,cAAc,CAAC,QAAQ,EAAE,GAAG,sBAAc,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;QACjE,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAA;AACJ,CAAC;AAdD,oCAcC"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||
* @param input input to sanitize into a string
|
||||
*/
|
||||
export declare function toCommandValue(input: any): string;
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
// We use any as a valid input type
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* 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;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA,mCAAmC;AACnC,uDAAuD;;AAEvD;;;GAGG;AACH,SAAgB,cAAc,CAAC,KAAU;IACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;QACzC,OAAO,EAAE,CAAA;KACV;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE;QAC/D,OAAO,KAAe,CAAA;KACvB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAC9B,CAAC;AAPD,wCAOC"}
|
||||
+5
-4
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@actions/core",
|
||||
"version": "1.2.3",
|
||||
"version": "1.2.7",
|
||||
"description": "Actions core lib",
|
||||
"keywords": [
|
||||
"github",
|
||||
"actions",
|
||||
"core"
|
||||
],
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core",
|
||||
"license": "MIT",
|
||||
"main": "lib/core.js",
|
||||
"types": "lib/core.d.ts",
|
||||
@@ -16,7 +16,8 @@
|
||||
"test": "__tests__"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
"lib",
|
||||
"!.DS_Store"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -27,7 +28,7 @@
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"scripts": {
|
||||
"audit-moderate": "npm install && npm audit --audit-level=moderate",
|
||||
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
import * as im from './interfaces';
|
||||
import { ExecOptions } from './interfaces';
|
||||
export { ExecOptions };
|
||||
/**
|
||||
* Exec a command.
|
||||
* Output will be streamed to the live console.
|
||||
@@ -9,4 +10,4 @@ import * as im from './interfaces';
|
||||
* @param options optional exec options. See ExecOptions
|
||||
* @returns Promise<number> exit code
|
||||
*/
|
||||
export declare function exec(commandLine: string, args?: string[], options?: im.ExecOptions): Promise<number>;
|
||||
export declare function exec(commandLine: string, args?: string[], options?: ExecOptions): Promise<number>;
|
||||
|
||||
+8
-1
@@ -8,8 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tr = require("./toolrunner");
|
||||
const tr = __importStar(require("./toolrunner"));
|
||||
/**
|
||||
* Exec a command.
|
||||
* Output will be streamed to the live console.
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,mCAAkC;AAElC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAwB;;QAExB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;IACtB,CAAC;CAAA;AAdD,oBAcC"}
|
||||
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../src/exec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,iDAAkC;AAIlC;;;;;;;;;GASG;AACH,SAAsB,IAAI,CACxB,WAAmB,EACnB,IAAe,EACf,OAAqB;;QAErB,MAAM,WAAW,GAAG,EAAE,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAA;QACpD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;SACpE;QACD,8CAA8C;QAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC/B,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;QAC9C,MAAM,MAAM,GAAkB,IAAI,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;QACxE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;IACtB,CAAC;CAAA;AAdD,oBAcC"}
|
||||
+2
@@ -24,6 +24,8 @@ export interface ExecOptions {
|
||||
ignoreReturnCode?: boolean;
|
||||
/** optional. How long in ms to wait for STDIO streams to close after the exit event of the process before terminating. defaults to 10000 */
|
||||
delay?: number;
|
||||
/** optional. input to write to the process on STDIN. */
|
||||
input?: Buffer;
|
||||
/** optional. Listeners for output. Callback functions that will be called on these events */
|
||||
listeners?: {
|
||||
stdout?: (data: Buffer) => void;
|
||||
|
||||
+19
-6
@@ -8,13 +8,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const os = require("os");
|
||||
const events = require("events");
|
||||
const child = require("child_process");
|
||||
const path = require("path");
|
||||
const io = require("@actions/io");
|
||||
const ioUtil = require("@actions/io/lib/io-util");
|
||||
const os = __importStar(require("os"));
|
||||
const events = __importStar(require("events"));
|
||||
const child = __importStar(require("child_process"));
|
||||
const path = __importStar(require("path"));
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const ioUtil = __importStar(require("@actions/io/lib/io-util"));
|
||||
/* eslint-disable @typescript-eslint/unbound-method */
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
/*
|
||||
@@ -458,6 +465,12 @@ class ToolRunner extends events.EventEmitter {
|
||||
resolve(exitCode);
|
||||
}
|
||||
});
|
||||
if (this.options.input) {
|
||||
if (!cp.stdin) {
|
||||
throw new Error('child process missing stdin');
|
||||
}
|
||||
cp.stdin.end(this.options.input);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@actions/exec",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"description": "Actions exec lib",
|
||||
"keywords": [
|
||||
"github",
|
||||
|
||||
+14
-1
@@ -1,5 +1,18 @@
|
||||
## Releases
|
||||
|
||||
## 1.0.10
|
||||
|
||||
Contains a bug fix where proxy is defined without a user and password. see [PR here](https://github.com/actions/http-client/pull/42)
|
||||
|
||||
## 1.0.9
|
||||
Throw HttpClientError instead of a generic Error from the \<verb>Json() helper methods when the server responds with a non-successful status code.
|
||||
|
||||
## 1.0.8
|
||||
Fixed security issue where a redirect (e.g. 302) to another domain would pass headers. The fix was to strip the authorization header if the hostname was different. More [details in PR #27](https://github.com/actions/http-client/pull/27)
|
||||
|
||||
## 1.0.7
|
||||
Update NPM dependencies and add 429 to the list of HttpCodes
|
||||
|
||||
## 1.0.6
|
||||
Automatically sends Content-Type and Accept application/json headers for \<verb>Json() helper methods if not set in the client or parameters.
|
||||
|
||||
@@ -10,4 +23,4 @@ Adds \<verb>Json() helper methods for json over http scenarios.
|
||||
Started to add \<verb>Json() helper methods. Do not use this release for that. Use >= 1.0.5 since there was an issue with types.
|
||||
|
||||
## 1.0.1 to 1.0.3
|
||||
Adds proxy support.
|
||||
Adds proxy support.
|
||||
|
||||
+5
-2
@@ -6,7 +6,9 @@ class BasicCredentialHandler {
|
||||
this.password = password;
|
||||
}
|
||||
prepareRequest(options) {
|
||||
options.headers['Authorization'] = 'Basic ' + Buffer.from(this.username + ':' + this.password).toString('base64');
|
||||
options.headers['Authorization'] =
|
||||
'Basic ' +
|
||||
Buffer.from(this.username + ':' + this.password).toString('base64');
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication(response) {
|
||||
@@ -42,7 +44,8 @@ class PersonalAccessTokenCredentialHandler {
|
||||
// currently implements pre-authorization
|
||||
// TODO: support preAuth = false where it hooks on 401
|
||||
prepareRequest(options) {
|
||||
options.headers['Authorization'] = 'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
|
||||
options.headers['Authorization'] =
|
||||
'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
|
||||
}
|
||||
// This handler cannot handle 401
|
||||
canHandleAuthentication(response) {
|
||||
|
||||
+7
-1
@@ -1,5 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import http = require("http");
|
||||
import http = require('http');
|
||||
import ifm = require('./interfaces');
|
||||
export declare enum HttpCodes {
|
||||
OK = 200,
|
||||
@@ -23,6 +23,7 @@ export declare enum HttpCodes {
|
||||
RequestTimeout = 408,
|
||||
Conflict = 409,
|
||||
Gone = 410,
|
||||
TooManyRequests = 429,
|
||||
InternalServerError = 500,
|
||||
NotImplemented = 501,
|
||||
BadGateway = 502,
|
||||
@@ -41,6 +42,11 @@ export declare enum MediaTypes {
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
export declare function getProxyUrl(serverUrl: string): string;
|
||||
export declare class HttpClientError extends Error {
|
||||
constructor(message: string, statusCode: number);
|
||||
statusCode: number;
|
||||
result?: any;
|
||||
}
|
||||
export declare class HttpClientResponse implements ifm.IHttpClientResponse {
|
||||
constructor(message: http.IncomingMessage);
|
||||
message: http.IncomingMessage;
|
||||
|
||||
+75
-38
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const url = require("url");
|
||||
const http = require("http");
|
||||
const https = require("https");
|
||||
const pm = require("./proxy");
|
||||
@@ -28,6 +27,7 @@ var HttpCodes;
|
||||
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";
|
||||
@@ -48,15 +48,34 @@ var MediaTypes;
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
function getProxyUrl(serverUrl) {
|
||||
let proxyUrl = pm.getProxyUrl(url.parse(serverUrl));
|
||||
let 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 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;
|
||||
@@ -75,7 +94,7 @@ class HttpClientResponse {
|
||||
}
|
||||
exports.HttpClientResponse = HttpClientResponse;
|
||||
function isHttps(requestUrl) {
|
||||
let parsedUrl = url.parse(requestUrl);
|
||||
let parsedUrl = new URL(requestUrl);
|
||||
return parsedUrl.protocol === 'https:';
|
||||
}
|
||||
exports.isHttps = isHttps;
|
||||
@@ -178,18 +197,22 @@ class HttpClient {
|
||||
*/
|
||||
async request(verb, requestUrl, data, headers) {
|
||||
if (this._disposed) {
|
||||
throw new Error("Client has already been disposed.");
|
||||
throw new Error('Client has already been disposed.');
|
||||
}
|
||||
let parsedUrl = url.parse(requestUrl);
|
||||
let parsedUrl = new URL(requestUrl);
|
||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||
// Only perform retries on reads since writes may not be idempotent.
|
||||
let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1;
|
||||
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
|
||||
? this._maxRetries + 1
|
||||
: 1;
|
||||
let numTries = 0;
|
||||
let response;
|
||||
while (numTries < maxTries) {
|
||||
response = await this.requestRaw(info, data);
|
||||
// Check if it's an authentication challenge
|
||||
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
|
||||
if (response &&
|
||||
response.message &&
|
||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||
let authenticationHandler;
|
||||
for (let i = 0; i < this.handlers.length; i++) {
|
||||
if (this.handlers[i].canHandleAuthentication(response)) {
|
||||
@@ -207,21 +230,32 @@ class HttpClient {
|
||||
}
|
||||
}
|
||||
let redirectsRemaining = this._maxRedirects;
|
||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
|
||||
&& this._allowRedirects
|
||||
&& redirectsRemaining > 0) {
|
||||
const redirectUrl = response.message.headers["location"];
|
||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
|
||||
this._allowRedirects &&
|
||||
redirectsRemaining > 0) {
|
||||
const redirectUrl = response.message.headers['location'];
|
||||
if (!redirectUrl) {
|
||||
// if there's no location to redirect to, we won't
|
||||
break;
|
||||
}
|
||||
let parsedRedirectUrl = url.parse(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.");
|
||||
let 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.
|
||||
await response.readBody();
|
||||
// strip authorization header if redirected to a different hostname
|
||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||
for (let 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 = await this.requestRaw(info, data);
|
||||
@@ -272,8 +306,8 @@ class HttpClient {
|
||||
*/
|
||||
requestRawWithCallback(info, data, onResult) {
|
||||
let socket;
|
||||
if (typeof (data) === 'string') {
|
||||
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
|
||||
if (typeof data === 'string') {
|
||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||
}
|
||||
let callbackCalled = false;
|
||||
let handleResult = (err, res) => {
|
||||
@@ -286,7 +320,7 @@ class HttpClient {
|
||||
let res = new HttpClientResponse(msg);
|
||||
handleResult(null, res);
|
||||
});
|
||||
req.on('socket', (sock) => {
|
||||
req.on('socket', sock => {
|
||||
socket = sock;
|
||||
});
|
||||
// If we ever get disconnected, we want the socket to timeout eventually
|
||||
@@ -301,10 +335,10 @@ class HttpClient {
|
||||
// res should have headers
|
||||
handleResult(err, null);
|
||||
});
|
||||
if (data && typeof (data) === 'string') {
|
||||
if (data && typeof data === 'string') {
|
||||
req.write(data, 'utf8');
|
||||
}
|
||||
if (data && typeof (data) !== 'string') {
|
||||
if (data && typeof data !== 'string') {
|
||||
data.on('close', function () {
|
||||
req.end();
|
||||
});
|
||||
@@ -320,7 +354,7 @@ class HttpClient {
|
||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||
*/
|
||||
getAgent(serverUrl) {
|
||||
let parsedUrl = url.parse(serverUrl);
|
||||
let parsedUrl = new URL(serverUrl);
|
||||
return this._getAgent(parsedUrl);
|
||||
}
|
||||
_prepareRequest(method, requestUrl, headers) {
|
||||
@@ -331,31 +365,34 @@ class HttpClient {
|
||||
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.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.headers['user-agent'] = this.userAgent;
|
||||
}
|
||||
info.options.agent = this._getAgent(info.parsedUrl);
|
||||
// gives handlers an opportunity to participate
|
||||
if (this.handlers) {
|
||||
this.handlers.forEach((handler) => {
|
||||
this.handlers.forEach(handler => {
|
||||
handler.prepareRequest(info.options);
|
||||
});
|
||||
}
|
||||
return info;
|
||||
}
|
||||
_mergeHeaders(headers) {
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
||||
}
|
||||
return lowercaseKeys(headers || {});
|
||||
}
|
||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
|
||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||
let clientHeader;
|
||||
if (this.requestOptions && this.requestOptions.headers) {
|
||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||
@@ -390,10 +427,12 @@ class HttpClient {
|
||||
maxSockets: maxSockets,
|
||||
keepAlive: this._keepAlive,
|
||||
proxy: {
|
||||
proxyAuth: proxyUrl.auth,
|
||||
...((proxyUrl.username || proxyUrl.password) && {
|
||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||
}),
|
||||
host: proxyUrl.hostname,
|
||||
port: proxyUrl.port
|
||||
},
|
||||
}
|
||||
};
|
||||
let tunnelAgent;
|
||||
const overHttps = proxyUrl.protocol === 'https:';
|
||||
@@ -420,7 +459,9 @@ class HttpClient {
|
||||
// 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 });
|
||||
agent.options = Object.assign(agent.options || {}, {
|
||||
rejectUnauthorized: false
|
||||
});
|
||||
}
|
||||
return agent;
|
||||
}
|
||||
@@ -481,14 +522,10 @@ class HttpClient {
|
||||
msg = contents;
|
||||
}
|
||||
else {
|
||||
msg = "Failed request: (" + statusCode + ")";
|
||||
}
|
||||
let err = new Error(msg);
|
||||
// attach statusCode and body obj (if available) to the error object
|
||||
err['statusCode'] = statusCode;
|
||||
if (response.result) {
|
||||
err['result'] = response.result;
|
||||
msg = 'Failed request: (' + statusCode + ')';
|
||||
}
|
||||
let err = new HttpClientError(msg, statusCode);
|
||||
err.result = response.result;
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
import http = require("http");
|
||||
import url = require("url");
|
||||
import http = require('http');
|
||||
export interface IHeaders {
|
||||
[key: string]: any;
|
||||
}
|
||||
@@ -27,7 +26,7 @@ export interface IHttpClientResponse {
|
||||
}
|
||||
export interface IRequestInfo {
|
||||
options: http.RequestOptions;
|
||||
parsedUrl: url.Url;
|
||||
parsedUrl: URL;
|
||||
httpModule: any;
|
||||
}
|
||||
export interface IRequestOptions {
|
||||
|
||||
-1
@@ -1,3 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
;
|
||||
|
||||
+11
-7
@@ -1,11 +1,14 @@
|
||||
{
|
||||
"name": "@actions/http-client",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.11",
|
||||
"description": "Actions Http Client",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "rm -Rf ./_out && tsc && cp package*.json ./_out && cp *.md ./_out && cp LICENSE ./_out && cp actions.png ./_out",
|
||||
"test": "jest"
|
||||
"test": "jest",
|
||||
"format": "prettier --write *.ts && prettier --write **/*.ts",
|
||||
"format-check": "prettier --check *.ts && prettier --check **/*.ts",
|
||||
"audit-check": "npm audit --audit-level=moderate"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -22,12 +25,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/actions/http-client#readme",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.0.25",
|
||||
"@types/node": "^12.12.24",
|
||||
"jest": "^24.9.0",
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^12.12.31",
|
||||
"jest": "^25.1.0",
|
||||
"prettier": "^2.0.4",
|
||||
"proxy": "^1.0.1",
|
||||
"ts-jest": "^24.3.0",
|
||||
"typescript": "^3.7.4"
|
||||
"ts-jest": "^25.2.1",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"tunnel": "0.0.6"
|
||||
|
||||
+2
-4
@@ -1,4 +1,2 @@
|
||||
/// <reference types="node" />
|
||||
import * as url from 'url';
|
||||
export declare function getProxyUrl(reqUrl: url.Url): url.Url | undefined;
|
||||
export declare function checkBypass(reqUrl: url.Url): boolean;
|
||||
export declare function getProxyUrl(reqUrl: URL): URL | undefined;
|
||||
export declare function checkBypass(reqUrl: URL): boolean;
|
||||
|
||||
+8
-8
@@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const url = require("url");
|
||||
function getProxyUrl(reqUrl) {
|
||||
let usingSsl = reqUrl.protocol === 'https:';
|
||||
let proxyUrl;
|
||||
@@ -9,15 +8,13 @@ function getProxyUrl(reqUrl) {
|
||||
}
|
||||
let proxyVar;
|
||||
if (usingSsl) {
|
||||
proxyVar = process.env["https_proxy"] ||
|
||||
process.env["HTTPS_PROXY"];
|
||||
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||
}
|
||||
else {
|
||||
proxyVar = process.env["http_proxy"] ||
|
||||
process.env["HTTP_PROXY"];
|
||||
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||
}
|
||||
if (proxyVar) {
|
||||
proxyUrl = url.parse(proxyVar);
|
||||
proxyUrl = new URL(proxyVar);
|
||||
}
|
||||
return proxyUrl;
|
||||
}
|
||||
@@ -26,7 +23,7 @@ function checkBypass(reqUrl) {
|
||||
if (!reqUrl.hostname) {
|
||||
return false;
|
||||
}
|
||||
let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || '';
|
||||
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||
if (!noProxy) {
|
||||
return false;
|
||||
}
|
||||
@@ -47,7 +44,10 @@ function checkBypass(reqUrl) {
|
||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||
}
|
||||
// Compare request host against noproxy
|
||||
for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) {
|
||||
for (let upperNoProxyItem of noProxy
|
||||
.split(',')
|
||||
.map(x => x.trim().toUpperCase())
|
||||
.filter(x => x)) {
|
||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+9
-2
@@ -8,11 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const assert_1 = require("assert");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
_a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink;
|
||||
exports.IS_WINDOWS = process.platform === 'win32';
|
||||
function exists(fsPath) {
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"io-util.js","sourceRoot":"","sources":["../src/io-util.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAyB;AACzB,yBAAwB;AACxB,6BAA4B;AAEf,gBAYE,qTAAA;AAEF,QAAA,UAAU,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAA;AAEtD,SAAsB,MAAM,CAAC,MAAc;;QACzC,IAAI;YACF,MAAM,YAAI,CAAC,MAAM,CAAC,CAAA;SACnB;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACzB,OAAO,KAAK,CAAA;aACb;YAED,MAAM,GAAG,CAAA;SACV;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAZD,wBAYC;AAED,SAAsB,WAAW,CAC/B,MAAc,EACd,UAAmB,KAAK;;QAExB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,YAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,aAAK,CAAC,MAAM,CAAC,CAAA;QAChE,OAAO,KAAK,CAAC,WAAW,EAAE,CAAA;IAC5B,CAAC;CAAA;AAND,kCAMC;AAED;;;GAGG;AACH,SAAgB,QAAQ,CAAC,CAAS;IAChC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAAA;IAC1B,IAAI,CAAC,CAAC,EAAE;QACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAA;KAC5D;IAED,IAAI,kBAAU,EAAE;QACd,OAAO,CACL,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,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,CAAC;QACxD,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC"}
|
||||
+6
@@ -54,3 +54,9 @@ export declare function mkdirP(fsPath: string): Promise<void>;
|
||||
* @returns Promise<string> path to tool
|
||||
*/
|
||||
export declare function which(tool: string, check?: boolean): Promise<string>;
|
||||
/**
|
||||
* Returns a list of all occurrences of the given tool on the system path.
|
||||
*
|
||||
* @returns Promise<string[]> the paths of the tool
|
||||
*/
|
||||
export declare function findInPath(tool: string): Promise<string[]>;
|
||||
|
||||
+72
-50
@@ -8,11 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const childProcess = require("child_process");
|
||||
const path = require("path");
|
||||
const childProcess = __importStar(require("child_process"));
|
||||
const path = __importStar(require("path"));
|
||||
const util_1 = require("util");
|
||||
const ioUtil = require("./io-util");
|
||||
const ioUtil = __importStar(require("./io-util"));
|
||||
const exec = util_1.promisify(childProcess.exec);
|
||||
/**
|
||||
* Copies a file or folder.
|
||||
@@ -180,58 +187,73 @@ function which(tool, check) {
|
||||
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;
|
||||
}
|
||||
try {
|
||||
// build the list of extensions to try
|
||||
const extensions = [];
|
||||
if (ioUtil.IS_WINDOWS && process.env.PATHEXT) {
|
||||
for (const extension of process.env.PATHEXT.split(path.delimiter)) {
|
||||
if (extension) {
|
||||
extensions.push(extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if it's rooted, return it if exists. otherwise return empty.
|
||||
if (ioUtil.isRooted(tool)) {
|
||||
const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions);
|
||||
if (filePath) {
|
||||
return filePath;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
// if any path separators, return empty
|
||||
if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) {
|
||||
return '';
|
||||
}
|
||||
// build the list of directories
|
||||
//
|
||||
// Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
|
||||
// it feels like we should not do this. Checking the current directory seems like more of a use
|
||||
// case of a shell, and the which() function exposed by the toolkit should strive for consistency
|
||||
// across platforms.
|
||||
const directories = [];
|
||||
if (process.env.PATH) {
|
||||
for (const p of process.env.PATH.split(path.delimiter)) {
|
||||
if (p) {
|
||||
directories.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
// return the first match
|
||||
for (const directory of directories) {
|
||||
const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions);
|
||||
if (filePath) {
|
||||
return filePath;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
catch (err) {
|
||||
throw new Error(`which failed with message ${err.message}`);
|
||||
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);
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+3
-3
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@actions/io",
|
||||
"version": "1.0.2",
|
||||
"version": "1.1.0",
|
||||
"description": "Actions io lib",
|
||||
"keywords": [
|
||||
"github",
|
||||
"actions",
|
||||
"io"
|
||||
],
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/io",
|
||||
"license": "MIT",
|
||||
"main": "lib/io.js",
|
||||
"types": "lib/io.d.ts",
|
||||
@@ -27,7 +27,7 @@
|
||||
"directory": "packages/io"
|
||||
},
|
||||
"scripts": {
|
||||
"audit-moderate": "npm install && npm audit --audit-level=moderate",
|
||||
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+4
@@ -29,6 +29,10 @@ if (process.platform === 'win32') {
|
||||
const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-win-x64.7z');
|
||||
const node12ExtractedFolder = await tc.extract7z(node12Path, 'path/to/extract/to');
|
||||
}
|
||||
else if (process.platform === 'darwin') {
|
||||
const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0.pkg');
|
||||
const node12ExtractedFolder = await tc.extractXar(node12Path, 'path/to/extract/to');
|
||||
}
|
||||
else {
|
||||
const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
||||
const node12ExtractedFolder = await tc.extractTar(node12Path, 'path/to/extract/to');
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export interface IToolReleaseFile {
|
||||
filename: string;
|
||||
platform: string;
|
||||
platform_version?: string;
|
||||
arch: string;
|
||||
download_url: string;
|
||||
}
|
||||
export interface IToolRelease {
|
||||
version: string;
|
||||
stable: boolean;
|
||||
release_url: string;
|
||||
files: IToolReleaseFile[];
|
||||
}
|
||||
export declare function _findMatch(versionSpec: string, stable: boolean, candidates: IToolRelease[], archFilter: string): Promise<IToolRelease | undefined>;
|
||||
export declare function _getOsVersion(): string;
|
||||
export declare function _readLinuxVersionFile(): string;
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const semver = __importStar(require("semver"));
|
||||
const core_1 = require("@actions/core");
|
||||
// needs to be require for core node modules to be mocked
|
||||
/* eslint @typescript-eslint/no-require-imports: 0 */
|
||||
const os = require("os");
|
||||
const cp = require("child_process");
|
||||
const fs = require("fs");
|
||||
function _findMatch(versionSpec, stable, candidates, archFilter) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const platFilter = os.platform();
|
||||
let result;
|
||||
let match;
|
||||
let file;
|
||||
for (const candidate of candidates) {
|
||||
const version = candidate.version;
|
||||
core_1.debug(`check ${version} satisfies ${versionSpec}`);
|
||||
if (semver.satisfies(version, versionSpec) &&
|
||||
(!stable || candidate.stable === stable)) {
|
||||
file = candidate.files.find(item => {
|
||||
core_1.debug(`${item.arch}===${archFilter} && ${item.platform}===${platFilter}`);
|
||||
let chk = item.arch === archFilter && item.platform === platFilter;
|
||||
if (chk && item.platform_version) {
|
||||
const osVersion = module.exports._getOsVersion();
|
||||
if (osVersion === item.platform_version) {
|
||||
chk = true;
|
||||
}
|
||||
else {
|
||||
chk = semver.satisfies(osVersion, item.platform_version);
|
||||
}
|
||||
}
|
||||
return chk;
|
||||
});
|
||||
if (file) {
|
||||
core_1.debug(`matched ${candidate.version}`);
|
||||
match = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match && file) {
|
||||
// clone since we're mutating the file list to be only the file that matches
|
||||
result = Object.assign({}, match);
|
||||
result.files = [file];
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
exports._findMatch = _findMatch;
|
||||
function _getOsVersion() {
|
||||
// TODO: add windows and other linux, arm variants
|
||||
// right now filtering on version is only an ubuntu and macos scenario for tools we build for hosted (python)
|
||||
const plat = os.platform();
|
||||
let version = '';
|
||||
if (plat === 'darwin') {
|
||||
version = cp.execSync('sw_vers -productVersion').toString();
|
||||
}
|
||||
else if (plat === 'linux') {
|
||||
// lsb_release process not in some containers, readfile
|
||||
// Run cat /etc/lsb-release
|
||||
// DISTRIB_ID=Ubuntu
|
||||
// DISTRIB_RELEASE=18.04
|
||||
// DISTRIB_CODENAME=bionic
|
||||
// DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
|
||||
const lsbContents = module.exports._readLinuxVersionFile();
|
||||
if (lsbContents) {
|
||||
const lines = lsbContents.split('\n');
|
||||
for (const line of lines) {
|
||||
const parts = line.split('=');
|
||||
if (parts.length === 2 && parts[0].trim() === 'DISTRIB_RELEASE') {
|
||||
version = parts[1].trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
exports._getOsVersion = _getOsVersion;
|
||||
function _readLinuxVersionFile() {
|
||||
const lsbFile = '/etc/lsb-release';
|
||||
let contents = '';
|
||||
if (fs.existsSync(lsbFile)) {
|
||||
contents = fs.readFileSync(lsbFile).toString();
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
exports._readLinuxVersionFile = _readLinuxVersionFile;
|
||||
//# sourceMappingURL=manifest.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,wCAAmC;AAEnC,yDAAyD;AACzD,qDAAqD;AAErD,yBAAyB;AACzB,oCAAoC;AACpC,yBAAyB;AAqDzB,SAAsB,UAAU,CAC9B,WAAmB,EACnB,MAAe,EACf,UAA0B,EAC1B,UAAkB;;QAElB,MAAM,UAAU,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAA;QAEhC,IAAI,MAAgC,CAAA;QACpC,IAAI,KAA+B,CAAA;QAEnC,IAAI,IAAkC,CAAA;QACtC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAA;YAEjC,YAAK,CAAC,SAAS,OAAO,cAAc,WAAW,EAAE,CAAC,CAAA;YAClD,IACE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,WAAW,CAAC;gBACtC,CAAC,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,CAAC,EACxC;g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CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,QAAQ,EAAE,CAAA;KAC5D;SAAM,IAAI,IAAI,KAAK,OAAO,EAAE;QAC3B,uDAAuD;QACvD,2BAA2B;QAC3B,oBAAoB;QACpB,wBAAwB;QACxB,0BAA0B;QAC1B,2CAA2C;QAC3C,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAA;QAC1D,IAAI,WAAW,EAAE;YACf,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YACrC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;gBACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,iBAAiB,EAAE;oBAC/D,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;oBACzB,MAAK;iBACN;aACF;SACF;KACF;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AA7BD,sCA6BC;AAED,SAAgB,qBAAqB;IACnC,MAAM,OAAO,GAAG,kBAAkB,CAAA;IAClC,IAAI,QAAQ,GAAG,EAAE,CAAA;IAEjB,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QAC1B,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAA;KAC/C;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AATD,sDASC"}
|
||||
+17
-2
@@ -1,3 +1,4 @@
|
||||
import * as mm from './manifest';
|
||||
export declare class HTTPError extends Error {
|
||||
readonly httpStatusCode: number | undefined;
|
||||
constructor(httpStatusCode: number | undefined);
|
||||
@@ -7,9 +8,10 @@ export declare class HTTPError extends Error {
|
||||
*
|
||||
* @param url url of tool to download
|
||||
* @param dest path to download tool
|
||||
* @param auth authorization header
|
||||
* @returns path to downloaded tool
|
||||
*/
|
||||
export declare function downloadTool(url: string, dest?: string): Promise<string>;
|
||||
export declare function downloadTool(url: string, dest?: string, auth?: string): Promise<string>;
|
||||
/**
|
||||
* Extract a .7z file
|
||||
*
|
||||
@@ -34,7 +36,16 @@ export declare function extract7z(file: string, dest?: string, _7zPath?: string)
|
||||
* @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional.
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
export declare function extractTar(file: string, dest?: string, flags?: string): Promise<string>;
|
||||
export declare function extractTar(file: string, dest?: string, flags?: string | string[]): Promise<string>;
|
||||
/**
|
||||
* Extract a xar compatible archive
|
||||
*
|
||||
* @param file path to the archive
|
||||
* @param dest destination directory. Optional.
|
||||
* @param flags flags for the xar. Optional.
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
export declare function extractXar(file: string, dest?: string, flags?: string | string[]): Promise<string>;
|
||||
/**
|
||||
* Extract a zip
|
||||
*
|
||||
@@ -78,3 +89,7 @@ export declare function find(toolName: string, versionSpec: string, arch?: strin
|
||||
* @param arch optional arch. defaults to arch of computer
|
||||
*/
|
||||
export declare function findAllVersions(toolName: string, arch?: string): string[];
|
||||
export declare type IToolRelease = mm.IToolRelease;
|
||||
export declare type IToolReleaseFile = mm.IToolReleaseFile;
|
||||
export declare function getManifestFromRepo(owner: string, repo: string, auth?: string, branch?: string): Promise<IToolRelease[]>;
|
||||
export declare function findFromManifest(versionSpec: string, stable: boolean, manifest: IToolRelease[], archFilter?: string): Promise<IToolRelease | undefined>;
|
||||
|
||||
+115
-9
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const mm = __importStar(require("./manifest"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const httpm = __importStar(require("@actions/http-client"));
|
||||
@@ -41,15 +42,17 @@ class HTTPError extends Error {
|
||||
}
|
||||
exports.HTTPError = HTTPError;
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
const IS_MAC = process.platform === 'darwin';
|
||||
const userAgent = 'actions/tool-cache';
|
||||
/**
|
||||
* Download a tool from an url and stream it into a file
|
||||
*
|
||||
* @param url url of tool to download
|
||||
* @param dest path to download tool
|
||||
* @param auth authorization header
|
||||
* @returns path to downloaded tool
|
||||
*/
|
||||
function downloadTool(url, dest) {
|
||||
function downloadTool(url, dest, auth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
dest = dest || path.join(_getTempDirectory(), v4_1.default());
|
||||
yield io.mkdirP(path.dirname(dest));
|
||||
@@ -60,7 +63,7 @@ function downloadTool(url, dest) {
|
||||
const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
|
||||
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
|
||||
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
||||
return yield downloadToolAttempt(url, dest || '');
|
||||
return yield downloadToolAttempt(url, dest || '', auth);
|
||||
}), (err) => {
|
||||
if (err instanceof HTTPError && err.httpStatusCode) {
|
||||
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
|
||||
@@ -76,7 +79,7 @@ function downloadTool(url, dest) {
|
||||
});
|
||||
}
|
||||
exports.downloadTool = downloadTool;
|
||||
function downloadToolAttempt(url, dest) {
|
||||
function downloadToolAttempt(url, dest, auth) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (fs.existsSync(dest)) {
|
||||
throw new Error(`Destination file path ${dest} already exists`);
|
||||
@@ -85,7 +88,14 @@ function downloadToolAttempt(url, dest) {
|
||||
const http = new httpm.HttpClient(userAgent, [], {
|
||||
allowRetries: false
|
||||
});
|
||||
const response = yield http.get(url);
|
||||
let headers;
|
||||
if (auth) {
|
||||
core.debug('set auth');
|
||||
headers = {
|
||||
authorization: auth
|
||||
};
|
||||
}
|
||||
const response = yield http.get(url, headers);
|
||||
if (response.message.statusCode !== 200) {
|
||||
const err = new HTTPError(response.message.statusCode);
|
||||
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||
@@ -140,9 +150,10 @@ function extract7z(file, dest, _7zPath) {
|
||||
process.chdir(dest);
|
||||
if (_7zPath) {
|
||||
try {
|
||||
const logLevel = core.isDebug() ? '-bb1' : '-bb0';
|
||||
const args = [
|
||||
'x',
|
||||
'-bb1',
|
||||
logLevel,
|
||||
'-bd',
|
||||
'-sccUTF-8',
|
||||
file
|
||||
@@ -218,7 +229,16 @@ function extractTar(file, dest, flags = 'xz') {
|
||||
core.debug(versionOutput.trim());
|
||||
const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR');
|
||||
// Initialize args
|
||||
const args = [flags];
|
||||
let args;
|
||||
if (flags instanceof Array) {
|
||||
args = flags;
|
||||
}
|
||||
else {
|
||||
args = [flags];
|
||||
}
|
||||
if (core.isDebug() && !flags.includes('v')) {
|
||||
args.push('-v');
|
||||
}
|
||||
let destArg = dest;
|
||||
let fileArg = file;
|
||||
if (IS_WINDOWS && isGnuTar) {
|
||||
@@ -238,6 +258,36 @@ function extractTar(file, dest, flags = 'xz') {
|
||||
});
|
||||
}
|
||||
exports.extractTar = extractTar;
|
||||
/**
|
||||
* Extract a xar compatible archive
|
||||
*
|
||||
* @param file path to the archive
|
||||
* @param dest destination directory. Optional.
|
||||
* @param flags flags for the xar. Optional.
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
function extractXar(file, dest, flags = []) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
assert_1.ok(IS_MAC, 'extractXar() not supported on current OS');
|
||||
assert_1.ok(file, 'parameter "file" is required');
|
||||
dest = yield _createExtractFolder(dest);
|
||||
let args;
|
||||
if (flags instanceof Array) {
|
||||
args = flags;
|
||||
}
|
||||
else {
|
||||
args = [flags];
|
||||
}
|
||||
args.push('-x', '-C', dest, '-f', file);
|
||||
if (core.isDebug()) {
|
||||
args.push('-v');
|
||||
}
|
||||
const xarPath = yield io.which('xar', true);
|
||||
yield exec_1.exec(`"${xarPath}"`, _unique(args));
|
||||
return dest;
|
||||
});
|
||||
}
|
||||
exports.extractXar = extractXar;
|
||||
/**
|
||||
* Extract a zip
|
||||
*
|
||||
@@ -268,7 +318,7 @@ function extractZipWin(file, dest) {
|
||||
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
||||
const command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
|
||||
// run powershell
|
||||
const powershellPath = yield io.which('powershell');
|
||||
const powershellPath = yield io.which('powershell', true);
|
||||
const args = [
|
||||
'-NoLogo',
|
||||
'-Sta',
|
||||
@@ -284,8 +334,12 @@ function extractZipWin(file, dest) {
|
||||
}
|
||||
function extractZipNix(file, dest) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const unzipPath = yield io.which('unzip');
|
||||
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
||||
const unzipPath = yield io.which('unzip', true);
|
||||
const args = [file];
|
||||
if (!core.isDebug()) {
|
||||
args.unshift('-q');
|
||||
}
|
||||
yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest });
|
||||
});
|
||||
}
|
||||
/**
|
||||
@@ -413,6 +467,51 @@ function findAllVersions(toolName, arch) {
|
||||
return versions;
|
||||
}
|
||||
exports.findAllVersions = findAllVersions;
|
||||
function getManifestFromRepo(owner, repo, auth, branch = 'master') {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let releases = [];
|
||||
const treeUrl = `https://api.github.com/repos/${owner}/${repo}/git/trees/${branch}`;
|
||||
const http = new httpm.HttpClient('tool-cache');
|
||||
const headers = {};
|
||||
if (auth) {
|
||||
core.debug('set auth');
|
||||
headers.authorization = auth;
|
||||
}
|
||||
const response = yield http.getJson(treeUrl, headers);
|
||||
if (!response.result) {
|
||||
return releases;
|
||||
}
|
||||
let manifestUrl = '';
|
||||
for (const item of response.result.tree) {
|
||||
if (item.path === 'versions-manifest.json') {
|
||||
manifestUrl = item.url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
headers['accept'] = 'application/vnd.github.VERSION.raw';
|
||||
let versionsRaw = yield (yield http.get(manifestUrl, headers)).readBody();
|
||||
if (versionsRaw) {
|
||||
// shouldn't be needed but protects against invalid json saved with BOM
|
||||
versionsRaw = versionsRaw.replace(/^\uFEFF/, '');
|
||||
try {
|
||||
releases = JSON.parse(versionsRaw);
|
||||
}
|
||||
catch (_a) {
|
||||
core.debug('Invalid json');
|
||||
}
|
||||
}
|
||||
return releases;
|
||||
});
|
||||
}
|
||||
exports.getManifestFromRepo = getManifestFromRepo;
|
||||
function findFromManifest(versionSpec, stable, manifest, archFilter = os.arch()) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// wrap the internal impl
|
||||
const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter);
|
||||
return match;
|
||||
});
|
||||
}
|
||||
exports.findFromManifest = findFromManifest;
|
||||
function _createExtractFolder(dest) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!dest) {
|
||||
@@ -497,4 +596,11 @@ function _getGlobal(key, defaultValue) {
|
||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||
return value !== undefined ? value : defaultValue;
|
||||
}
|
||||
/**
|
||||
* Returns an array of unique values.
|
||||
* @param values Values to make unique.
|
||||
*/
|
||||
function _unique(values) {
|
||||
return Array.from(new Set(values));
|
||||
}
|
||||
//# sourceMappingURL=tool-cache.js.map
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
Regular → Executable
+5
-5
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@actions/tool-cache",
|
||||
"version": "1.3.3",
|
||||
"version": "1.6.1",
|
||||
"description": "Actions tool-cache lib",
|
||||
"keywords": [
|
||||
"github",
|
||||
"actions",
|
||||
"exec"
|
||||
],
|
||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
||||
"homepage": "https://github.com/actions/toolkit/tree/main/packages/tool-cache",
|
||||
"license": "MIT",
|
||||
"main": "lib/tool-cache.js",
|
||||
"types": "lib/tool-cache.d.ts",
|
||||
@@ -28,7 +28,7 @@
|
||||
"directory": "packages/tool-cache"
|
||||
},
|
||||
"scripts": {
|
||||
"audit-moderate": "npm install && npm audit --audit-level=moderate",
|
||||
"audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json",
|
||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||
"tsc": "tsc"
|
||||
},
|
||||
@@ -36,9 +36,9 @@
|
||||
"url": "https://github.com/actions/toolkit/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.0",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@actions/exec": "^1.0.0",
|
||||
"@actions/http-client": "^1.0.3",
|
||||
"@actions/http-client": "^1.0.8",
|
||||
"@actions/io": "^1.0.1",
|
||||
"semver": "^6.1.0",
|
||||
"uuid": "^3.3.2"
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
# lru cache
|
||||
|
||||
A cache object that deletes the least-recently-used items.
|
||||
|
||||
[](https://travis-ci.org/isaacs/node-lru-cache) [](https://coveralls.io/github/isaacs/node-lru-cache)
|
||||
|
||||
## Installation:
|
||||
|
||||
```javascript
|
||||
npm install lru-cache --save
|
||||
```
|
||||
|
||||
## Usage:
|
||||
|
||||
```javascript
|
||||
var LRU = require("lru-cache")
|
||||
, options = { max: 500
|
||||
, length: function (n, key) { return n * 2 + key.length }
|
||||
, dispose: function (key, n) { n.close() }
|
||||
, maxAge: 1000 * 60 * 60 }
|
||||
, cache = new LRU(options)
|
||||
, otherCache = new LRU(50) // sets just the max size
|
||||
|
||||
cache.set("key", "value")
|
||||
cache.get("key") // "value"
|
||||
|
||||
// non-string keys ARE fully supported
|
||||
// but note that it must be THE SAME object, not
|
||||
// just a JSON-equivalent object.
|
||||
var someObject = { a: 1 }
|
||||
cache.set(someObject, 'a value')
|
||||
// Object keys are not toString()-ed
|
||||
cache.set('[object Object]', 'a different value')
|
||||
assert.equal(cache.get(someObject), 'a value')
|
||||
// A similar object with same keys/values won't work,
|
||||
// because it's a different object identity
|
||||
assert.equal(cache.get({ a: 1 }), undefined)
|
||||
|
||||
cache.reset() // empty the cache
|
||||
```
|
||||
|
||||
If you put more stuff in it, then items will fall out.
|
||||
|
||||
If you try to put an oversized thing in it, then it'll fall out right
|
||||
away.
|
||||
|
||||
## Options
|
||||
|
||||
* `max` The maximum size of the cache, checked by applying the length
|
||||
function to all values in the cache. Not setting this is kind of
|
||||
silly, since that's the whole purpose of this lib, but it defaults
|
||||
to `Infinity`. Setting it to a non-number or negative number will
|
||||
throw a `TypeError`. Setting it to 0 makes it be `Infinity`.
|
||||
* `maxAge` Maximum age in ms. Items are not pro-actively pruned out
|
||||
as they age, but if you try to get an item that is too old, it'll
|
||||
drop it and return undefined instead of giving it to you.
|
||||
Setting this to a negative value will make everything seem old!
|
||||
Setting it to a non-number will throw a `TypeError`.
|
||||
* `length` Function that is used to calculate the length of stored
|
||||
items. If you're storing strings or buffers, then you probably want
|
||||
to do something like `function(n, key){return n.length}`. The default is
|
||||
`function(){return 1}`, which is fine if you want to store `max`
|
||||
like-sized things. The item is passed as the first argument, and
|
||||
the key is passed as the second argumnet.
|
||||
* `dispose` Function that is called on items when they are dropped
|
||||
from the cache. This can be handy if you want to close file
|
||||
descriptors or do other cleanup tasks when items are no longer
|
||||
accessible. Called with `key, value`. It's called *before*
|
||||
actually removing the item from the internal cache, so if you want
|
||||
to immediately put it back in, you'll have to do that in a
|
||||
`nextTick` or `setTimeout` callback or it won't do anything.
|
||||
* `stale` By default, if you set a `maxAge`, it'll only actually pull
|
||||
stale items out of the cache when you `get(key)`. (That is, it's
|
||||
not pre-emptively doing a `setTimeout` or anything.) If you set
|
||||
`stale:true`, it'll return the stale value before deleting it. If
|
||||
you don't set this, then it'll return `undefined` when you try to
|
||||
get a stale entry, as if it had already been deleted.
|
||||
* `noDisposeOnSet` By default, if you set a `dispose()` method, then
|
||||
it'll be called whenever a `set()` operation overwrites an existing
|
||||
key. If you set this option, `dispose()` will only be called when a
|
||||
key falls out of the cache, not when it is overwritten.
|
||||
* `updateAgeOnGet` When using time-expiring entries with `maxAge`,
|
||||
setting this to `true` will make each item's effective time update
|
||||
to the current time whenever it is retrieved from cache, causing it
|
||||
to not expire. (It can still fall out of cache based on recency of
|
||||
use, of course.)
|
||||
|
||||
## API
|
||||
|
||||
* `set(key, value, maxAge)`
|
||||
* `get(key) => value`
|
||||
|
||||
Both of these will update the "recently used"-ness of the key.
|
||||
They do what you think. `maxAge` is optional and overrides the
|
||||
cache `maxAge` option if provided.
|
||||
|
||||
If the key is not found, `get()` will return `undefined`.
|
||||
|
||||
The key and val can be any value.
|
||||
|
||||
* `peek(key)`
|
||||
|
||||
Returns the key value (or `undefined` if not found) without
|
||||
updating the "recently used"-ness of the key.
|
||||
|
||||
(If you find yourself using this a lot, you *might* be using the
|
||||
wrong sort of data structure, but there are some use cases where
|
||||
it's handy.)
|
||||
|
||||
* `del(key)`
|
||||
|
||||
Deletes a key out of the cache.
|
||||
|
||||
* `reset()`
|
||||
|
||||
Clear the cache entirely, throwing away all values.
|
||||
|
||||
* `has(key)`
|
||||
|
||||
Check if a key is in the cache, without updating the recent-ness
|
||||
or deleting it for being stale.
|
||||
|
||||
* `forEach(function(value,key,cache), [thisp])`
|
||||
|
||||
Just like `Array.prototype.forEach`. Iterates over all the keys
|
||||
in the cache, in order of recent-ness. (Ie, more recently used
|
||||
items are iterated over first.)
|
||||
|
||||
* `rforEach(function(value,key,cache), [thisp])`
|
||||
|
||||
The same as `cache.forEach(...)` but items are iterated over in
|
||||
reverse order. (ie, less recently used items are iterated over
|
||||
first.)
|
||||
|
||||
* `keys()`
|
||||
|
||||
Return an array of the keys in the cache.
|
||||
|
||||
* `values()`
|
||||
|
||||
Return an array of the values in the cache.
|
||||
|
||||
* `length`
|
||||
|
||||
Return total length of objects in cache taking into account
|
||||
`length` options function.
|
||||
|
||||
* `itemCount`
|
||||
|
||||
Return total quantity of objects currently in cache. Note, that
|
||||
`stale` (see options) items are returned as part of this item
|
||||
count.
|
||||
|
||||
* `dump()`
|
||||
|
||||
Return an array of the cache entries ready for serialization and usage
|
||||
with 'destinationCache.load(arr)`.
|
||||
|
||||
* `load(cacheEntriesArray)`
|
||||
|
||||
Loads another cache entries array, obtained with `sourceCache.dump()`,
|
||||
into the cache. The destination cache is reset before loading new entries
|
||||
|
||||
* `prune()`
|
||||
|
||||
Manually iterates over the entire cache proactively pruning old entries
|
||||
+334
@@ -0,0 +1,334 @@
|
||||
'use strict'
|
||||
|
||||
// A linked list to keep track of recently-used-ness
|
||||
const Yallist = require('yallist')
|
||||
|
||||
const MAX = Symbol('max')
|
||||
const LENGTH = Symbol('length')
|
||||
const LENGTH_CALCULATOR = Symbol('lengthCalculator')
|
||||
const ALLOW_STALE = Symbol('allowStale')
|
||||
const MAX_AGE = Symbol('maxAge')
|
||||
const DISPOSE = Symbol('dispose')
|
||||
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')
|
||||
const LRU_LIST = Symbol('lruList')
|
||||
const CACHE = Symbol('cache')
|
||||
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')
|
||||
|
||||
const naiveLength = () => 1
|
||||
|
||||
// lruList is a yallist where the head is the youngest
|
||||
// item, and the tail is the oldest. the list contains the Hit
|
||||
// objects as the entries.
|
||||
// Each Hit object has a reference to its Yallist.Node. This
|
||||
// never changes.
|
||||
//
|
||||
// cache is a Map (or PseudoMap) that matches the keys to
|
||||
// the Yallist.Node object.
|
||||
class LRUCache {
|
||||
constructor (options) {
|
||||
if (typeof options === 'number')
|
||||
options = { max: options }
|
||||
|
||||
if (!options)
|
||||
options = {}
|
||||
|
||||
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
||||
throw new TypeError('max must be a non-negative number')
|
||||
// Kind of weird to have a default max of Infinity, but oh well.
|
||||
const max = this[MAX] = options.max || Infinity
|
||||
|
||||
const lc = options.length || naiveLength
|
||||
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc
|
||||
this[ALLOW_STALE] = options.stale || false
|
||||
if (options.maxAge && typeof options.maxAge !== 'number')
|
||||
throw new TypeError('maxAge must be a number')
|
||||
this[MAX_AGE] = options.maxAge || 0
|
||||
this[DISPOSE] = options.dispose
|
||||
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
|
||||
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false
|
||||
this.reset()
|
||||
}
|
||||
|
||||
// resize the cache when the max changes.
|
||||
set max (mL) {
|
||||
if (typeof mL !== 'number' || mL < 0)
|
||||
throw new TypeError('max must be a non-negative number')
|
||||
|
||||
this[MAX] = mL || Infinity
|
||||
trim(this)
|
||||
}
|
||||
get max () {
|
||||
return this[MAX]
|
||||
}
|
||||
|
||||
set allowStale (allowStale) {
|
||||
this[ALLOW_STALE] = !!allowStale
|
||||
}
|
||||
get allowStale () {
|
||||
return this[ALLOW_STALE]
|
||||
}
|
||||
|
||||
set maxAge (mA) {
|
||||
if (typeof mA !== 'number')
|
||||
throw new TypeError('maxAge must be a non-negative number')
|
||||
|
||||
this[MAX_AGE] = mA
|
||||
trim(this)
|
||||
}
|
||||
get maxAge () {
|
||||
return this[MAX_AGE]
|
||||
}
|
||||
|
||||
// resize the cache when the lengthCalculator changes.
|
||||
set lengthCalculator (lC) {
|
||||
if (typeof lC !== 'function')
|
||||
lC = naiveLength
|
||||
|
||||
if (lC !== this[LENGTH_CALCULATOR]) {
|
||||
this[LENGTH_CALCULATOR] = lC
|
||||
this[LENGTH] = 0
|
||||
this[LRU_LIST].forEach(hit => {
|
||||
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
|
||||
this[LENGTH] += hit.length
|
||||
})
|
||||
}
|
||||
trim(this)
|
||||
}
|
||||
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
||||
|
||||
get length () { return this[LENGTH] }
|
||||
get itemCount () { return this[LRU_LIST].length }
|
||||
|
||||
rforEach (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
||||
const prev = walker.prev
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
|
||||
forEach (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
||||
const next = walker.next
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = next
|
||||
}
|
||||
}
|
||||
|
||||
keys () {
|
||||
return this[LRU_LIST].toArray().map(k => k.key)
|
||||
}
|
||||
|
||||
values () {
|
||||
return this[LRU_LIST].toArray().map(k => k.value)
|
||||
}
|
||||
|
||||
reset () {
|
||||
if (this[DISPOSE] &&
|
||||
this[LRU_LIST] &&
|
||||
this[LRU_LIST].length) {
|
||||
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))
|
||||
}
|
||||
|
||||
this[CACHE] = new Map() // hash of items by key
|
||||
this[LRU_LIST] = new Yallist() // list of items in order of use recency
|
||||
this[LENGTH] = 0 // length of items in the list
|
||||
}
|
||||
|
||||
dump () {
|
||||
return this[LRU_LIST].map(hit =>
|
||||
isStale(this, hit) ? false : {
|
||||
k: hit.key,
|
||||
v: hit.value,
|
||||
e: hit.now + (hit.maxAge || 0)
|
||||
}).toArray().filter(h => h)
|
||||
}
|
||||
|
||||
dumpLru () {
|
||||
return this[LRU_LIST]
|
||||
}
|
||||
|
||||
set (key, value, maxAge) {
|
||||
maxAge = maxAge || this[MAX_AGE]
|
||||
|
||||
if (maxAge && typeof maxAge !== 'number')
|
||||
throw new TypeError('maxAge must be a number')
|
||||
|
||||
const now = maxAge ? Date.now() : 0
|
||||
const len = this[LENGTH_CALCULATOR](value, key)
|
||||
|
||||
if (this[CACHE].has(key)) {
|
||||
if (len > this[MAX]) {
|
||||
del(this, this[CACHE].get(key))
|
||||
return false
|
||||
}
|
||||
|
||||
const node = this[CACHE].get(key)
|
||||
const item = node.value
|
||||
|
||||
// dispose of the old one before overwriting
|
||||
// split out into 2 ifs for better coverage tracking
|
||||
if (this[DISPOSE]) {
|
||||
if (!this[NO_DISPOSE_ON_SET])
|
||||
this[DISPOSE](key, item.value)
|
||||
}
|
||||
|
||||
item.now = now
|
||||
item.maxAge = maxAge
|
||||
item.value = value
|
||||
this[LENGTH] += len - item.length
|
||||
item.length = len
|
||||
this.get(key)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
const hit = new Entry(key, value, len, now, maxAge)
|
||||
|
||||
// oversized objects fall out of cache automatically.
|
||||
if (hit.length > this[MAX]) {
|
||||
if (this[DISPOSE])
|
||||
this[DISPOSE](key, value)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
this[LENGTH] += hit.length
|
||||
this[LRU_LIST].unshift(hit)
|
||||
this[CACHE].set(key, this[LRU_LIST].head)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
has (key) {
|
||||
if (!this[CACHE].has(key)) return false
|
||||
const hit = this[CACHE].get(key).value
|
||||
return !isStale(this, hit)
|
||||
}
|
||||
|
||||
get (key) {
|
||||
return get(this, key, true)
|
||||
}
|
||||
|
||||
peek (key) {
|
||||
return get(this, key, false)
|
||||
}
|
||||
|
||||
pop () {
|
||||
const node = this[LRU_LIST].tail
|
||||
if (!node)
|
||||
return null
|
||||
|
||||
del(this, node)
|
||||
return node.value
|
||||
}
|
||||
|
||||
del (key) {
|
||||
del(this, this[CACHE].get(key))
|
||||
}
|
||||
|
||||
load (arr) {
|
||||
// reset the cache
|
||||
this.reset()
|
||||
|
||||
const now = Date.now()
|
||||
// A previous serialized cache has the most recent items first
|
||||
for (let l = arr.length - 1; l >= 0; l--) {
|
||||
const hit = arr[l]
|
||||
const expiresAt = hit.e || 0
|
||||
if (expiresAt === 0)
|
||||
// the item was created without expiration in a non aged cache
|
||||
this.set(hit.k, hit.v)
|
||||
else {
|
||||
const maxAge = expiresAt - now
|
||||
// dont add already expired items
|
||||
if (maxAge > 0) {
|
||||
this.set(hit.k, hit.v, maxAge)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prune () {
|
||||
this[CACHE].forEach((value, key) => get(this, key, false))
|
||||
}
|
||||
}
|
||||
|
||||
const get = (self, key, doUse) => {
|
||||
const node = self[CACHE].get(key)
|
||||
if (node) {
|
||||
const hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE])
|
||||
return undefined
|
||||
} else {
|
||||
if (doUse) {
|
||||
if (self[UPDATE_AGE_ON_GET])
|
||||
node.value.now = Date.now()
|
||||
self[LRU_LIST].unshiftNode(node)
|
||||
}
|
||||
}
|
||||
return hit.value
|
||||
}
|
||||
}
|
||||
|
||||
const isStale = (self, hit) => {
|
||||
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
||||
return false
|
||||
|
||||
const diff = Date.now() - hit.now
|
||||
return hit.maxAge ? diff > hit.maxAge
|
||||
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
||||
}
|
||||
|
||||
const trim = self => {
|
||||
if (self[LENGTH] > self[MAX]) {
|
||||
for (let walker = self[LRU_LIST].tail;
|
||||
self[LENGTH] > self[MAX] && walker !== null;) {
|
||||
// We know that we're about to delete this one, and also
|
||||
// what the next least recently used key will be, so just
|
||||
// go ahead and set it now.
|
||||
const prev = walker.prev
|
||||
del(self, walker)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const del = (self, node) => {
|
||||
if (node) {
|
||||
const hit = node.value
|
||||
if (self[DISPOSE])
|
||||
self[DISPOSE](hit.key, hit.value)
|
||||
|
||||
self[LENGTH] -= hit.length
|
||||
self[CACHE].delete(hit.key)
|
||||
self[LRU_LIST].removeNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
class Entry {
|
||||
constructor (key, value, length, now, maxAge) {
|
||||
this.key = key
|
||||
this.value = value
|
||||
this.length = length
|
||||
this.now = now
|
||||
this.maxAge = maxAge || 0
|
||||
}
|
||||
}
|
||||
|
||||
const forEachStep = (self, fn, node, thisp) => {
|
||||
let hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE])
|
||||
hit = undefined
|
||||
}
|
||||
if (hit)
|
||||
fn.call(thisp, hit.value, hit.key, self)
|
||||
}
|
||||
|
||||
module.exports = LRUCache
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "lru-cache",
|
||||
"description": "A cache object that deletes the least-recently-used items.",
|
||||
"version": "6.0.0",
|
||||
"author": "Isaac Z. Schlueter <i@izs.me>",
|
||||
"keywords": [
|
||||
"mru",
|
||||
"lru",
|
||||
"cache"
|
||||
],
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"snap": "tap",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"prepublishOnly": "git push origin --follow-tags"
|
||||
},
|
||||
"main": "index.js",
|
||||
"repository": "git://github.com/isaacs/node-lru-cache.git",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"tap": "^14.10.7"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"yallist": "^4.0.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
}
|
||||
+26
@@ -1,5 +1,31 @@
|
||||
# changes log
|
||||
|
||||
## 7.3.0
|
||||
|
||||
* Add `subset(r1, r2)` method to determine if `r1` range is entirely
|
||||
contained by `r2` range.
|
||||
|
||||
## 7.2.3
|
||||
|
||||
* Fix handling of `includePrelease` mode where version ranges like `1.0.0 -
|
||||
2.0.0` would include `3.0.0-pre` and not `1.0.0-pre`.
|
||||
|
||||
## 7.2.2
|
||||
|
||||
* Fix bug where `2.0.0-pre` would be included in `^1.0.0` if
|
||||
`includePrerelease` was set to true.
|
||||
|
||||
## 7.2.0
|
||||
|
||||
* Add `simplifyRange` method to attempt to generate a more human-readable
|
||||
range expression that is equivalent to a supplied range, for a given set
|
||||
of versions.
|
||||
|
||||
## 7.1.2
|
||||
|
||||
* Remove fancy lazy-loading logic, as it was causing problems for webpack
|
||||
users.
|
||||
|
||||
## 7.1.0
|
||||
|
||||
* Add `require('semver/preload')` to load the entire module without using
|
||||
|
||||
+35
-23
@@ -78,6 +78,8 @@ const semverOutside = require('semver/ranges/outside')
|
||||
const semverGtr = require('semver/ranges/gtr')
|
||||
const semverLtr = require('semver/ranges/ltr')
|
||||
const semverIntersects = require('semver/ranges/intersects')
|
||||
const simplifyRange = require('semver/ranges/simplify')
|
||||
const rangeSubset = require('semver/ranges/subset')
|
||||
```
|
||||
|
||||
As a command-line utility:
|
||||
@@ -254,8 +256,8 @@ inclusive range, then all versions that start with the supplied parts
|
||||
of the tuple are accepted, but nothing that would be greater than the
|
||||
provided tuple parts.
|
||||
|
||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0`
|
||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0`
|
||||
|
||||
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
||||
|
||||
@@ -263,28 +265,28 @@ Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
||||
numeric values in the `[major, minor, patch]` tuple.
|
||||
|
||||
* `*` := `>=0.0.0` (Any version satisfies)
|
||||
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
||||
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
||||
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)
|
||||
* `1.2.x` := `>=1.2.0 <1.3.0-0` (Matching major and minor versions)
|
||||
|
||||
A partial version range is treated as an X-Range, so the special
|
||||
character is in fact optional.
|
||||
|
||||
* `""` (empty string) := `*` := `>=0.0.0`
|
||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0`
|
||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0`
|
||||
|
||||
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
||||
|
||||
Allows patch-level changes if a minor version is specified on the
|
||||
comparator. Allows minor-level changes if not.
|
||||
|
||||
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
||||
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
||||
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
||||
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
||||
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
||||
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
||||
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
||||
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0-0`
|
||||
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0-0` (Same as `1.2.x`)
|
||||
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0-0` (Same as `1.x`)
|
||||
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0-0`
|
||||
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0-0` (Same as `0.2.x`)
|
||||
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0-0` (Same as `0.x`)
|
||||
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0-0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
@@ -306,15 +308,15 @@ However, it presumes that there will *not* be breaking changes between
|
||||
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
||||
additive (but non-breaking), according to commonly observed practices.
|
||||
|
||||
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
||||
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
||||
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
||||
* `^1.2.3` := `>=1.2.3 <2.0.0-0`
|
||||
* `^0.2.3` := `>=0.2.3 <0.3.0-0`
|
||||
* `^0.0.3` := `>=0.0.3 <0.0.4-0`
|
||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0-0` Note that prereleases in
|
||||
the `1.2.3` version will be allowed, if they are greater than or
|
||||
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
||||
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||
different `[major, minor, patch]` tuple.
|
||||
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
||||
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4-0` Note that prereleases in the
|
||||
`0.0.3` version *only* will be allowed, if they are greater than or
|
||||
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
||||
|
||||
@@ -322,16 +324,16 @@ When parsing caret ranges, a missing `patch` value desugars to the
|
||||
number `0`, but will allow flexibility within that value, even if the
|
||||
major and minor versions are both `0`.
|
||||
|
||||
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
||||
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
||||
* `^0.0` := `>=0.0.0 <0.1.0`
|
||||
* `^1.2.x` := `>=1.2.0 <2.0.0-0`
|
||||
* `^0.0.x` := `>=0.0.0 <0.1.0-0`
|
||||
* `^0.0` := `>=0.0.0 <0.1.0-0`
|
||||
|
||||
A missing `minor` and `patch` values will desugar to zero, but also
|
||||
allow flexibility within those values, even if the major version is
|
||||
zero.
|
||||
|
||||
* `^1.x` := `>=1.0.0 <2.0.0`
|
||||
* `^0.x` := `>=0.0.0 <1.0.0`
|
||||
* `^1.x` := `>=1.0.0 <2.0.0-0`
|
||||
* `^0.x` := `>=0.0.0 <1.0.0-0`
|
||||
|
||||
### Range Grammar
|
||||
|
||||
@@ -446,6 +448,16 @@ strings that they parse.
|
||||
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
||||
the function called by `gtr` and `ltr`.)
|
||||
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
||||
* `simplifyRange(versions, range)`: Return a "simplified" range that
|
||||
matches the same items in `versions` list as the range specified. Note
|
||||
that it does *not* guarantee that it would match the same versions in all
|
||||
cases, only for the set of versions provided. This is useful when
|
||||
generating ranges by joining together multiple versions with `||`
|
||||
programmatically, to provide the user with something a bit more
|
||||
ergonomic. If the provided range is shorter in string-length than the
|
||||
generated range, then that is returned.
|
||||
* `subset(subRange, superRange)`: Return `true` if the `subRange` range is
|
||||
entirely contained by the `superRange` range.
|
||||
|
||||
Note that, since ranges may be non-contiguous, a version might not be
|
||||
greater than a range, less than a range, *or* satisfy a range! For
|
||||
|
||||
+2
-6
@@ -5,12 +5,7 @@ class Comparator {
|
||||
return ANY
|
||||
}
|
||||
constructor (comp, options) {
|
||||
if (!options || typeof options !== 'object') {
|
||||
options = {
|
||||
loose: !!options,
|
||||
includePrerelease: false
|
||||
}
|
||||
}
|
||||
options = parseOptions(options)
|
||||
|
||||
if (comp instanceof Comparator) {
|
||||
if (comp.loose === !!options.loose) {
|
||||
@@ -132,6 +127,7 @@ class Comparator {
|
||||
|
||||
module.exports = Comparator
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const {re, t} = require('../internal/re')
|
||||
const cmp = require('../functions/cmp')
|
||||
const debug = require('../internal/debug')
|
||||
|
||||
+106
-44
@@ -1,12 +1,7 @@
|
||||
// hoisted class for cyclic dependency
|
||||
class Range {
|
||||
constructor (range, options) {
|
||||
if (!options || typeof options !== 'object') {
|
||||
options = {
|
||||
loose: !!options,
|
||||
includePrerelease: false
|
||||
}
|
||||
}
|
||||
options = parseOptions(options)
|
||||
|
||||
if (range instanceof Range) {
|
||||
if (
|
||||
@@ -46,6 +41,24 @@ class Range {
|
||||
throw new TypeError(`Invalid SemVer Range: ${range}`)
|
||||
}
|
||||
|
||||
// if we have any that are not the null set, throw out null sets.
|
||||
if (this.set.length > 1) {
|
||||
// keep the first one, in case they're all null sets
|
||||
const first = this.set[0]
|
||||
this.set = this.set.filter(c => !isNullSet(c[0]))
|
||||
if (this.set.length === 0)
|
||||
this.set = [first]
|
||||
else if (this.set.length > 1) {
|
||||
// if we have any that are *, then the range is just *
|
||||
for (const c of this.set) {
|
||||
if (c.length === 1 && isAny(c[0])) {
|
||||
this.set = [c]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.format()
|
||||
}
|
||||
|
||||
@@ -64,11 +77,20 @@ class Range {
|
||||
}
|
||||
|
||||
parseRange (range) {
|
||||
const loose = this.options.loose
|
||||
range = range.trim()
|
||||
|
||||
// memoize range parsing for performance.
|
||||
// this is a very hot path, and fully deterministic.
|
||||
const memoOpts = Object.keys(this.options).join(',')
|
||||
const memoKey = `parseRange:${memoOpts}:${range}`
|
||||
const cached = cache.get(memoKey)
|
||||
if (cached)
|
||||
return cached
|
||||
|
||||
const loose = this.options.loose
|
||||
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
||||
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
||||
range = range.replace(hr, hyphenReplace)
|
||||
range = range.replace(hr, hyphenReplace(this.options.includePrerelease))
|
||||
debug('hyphen replace', range)
|
||||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
||||
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
||||
@@ -87,14 +109,33 @@ class Range {
|
||||
// ready to be split into comparators.
|
||||
|
||||
const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
||||
return range
|
||||
const rangeList = range
|
||||
.split(' ')
|
||||
.map(comp => parseComparator(comp, this.options))
|
||||
.join(' ')
|
||||
.split(/\s+/)
|
||||
// >=0.0.0 is equivalent to *
|
||||
.map(comp => replaceGTE0(comp, this.options))
|
||||
// in loose mode, throw out any that are not valid comparators
|
||||
.filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
|
||||
.map(comp => new Comparator(comp, this.options))
|
||||
|
||||
// if any comparators are the null set, then replace with JUST null set
|
||||
// if more than one comparator, remove any * comparators
|
||||
// also, don't include the same comparator more than once
|
||||
const l = rangeList.length
|
||||
const rangeMap = new Map()
|
||||
for (const comp of rangeList) {
|
||||
if (isNullSet(comp))
|
||||
return [comp]
|
||||
rangeMap.set(comp.value, comp)
|
||||
}
|
||||
if (rangeMap.size > 1 && rangeMap.has(''))
|
||||
rangeMap.delete('')
|
||||
|
||||
const result = [...rangeMap.values()]
|
||||
cache.set(memoKey, result)
|
||||
return result
|
||||
}
|
||||
|
||||
intersects (range, options) {
|
||||
@@ -143,6 +184,10 @@ class Range {
|
||||
}
|
||||
module.exports = Range
|
||||
|
||||
const LRU = require('lru-cache')
|
||||
const cache = new LRU({ max: 1000 })
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const Comparator = require('./comparator')
|
||||
const debug = require('../internal/debug')
|
||||
const SemVer = require('./semver')
|
||||
@@ -154,6 +199,9 @@ const {
|
||||
caretTrimReplace
|
||||
} = require('../internal/re')
|
||||
|
||||
const isNullSet = c => c.value === '<0.0.0-0'
|
||||
const isAny = c => c.value === ''
|
||||
|
||||
// take a set of comparators and determine whether there
|
||||
// exists a version which can satisfy it
|
||||
const isSatisfiable = (comparators, options) => {
|
||||
@@ -191,11 +239,11 @@ const parseComparator = (comp, options) => {
|
||||
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
||||
|
||||
// ~, ~> --> * (any, kinda silly)
|
||||
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
||||
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
||||
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
||||
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
||||
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
||||
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
|
||||
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
|
||||
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0-0
|
||||
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
||||
const replaceTildes = (comp, options) =>
|
||||
comp.trim().split(/\s+/).map((comp) => {
|
||||
return replaceTilde(comp, options)
|
||||
@@ -210,18 +258,18 @@ const replaceTilde = (comp, options) => {
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0 <${+M + 1}.0.0`
|
||||
ret = `>=${M}.0.0 <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
// ~1.2 == >=1.2.0 <1.3.0
|
||||
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0`
|
||||
// ~1.2 == >=1.2.0 <1.3.0-0
|
||||
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
|
||||
} else if (pr) {
|
||||
debug('replaceTilde pr', pr)
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0`
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
// ~1.2.3 == >=1.2.3 <1.3.0
|
||||
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${+m + 1}.0`
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('tilde return', ret)
|
||||
@@ -230,11 +278,11 @@ const replaceTilde = (comp, options) => {
|
||||
}
|
||||
|
||||
// ^ --> * (any, kinda silly)
|
||||
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
||||
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
||||
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
||||
// ^1.2.3 --> >=1.2.3 <2.0.0
|
||||
// ^1.2.0 --> >=1.2.0 <2.0.0
|
||||
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
|
||||
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
||||
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
||||
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
||||
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
||||
const replaceCarets = (comp, options) =>
|
||||
comp.trim().split(/\s+/).map((comp) => {
|
||||
return replaceCaret(comp, options)
|
||||
@@ -243,6 +291,7 @@ const replaceCarets = (comp, options) =>
|
||||
const replaceCaret = (comp, options) => {
|
||||
debug('caret', comp, options)
|
||||
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
||||
const z = options.includePrerelease ? '-0' : ''
|
||||
return comp.replace(r, (_, M, m, p, pr) => {
|
||||
debug('caret', comp, _, M, m, p, pr)
|
||||
let ret
|
||||
@@ -250,40 +299,40 @@ const replaceCaret = (comp, options) => {
|
||||
if (isX(M)) {
|
||||
ret = ''
|
||||
} else if (isX(m)) {
|
||||
ret = `>=${M}.0.0 <${+M + 1}.0.0`
|
||||
ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`
|
||||
} else if (isX(p)) {
|
||||
if (M === '0') {
|
||||
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0`
|
||||
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.0 <${+M + 1}.0.0`
|
||||
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else if (pr) {
|
||||
debug('replaceCaret pr', pr)
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${m}.${+p + 1}`
|
||||
} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${M}.${+m + 1}.0`
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p}-${pr
|
||||
} <${+M + 1}.0.0`
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
} else {
|
||||
debug('no pr')
|
||||
if (M === '0') {
|
||||
if (m === '0') {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${m}.${+p + 1}`
|
||||
}${z} <${M}.${m}.${+p + 1}-0`
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${M}.${+m + 1}.0`
|
||||
}${z} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
} else {
|
||||
ret = `>=${M}.${m}.${p
|
||||
} <${+M + 1}.0.0`
|
||||
} <${+M + 1}.0.0-0`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,12 +405,15 @@ const replaceXRange = (comp, options) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (gtlt === '<')
|
||||
pr = '-0'
|
||||
|
||||
ret = `${gtlt + M}.${m}.${p}${pr}`
|
||||
} else if (xm) {
|
||||
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0${pr}`
|
||||
ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`
|
||||
} else if (xp) {
|
||||
ret = `>=${M}.${m}.0${pr
|
||||
} <${M}.${+m + 1}.0${pr}`
|
||||
} <${M}.${+m + 1}.0-0`
|
||||
}
|
||||
|
||||
debug('xRange return', ret)
|
||||
@@ -378,32 +430,42 @@ const replaceStars = (comp, options) => {
|
||||
return comp.trim().replace(re[t.STAR], '')
|
||||
}
|
||||
|
||||
const replaceGTE0 = (comp, options) => {
|
||||
debug('replaceGTE0', comp, options)
|
||||
return comp.trim()
|
||||
.replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], '')
|
||||
}
|
||||
|
||||
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
||||
// M, m, patch, prerelease, build
|
||||
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
||||
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
||||
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
||||
const hyphenReplace = ($0,
|
||||
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
|
||||
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
||||
const hyphenReplace = incPr => ($0,
|
||||
from, fM, fm, fp, fpr, fb,
|
||||
to, tM, tm, tp, tpr, tb) => {
|
||||
if (isX(fM)) {
|
||||
from = ''
|
||||
} else if (isX(fm)) {
|
||||
from = `>=${fM}.0.0`
|
||||
from = `>=${fM}.0.0${incPr ? '-0' : ''}`
|
||||
} else if (isX(fp)) {
|
||||
from = `>=${fM}.${fm}.0`
|
||||
} else {
|
||||
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
|
||||
} else if (fpr) {
|
||||
from = `>=${from}`
|
||||
} else {
|
||||
from = `>=${from}${incPr ? '-0' : ''}`
|
||||
}
|
||||
|
||||
if (isX(tM)) {
|
||||
to = ''
|
||||
} else if (isX(tm)) {
|
||||
to = `<${+tM + 1}.0.0`
|
||||
to = `<${+tM + 1}.0.0-0`
|
||||
} else if (isX(tp)) {
|
||||
to = `<${tM}.${+tm + 1}.0`
|
||||
to = `<${tM}.${+tm + 1}.0-0`
|
||||
} else if (tpr) {
|
||||
to = `<=${tM}.${tm}.${tp}-${tpr}`
|
||||
} else if (incPr) {
|
||||
to = `<${tM}.${tm}.${+tp + 1}-0`
|
||||
} else {
|
||||
to = `<=${to}`
|
||||
}
|
||||
|
||||
+3
-6
@@ -2,15 +2,12 @@ const debug = require('../internal/debug')
|
||||
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
|
||||
const { re, t } = require('../internal/re')
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const { compareIdentifiers } = require('../internal/identifiers')
|
||||
class SemVer {
|
||||
constructor (version, options) {
|
||||
if (!options || typeof options !== 'object') {
|
||||
options = {
|
||||
loose: !!options,
|
||||
includePrerelease: false
|
||||
}
|
||||
}
|
||||
options = parseOptions(options)
|
||||
|
||||
if (version instanceof SemVer) {
|
||||
if (version.loose === !!options.loose &&
|
||||
version.includePrerelease === !!options.includePrerelease) {
|
||||
|
||||
+2
-6
@@ -2,13 +2,9 @@ const {MAX_LENGTH} = require('../internal/constants')
|
||||
const { re, t } = require('../internal/re')
|
||||
const SemVer = require('../classes/semver')
|
||||
|
||||
const parseOptions = require('../internal/parse-options')
|
||||
const parse = (version, options) => {
|
||||
if (!options || typeof options !== 'object') {
|
||||
options = {
|
||||
loose: !!options,
|
||||
includePrerelease: false
|
||||
}
|
||||
}
|
||||
options = parseOptions(options)
|
||||
|
||||
if (version instanceof SemVer) {
|
||||
return version
|
||||
|
||||
+2
@@ -43,4 +43,6 @@ module.exports = {
|
||||
gtr: require('./ranges/gtr'),
|
||||
ltr: require('./ranges/ltr'),
|
||||
intersects: require('./ranges/intersects'),
|
||||
simplifyRange: require('./ranges/simplify'),
|
||||
subset: require('./ranges/subset'),
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// parse out just the options we care about so we always get a consistent
|
||||
// obj with keys in a consistent order.
|
||||
const opts = ['includePrerelease', 'loose', 'rtl']
|
||||
const parseOptions = options =>
|
||||
!options ? {}
|
||||
: typeof options !== 'object' ? { loose: true }
|
||||
: opts.filter(k => options[k]).reduce((options, k) => {
|
||||
options[k] = true
|
||||
return options
|
||||
}, {})
|
||||
module.exports = parseOptions
|
||||
+3
@@ -177,3 +177,6 @@ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
||||
|
||||
// Star ranges basically just allow anything at all.
|
||||
createToken('STAR', '(<|>)?=?\\s*\\*')
|
||||
// >=0.0.0 is like a star
|
||||
createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$')
|
||||
createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$')
|
||||
|
||||
+11
-8
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "semver",
|
||||
"version": "7.1.3",
|
||||
"version": "7.3.5",
|
||||
"description": "The semantic version parser used by npm.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -11,20 +11,20 @@
|
||||
"postpublish": "git push origin --follow-tags"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^14.10.2"
|
||||
"tap": "^14.10.7"
|
||||
},
|
||||
"license": "ISC",
|
||||
"repository": "https://github.com/npm/node-semver",
|
||||
"bin": {
|
||||
"semver": "./bin/semver.js"
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"bin/**/*.js",
|
||||
"range.bnf",
|
||||
"classes",
|
||||
"functions",
|
||||
"internal",
|
||||
"ranges",
|
||||
"classes/**/*.js",
|
||||
"functions/**/*.js",
|
||||
"internal/**/*.js",
|
||||
"ranges/**/*.js",
|
||||
"index.js",
|
||||
"preload.js"
|
||||
],
|
||||
@@ -34,5 +34,8 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"dependencies": {
|
||||
"lru-cache": "^6.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -19,6 +19,7 @@ const minVersion = (range, loose) => {
|
||||
for (let i = 0; i < range.set.length; ++i) {
|
||||
const comparators = range.set[i]
|
||||
|
||||
let setMin = null
|
||||
comparators.forEach((comparator) => {
|
||||
// Clone to avoid manipulating the comparator's semver object.
|
||||
const compver = new SemVer(comparator.semver.version)
|
||||
@@ -33,8 +34,8 @@ const minVersion = (range, loose) => {
|
||||
/* fallthrough */
|
||||
case '':
|
||||
case '>=':
|
||||
if (!minver || gt(minver, compver)) {
|
||||
minver = compver
|
||||
if (!setMin || gt(compver, setMin)) {
|
||||
setMin = compver
|
||||
}
|
||||
break
|
||||
case '<':
|
||||
@@ -46,6 +47,8 @@ const minVersion = (range, loose) => {
|
||||
throw new Error(`Unexpected operation: ${comparator.operator}`)
|
||||
}
|
||||
})
|
||||
if (setMin && (!minver || gt(minver, setMin)))
|
||||
minver = setMin
|
||||
}
|
||||
|
||||
if (minver && range.test(minver)) {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ const outside = (version, range, hilo, options) => {
|
||||
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
||||
}
|
||||
|
||||
// If it satisifes the range it is not outside
|
||||
// If it satisfies the range it is not outside
|
||||
if (satisfies(version, range, options)) {
|
||||
return false
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// given a set of versions and a range, create a "simplified" range
|
||||
// that includes the same versions that the original range does
|
||||
// If the original range is shorter than the simplified one, return that.
|
||||
const satisfies = require('../functions/satisfies.js')
|
||||
const compare = require('../functions/compare.js')
|
||||
module.exports = (versions, range, options) => {
|
||||
const set = []
|
||||
let min = null
|
||||
let prev = null
|
||||
const v = versions.sort((a, b) => compare(a, b, options))
|
||||
for (const version of v) {
|
||||
const included = satisfies(version, range, options)
|
||||
if (included) {
|
||||
prev = version
|
||||
if (!min)
|
||||
min = version
|
||||
} else {
|
||||
if (prev) {
|
||||
set.push([min, prev])
|
||||
}
|
||||
prev = null
|
||||
min = null
|
||||
}
|
||||
}
|
||||
if (min)
|
||||
set.push([min, null])
|
||||
|
||||
const ranges = []
|
||||
for (const [min, max] of set) {
|
||||
if (min === max)
|
||||
ranges.push(min)
|
||||
else if (!max && min === v[0])
|
||||
ranges.push('*')
|
||||
else if (!max)
|
||||
ranges.push(`>=${min}`)
|
||||
else if (min === v[0])
|
||||
ranges.push(`<=${max}`)
|
||||
else
|
||||
ranges.push(`${min} - ${max}`)
|
||||
}
|
||||
const simplified = ranges.join(' || ')
|
||||
const original = typeof range.raw === 'string' ? range.raw : String(range)
|
||||
return simplified.length < original.length ? simplified : range
|
||||
}
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
const Range = require('../classes/range.js')
|
||||
const Comparator = require('../classes/comparator.js')
|
||||
const { ANY } = Comparator
|
||||
const satisfies = require('../functions/satisfies.js')
|
||||
const compare = require('../functions/compare.js')
|
||||
|
||||
// Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
|
||||
// - Every simple range `r1, r2, ...` is a null set, OR
|
||||
// - Every simple range `r1, r2, ...` which is not a null set is a subset of
|
||||
// some `R1, R2, ...`
|
||||
//
|
||||
// Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
|
||||
// - If c is only the ANY comparator
|
||||
// - If C is only the ANY comparator, return true
|
||||
// - Else if in prerelease mode, return false
|
||||
// - else replace c with `[>=0.0.0]`
|
||||
// - If C is only the ANY comparator
|
||||
// - if in prerelease mode, return true
|
||||
// - else replace C with `[>=0.0.0]`
|
||||
// - Let EQ be the set of = comparators in c
|
||||
// - If EQ is more than one, return true (null set)
|
||||
// - Let GT be the highest > or >= comparator in c
|
||||
// - Let LT be the lowest < or <= comparator in c
|
||||
// - If GT and LT, and GT.semver > LT.semver, return true (null set)
|
||||
// - If any C is a = range, and GT or LT are set, return false
|
||||
// - If EQ
|
||||
// - If GT, and EQ does not satisfy GT, return true (null set)
|
||||
// - If LT, and EQ does not satisfy LT, return true (null set)
|
||||
// - If EQ satisfies every C, return true
|
||||
// - Else return false
|
||||
// - If GT
|
||||
// - If GT.semver is lower than any > or >= comp in C, return false
|
||||
// - If GT is >=, and GT.semver does not satisfy every C, return false
|
||||
// - If GT.semver has a prerelease, and not in prerelease mode
|
||||
// - If no C has a prerelease and the GT.semver tuple, return false
|
||||
// - If LT
|
||||
// - If LT.semver is greater than any < or <= comp in C, return false
|
||||
// - If LT is <=, and LT.semver does not satisfy every C, return false
|
||||
// - If GT.semver has a prerelease, and not in prerelease mode
|
||||
// - If no C has a prerelease and the LT.semver tuple, return false
|
||||
// - Else return true
|
||||
|
||||
const subset = (sub, dom, options = {}) => {
|
||||
if (sub === dom)
|
||||
return true
|
||||
|
||||
sub = new Range(sub, options)
|
||||
dom = new Range(dom, options)
|
||||
let sawNonNull = false
|
||||
|
||||
OUTER: for (const simpleSub of sub.set) {
|
||||
for (const simpleDom of dom.set) {
|
||||
const isSub = simpleSubset(simpleSub, simpleDom, options)
|
||||
sawNonNull = sawNonNull || isSub !== null
|
||||
if (isSub)
|
||||
continue OUTER
|
||||
}
|
||||
// the null set is a subset of everything, but null simple ranges in
|
||||
// a complex range should be ignored. so if we saw a non-null range,
|
||||
// then we know this isn't a subset, but if EVERY simple range was null,
|
||||
// then it is a subset.
|
||||
if (sawNonNull)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const simpleSubset = (sub, dom, options) => {
|
||||
if (sub === dom)
|
||||
return true
|
||||
|
||||
if (sub.length === 1 && sub[0].semver === ANY) {
|
||||
if (dom.length === 1 && dom[0].semver === ANY)
|
||||
return true
|
||||
else if (options.includePrerelease)
|
||||
sub = [ new Comparator('>=0.0.0-0') ]
|
||||
else
|
||||
sub = [ new Comparator('>=0.0.0') ]
|
||||
}
|
||||
|
||||
if (dom.length === 1 && dom[0].semver === ANY) {
|
||||
if (options.includePrerelease)
|
||||
return true
|
||||
else
|
||||
dom = [ new Comparator('>=0.0.0') ]
|
||||
}
|
||||
|
||||
const eqSet = new Set()
|
||||
let gt, lt
|
||||
for (const c of sub) {
|
||||
if (c.operator === '>' || c.operator === '>=')
|
||||
gt = higherGT(gt, c, options)
|
||||
else if (c.operator === '<' || c.operator === '<=')
|
||||
lt = lowerLT(lt, c, options)
|
||||
else
|
||||
eqSet.add(c.semver)
|
||||
}
|
||||
|
||||
if (eqSet.size > 1)
|
||||
return null
|
||||
|
||||
let gtltComp
|
||||
if (gt && lt) {
|
||||
gtltComp = compare(gt.semver, lt.semver, options)
|
||||
if (gtltComp > 0)
|
||||
return null
|
||||
else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<='))
|
||||
return null
|
||||
}
|
||||
|
||||
// will iterate one or zero times
|
||||
for (const eq of eqSet) {
|
||||
if (gt && !satisfies(eq, String(gt), options))
|
||||
return null
|
||||
|
||||
if (lt && !satisfies(eq, String(lt), options))
|
||||
return null
|
||||
|
||||
for (const c of dom) {
|
||||
if (!satisfies(eq, String(c), options))
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
let higher, lower
|
||||
let hasDomLT, hasDomGT
|
||||
// if the subset has a prerelease, we need a comparator in the superset
|
||||
// with the same tuple and a prerelease, or it's not a subset
|
||||
let needDomLTPre = lt &&
|
||||
!options.includePrerelease &&
|
||||
lt.semver.prerelease.length ? lt.semver : false
|
||||
let needDomGTPre = gt &&
|
||||
!options.includePrerelease &&
|
||||
gt.semver.prerelease.length ? gt.semver : false
|
||||
// exception: <1.2.3-0 is the same as <1.2.3
|
||||
if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
|
||||
lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
|
||||
needDomLTPre = false
|
||||
}
|
||||
|
||||
for (const c of dom) {
|
||||
hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='
|
||||
hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='
|
||||
if (gt) {
|
||||
if (needDomGTPre) {
|
||||
if (c.semver.prerelease && c.semver.prerelease.length &&
|
||||
c.semver.major === needDomGTPre.major &&
|
||||
c.semver.minor === needDomGTPre.minor &&
|
||||
c.semver.patch === needDomGTPre.patch) {
|
||||
needDomGTPre = false
|
||||
}
|
||||
}
|
||||
if (c.operator === '>' || c.operator === '>=') {
|
||||
higher = higherGT(gt, c, options)
|
||||
if (higher === c && higher !== gt)
|
||||
return false
|
||||
} else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options))
|
||||
return false
|
||||
}
|
||||
if (lt) {
|
||||
if (needDomLTPre) {
|
||||
if (c.semver.prerelease && c.semver.prerelease.length &&
|
||||
c.semver.major === needDomLTPre.major &&
|
||||
c.semver.minor === needDomLTPre.minor &&
|
||||
c.semver.patch === needDomLTPre.patch) {
|
||||
needDomLTPre = false
|
||||
}
|
||||
}
|
||||
if (c.operator === '<' || c.operator === '<=') {
|
||||
lower = lowerLT(lt, c, options)
|
||||
if (lower === c && lower !== lt)
|
||||
return false
|
||||
} else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options))
|
||||
return false
|
||||
}
|
||||
if (!c.operator && (lt || gt) && gtltComp !== 0)
|
||||
return false
|
||||
}
|
||||
|
||||
// if there was a < or >, and nothing in the dom, then must be false
|
||||
// UNLESS it was limited by another range in the other direction.
|
||||
// Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
|
||||
if (gt && hasDomLT && !lt && gtltComp !== 0)
|
||||
return false
|
||||
|
||||
if (lt && hasDomGT && !gt && gtltComp !== 0)
|
||||
return false
|
||||
|
||||
// we needed a prerelease range in a specific tuple, but didn't get one
|
||||
// then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
|
||||
// because it includes prereleases in the 1.2.3 tuple
|
||||
if (needDomGTPre || needDomLTPre)
|
||||
return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// >=1.2.3 is lower than >1.2.3
|
||||
const higherGT = (a, b, options) => {
|
||||
if (!a)
|
||||
return b
|
||||
const comp = compare(a.semver, b.semver, options)
|
||||
return comp > 0 ? a
|
||||
: comp < 0 ? b
|
||||
: b.operator === '>' && a.operator === '>=' ? b
|
||||
: a
|
||||
}
|
||||
|
||||
// <=1.2.3 is higher than <1.2.3
|
||||
const lowerLT = (a, b, options) => {
|
||||
if (!a)
|
||||
return b
|
||||
const comp = compare(a.semver, b.semver, options)
|
||||
return comp < 0 ? a
|
||||
: comp > 0 ? b
|
||||
: b.operator === '<' && a.operator === '<=' ? b
|
||||
: a
|
||||
}
|
||||
|
||||
module.exports = subset
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
# yallist
|
||||
|
||||
Yet Another Linked List
|
||||
|
||||
There are many doubly-linked list implementations like it, but this
|
||||
one is mine.
|
||||
|
||||
For when an array would be too big, and a Map can't be iterated in
|
||||
reverse order.
|
||||
|
||||
|
||||
[](https://travis-ci.org/isaacs/yallist) [](https://coveralls.io/github/isaacs/yallist)
|
||||
|
||||
## basic usage
|
||||
|
||||
```javascript
|
||||
var yallist = require('yallist')
|
||||
var myList = yallist.create([1, 2, 3])
|
||||
myList.push('foo')
|
||||
myList.unshift('bar')
|
||||
// of course pop() and shift() are there, too
|
||||
console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']
|
||||
myList.forEach(function (k) {
|
||||
// walk the list head to tail
|
||||
})
|
||||
myList.forEachReverse(function (k, index, list) {
|
||||
// walk the list tail to head
|
||||
})
|
||||
var myDoubledList = myList.map(function (k) {
|
||||
return k + k
|
||||
})
|
||||
// now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']
|
||||
// mapReverse is also a thing
|
||||
var myDoubledListReverse = myList.mapReverse(function (k) {
|
||||
return k + k
|
||||
}) // ['foofoo', 6, 4, 2, 'barbar']
|
||||
|
||||
var reduced = myList.reduce(function (set, entry) {
|
||||
set += entry
|
||||
return set
|
||||
}, 'start')
|
||||
console.log(reduced) // 'startfoo123bar'
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
The whole API is considered "public".
|
||||
|
||||
Functions with the same name as an Array method work more or less the
|
||||
same way.
|
||||
|
||||
There's reverse versions of most things because that's the point.
|
||||
|
||||
### Yallist
|
||||
|
||||
Default export, the class that holds and manages a list.
|
||||
|
||||
Call it with either a forEach-able (like an array) or a set of
|
||||
arguments, to initialize the list.
|
||||
|
||||
The Array-ish methods all act like you'd expect. No magic length,
|
||||
though, so if you change that it won't automatically prune or add
|
||||
empty spots.
|
||||
|
||||
### Yallist.create(..)
|
||||
|
||||
Alias for Yallist function. Some people like factories.
|
||||
|
||||
#### yallist.head
|
||||
|
||||
The first node in the list
|
||||
|
||||
#### yallist.tail
|
||||
|
||||
The last node in the list
|
||||
|
||||
#### yallist.length
|
||||
|
||||
The number of nodes in the list. (Change this at your peril. It is
|
||||
not magic like Array length.)
|
||||
|
||||
#### yallist.toArray()
|
||||
|
||||
Convert the list to an array.
|
||||
|
||||
#### yallist.forEach(fn, [thisp])
|
||||
|
||||
Call a function on each item in the list.
|
||||
|
||||
#### yallist.forEachReverse(fn, [thisp])
|
||||
|
||||
Call a function on each item in the list, in reverse order.
|
||||
|
||||
#### yallist.get(n)
|
||||
|
||||
Get the data at position `n` in the list. If you use this a lot,
|
||||
probably better off just using an Array.
|
||||
|
||||
#### yallist.getReverse(n)
|
||||
|
||||
Get the data at position `n`, counting from the tail.
|
||||
|
||||
#### yallist.map(fn, thisp)
|
||||
|
||||
Create a new Yallist with the result of calling the function on each
|
||||
item.
|
||||
|
||||
#### yallist.mapReverse(fn, thisp)
|
||||
|
||||
Same as `map`, but in reverse.
|
||||
|
||||
#### yallist.pop()
|
||||
|
||||
Get the data from the list tail, and remove the tail from the list.
|
||||
|
||||
#### yallist.push(item, ...)
|
||||
|
||||
Insert one or more items to the tail of the list.
|
||||
|
||||
#### yallist.reduce(fn, initialValue)
|
||||
|
||||
Like Array.reduce.
|
||||
|
||||
#### yallist.reduceReverse
|
||||
|
||||
Like Array.reduce, but in reverse.
|
||||
|
||||
#### yallist.reverse
|
||||
|
||||
Reverse the list in place.
|
||||
|
||||
#### yallist.shift()
|
||||
|
||||
Get the data from the list head, and remove the head from the list.
|
||||
|
||||
#### yallist.slice([from], [to])
|
||||
|
||||
Just like Array.slice, but returns a new Yallist.
|
||||
|
||||
#### yallist.sliceReverse([from], [to])
|
||||
|
||||
Just like yallist.slice, but the result is returned in reverse.
|
||||
|
||||
#### yallist.toArray()
|
||||
|
||||
Create an array representation of the list.
|
||||
|
||||
#### yallist.toArrayReverse()
|
||||
|
||||
Create a reversed array representation of the list.
|
||||
|
||||
#### yallist.unshift(item, ...)
|
||||
|
||||
Insert one or more items to the head of the list.
|
||||
|
||||
#### yallist.unshiftNode(node)
|
||||
|
||||
Move a Node object to the front of the list. (That is, pull it out of
|
||||
wherever it lives, and make it the new head.)
|
||||
|
||||
If the node belongs to a different list, then that list will remove it
|
||||
first.
|
||||
|
||||
#### yallist.pushNode(node)
|
||||
|
||||
Move a Node object to the end of the list. (That is, pull it out of
|
||||
wherever it lives, and make it the new tail.)
|
||||
|
||||
If the node belongs to a list already, then that list will remove it
|
||||
first.
|
||||
|
||||
#### yallist.removeNode(node)
|
||||
|
||||
Remove a node from the list, preserving referential integrity of head
|
||||
and tail and other nodes.
|
||||
|
||||
Will throw an error if you try to have a list remove a node that
|
||||
doesn't belong to it.
|
||||
|
||||
### Yallist.Node
|
||||
|
||||
The class that holds the data and is actually the list.
|
||||
|
||||
Call with `var n = new Node(value, previousNode, nextNode)`
|
||||
|
||||
Note that if you do direct operations on Nodes themselves, it's very
|
||||
easy to get into weird states where the list is broken. Be careful :)
|
||||
|
||||
#### node.next
|
||||
|
||||
The next node in the list.
|
||||
|
||||
#### node.prev
|
||||
|
||||
The previous node in the list.
|
||||
|
||||
#### node.value
|
||||
|
||||
The data the node contains.
|
||||
|
||||
#### node.list
|
||||
|
||||
The list to which this node belongs. (Null if it does not belong to
|
||||
any list.)
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
'use strict'
|
||||
module.exports = function (Yallist) {
|
||||
Yallist.prototype[Symbol.iterator] = function* () {
|
||||
for (let walker = this.head; walker; walker = walker.next) {
|
||||
yield walker.value
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "yallist",
|
||||
"version": "4.0.0",
|
||||
"description": "Yet Another Linked List",
|
||||
"main": "yallist.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"files": [
|
||||
"yallist.js",
|
||||
"iterator.js"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tap": "^12.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js --100",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"postpublish": "git push origin --all; git push origin --tags"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/isaacs/yallist.git"
|
||||
},
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"license": "ISC"
|
||||
}
|
||||
+426
@@ -0,0 +1,426 @@
|
||||
'use strict'
|
||||
module.exports = Yallist
|
||||
|
||||
Yallist.Node = Node
|
||||
Yallist.create = Yallist
|
||||
|
||||
function Yallist (list) {
|
||||
var self = this
|
||||
if (!(self instanceof Yallist)) {
|
||||
self = new Yallist()
|
||||
}
|
||||
|
||||
self.tail = null
|
||||
self.head = null
|
||||
self.length = 0
|
||||
|
||||
if (list && typeof list.forEach === 'function') {
|
||||
list.forEach(function (item) {
|
||||
self.push(item)
|
||||
})
|
||||
} else if (arguments.length > 0) {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
self.push(arguments[i])
|
||||
}
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
Yallist.prototype.removeNode = function (node) {
|
||||
if (node.list !== this) {
|
||||
throw new Error('removing node which does not belong to this list')
|
||||
}
|
||||
|
||||
var next = node.next
|
||||
var prev = node.prev
|
||||
|
||||
if (next) {
|
||||
next.prev = prev
|
||||
}
|
||||
|
||||
if (prev) {
|
||||
prev.next = next
|
||||
}
|
||||
|
||||
if (node === this.head) {
|
||||
this.head = next
|
||||
}
|
||||
if (node === this.tail) {
|
||||
this.tail = prev
|
||||
}
|
||||
|
||||
node.list.length--
|
||||
node.next = null
|
||||
node.prev = null
|
||||
node.list = null
|
||||
|
||||
return next
|
||||
}
|
||||
|
||||
Yallist.prototype.unshiftNode = function (node) {
|
||||
if (node === this.head) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node)
|
||||
}
|
||||
|
||||
var head = this.head
|
||||
node.list = this
|
||||
node.next = head
|
||||
if (head) {
|
||||
head.prev = node
|
||||
}
|
||||
|
||||
this.head = node
|
||||
if (!this.tail) {
|
||||
this.tail = node
|
||||
}
|
||||
this.length++
|
||||
}
|
||||
|
||||
Yallist.prototype.pushNode = function (node) {
|
||||
if (node === this.tail) {
|
||||
return
|
||||
}
|
||||
|
||||
if (node.list) {
|
||||
node.list.removeNode(node)
|
||||
}
|
||||
|
||||
var tail = this.tail
|
||||
node.list = this
|
||||
node.prev = tail
|
||||
if (tail) {
|
||||
tail.next = node
|
||||
}
|
||||
|
||||
this.tail = node
|
||||
if (!this.head) {
|
||||
this.head = node
|
||||
}
|
||||
this.length++
|
||||
}
|
||||
|
||||
Yallist.prototype.push = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
push(this, arguments[i])
|
||||
}
|
||||
return this.length
|
||||
}
|
||||
|
||||
Yallist.prototype.unshift = function () {
|
||||
for (var i = 0, l = arguments.length; i < l; i++) {
|
||||
unshift(this, arguments[i])
|
||||
}
|
||||
return this.length
|
||||
}
|
||||
|
||||
Yallist.prototype.pop = function () {
|
||||
if (!this.tail) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.tail.value
|
||||
this.tail = this.tail.prev
|
||||
if (this.tail) {
|
||||
this.tail.next = null
|
||||
} else {
|
||||
this.head = null
|
||||
}
|
||||
this.length--
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.shift = function () {
|
||||
if (!this.head) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
var res = this.head.value
|
||||
this.head = this.head.next
|
||||
if (this.head) {
|
||||
this.head.prev = null
|
||||
} else {
|
||||
this.tail = null
|
||||
}
|
||||
this.length--
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.forEach = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this.head, i = 0; walker !== null; i++) {
|
||||
fn.call(thisp, walker.value, i, this)
|
||||
walker = walker.next
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
||||
fn.call(thisp, walker.value, i, this)
|
||||
walker = walker.prev
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.get = function (n) {
|
||||
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.next
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.getReverse = function (n) {
|
||||
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
||||
// abort out of the list early if we hit a cycle
|
||||
walker = walker.prev
|
||||
}
|
||||
if (i === n && walker !== null) {
|
||||
return walker.value
|
||||
}
|
||||
}
|
||||
|
||||
Yallist.prototype.map = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
var res = new Yallist()
|
||||
for (var walker = this.head; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this))
|
||||
walker = walker.next
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.mapReverse = function (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
var res = new Yallist()
|
||||
for (var walker = this.tail; walker !== null;) {
|
||||
res.push(fn.call(thisp, walker.value, this))
|
||||
walker = walker.prev
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
Yallist.prototype.reduce = function (fn, initial) {
|
||||
var acc
|
||||
var walker = this.head
|
||||
if (arguments.length > 1) {
|
||||
acc = initial
|
||||
} else if (this.head) {
|
||||
walker = this.head.next
|
||||
acc = this.head.value
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = 0; walker !== null; i++) {
|
||||
acc = fn(acc, walker.value, i)
|
||||
walker = walker.next
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
Yallist.prototype.reduceReverse = function (fn, initial) {
|
||||
var acc
|
||||
var walker = this.tail
|
||||
if (arguments.length > 1) {
|
||||
acc = initial
|
||||
} else if (this.tail) {
|
||||
walker = this.tail.prev
|
||||
acc = this.tail.value
|
||||
} else {
|
||||
throw new TypeError('Reduce of empty list with no initial value')
|
||||
}
|
||||
|
||||
for (var i = this.length - 1; walker !== null; i--) {
|
||||
acc = fn(acc, walker.value, i)
|
||||
walker = walker.prev
|
||||
}
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
Yallist.prototype.toArray = function () {
|
||||
var arr = new Array(this.length)
|
||||
for (var i = 0, walker = this.head; walker !== null; i++) {
|
||||
arr[i] = walker.value
|
||||
walker = walker.next
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
Yallist.prototype.toArrayReverse = function () {
|
||||
var arr = new Array(this.length)
|
||||
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
||||
arr[i] = walker.value
|
||||
walker = walker.prev
|
||||
}
|
||||
return arr
|
||||
}
|
||||
|
||||
Yallist.prototype.slice = function (from, to) {
|
||||
to = to || this.length
|
||||
if (to < 0) {
|
||||
to += this.length
|
||||
}
|
||||
from = from || 0
|
||||
if (from < 0) {
|
||||
from += this.length
|
||||
}
|
||||
var ret = new Yallist()
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length
|
||||
}
|
||||
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
||||
walker = walker.next
|
||||
}
|
||||
for (; walker !== null && i < to; i++, walker = walker.next) {
|
||||
ret.push(walker.value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
Yallist.prototype.sliceReverse = function (from, to) {
|
||||
to = to || this.length
|
||||
if (to < 0) {
|
||||
to += this.length
|
||||
}
|
||||
from = from || 0
|
||||
if (from < 0) {
|
||||
from += this.length
|
||||
}
|
||||
var ret = new Yallist()
|
||||
if (to < from || to < 0) {
|
||||
return ret
|
||||
}
|
||||
if (from < 0) {
|
||||
from = 0
|
||||
}
|
||||
if (to > this.length) {
|
||||
to = this.length
|
||||
}
|
||||
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
||||
walker = walker.prev
|
||||
}
|
||||
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
||||
ret.push(walker.value)
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
Yallist.prototype.splice = function (start, deleteCount, ...nodes) {
|
||||
if (start > this.length) {
|
||||
start = this.length - 1
|
||||
}
|
||||
if (start < 0) {
|
||||
start = this.length + start;
|
||||
}
|
||||
|
||||
for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
|
||||
walker = walker.next
|
||||
}
|
||||
|
||||
var ret = []
|
||||
for (var i = 0; walker && i < deleteCount; i++) {
|
||||
ret.push(walker.value)
|
||||
walker = this.removeNode(walker)
|
||||
}
|
||||
if (walker === null) {
|
||||
walker = this.tail
|
||||
}
|
||||
|
||||
if (walker !== this.head && walker !== this.tail) {
|
||||
walker = walker.prev
|
||||
}
|
||||
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
walker = insert(this, walker, nodes[i])
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Yallist.prototype.reverse = function () {
|
||||
var head = this.head
|
||||
var tail = this.tail
|
||||
for (var walker = head; walker !== null; walker = walker.prev) {
|
||||
var p = walker.prev
|
||||
walker.prev = walker.next
|
||||
walker.next = p
|
||||
}
|
||||
this.head = tail
|
||||
this.tail = head
|
||||
return this
|
||||
}
|
||||
|
||||
function insert (self, node, value) {
|
||||
var inserted = node === self.head ?
|
||||
new Node(value, null, node, self) :
|
||||
new Node(value, node, node.next, self)
|
||||
|
||||
if (inserted.next === null) {
|
||||
self.tail = inserted
|
||||
}
|
||||
if (inserted.prev === null) {
|
||||
self.head = inserted
|
||||
}
|
||||
|
||||
self.length++
|
||||
|
||||
return inserted
|
||||
}
|
||||
|
||||
function push (self, item) {
|
||||
self.tail = new Node(item, self.tail, null, self)
|
||||
if (!self.head) {
|
||||
self.head = self.tail
|
||||
}
|
||||
self.length++
|
||||
}
|
||||
|
||||
function unshift (self, item) {
|
||||
self.head = new Node(item, null, self.head, self)
|
||||
if (!self.tail) {
|
||||
self.tail = self.head
|
||||
}
|
||||
self.length++
|
||||
}
|
||||
|
||||
function Node (value, prev, next, list) {
|
||||
if (!(this instanceof Node)) {
|
||||
return new Node(value, prev, next, list)
|
||||
}
|
||||
|
||||
this.list = list
|
||||
this.value = value
|
||||
|
||||
if (prev) {
|
||||
prev.next = this
|
||||
this.prev = prev
|
||||
} else {
|
||||
this.prev = null
|
||||
}
|
||||
|
||||
if (next) {
|
||||
next.prev = this
|
||||
this.next = next
|
||||
} else {
|
||||
this.next = null
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// add if support for Symbol.iterator is present
|
||||
require('./iterator.js')(Yallist)
|
||||
} catch (er) {}
|
||||
+21
-19
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "github-action-setup-xmake",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.10",
|
||||
"description": "Set up your GitHub Actions workflow with a specific version of xmake",
|
||||
"main": "dist/index.js",
|
||||
"author": "OpportunityLiu",
|
||||
@@ -14,29 +14,31 @@
|
||||
"rebuild": "yarn clean && yarn build",
|
||||
"clean": "rimraf dist",
|
||||
"lint": "eslint --fix src/**/*.ts",
|
||||
"format": "prettier --write .",
|
||||
"test": "jest",
|
||||
"release": "yarn rebuild && yarn lint && yarn install --production --no-bin-links"
|
||||
"release": "yarn clean && yarn format && yarn lint && yarn build && yarn install --production --frozen-lockfile --no-bin-links"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.1.3",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/io": "^1.0.1",
|
||||
"@actions/tool-cache": "^1.1.2",
|
||||
"semver": "^7.1.3"
|
||||
"@actions/core": "^1.2.7",
|
||||
"@actions/exec": "^1.0.4",
|
||||
"@actions/io": "^1.1.0",
|
||||
"@actions/tool-cache": "^1.6.1",
|
||||
"semver": "^7.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^13.9.8",
|
||||
"@types/semver": "^7.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^2.26.0",
|
||||
"@typescript-eslint/parser": "^2.26.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-config-prettier": "^6.10.1",
|
||||
"eslint-plugin-prettier": "^3.1.2",
|
||||
"jest": "^25.2.4",
|
||||
"prettier": "^2.0.2",
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/node": "^15.0.2",
|
||||
"@types/semver": "^7.3.5",
|
||||
"@typescript-eslint/eslint-plugin": "^4.23.0",
|
||||
"@typescript-eslint/parser": "^4.23.0",
|
||||
"eslint": "^7.26.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
"jest": "^26.6.3",
|
||||
"prettier": "^2.3.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-jest": "^25.3.0",
|
||||
"typescript": "^3.8.3"
|
||||
"ts-jest": "^26.5.6",
|
||||
"type-fest": "^1.1.1",
|
||||
"typescript": "^4.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
import * as git from './git';
|
||||
import * as semver from 'semver';
|
||||
import { Repo } from './interfaces';
|
||||
|
||||
describe('lsRemote', () => {
|
||||
it('should return correct records', async () => {
|
||||
const records = await git.lsRemote();
|
||||
const records = await git.lsRemote(Repo('xmake-io/xmake'));
|
||||
expect(records).toHaveProperty('heads');
|
||||
expect(records).toHaveProperty('tags');
|
||||
expect(records).toHaveProperty('pull');
|
||||
|
||||
+19
-27
@@ -2,33 +2,17 @@ import { exec } from '@actions/exec';
|
||||
import * as io from '@actions/io';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import { Sha, RefDic, Repo } from './interfaces';
|
||||
|
||||
function makeOpt(ref: string): { cwd: string } {
|
||||
function makeOpt(ref: Sha): { cwd: string } {
|
||||
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
|
||||
}
|
||||
|
||||
export type RefDic = {
|
||||
/** branches */
|
||||
heads: Record<string, string>;
|
||||
/** tags */
|
||||
tags: Record<string, string>;
|
||||
/** pull requests */
|
||||
pull: Record<
|
||||
number,
|
||||
{
|
||||
/** the current state of the pull request */
|
||||
head: string;
|
||||
/** the current branch we're merging onto */
|
||||
base?: string;
|
||||
/** merge result */
|
||||
merge?: string;
|
||||
}
|
||||
>;
|
||||
};
|
||||
const repoUrl = (repo: Repo): string => `https://github.com/${repo}.git`;
|
||||
|
||||
export async function lsRemote(): Promise<RefDic> {
|
||||
export async function lsRemote(repo: Repo): Promise<RefDic> {
|
||||
let out = '';
|
||||
await exec('git', ['ls-remote', 'https://github.com/xmake-io/xmake.git'], {
|
||||
await exec('git', ['ls-remote', repoUrl(repo)], {
|
||||
silent: true,
|
||||
listeners: {
|
||||
stdout: (d) => (out += d.toString()),
|
||||
@@ -40,34 +24,42 @@ export async function lsRemote(): Promise<RefDic> {
|
||||
if (ref && tag && tag.startsWith('refs/')) {
|
||||
const tagPath = tag.split('/').splice(1);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let ldata = data as any;
|
||||
let ldata = data as any; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
||||
for (let i = 0; i < tagPath.length - 1; i++) {
|
||||
const seg = tagPath[i];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
if (typeof ldata[seg] === 'object') {
|
||||
ldata = ldata[seg];
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
ldata = ldata[seg]; // eslint-disable-line @typescript-eslint/no-unsafe-assignment
|
||||
} else {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
ldata = ldata[seg] = {};
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
ldata[tagPath[tagPath.length - 1]] = ref;
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function create(ref: string): Promise<string> {
|
||||
export async function create(repo: Repo, ref: Sha): Promise<string> {
|
||||
const opt = makeOpt(ref);
|
||||
await io.rmRF(opt.cwd);
|
||||
await io.mkdirP(opt.cwd);
|
||||
await exec('git', ['init'], opt);
|
||||
await exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], opt);
|
||||
await exec('git', ['fetch', 'origin', '+refs/pull/*:refs/remotes/origin/pull/*', '+refs/heads/*:refs/remotes/origin/*'], opt);
|
||||
await exec('git', ['remote', 'add', 'origin', repoUrl(repo)], opt);
|
||||
await exec(
|
||||
'git',
|
||||
['fetch', 'origin', '+refs/pull/*:refs/remotes/origin/pull/*', '+refs/heads/*:refs/remotes/origin/*'],
|
||||
opt,
|
||||
);
|
||||
await exec('git', ['checkout', ref], opt);
|
||||
await exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
||||
return opt.cwd;
|
||||
}
|
||||
|
||||
export async function cleanup(ref: string): Promise<void> {
|
||||
export async function cleanup(ref: Sha): Promise<void> {
|
||||
const opt = makeOpt(ref);
|
||||
await io.rmRF(opt.cwd);
|
||||
}
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@ async function run(): Promise<void> {
|
||||
else await unixInstall(version);
|
||||
await exec('xmake --version');
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
const ex = error as Error;
|
||||
core.setFailed(ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import { Opaque } from 'type-fest';
|
||||
|
||||
export type Sha = Opaque<string, 'sha'>;
|
||||
export function Sha(sha: string): Sha {
|
||||
sha = sha.trim().toLowerCase();
|
||||
if (!/^[a-f0-9]{40}$/g.test(sha)) throw new Error(`Invalid sha value ${sha}`);
|
||||
return sha as Sha;
|
||||
}
|
||||
|
||||
export type Repo = Opaque<string, 'repo'>;
|
||||
export function Repo(repo: string): Repo {
|
||||
repo = repo.trim();
|
||||
if (!/^([^/#]+\/[^/#]+)$/g.test(repo)) throw new Error(`Invalid repo value ${repo}`);
|
||||
return repo as Repo;
|
||||
}
|
||||
|
||||
export type RefDic = {
|
||||
/** branches */
|
||||
heads: Record<string, Sha>;
|
||||
/** tags */
|
||||
tags: Record<string, Sha>;
|
||||
/** pull requests */
|
||||
pull: Record<
|
||||
number,
|
||||
{
|
||||
/** the current state of the pull request */
|
||||
head: Sha;
|
||||
/** the current branch we're merging onto */
|
||||
base?: Sha;
|
||||
/** merge result */
|
||||
merge?: Sha;
|
||||
}
|
||||
>;
|
||||
};
|
||||
|
||||
export interface GitVersion {
|
||||
version: string;
|
||||
sha: Sha;
|
||||
type: keyof RefDic | 'sha';
|
||||
repo: Repo;
|
||||
}
|
||||
|
||||
export interface LocalVersion {
|
||||
type: 'local';
|
||||
path: string;
|
||||
version: undefined;
|
||||
}
|
||||
|
||||
export type Version = GitVersion | LocalVersion;
|
||||
+30
-14
@@ -6,25 +6,41 @@ import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import * as git from './git';
|
||||
import { Version } from './versions';
|
||||
import { Version } from './interfaces';
|
||||
|
||||
async function install(sourceDir: string, binDir: string): Promise<void> {
|
||||
await exec('make', ['build'], { cwd: sourceDir });
|
||||
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||
}
|
||||
|
||||
export async function unixInstall(version: Version): Promise<void> {
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core.group(`download xmake ${version}`, () => git.create(version.sha));
|
||||
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||
await exec('make', ['build'], { cwd: sourceDir });
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
let toolDir: string;
|
||||
if (version.type !== 'local') {
|
||||
const ver = version.version;
|
||||
toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const sourceDir = await core.group(`download xmake ${String(version)}`, () =>
|
||||
git.create(version.repo, version.sha),
|
||||
);
|
||||
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
await install(sourceDir, binDir);
|
||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||
await io.rmRF(binDir);
|
||||
await git.cleanup(version.sha);
|
||||
return cacheDir;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// no tool cache for local install
|
||||
toolDir = await core.group(`install local xmake at '${version.path}'`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${Date.now()}`);
|
||||
await install(version.path, binDir);
|
||||
return binDir;
|
||||
});
|
||||
}
|
||||
// for versions 2.3.2 and above, xmake will be installed directly into the bin directory, and no script will be used to wrap it.
|
||||
if (version.type !== 'tags' || semver.gt(ver, '2.3.1')) {
|
||||
if (version.type !== 'tags' || semver.gt(version.version, '2.3.1')) {
|
||||
core.addPath(path.join(toolDir, 'bin'));
|
||||
} else {
|
||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||
|
||||
+337
-255
@@ -1,268 +1,282 @@
|
||||
jest.mock('./git', () => ({
|
||||
lsRemote() {
|
||||
return {
|
||||
heads: {
|
||||
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
||||
master: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
test: '18f0605f2e1764d4c07fa4f9fc24274275e1562c',
|
||||
},
|
||||
tags: {
|
||||
'v1.0.1': '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
||||
'v1.0.2': '84fa20ca3ded99b9667609c5cb2e56b2308c8e4b',
|
||||
'v1.0.3': 'e56812a09d3677957c41bccc8988599208e3b49a',
|
||||
'v1.0.4': '825dda9d93448ba783e18f7947eef0b4eb07942e',
|
||||
'v2.0.1': '432fd6a40018f4c29e08f1d4cadf1ccc387a0cff',
|
||||
'v2.0.2': 'd24fcddbc2f1093f3943a917d99c5a8989ef2644',
|
||||
'v2.0.3': 'b5f21a05b1cdaf46314238b4cc665976294df1da',
|
||||
'v2.0.4': '2b15a1b5b149e5156e22358f3d29b4de63473376',
|
||||
'v2.0.5': 'b168ce05d763957ed05844141d77d155bf842e7a',
|
||||
'v2.1.1': '5ba22ca230c3f3f9477491df6d39f11d53132fb1',
|
||||
'v2.1.2': 'bf69a2413117cf21c53bde1edbda713e77d4fd9b',
|
||||
'v2.1.3': '248b2cc8a96d41445a2e46d259d14fea8e4203ec',
|
||||
'v2.1.4': '1d94a23a7db35631f4b33b8b0b3968d0e62ffe2a',
|
||||
'v2.1.5': '72f68f941f9b6d07f71811fe403a2dc178270af0',
|
||||
'v2.1.6': '7ea60d24da152469258a4cb35b3ce591ea2fd961',
|
||||
'v2.1.7': 'a04725662933fbbe3ad4a319d03267fc32907242',
|
||||
'v2.1.8': '6c3f42dad5840210ee7294ca295f6c7b18c32291',
|
||||
'v2.1.9': '0f1e8530e89a9432678ed6fe4fef25d0485d1293',
|
||||
'v2.2.1': 'f15ff1ca73b02ff5f522c9fe59004331b1b410fb',
|
||||
'v2.2.2': '18a42e0e8980e3edc39198b18c5c4b9a464ea381',
|
||||
'v2.2.3': 'c4d0e69abf2b9caa88b997ca1f2935b6e0b00c9f',
|
||||
'v2.2.5': 'd71a01615883fffa53fbd28e578db14353628a52',
|
||||
'v2.2.6': 'eb60a76b7454975d151f2d8b5d9e19b26d561c2d',
|
||||
'v2.2.7': '72bd93de8dd64cc5de8986860819a5873ce08fe5',
|
||||
'v2.2.8': '6a2e390a79c4f0444a03b566d4bf24849a6ee3a3',
|
||||
'v2.2.9': '4c22b7a7823518d538a81081d2e795b9ce4403e2',
|
||||
'v2.3.1': 'f6155f883fd6377e0ee5002425f84f05eb420bef',
|
||||
'v2.3.2': '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
},
|
||||
pull: {
|
||||
'8': { head: '7e3ee3281df2b4caffebe25c87e871ba682dd701' },
|
||||
'11': {
|
||||
head: 'a18d2890ee7615f000b3a6b35150733e2e0013e3',
|
||||
merge: 'ac07a6f13d09ba445af6ba403647f09c6f10dc9b',
|
||||
lsRemote(repo: Repo) {
|
||||
if (repo === 'xmake-io/xmake')
|
||||
return {
|
||||
heads: {
|
||||
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
||||
master: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
test: '18f0605f2e1764d4c07fa4f9fc24274275e1562c',
|
||||
},
|
||||
'23': {
|
||||
head: 'c33fd5a8b3e7ff7692630bbc8f5d5b6166502493',
|
||||
merge: '9041fc8587c9b797440ec2f58deb4626de688010',
|
||||
tags: {
|
||||
'v1.0.1': '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
||||
'v1.0.2': '84fa20ca3ded99b9667609c5cb2e56b2308c8e4b',
|
||||
'v1.0.3': 'e56812a09d3677957c41bccc8988599208e3b49a',
|
||||
'v1.0.4': '825dda9d93448ba783e18f7947eef0b4eb07942e',
|
||||
'v2.0.1': '432fd6a40018f4c29e08f1d4cadf1ccc387a0cff',
|
||||
'v2.0.2': 'd24fcddbc2f1093f3943a917d99c5a8989ef2644',
|
||||
'v2.0.3': 'b5f21a05b1cdaf46314238b4cc665976294df1da',
|
||||
'v2.0.4': '2b15a1b5b149e5156e22358f3d29b4de63473376',
|
||||
'v2.0.5': 'b168ce05d763957ed05844141d77d155bf842e7a',
|
||||
'v2.1.1': '5ba22ca230c3f3f9477491df6d39f11d53132fb1',
|
||||
'v2.1.2': 'bf69a2413117cf21c53bde1edbda713e77d4fd9b',
|
||||
'v2.1.3': '248b2cc8a96d41445a2e46d259d14fea8e4203ec',
|
||||
'v2.1.4': '1d94a23a7db35631f4b33b8b0b3968d0e62ffe2a',
|
||||
'v2.1.5': '72f68f941f9b6d07f71811fe403a2dc178270af0',
|
||||
'v2.1.6': '7ea60d24da152469258a4cb35b3ce591ea2fd961',
|
||||
'v2.1.7': 'a04725662933fbbe3ad4a319d03267fc32907242',
|
||||
'v2.1.8': '6c3f42dad5840210ee7294ca295f6c7b18c32291',
|
||||
'v2.1.9': '0f1e8530e89a9432678ed6fe4fef25d0485d1293',
|
||||
'v2.2.1': 'f15ff1ca73b02ff5f522c9fe59004331b1b410fb',
|
||||
'v2.2.2': '18a42e0e8980e3edc39198b18c5c4b9a464ea381',
|
||||
'v2.2.3': 'c4d0e69abf2b9caa88b997ca1f2935b6e0b00c9f',
|
||||
'v2.2.5': 'd71a01615883fffa53fbd28e578db14353628a52',
|
||||
'v2.2.6': 'eb60a76b7454975d151f2d8b5d9e19b26d561c2d',
|
||||
'v2.2.7': '72bd93de8dd64cc5de8986860819a5873ce08fe5',
|
||||
'v2.2.8': '6a2e390a79c4f0444a03b566d4bf24849a6ee3a3',
|
||||
'v2.2.9': '4c22b7a7823518d538a81081d2e795b9ce4403e2',
|
||||
'v2.3.1': 'f6155f883fd6377e0ee5002425f84f05eb420bef',
|
||||
'v2.3.2': '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
},
|
||||
'24': { head: '5777dbc4397360e21e26466634cfddc633531054' },
|
||||
'28': {
|
||||
head: 'a3a28f8abdfe8711b2e4d7496ade02e910070e9f',
|
||||
merge: '3bb5cf13cfa93ab186e7df168dce87718914696b',
|
||||
pull: {
|
||||
'8': { head: '7e3ee3281df2b4caffebe25c87e871ba682dd701' },
|
||||
'11': {
|
||||
head: 'a18d2890ee7615f000b3a6b35150733e2e0013e3',
|
||||
merge: 'ac07a6f13d09ba445af6ba403647f09c6f10dc9b',
|
||||
},
|
||||
'23': {
|
||||
head: 'c33fd5a8b3e7ff7692630bbc8f5d5b6166502493',
|
||||
merge: '9041fc8587c9b797440ec2f58deb4626de688010',
|
||||
},
|
||||
'24': { head: '5777dbc4397360e21e26466634cfddc633531054' },
|
||||
'28': {
|
||||
head: 'a3a28f8abdfe8711b2e4d7496ade02e910070e9f',
|
||||
merge: '3bb5cf13cfa93ab186e7df168dce87718914696b',
|
||||
},
|
||||
'29': { head: '9400826a6fb06bbe08c23550c063eddafa65fe4b' },
|
||||
'38': { head: '745c8f9a3ad7d4c0282fcfbb108bfb053864cbbc' },
|
||||
'45': { head: '0a8ae5b98d2297bbad38fbf96cc78b373ac6f4ff' },
|
||||
'52': { head: 'c53c28bc7b0cd59ea984a3c687273aa47d608c2a' },
|
||||
'59': { head: '1e766da707d9b1075144303755f4e772fa33193d' },
|
||||
'61': {
|
||||
head: '75df3c9a5dafac83a8227ce84b004d3450b10c38',
|
||||
merge: '08962c4c13c6eea78e3c840711b030d30afebeb4',
|
||||
},
|
||||
'63': { head: 'c3fc0841da49c875cadf225ed2da2dc624c1c72f' },
|
||||
'65': {
|
||||
head: '7c6dca6fe620ee41cd09162bc31d2ab0ab371832',
|
||||
merge: '8c50b1e623668850f936ff980080425aedb7fac9',
|
||||
},
|
||||
'72': {
|
||||
head: 'db0f89089bab6a8b6444712b48d4e05d36b05bf4',
|
||||
merge: '3cf6fc8c23edfa66dff224e884a7faed8c2ecf02',
|
||||
},
|
||||
'74': { head: 'e9dde75d0f1159fda52b05f10646eae2cbdfc589' },
|
||||
'75': { head: '3b9b9fb9c1c302be15e87ffe47309b2c6bc8eaec' },
|
||||
'76': { head: '630f5f17601e5a35fb8b2e03fd7e3aad7af76c02' },
|
||||
'77': { head: '61ae623bda980eeb65f5f26c86e9a246a43b93cd' },
|
||||
'78': { head: '831481cdfbf0905b543ad503950233d7736b97d6' },
|
||||
'80': { head: '52c8ee6e3a5782f49e19bb1b4b9c8fa79661c0e0' },
|
||||
'81': { head: 'a145b7c6e0e491df3bc96a8b55201bacf6d73c77' },
|
||||
'82': { head: '55c84b7fc414036f783396b8e8f937c032dc2f34' },
|
||||
'84': { head: 'da6e4cce0e4c1736db0898d53c16ac8ca0441846' },
|
||||
'85': { head: '05590ed02faa985c7b358d4c10126db549e50a77' },
|
||||
'90': { head: 'c57aa4cf4463f33d3deaf8d58e42abbbd83b0e1b' },
|
||||
'91': { head: 'f04981e7a207a25ece6047e83ac3c34c8747e89b' },
|
||||
'92': {
|
||||
head: 'b226dc77e49c31bf41ca55440aede275a642cb0a',
|
||||
merge: '02f98269a1d7580621fedd809a182a47bf832dd6',
|
||||
},
|
||||
'93': { head: '37b4a7647163afdd392c7afcc61955244b6117cb' },
|
||||
'97': { head: 'd35751770b68b1daa7154e3dfbae4169e71af4dd' },
|
||||
'98': { head: '3687f2a29216e84aa182738e91bb0046a3950916' },
|
||||
'100': {
|
||||
head: '4f02b28754d131cbc3354a05535382eefd729231',
|
||||
merge: '0cd4dc9a46b7418e8471c758d6003e4e4d34ce87',
|
||||
},
|
||||
'102': {
|
||||
head: '0042b79375fd532220f9e9639ca6dfdc9007265a',
|
||||
merge: '6eceac557545ef3022e7401ef3daff235694fde3',
|
||||
},
|
||||
'103': { head: 'cbd86c9b25592b81dd010b6fa2e7ce52c31f50db' },
|
||||
'104': { head: 'e0be61b29d1d88ad7daa5f876faaf296e5935f9c' },
|
||||
'105': { head: '4456dbd2f7b2f96812ed00d67cf484178375931c' },
|
||||
'107': { head: '3f3b52d9b053a38b38557bc3a3e9aeb75d749350' },
|
||||
'108': { head: 'b54b263ab4f05564cc463a53d1efedc1c3703f2f' },
|
||||
'110': { head: 'b6724648232ed892301457c05cf5ec4deaefc2ed' },
|
||||
'112': { head: 'ba4864ad076d07320b9d0f0b4b11b3b22644031e' },
|
||||
'113': { head: '2cb7a91bf266680266de51636ce6620cbecc9362' },
|
||||
'114': { head: '1ad0641672627b5ae2cc417b73614c6ce842bb12' },
|
||||
'115': { head: '67a5ad78de9453d14b562cd7c3f2a4364e370d24' },
|
||||
'116': { head: '98a844e670ee733c1036947efd9099f7763fb544' },
|
||||
'118': { head: 'f2d1fc547a2f57da992b947cc3b3f615f9f2d34d' },
|
||||
'119': { head: '64645daebde9aceaeea7f24c9156cdaa4ac5e035' },
|
||||
'131': { head: '28353b3a76db9592acb23fed82461c07c8d6265b' },
|
||||
'187': { head: '92ea65b345d93a88777d02cccaedbccb12fe5fc3' },
|
||||
'188': { head: 'be03b89501a829e19932f86f491df80962bfe8d5' },
|
||||
'198': { head: '49298d9ead57f63b85f2a8ad9e072915617cc58d' },
|
||||
'204': {
|
||||
head: 'ac21734c1d1ae754146754f2656451091ff22014',
|
||||
merge: '39fcf9250a92c05eb837f82aefa0e1dc49660518',
|
||||
},
|
||||
'205': { head: 'd74715b3615e171776a6e5b9971d2ec2bff115d5' },
|
||||
'210': { head: '9ee12112e49db451a49a66d77dd2990d9f6ddab9' },
|
||||
'214': { head: 'b5b1c689f508068ffbde704194b08569151e383a' },
|
||||
'215': { head: '05b6182def036b36c8e4aeac8cdc55441fc4a4db' },
|
||||
'216': { head: 'e8af37c32549f54059f6e7635064c623b80c039c' },
|
||||
'217': {
|
||||
head: '905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||
merge: '2f93475049575ed5e44699daa378239bc141aad3',
|
||||
},
|
||||
'221': { head: 'ca7b50a40cf7c120d49ca8164f9a54c289dd5743' },
|
||||
'228': { head: '92f1645146c22699f4e2b567451f87fb0dbf2fc6' },
|
||||
'231': { head: 'ca72eb0cf60c3e0747444859d9fc738b98ecc4b5' },
|
||||
'235': { head: '69efc61859543613abc7ec553029852cd5693d17' },
|
||||
'245': { head: '5d33e86c3190d37d04ac26da804db3c53218ae7e' },
|
||||
'247': { head: '9ce75001587cc47db9c980dd99ba28d17b9cc7e8' },
|
||||
'248': { head: '8c6cd6b4dc6b6a6b18150480d9711595f0043f26' },
|
||||
'249': { head: 'a7543cbdfa7fcbe04178d53add85de04b54933b7' },
|
||||
'267': { head: '7d0901f3014960bd53afa0918f21c4a53094faad' },
|
||||
'270': { head: 'c584463f1cd693c2a5df78611816697343ac6ac4' },
|
||||
'273': { head: 'da267497a9677d4cfc7175d462494e1334823476' },
|
||||
'276': { head: '8a80645e856deeaa1df5ad6a2ef91a9c4d475cc8' },
|
||||
'282': { head: 'f9df7b9a3594c8613e6f54003add9ffdaa7e4b49' },
|
||||
'286': { head: '4c59f260714576e2c23aa068b4a1beae62756fd3' },
|
||||
'298': { head: '4175116555b4337ad6cd423373462eb9107617ec' },
|
||||
'303': { head: 'f114c56acb0264a094a99ceff5f45735ea17e54c' },
|
||||
'333': { head: '0f2f41de06a0a7e2852ae9d6b01fd8cde6da4965' },
|
||||
'365': { head: '88b7af92f6988abb30b72095592c74a245c06507' },
|
||||
'380': { head: '5462c4ef4fb470c5878a46cb809203fc1459998f' },
|
||||
'381': { head: 'bd186f9cf5a142aec24bf2d17eff4393487fbd87' },
|
||||
'384': { head: 'e3e646d4e39695b398d719c3340345c8f53750bc' },
|
||||
'387': { head: '84a97cf3471a039bbde45491d5db8eb470b3373e' },
|
||||
'392': { head: '4572f4895e11712ba620097cb504195abc060df2' },
|
||||
'394': { head: 'e34797ed62a4f5f7bab841a0982b3138300d637c' },
|
||||
'395': { head: 'c2a04219cf41346bfa2f4871eda8915d43f38f09' },
|
||||
'398': { head: '0e3f93ad95a57e2dbc3360c26292dacb767f8f54' },
|
||||
'402': { head: '9cebcd69efd4587e3ac56b23e488fbbc9b359f48' },
|
||||
'417': { head: '59a6c75f86de2cb080839910fa9395ccf1089083' },
|
||||
'418': { head: 'c2c491ab4bedea3be7b1a6aca8bb4e65a9d763db' },
|
||||
'420': { head: 'c9208456c2d0c8175d19290a50ccb6fdf95139bb' },
|
||||
'421': { head: '82277e5222154ff4463127681f2d18abb07d7f4a' },
|
||||
'422': { head: 'ace80d7f0b4b6e06a53b7d4bbad3eab28cd65915' },
|
||||
'430': { head: '117f22a385f0118eac2aa6ef8fedf4b29062e973' },
|
||||
'431': { head: '52d8932c29ccf051e2cd400493c38ff1c90f4ccb' },
|
||||
'432': { head: '18ac66eebce733b1112b419f9896cdfa2ede395a' },
|
||||
'435': { head: 'acad517e5ce23a82979a87155bb639f91098adaf' },
|
||||
'438': { head: 'b4c94415e8c7ee24cb3f8c0ba6e0536282121adf' },
|
||||
'441': { head: 'a674530614fbce03122c7d9c72712a6e7a23acb4' },
|
||||
'443': { head: '34cf94bc1650a6e909e9fa3ee88d5cc3cb46eec2' },
|
||||
'444': { head: '8049d92b3e9aef35e4f124e5ae361bdd1f5c5435' },
|
||||
'445': { head: '69c93dba3591d9404bc6b38d84aca731db84ad15' },
|
||||
'447': { head: 'a483b7a9f28c232d66a5c7596926e5c31af865e2' },
|
||||
'448': { head: '9c2c26c81c8c43bc1a834522bc085392c766e7e0' },
|
||||
'449': { head: '52f3bbe24e365b28f4bcd1e277d178a2561a1e8b' },
|
||||
'450': { head: 'fddedb324fbff0546c2cbe304fe95c8e254da6fb' },
|
||||
'451': { head: '17332ad1070bb6190bcd24f0a96cca823b4d8d26' },
|
||||
'452': { head: 'b357d95010f883bff0d1a92ba2390f4c0a50e8ec' },
|
||||
'453': { head: '3ac4190baf80ca6734a35acdfd5ac5f089acbe3e' },
|
||||
'454': { head: '3a5a625a1f498350b05eaa70066c9e77e32ee85f' },
|
||||
'455': { head: '98d4504577b586ef2398346a0db2743081cf03a8' },
|
||||
'457': { head: '72f86392dd7bf482f409dfe4dd00219ef422ad9c' },
|
||||
'458': { head: '4e01df47f2e594796ba6b36858cbe924533dd7aa' },
|
||||
'459': { head: '608f198b3ab87f83b2458e58c1f7dcc6a2beebc0' },
|
||||
'460': { head: 'f264f50f6c1ec488c1608bf69c463d57cc7ccca9' },
|
||||
'462': { head: '5d8c5b6d686b802c48ff52bfe72f188c92509f49' },
|
||||
'464': { head: 'f38741505acb528f609a8b269c911fc037a03fcc' },
|
||||
'465': { head: '318bb739dd64d19a4b4d91d8be49b22fc3403cff' },
|
||||
'468': { head: '117c7cc8a9bea5c9ef65bf00689e1917d91571ec' },
|
||||
'470': { head: '9f73278f8f7631bc53daba27ffdf84d96068c562' },
|
||||
'472': { head: '8cd138e181b63fa327b4b3caa3250fb1dce4b407' },
|
||||
'473': { head: '45a4253be8540240758a69eb8c0c103a3edde057' },
|
||||
'475': { head: 'b93b3d0cc8241e099fc508ffb1f9dace6ab8586a' },
|
||||
'476': { head: '639552074da609025ca6609350c90263ebe684e7' },
|
||||
'477': { head: 'dae10753450c75af10c300dbaf00653b15a27e87' },
|
||||
'478': { head: '9ec42e0f156e0f82068eabbab6ccbfd17549486a' },
|
||||
'481': { head: 'b11c6f57662624732501045e6cccf6b6188dacee' },
|
||||
'482': { head: '887d8d84223de495f0442baa9ae143c382747285' },
|
||||
'483': { head: '4cc123809f92db0a32f4fedbcbf4862484406da0' },
|
||||
'484': { head: '7cff50433386d8c7793884cddd1eb6e1c3c2681e' },
|
||||
'485': { head: '9ce1420b43db72da9d6a57bcc3d4ba478d614484' },
|
||||
'486': { head: '18714381a6257fd93c93344cb559fc409f6b1017' },
|
||||
'488': { head: 'ca45f8941e0b69582021d34061873c8752f76154' },
|
||||
'491': { head: 'e7bcde1188f02ac07e64f6b9a798e0b1ca1e049c' },
|
||||
'492': { head: '09f10b74034b040a6cb56640cd2c2f1027051b50' },
|
||||
'495': { head: 'a6396622cdb3af334c1ec044d5a699affa0dccc2' },
|
||||
'496': { head: 'e5ddd73878d170312580a9284edd5521a2115873' },
|
||||
'497': { head: '74909f788acd34051cf4d32e94b5bcfe1f2c292b' },
|
||||
'498': { head: '08c5864bbfcdc8238716ca8929a71554d08dabfd' },
|
||||
'499': { head: 'bc6896917a2e150adb5aa2a063f72fc85d2ab9f5' },
|
||||
'500': { head: 'ff0595d384a9b4e7656e0c44f327f7614e2a8fd6' },
|
||||
'501': { head: '81acc02e79365957d37e98fbe70887edccfebba6' },
|
||||
'503': { head: '145358ba831e7a90f275118a0556787754fe2fa6' },
|
||||
'505': { head: '1cf79ba882fb24eca13829c12f6e39584ccd1f5f' },
|
||||
'506': { head: '49f14868b5fa9bca4aa2f51ea2b70f9edae89cb6' },
|
||||
'507': { head: '726997c8d83f2a9dff3bb96685dd35ea555e7b8c' },
|
||||
'508': { head: 'a99ed5924ed00e195c0dacc036625bdb4d10f9a8' },
|
||||
'509': { head: '7d4023cf698bff82b2c0f2b4aad86286d4890b49' },
|
||||
'510': { head: 'fb9a434ada47e47e543f62e353c7375f93f82c39' },
|
||||
'523': { head: '0bdcae97d8d9b2b3afe725f9b857a9994d3b28fa' },
|
||||
'525': { head: 'ebe4099e7ea32b023edfc7a5559db5d1d5262e20' },
|
||||
'526': { head: '454f1c64dae6c213177007885e54a1ab497f4b1b' },
|
||||
'527': { head: '786c94fb869b6bbcf310e93f3068b795b177fc0b' },
|
||||
'529': { head: 'df6f615305180ef67c9daa25038af1bc91ff44b0' },
|
||||
'530': { head: '4f2e25226853830f157a2da79097c527030d42b4' },
|
||||
'531': { head: '0b57414998b5404f93209f5b06141911cc9af503' },
|
||||
'534': { head: 'bd4181e0321ec9db4dd6b304db51f5cf6566a484' },
|
||||
'537': { head: 'b515795919b7eb114032a441564512645fae489c' },
|
||||
'542': { head: '7ce304f9ee9946471d4ad11e78ea25149a05483f' },
|
||||
'543': { head: 'f6b1a4866e1c73aafe6decdc6bfc1d99653f2b64' },
|
||||
'547': { head: '9943cbae2e39a219cd5f889802d9db11aaefda5c' },
|
||||
'550': { head: '172076db9fa929c5b6dd20a733d15cf28ef092aa' },
|
||||
'551': { head: 'ff103cd4816ca50102c3bc10906695581c734f60' },
|
||||
'552': { head: '99a3da1ff1e25e76a2cbf19f2f3a3ff43b6be013' },
|
||||
'554': { head: '689068989bcda7bd099f920691dc388eae82bd9a' },
|
||||
'557': { head: '416efddbbac77ecad9be41bdafd36bdea89e25d5' },
|
||||
'563': { head: '3d72809db048911efec3d52106dd6968349ef4d1' },
|
||||
'569': { head: 'ce51c2de7c11b6368ce8956329f9ebbe4ffd1b67' },
|
||||
'593': { head: 'f00316a42943a9a75303658f8d646d35f9e8d1b9' },
|
||||
'613': { head: '155deaae3ea36460929db9c8f28f2b97a319f54c' },
|
||||
'625': { head: 'a027cf0843001dd2cb608c1c42cf643f48a56749' },
|
||||
'628': { head: '23ae1e8af491342ef3e4f899ed0bdb5dd1a1284a' },
|
||||
'631': { head: '30d4183095aa5dcdb9cbe00b1b48e45ca31424fe' },
|
||||
'633': { head: '54ba9a0faf46957c3da37366119e0dab52fc02cc' },
|
||||
'642': { head: 'c68a8ac90d822f74478cc36b6ba5a7e9ac225ee9' },
|
||||
'655': { head: '6da12e9e3387be62b5b00cba64d1fb4d2e1ac140' },
|
||||
'664': { head: 'e011000482dccb3e215d0eb895e280de6cda627e' },
|
||||
'667': { head: 'dc25ac7a87256a0470f523017ee790b29e9b6f2d' },
|
||||
'669': { head: 'd0b39e229426a336f71a0cc24f6319a47e2ce975' },
|
||||
'671': { head: 'aa0cd8e58d2effab424214d12ab2122ff39a0f4a' },
|
||||
'672': { head: '0cb3bd5f5aa0605835d7c785bd58e9d75b362fdd' },
|
||||
'673': { head: '97b0e9c8e673325545d2e55288d66a2dd99d1cc0' },
|
||||
'674': { head: '5d7a6efa13021da59a370bb011f4caf494b35da3' },
|
||||
'678': { head: '98d788b6df2e95725e2435fff8469deb3ff74e8c' },
|
||||
'679': { head: 'ea8ee4a153af424e238ed0e0772c32bfb0a881b1' },
|
||||
'682': { head: 'fd12dc4bd31ebe9dc6370ab150c39441ce4d6061' },
|
||||
'686': { head: 'd76b2b96872e3860af34b3256bc1df2189835829' },
|
||||
'703': { head: '3b0f6e396c4a1d53b1b046c416681da6229fbdce' },
|
||||
'708': { head: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a' },
|
||||
},
|
||||
'29': { head: '9400826a6fb06bbe08c23550c063eddafa65fe4b' },
|
||||
'38': { head: '745c8f9a3ad7d4c0282fcfbb108bfb053864cbbc' },
|
||||
'45': { head: '0a8ae5b98d2297bbad38fbf96cc78b373ac6f4ff' },
|
||||
'52': { head: 'c53c28bc7b0cd59ea984a3c687273aa47d608c2a' },
|
||||
'59': { head: '1e766da707d9b1075144303755f4e772fa33193d' },
|
||||
'61': {
|
||||
head: '75df3c9a5dafac83a8227ce84b004d3450b10c38',
|
||||
merge: '08962c4c13c6eea78e3c840711b030d30afebeb4',
|
||||
};
|
||||
if (repo === 'my/xmake')
|
||||
return {
|
||||
heads: {
|
||||
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
||||
master: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
'patch-1': '77cd51991f8b9c76e54d668103a06ca6c597e64a',
|
||||
},
|
||||
'63': { head: 'c3fc0841da49c875cadf225ed2da2dc624c1c72f' },
|
||||
'65': {
|
||||
head: '7c6dca6fe620ee41cd09162bc31d2ab0ab371832',
|
||||
merge: '8c50b1e623668850f936ff980080425aedb7fac9',
|
||||
},
|
||||
'72': {
|
||||
head: 'db0f89089bab6a8b6444712b48d4e05d36b05bf4',
|
||||
merge: '3cf6fc8c23edfa66dff224e884a7faed8c2ecf02',
|
||||
},
|
||||
'74': { head: 'e9dde75d0f1159fda52b05f10646eae2cbdfc589' },
|
||||
'75': { head: '3b9b9fb9c1c302be15e87ffe47309b2c6bc8eaec' },
|
||||
'76': { head: '630f5f17601e5a35fb8b2e03fd7e3aad7af76c02' },
|
||||
'77': { head: '61ae623bda980eeb65f5f26c86e9a246a43b93cd' },
|
||||
'78': { head: '831481cdfbf0905b543ad503950233d7736b97d6' },
|
||||
'80': { head: '52c8ee6e3a5782f49e19bb1b4b9c8fa79661c0e0' },
|
||||
'81': { head: 'a145b7c6e0e491df3bc96a8b55201bacf6d73c77' },
|
||||
'82': { head: '55c84b7fc414036f783396b8e8f937c032dc2f34' },
|
||||
'84': { head: 'da6e4cce0e4c1736db0898d53c16ac8ca0441846' },
|
||||
'85': { head: '05590ed02faa985c7b358d4c10126db549e50a77' },
|
||||
'90': { head: 'c57aa4cf4463f33d3deaf8d58e42abbbd83b0e1b' },
|
||||
'91': { head: 'f04981e7a207a25ece6047e83ac3c34c8747e89b' },
|
||||
'92': {
|
||||
head: 'b226dc77e49c31bf41ca55440aede275a642cb0a',
|
||||
merge: '02f98269a1d7580621fedd809a182a47bf832dd6',
|
||||
},
|
||||
'93': { head: '37b4a7647163afdd392c7afcc61955244b6117cb' },
|
||||
'97': { head: 'd35751770b68b1daa7154e3dfbae4169e71af4dd' },
|
||||
'98': { head: '3687f2a29216e84aa182738e91bb0046a3950916' },
|
||||
'100': {
|
||||
head: '4f02b28754d131cbc3354a05535382eefd729231',
|
||||
merge: '0cd4dc9a46b7418e8471c758d6003e4e4d34ce87',
|
||||
},
|
||||
'102': {
|
||||
head: '0042b79375fd532220f9e9639ca6dfdc9007265a',
|
||||
merge: '6eceac557545ef3022e7401ef3daff235694fde3',
|
||||
},
|
||||
'103': { head: 'cbd86c9b25592b81dd010b6fa2e7ce52c31f50db' },
|
||||
'104': { head: 'e0be61b29d1d88ad7daa5f876faaf296e5935f9c' },
|
||||
'105': { head: '4456dbd2f7b2f96812ed00d67cf484178375931c' },
|
||||
'107': { head: '3f3b52d9b053a38b38557bc3a3e9aeb75d749350' },
|
||||
'108': { head: 'b54b263ab4f05564cc463a53d1efedc1c3703f2f' },
|
||||
'110': { head: 'b6724648232ed892301457c05cf5ec4deaefc2ed' },
|
||||
'112': { head: 'ba4864ad076d07320b9d0f0b4b11b3b22644031e' },
|
||||
'113': { head: '2cb7a91bf266680266de51636ce6620cbecc9362' },
|
||||
'114': { head: '1ad0641672627b5ae2cc417b73614c6ce842bb12' },
|
||||
'115': { head: '67a5ad78de9453d14b562cd7c3f2a4364e370d24' },
|
||||
'116': { head: '98a844e670ee733c1036947efd9099f7763fb544' },
|
||||
'118': { head: 'f2d1fc547a2f57da992b947cc3b3f615f9f2d34d' },
|
||||
'119': { head: '64645daebde9aceaeea7f24c9156cdaa4ac5e035' },
|
||||
'131': { head: '28353b3a76db9592acb23fed82461c07c8d6265b' },
|
||||
'187': { head: '92ea65b345d93a88777d02cccaedbccb12fe5fc3' },
|
||||
'188': { head: 'be03b89501a829e19932f86f491df80962bfe8d5' },
|
||||
'198': { head: '49298d9ead57f63b85f2a8ad9e072915617cc58d' },
|
||||
'204': {
|
||||
head: 'ac21734c1d1ae754146754f2656451091ff22014',
|
||||
merge: '39fcf9250a92c05eb837f82aefa0e1dc49660518',
|
||||
},
|
||||
'205': { head: 'd74715b3615e171776a6e5b9971d2ec2bff115d5' },
|
||||
'210': { head: '9ee12112e49db451a49a66d77dd2990d9f6ddab9' },
|
||||
'214': { head: 'b5b1c689f508068ffbde704194b08569151e383a' },
|
||||
'215': { head: '05b6182def036b36c8e4aeac8cdc55441fc4a4db' },
|
||||
'216': { head: 'e8af37c32549f54059f6e7635064c623b80c039c' },
|
||||
'217': {
|
||||
head: '905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||
merge: '2f93475049575ed5e44699daa378239bc141aad3',
|
||||
},
|
||||
'221': { head: 'ca7b50a40cf7c120d49ca8164f9a54c289dd5743' },
|
||||
'228': { head: '92f1645146c22699f4e2b567451f87fb0dbf2fc6' },
|
||||
'231': { head: 'ca72eb0cf60c3e0747444859d9fc738b98ecc4b5' },
|
||||
'235': { head: '69efc61859543613abc7ec553029852cd5693d17' },
|
||||
'245': { head: '5d33e86c3190d37d04ac26da804db3c53218ae7e' },
|
||||
'247': { head: '9ce75001587cc47db9c980dd99ba28d17b9cc7e8' },
|
||||
'248': { head: '8c6cd6b4dc6b6a6b18150480d9711595f0043f26' },
|
||||
'249': { head: 'a7543cbdfa7fcbe04178d53add85de04b54933b7' },
|
||||
'267': { head: '7d0901f3014960bd53afa0918f21c4a53094faad' },
|
||||
'270': { head: 'c584463f1cd693c2a5df78611816697343ac6ac4' },
|
||||
'273': { head: 'da267497a9677d4cfc7175d462494e1334823476' },
|
||||
'276': { head: '8a80645e856deeaa1df5ad6a2ef91a9c4d475cc8' },
|
||||
'282': { head: 'f9df7b9a3594c8613e6f54003add9ffdaa7e4b49' },
|
||||
'286': { head: '4c59f260714576e2c23aa068b4a1beae62756fd3' },
|
||||
'298': { head: '4175116555b4337ad6cd423373462eb9107617ec' },
|
||||
'303': { head: 'f114c56acb0264a094a99ceff5f45735ea17e54c' },
|
||||
'333': { head: '0f2f41de06a0a7e2852ae9d6b01fd8cde6da4965' },
|
||||
'365': { head: '88b7af92f6988abb30b72095592c74a245c06507' },
|
||||
'380': { head: '5462c4ef4fb470c5878a46cb809203fc1459998f' },
|
||||
'381': { head: 'bd186f9cf5a142aec24bf2d17eff4393487fbd87' },
|
||||
'384': { head: 'e3e646d4e39695b398d719c3340345c8f53750bc' },
|
||||
'387': { head: '84a97cf3471a039bbde45491d5db8eb470b3373e' },
|
||||
'392': { head: '4572f4895e11712ba620097cb504195abc060df2' },
|
||||
'394': { head: 'e34797ed62a4f5f7bab841a0982b3138300d637c' },
|
||||
'395': { head: 'c2a04219cf41346bfa2f4871eda8915d43f38f09' },
|
||||
'398': { head: '0e3f93ad95a57e2dbc3360c26292dacb767f8f54' },
|
||||
'402': { head: '9cebcd69efd4587e3ac56b23e488fbbc9b359f48' },
|
||||
'417': { head: '59a6c75f86de2cb080839910fa9395ccf1089083' },
|
||||
'418': { head: 'c2c491ab4bedea3be7b1a6aca8bb4e65a9d763db' },
|
||||
'420': { head: 'c9208456c2d0c8175d19290a50ccb6fdf95139bb' },
|
||||
'421': { head: '82277e5222154ff4463127681f2d18abb07d7f4a' },
|
||||
'422': { head: 'ace80d7f0b4b6e06a53b7d4bbad3eab28cd65915' },
|
||||
'430': { head: '117f22a385f0118eac2aa6ef8fedf4b29062e973' },
|
||||
'431': { head: '52d8932c29ccf051e2cd400493c38ff1c90f4ccb' },
|
||||
'432': { head: '18ac66eebce733b1112b419f9896cdfa2ede395a' },
|
||||
'435': { head: 'acad517e5ce23a82979a87155bb639f91098adaf' },
|
||||
'438': { head: 'b4c94415e8c7ee24cb3f8c0ba6e0536282121adf' },
|
||||
'441': { head: 'a674530614fbce03122c7d9c72712a6e7a23acb4' },
|
||||
'443': { head: '34cf94bc1650a6e909e9fa3ee88d5cc3cb46eec2' },
|
||||
'444': { head: '8049d92b3e9aef35e4f124e5ae361bdd1f5c5435' },
|
||||
'445': { head: '69c93dba3591d9404bc6b38d84aca731db84ad15' },
|
||||
'447': { head: 'a483b7a9f28c232d66a5c7596926e5c31af865e2' },
|
||||
'448': { head: '9c2c26c81c8c43bc1a834522bc085392c766e7e0' },
|
||||
'449': { head: '52f3bbe24e365b28f4bcd1e277d178a2561a1e8b' },
|
||||
'450': { head: 'fddedb324fbff0546c2cbe304fe95c8e254da6fb' },
|
||||
'451': { head: '17332ad1070bb6190bcd24f0a96cca823b4d8d26' },
|
||||
'452': { head: 'b357d95010f883bff0d1a92ba2390f4c0a50e8ec' },
|
||||
'453': { head: '3ac4190baf80ca6734a35acdfd5ac5f089acbe3e' },
|
||||
'454': { head: '3a5a625a1f498350b05eaa70066c9e77e32ee85f' },
|
||||
'455': { head: '98d4504577b586ef2398346a0db2743081cf03a8' },
|
||||
'457': { head: '72f86392dd7bf482f409dfe4dd00219ef422ad9c' },
|
||||
'458': { head: '4e01df47f2e594796ba6b36858cbe924533dd7aa' },
|
||||
'459': { head: '608f198b3ab87f83b2458e58c1f7dcc6a2beebc0' },
|
||||
'460': { head: 'f264f50f6c1ec488c1608bf69c463d57cc7ccca9' },
|
||||
'462': { head: '5d8c5b6d686b802c48ff52bfe72f188c92509f49' },
|
||||
'464': { head: 'f38741505acb528f609a8b269c911fc037a03fcc' },
|
||||
'465': { head: '318bb739dd64d19a4b4d91d8be49b22fc3403cff' },
|
||||
'468': { head: '117c7cc8a9bea5c9ef65bf00689e1917d91571ec' },
|
||||
'470': { head: '9f73278f8f7631bc53daba27ffdf84d96068c562' },
|
||||
'472': { head: '8cd138e181b63fa327b4b3caa3250fb1dce4b407' },
|
||||
'473': { head: '45a4253be8540240758a69eb8c0c103a3edde057' },
|
||||
'475': { head: 'b93b3d0cc8241e099fc508ffb1f9dace6ab8586a' },
|
||||
'476': { head: '639552074da609025ca6609350c90263ebe684e7' },
|
||||
'477': { head: 'dae10753450c75af10c300dbaf00653b15a27e87' },
|
||||
'478': { head: '9ec42e0f156e0f82068eabbab6ccbfd17549486a' },
|
||||
'481': { head: 'b11c6f57662624732501045e6cccf6b6188dacee' },
|
||||
'482': { head: '887d8d84223de495f0442baa9ae143c382747285' },
|
||||
'483': { head: '4cc123809f92db0a32f4fedbcbf4862484406da0' },
|
||||
'484': { head: '7cff50433386d8c7793884cddd1eb6e1c3c2681e' },
|
||||
'485': { head: '9ce1420b43db72da9d6a57bcc3d4ba478d614484' },
|
||||
'486': { head: '18714381a6257fd93c93344cb559fc409f6b1017' },
|
||||
'488': { head: 'ca45f8941e0b69582021d34061873c8752f76154' },
|
||||
'491': { head: 'e7bcde1188f02ac07e64f6b9a798e0b1ca1e049c' },
|
||||
'492': { head: '09f10b74034b040a6cb56640cd2c2f1027051b50' },
|
||||
'495': { head: 'a6396622cdb3af334c1ec044d5a699affa0dccc2' },
|
||||
'496': { head: 'e5ddd73878d170312580a9284edd5521a2115873' },
|
||||
'497': { head: '74909f788acd34051cf4d32e94b5bcfe1f2c292b' },
|
||||
'498': { head: '08c5864bbfcdc8238716ca8929a71554d08dabfd' },
|
||||
'499': { head: 'bc6896917a2e150adb5aa2a063f72fc85d2ab9f5' },
|
||||
'500': { head: 'ff0595d384a9b4e7656e0c44f327f7614e2a8fd6' },
|
||||
'501': { head: '81acc02e79365957d37e98fbe70887edccfebba6' },
|
||||
'503': { head: '145358ba831e7a90f275118a0556787754fe2fa6' },
|
||||
'505': { head: '1cf79ba882fb24eca13829c12f6e39584ccd1f5f' },
|
||||
'506': { head: '49f14868b5fa9bca4aa2f51ea2b70f9edae89cb6' },
|
||||
'507': { head: '726997c8d83f2a9dff3bb96685dd35ea555e7b8c' },
|
||||
'508': { head: 'a99ed5924ed00e195c0dacc036625bdb4d10f9a8' },
|
||||
'509': { head: '7d4023cf698bff82b2c0f2b4aad86286d4890b49' },
|
||||
'510': { head: 'fb9a434ada47e47e543f62e353c7375f93f82c39' },
|
||||
'523': { head: '0bdcae97d8d9b2b3afe725f9b857a9994d3b28fa' },
|
||||
'525': { head: 'ebe4099e7ea32b023edfc7a5559db5d1d5262e20' },
|
||||
'526': { head: '454f1c64dae6c213177007885e54a1ab497f4b1b' },
|
||||
'527': { head: '786c94fb869b6bbcf310e93f3068b795b177fc0b' },
|
||||
'529': { head: 'df6f615305180ef67c9daa25038af1bc91ff44b0' },
|
||||
'530': { head: '4f2e25226853830f157a2da79097c527030d42b4' },
|
||||
'531': { head: '0b57414998b5404f93209f5b06141911cc9af503' },
|
||||
'534': { head: 'bd4181e0321ec9db4dd6b304db51f5cf6566a484' },
|
||||
'537': { head: 'b515795919b7eb114032a441564512645fae489c' },
|
||||
'542': { head: '7ce304f9ee9946471d4ad11e78ea25149a05483f' },
|
||||
'543': { head: 'f6b1a4866e1c73aafe6decdc6bfc1d99653f2b64' },
|
||||
'547': { head: '9943cbae2e39a219cd5f889802d9db11aaefda5c' },
|
||||
'550': { head: '172076db9fa929c5b6dd20a733d15cf28ef092aa' },
|
||||
'551': { head: 'ff103cd4816ca50102c3bc10906695581c734f60' },
|
||||
'552': { head: '99a3da1ff1e25e76a2cbf19f2f3a3ff43b6be013' },
|
||||
'554': { head: '689068989bcda7bd099f920691dc388eae82bd9a' },
|
||||
'557': { head: '416efddbbac77ecad9be41bdafd36bdea89e25d5' },
|
||||
'563': { head: '3d72809db048911efec3d52106dd6968349ef4d1' },
|
||||
'569': { head: 'ce51c2de7c11b6368ce8956329f9ebbe4ffd1b67' },
|
||||
'593': { head: 'f00316a42943a9a75303658f8d646d35f9e8d1b9' },
|
||||
'613': { head: '155deaae3ea36460929db9c8f28f2b97a319f54c' },
|
||||
'625': { head: 'a027cf0843001dd2cb608c1c42cf643f48a56749' },
|
||||
'628': { head: '23ae1e8af491342ef3e4f899ed0bdb5dd1a1284a' },
|
||||
'631': { head: '30d4183095aa5dcdb9cbe00b1b48e45ca31424fe' },
|
||||
'633': { head: '54ba9a0faf46957c3da37366119e0dab52fc02cc' },
|
||||
'642': { head: 'c68a8ac90d822f74478cc36b6ba5a7e9ac225ee9' },
|
||||
'655': { head: '6da12e9e3387be62b5b00cba64d1fb4d2e1ac140' },
|
||||
'664': { head: 'e011000482dccb3e215d0eb895e280de6cda627e' },
|
||||
'667': { head: 'dc25ac7a87256a0470f523017ee790b29e9b6f2d' },
|
||||
'669': { head: 'd0b39e229426a336f71a0cc24f6319a47e2ce975' },
|
||||
'671': { head: 'aa0cd8e58d2effab424214d12ab2122ff39a0f4a' },
|
||||
'672': { head: '0cb3bd5f5aa0605835d7c785bd58e9d75b362fdd' },
|
||||
'673': { head: '97b0e9c8e673325545d2e55288d66a2dd99d1cc0' },
|
||||
'674': { head: '5d7a6efa13021da59a370bb011f4caf494b35da3' },
|
||||
'678': { head: '98d788b6df2e95725e2435fff8469deb3ff74e8c' },
|
||||
'679': { head: 'ea8ee4a153af424e238ed0e0772c32bfb0a881b1' },
|
||||
'682': { head: 'fd12dc4bd31ebe9dc6370ab150c39441ce4d6061' },
|
||||
'686': { head: 'd76b2b96872e3860af34b3256bc1df2189835829' },
|
||||
'703': { head: '3b0f6e396c4a1d53b1b046c416681da6229fbdce' },
|
||||
'708': { head: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a' },
|
||||
},
|
||||
};
|
||||
tags: {},
|
||||
pull: {},
|
||||
};
|
||||
},
|
||||
}));
|
||||
import { selectVersion } from './versions';
|
||||
import { Repo } from './interfaces';
|
||||
import { resolve } from 'path';
|
||||
|
||||
describe('selectVersion', () => {
|
||||
it('should return correct version for latest', async () => {
|
||||
await expect(selectVersion('latest')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v2.3.2',
|
||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
type: 'tags',
|
||||
@@ -271,10 +285,13 @@ describe('selectVersion', () => {
|
||||
it('should throw for no matched', async () => {
|
||||
await expect(selectVersion('0.2.3')).rejects.toThrowError('No matched releases of xmake-version 0.2.3');
|
||||
await expect(selectVersion('v0.2.3')).rejects.toThrowError('No matched releases of xmake-version 0.2.3');
|
||||
await expect(selectVersion('<0.2.3 > 0.1')).rejects.toThrowError('No matched releases of xmake-version <0.2.3 >=0.2.0');
|
||||
await expect(selectVersion('<0.2.3 > 0.1')).rejects.toThrowError(
|
||||
'No matched releases of xmake-version <0.2.3 >=0.2.0',
|
||||
);
|
||||
});
|
||||
it('should return correct version for given', async () => {
|
||||
await expect(selectVersion('v1.0.1')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v1.0.1',
|
||||
sha: '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
||||
type: 'tags',
|
||||
@@ -282,6 +299,7 @@ describe('selectVersion', () => {
|
||||
});
|
||||
it('should return correct version for range', async () => {
|
||||
await expect(selectVersion('>=2')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v2.3.2',
|
||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
type: 'tags',
|
||||
@@ -290,6 +308,7 @@ describe('selectVersion', () => {
|
||||
|
||||
it('should return correct branch', async () => {
|
||||
await expect(selectVersion('branch@master')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'master',
|
||||
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
type: 'heads',
|
||||
@@ -302,6 +321,7 @@ describe('selectVersion', () => {
|
||||
|
||||
it('should return correct pr', async () => {
|
||||
await expect(selectVersion('pr@708')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'pr#708',
|
||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
||||
type: 'pull',
|
||||
@@ -313,11 +333,14 @@ describe('selectVersion', () => {
|
||||
});
|
||||
|
||||
it('should throw invalid pr', async () => {
|
||||
await expect(selectVersion('pr@xxx')).rejects.toThrowError('Invalid pull requrest xxx, should be a positive integer');
|
||||
await expect(selectVersion('pr@xxx')).rejects.toThrowError(
|
||||
'Invalid pull requrest xxx, should be a positive integer',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return branch of sha', async () => {
|
||||
await expect(selectVersion('sha@efad01e547f30d66d90e486c91c3afa0dbaceed3')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'master',
|
||||
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||
type: 'heads',
|
||||
@@ -326,14 +349,43 @@ describe('selectVersion', () => {
|
||||
|
||||
it('should return tag of sha', async () => {
|
||||
await expect(selectVersion('sha@31bacc4f76101e6a865ec254c48d8bcba456378f')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'v2.3.2',
|
||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||
type: 'tags',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return pr merge of sha', async () => {
|
||||
await expect(selectVersion('sha@2f93475049575ed5e44699daa378239bc141aad3')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'pr#217',
|
||||
sha: '2f93475049575ed5e44699daa378239bc141aad3',
|
||||
type: 'pull',
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return pr head of sha if merge present', async () => {
|
||||
await expect(selectVersion('sha@905a8607f3f31ab9efeb68684d40df8284683f3a')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'sha#905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||
sha: '905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||
type: 'sha',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return pr head of sha', async () => {
|
||||
await expect(selectVersion('sha@af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'pr#708',
|
||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
||||
type: 'pull',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return correct normalized sha', async () => {
|
||||
await expect(selectVersion('sha@Af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b')).resolves.toEqual({
|
||||
repo: 'xmake-io/xmake',
|
||||
version: 'sha#af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
||||
type: 'sha',
|
||||
@@ -351,4 +403,34 @@ describe('selectVersion', () => {
|
||||
'Invalid sha value af28dba1f52990cb7b6c3c8f69f1f1bcf017c90g',
|
||||
);
|
||||
});
|
||||
|
||||
it('should return correct repo', async () => {
|
||||
await expect(selectVersion('my/xmake#branch@patch-1')).resolves.toEqual({
|
||||
repo: 'my/xmake',
|
||||
version: 'patch-1',
|
||||
sha: '77cd51991f8b9c76e54d668103a06ca6c597e64a',
|
||||
type: 'heads',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return local cwd', async () => {
|
||||
await expect(selectVersion('local#')).resolves.toEqual({
|
||||
path: process.cwd(),
|
||||
type: 'local',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return absolute path', async () => {
|
||||
await expect(selectVersion('local#/usr/bin')).resolves.toEqual({
|
||||
path: resolve('/usr/bin'),
|
||||
type: 'local',
|
||||
});
|
||||
});
|
||||
|
||||
it('should return relative path', async () => {
|
||||
await expect(selectVersion('local#xmake')).resolves.toEqual({
|
||||
path: resolve('xmake'),
|
||||
type: 'local',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+82
-39
@@ -1,22 +1,28 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as semver from 'semver';
|
||||
import { lsRemote, RefDic } from './git';
|
||||
import { lsRemote } from './git';
|
||||
import { RefDic, Sha, Version, Repo, GitVersion, LocalVersion } from './interfaces';
|
||||
import * as p from 'path';
|
||||
|
||||
export interface Version {
|
||||
version: string;
|
||||
sha: string;
|
||||
type: keyof RefDic | 'sha';
|
||||
const DEFAULT_REPO = Repo('xmake-io/xmake');
|
||||
|
||||
const VERSIONS = new Map<Repo, RefDic>();
|
||||
async function getVersions(repo: Repo): Promise<RefDic> {
|
||||
const cache = VERSIONS.get(repo);
|
||||
if (cache) return cache;
|
||||
const result = await lsRemote(repo);
|
||||
VERSIONS.set(repo, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
let VERSIONS: RefDic | undefined;
|
||||
|
||||
async function getVersions(): Promise<RefDic> {
|
||||
if (VERSIONS) return VERSIONS;
|
||||
return (VERSIONS = await lsRemote());
|
||||
}
|
||||
|
||||
class VersionImpl implements Version {
|
||||
constructor(readonly version: string, readonly sha: string, readonly type: Version['type'], toString: string) {
|
||||
class GitVersionImpl implements GitVersion {
|
||||
constructor(
|
||||
readonly repo: Repo,
|
||||
readonly version: string,
|
||||
readonly sha: Sha,
|
||||
readonly type: GitVersion['type'],
|
||||
toString: string,
|
||||
) {
|
||||
this.#string = toString;
|
||||
}
|
||||
readonly #string: string;
|
||||
@@ -25,58 +31,73 @@ class VersionImpl implements Version {
|
||||
}
|
||||
}
|
||||
|
||||
async function selectBranch(branch: string): Promise<Version> {
|
||||
const versions = await getVersions();
|
||||
class LocalVersionImpl implements LocalVersion {
|
||||
readonly type = 'local';
|
||||
readonly version: undefined;
|
||||
constructor(readonly path: string) {
|
||||
this.path = p.resolve(path);
|
||||
}
|
||||
}
|
||||
|
||||
async function selectBranch(repo: Repo, branch: string): Promise<Version> {
|
||||
const versions = await getVersions(repo);
|
||||
if (branch in versions.heads) {
|
||||
return new VersionImpl(branch, versions.heads[branch], 'heads', `branch ${branch}`);
|
||||
return new GitVersionImpl(repo, branch, versions.heads[branch], 'heads', `branch ${branch}`);
|
||||
}
|
||||
throw new Error(`Branch ${branch} not found`);
|
||||
}
|
||||
|
||||
async function selectPr(pr: number): Promise<Version> {
|
||||
const versions = await getVersions();
|
||||
async function selectPr(repo: Repo, pr: number): Promise<Version> {
|
||||
const versions = await getVersions(repo);
|
||||
if (pr in versions.pull) {
|
||||
const prheads = versions.pull[pr];
|
||||
const sha = prheads.merge ?? prheads.head;
|
||||
const prHeads = versions.pull[pr];
|
||||
const sha = prHeads.merge ?? prHeads.head;
|
||||
if (sha) {
|
||||
return new VersionImpl(`pr#${pr}`, sha, 'pull', `pull request #${pr}`);
|
||||
return new GitVersionImpl(repo, `pr#${pr}`, sha, 'pull', `pull request #${pr}`);
|
||||
}
|
||||
}
|
||||
throw new Error(`Pull requrest #${pr} not found`);
|
||||
}
|
||||
|
||||
async function selectSemver(version: string): Promise<Version> {
|
||||
async function selectSemver(repo: Repo, version: string): Promise<Version> {
|
||||
// check version valid
|
||||
const v = new semver.Range(version);
|
||||
if (!v) {
|
||||
throw new Error(`Invalid semver`);
|
||||
}
|
||||
|
||||
const versions = await getVersions();
|
||||
const versions = await getVersions(repo);
|
||||
const ver = semver.maxSatisfying(Object.keys(versions.tags), v);
|
||||
if (!ver) {
|
||||
throw new Error(`No matched releases of xmake-version ${v.format()}`);
|
||||
}
|
||||
|
||||
const sha = versions.tags[ver];
|
||||
return new VersionImpl(ver, sha, 'tags', ver);
|
||||
return new GitVersionImpl(repo, ver, sha, 'tags', ver);
|
||||
}
|
||||
|
||||
async function selectSha(sha: string): Promise<Version> {
|
||||
sha = sha.toLowerCase();
|
||||
if (!/^[a-f0-9]{40}$/gi.test(sha)) throw new Error(`Invalid sha value ${sha}`);
|
||||
const versions = await getVersions();
|
||||
async function selectSha(repo: Repo, sha: string): Promise<Version> {
|
||||
const shaValue = Sha(sha);
|
||||
const versions = await getVersions(repo);
|
||||
for (const branch in versions.heads) {
|
||||
if (versions.heads[branch] === sha) {
|
||||
return selectBranch(branch);
|
||||
if (versions.heads[branch] === shaValue) {
|
||||
return selectBranch(repo, branch);
|
||||
}
|
||||
}
|
||||
for (const tag in versions.tags) {
|
||||
if (versions.tags[tag] === sha) {
|
||||
return selectSemver(tag);
|
||||
if (versions.tags[tag] === shaValue) {
|
||||
return selectSemver(repo, tag);
|
||||
}
|
||||
}
|
||||
return Promise.resolve(new VersionImpl(`sha#${sha}`, sha, 'sha', `commit ${sha.substr(0, 8)}`));
|
||||
for (const pr in versions.pull) {
|
||||
const prData = versions.pull[pr];
|
||||
if ((prData.merge ?? prData.head) === shaValue) {
|
||||
return selectPr(repo, Number.parseInt(pr));
|
||||
}
|
||||
}
|
||||
return Promise.resolve(
|
||||
new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`),
|
||||
);
|
||||
}
|
||||
|
||||
export async function selectVersion(version?: string): Promise<Version> {
|
||||
@@ -84,11 +105,26 @@ export async function selectVersion(version?: string): Promise<Version> {
|
||||
version = (version ?? core.getInput('xmake-version')) || 'latest';
|
||||
if (version.toLowerCase() === 'latest') version = '';
|
||||
|
||||
let repo = DEFAULT_REPO;
|
||||
let ret: Version | undefined;
|
||||
// select local
|
||||
if (version.startsWith('local#')) {
|
||||
const path = version.slice('local#'.length);
|
||||
ret = new LocalVersionImpl(path);
|
||||
}
|
||||
|
||||
{
|
||||
const match = /^([^/#]+\/[^/#]+)#(.+)$/.exec(version);
|
||||
if (match) {
|
||||
repo = Repo(match[1]);
|
||||
version = match[2];
|
||||
}
|
||||
}
|
||||
|
||||
// select branch
|
||||
if (version.startsWith('branch@')) {
|
||||
const branch = version.substr('branch@'.length);
|
||||
ret = await selectBranch(branch);
|
||||
ret = await selectBranch(repo, branch);
|
||||
}
|
||||
// select pr
|
||||
if (version.startsWith('pr@')) {
|
||||
@@ -96,20 +132,27 @@ export async function selectVersion(version?: string): Promise<Version> {
|
||||
if (Number.isNaN(pr) || pr <= 0) {
|
||||
throw new Error(`Invalid pull requrest ${version.substr('pr@'.length)}, should be a positive integer`);
|
||||
}
|
||||
ret = await selectPr(pr);
|
||||
ret = await selectPr(repo, pr);
|
||||
}
|
||||
// select sha
|
||||
if (version.startsWith('sha@')) {
|
||||
const sha = version.substr('sha@'.length);
|
||||
ret = await selectSha(sha);
|
||||
ret = await selectSha(repo, sha);
|
||||
}
|
||||
// select version
|
||||
if (semver.validRange(version)) {
|
||||
ret = await selectSemver(version);
|
||||
ret = await selectSemver(repo, version);
|
||||
}
|
||||
if (!ret) {
|
||||
throw new Error(`Invalid input xmake-version ${core.getInput('xmake-version')}`);
|
||||
}
|
||||
core.info(`Selected xmake ${ret} (commit: ${ret.sha.substr(0, 8)})`);
|
||||
if (ret.type === 'local') {
|
||||
core.info(`Use local xmake at '${ret.path}'`);
|
||||
} else {
|
||||
core.info(
|
||||
`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` +
|
||||
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''),
|
||||
);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
+12
-6
@@ -5,9 +5,9 @@ import * as toolCache from '@actions/tool-cache';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as semver from 'semver';
|
||||
import { Version } from './versions';
|
||||
import { Version, GitVersion } from './interfaces';
|
||||
|
||||
function getInstallerUrl(version: Version): string {
|
||||
function getInstallerUrl(version: GitVersion): string {
|
||||
const ver = version.version;
|
||||
switch (version.type) {
|
||||
case 'heads': {
|
||||
@@ -30,7 +30,6 @@ function getInstallerUrl(version: Version): string {
|
||||
}
|
||||
default: {
|
||||
// check that we have tested all types
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const _: never = version.type;
|
||||
throw new Error('Unknown version type');
|
||||
}
|
||||
@@ -38,19 +37,26 @@ function getInstallerUrl(version: Version): string {
|
||||
}
|
||||
|
||||
export async function winInstall(version: Version): Promise<void> {
|
||||
if (version.type === 'local') {
|
||||
throw new Error('Local builds for windows is not supported');
|
||||
}
|
||||
const ver = version.version;
|
||||
let toolDir = toolCache.find('xmake', ver);
|
||||
if (!toolDir) {
|
||||
const installer = await core.group(`download xmake ${version}`, async () => {
|
||||
const installer = await core.group(`download xmake ${String(version)}`, async () => {
|
||||
const url = getInstallerUrl(version);
|
||||
core.info(`downloading from ${url}`);
|
||||
const file = await toolCache.downloadTool(url);
|
||||
const exe = path.format({ ...path.parse(file), ext: '.exe', base: undefined });
|
||||
const exe = path.format({
|
||||
...path.parse(file),
|
||||
ext: '.exe',
|
||||
base: undefined,
|
||||
});
|
||||
await io.mv(file, exe);
|
||||
core.info(`downloaded to ${exe}`);
|
||||
return exe;
|
||||
});
|
||||
toolDir = await core.group(`install xmake ${version}`, async () => {
|
||||
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||
core.info(`installing to ${binDir}`);
|
||||
await exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": [
|
||||
"**/*.spec.ts"
|
||||
]
|
||||
}
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"removeComments": true
|
||||
},
|
||||
"exclude": ["**/*.spec.ts"]
|
||||
}
|
||||
|
||||
+11
-12
@@ -1,13 +1,12 @@
|
||||
{
|
||||
"include": [
|
||||
"src/**/*"
|
||||
],
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"module": "commonjs",
|
||||
"target": "es2018",
|
||||
"outDir": "dist"
|
||||
}
|
||||
}
|
||||
"include": ["src/**/*"],
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"moduleResolution": "node",
|
||||
"module": "commonjs",
|
||||
"target": "es2018",
|
||||
"outDir": "dist",
|
||||
"types": ["node", "jest"]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user