Compare commits
30 Commits
+28
-29
@@ -1,42 +1,41 @@
|
|||||||
root: true
|
root: true
|
||||||
parser: "@typescript-eslint/parser"
|
parser: '@typescript-eslint/parser'
|
||||||
parserOptions:
|
parserOptions:
|
||||||
project: tsconfig.json
|
project: tsconfig.json
|
||||||
plugins:
|
plugins:
|
||||||
- "@typescript-eslint"
|
- '@typescript-eslint'
|
||||||
- prettier
|
- prettier
|
||||||
extends:
|
extends:
|
||||||
- eslint:recommended
|
- eslint:recommended
|
||||||
- plugin:@typescript-eslint/eslint-recommended
|
|
||||||
- plugin:@typescript-eslint/recommended
|
- plugin:@typescript-eslint/recommended
|
||||||
- plugin:@typescript-eslint/recommended-requiring-type-checking
|
- plugin:@typescript-eslint/recommended-requiring-type-checking
|
||||||
- prettier/@typescript-eslint
|
|
||||||
- plugin:prettier/recommended
|
- plugin:prettier/recommended
|
||||||
rules:
|
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
|
- 1
|
||||||
- singleQuote: true
|
- allowWithDecorator: true
|
||||||
trailingComma: all
|
allowStaticOnly: true
|
||||||
tabWidth: 4
|
'@typescript-eslint/no-parameter-properties':
|
||||||
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":
|
|
||||||
- 1
|
- 1
|
||||||
- allows:
|
- allows: [protected readonly, private readonly, public readonly, readonly]
|
||||||
- protected readonly
|
'@typescript-eslint/no-throw-literal': [2]
|
||||||
- private readonly
|
'no-unused-vars': [0]
|
||||||
- public readonly
|
'@typescript-eslint/no-unused-vars':
|
||||||
- readonly
|
- 1
|
||||||
"@typescript-eslint/no-throw-literal": [2]
|
- varsIgnorePattern: ^_
|
||||||
"no-unused-vars": [0]
|
argsIgnorePattern: ^_
|
||||||
"@typescript-eslint/prefer-for-of": [1]
|
'@typescript-eslint/prefer-for-of': [1]
|
||||||
"@typescript-eslint/prefer-function-type": [1]
|
'@typescript-eslint/prefer-function-type': [1]
|
||||||
"@typescript-eslint/prefer-nullish-coalescing": [1]
|
'@typescript-eslint/prefer-nullish-coalescing': [1]
|
||||||
"@typescript-eslint/prefer-optional-chain": [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
|
run: yarn test
|
||||||
- name: release
|
- name: release
|
||||||
run: yarn release
|
run: yarn release
|
||||||
- name: "check for uncommitted changes"
|
- name: 'check for uncommitted changes'
|
||||||
# Ensure no changes
|
# Ensure no changes
|
||||||
run: |
|
run: |
|
||||||
git add . && git diff --exit-code --stat \
|
git add .
|
||||||
|| (echo "##[error] found changed files after build. please 'yarn build && npm run format'" \
|
if ! git diff --cached --color=always --exit-code -- . ':!node_modules'; then
|
||||||
"and check in all changes" \
|
echo "::error::Found changed files after build. Please run 'yarn release' and check in all changes."
|
||||||
&& exit 1)
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
version: [latest, branch@master]
|
version: [latest, branch@master, branch@dev]
|
||||||
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
@@ -19,6 +19,7 @@ jobs:
|
|||||||
xmake-version: ${{ matrix.version }}
|
xmake-version: ${{ matrix.version }}
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
|
xmake --version
|
||||||
xmake create -P test
|
xmake create -P test
|
||||||
xmake build -P test
|
xmake build -P test
|
||||||
xmake run -P test
|
xmake run -P test
|
||||||
|
|||||||
@@ -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",
|
"npm.packageManager": "yarn",
|
||||||
"eslint.validate": [
|
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact", "vue"],
|
||||||
"javascript",
|
|
||||||
"javascriptreact",
|
|
||||||
"typescript",
|
|
||||||
"typescriptreact",
|
|
||||||
"vue"
|
|
||||||
],
|
|
||||||
"eslint.enable": true,
|
"eslint.enable": true,
|
||||||
"files.autoSave": "off",
|
"files.autoSave": "off",
|
||||||
"eslint.format.enable": true,
|
"eslint.format.enable": true,
|
||||||
@@ -22,4 +16,4 @@
|
|||||||
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
||||||
},
|
},
|
||||||
"git.ignoreLimitWarning": true
|
"git.ignoreLimitWarning": true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
# GitHub Action - Setup xmake
|
# GitHub Action - Setup xmake
|
||||||
|
|
||||||
[](https://github.com/xmake-io/github-action-setup-xmake/actions)
|
[](https://github.com/xmake-io/github-action-setup-xmake/actions)
|
||||||
[](https://github.com/marketplace/actions/setup-xmake)
|
[](https://github.com/marketplace/actions/setup-xmake)
|
||||||
|
|
||||||
@@ -23,7 +24,7 @@ Use specified version:
|
|||||||
```yml
|
```yml
|
||||||
uses: xmake-io/github-action-setup-xmake@v1
|
uses: xmake-io/github-action-setup-xmake@v1
|
||||||
with:
|
with:
|
||||||
xmake-version: '2.3.1'
|
xmake-version: '2.5.3'
|
||||||
```
|
```
|
||||||
|
|
||||||
Use specified branch:
|
Use specified branch:
|
||||||
@@ -39,5 +40,5 @@ Use semver:
|
|||||||
```yml
|
```yml
|
||||||
uses: xmake-io/github-action-setup-xmake@v1
|
uses: xmake-io/github-action-setup-xmake@v1
|
||||||
with:
|
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:
|
xmake-version:
|
||||||
required: true
|
required: true
|
||||||
default: latest
|
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:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|
||||||
Vendored
+6
-5
@@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.cleanup = exports.create = exports.lsRemote = void 0;
|
||||||
const exec_1 = require("@actions/exec");
|
const exec_1 = require("@actions/exec");
|
||||||
const io = require("@actions/io");
|
const io = require("@actions/io");
|
||||||
const os = require("os");
|
const os = require("os");
|
||||||
@@ -7,9 +8,10 @@ const path = require("path");
|
|||||||
function makeOpt(ref) {
|
function makeOpt(ref) {
|
||||||
return { cwd: path.join(os.tmpdir(), `xmake-git-${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 = '';
|
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,
|
silent: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (d) => (out += d.toString()),
|
stdout: (d) => (out += d.toString()),
|
||||||
@@ -20,7 +22,6 @@ async function lsRemote() {
|
|||||||
const [ref, tag] = line.trim().split('\t');
|
const [ref, tag] = line.trim().split('\t');
|
||||||
if (ref && tag && tag.startsWith('refs/')) {
|
if (ref && tag && tag.startsWith('refs/')) {
|
||||||
const tagPath = tag.split('/').splice(1);
|
const tagPath = tag.split('/').splice(1);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
let ldata = data;
|
let ldata = data;
|
||||||
for (let i = 0; i < tagPath.length - 1; i++) {
|
for (let i = 0; i < tagPath.length - 1; i++) {
|
||||||
const seg = tagPath[i];
|
const seg = tagPath[i];
|
||||||
@@ -37,12 +38,12 @@ async function lsRemote() {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
exports.lsRemote = lsRemote;
|
exports.lsRemote = lsRemote;
|
||||||
async function create(ref) {
|
async function create(repo, ref) {
|
||||||
const opt = makeOpt(ref);
|
const opt = makeOpt(ref);
|
||||||
await io.rmRF(opt.cwd);
|
await io.rmRF(opt.cwd);
|
||||||
await io.mkdirP(opt.cwd);
|
await io.mkdirP(opt.cwd);
|
||||||
await exec_1.exec('git', ['init'], opt);
|
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', ['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', ['checkout', ref], opt);
|
||||||
await exec_1.exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
await exec_1.exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
||||||
|
|||||||
Vendored
+8
-4
@@ -9,14 +9,18 @@ const unix_install_1 = require("./unix-install");
|
|||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const version = await versions_1.selectVersion();
|
const version = await versions_1.selectVersion();
|
||||||
if (os.platform() === 'win32' || os.platform() === 'cygwin')
|
if (os.platform() === 'win32' || os.platform() === 'cygwin') {
|
||||||
await win_install_1.winInstall(version);
|
const latest = await versions_1.selectVersion('latest');
|
||||||
else
|
await win_install_1.winInstall(version, latest);
|
||||||
|
}
|
||||||
|
else {
|
||||||
await unix_install_1.unixInstall(version);
|
await unix_install_1.unixInstall(version);
|
||||||
|
}
|
||||||
await exec_1.exec('xmake --version');
|
await exec_1.exec('xmake --version');
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
const ex = error;
|
||||||
|
core.setFailed(ex.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
run().catch((e) => core.error(e));
|
run().catch((e) => core.error(e));
|
||||||
|
|||||||
Vendored
+8
@@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Repo = exports.Sha = void 0;
|
||||||
function Sha(sha) {
|
function Sha(sha) {
|
||||||
sha = sha.trim().toLowerCase();
|
sha = sha.trim().toLowerCase();
|
||||||
if (!/^[a-f0-9]{40}$/g.test(sha))
|
if (!/^[a-f0-9]{40}$/g.test(sha))
|
||||||
@@ -7,3 +8,10 @@ function Sha(sha) {
|
|||||||
return sha;
|
return sha;
|
||||||
}
|
}
|
||||||
exports.Sha = 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";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.unixInstall = void 0;
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const exec_1 = require("@actions/exec");
|
const exec_1 = require("@actions/exec");
|
||||||
const io = require("@actions/io");
|
const io = require("@actions/io");
|
||||||
@@ -8,27 +9,39 @@ const os = require("os");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
const git = require("./git");
|
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) {
|
async function unixInstall(version) {
|
||||||
const ver = version.version;
|
let toolDir;
|
||||||
let toolDir = toolCache.find('xmake', ver);
|
if (version.type !== 'local') {
|
||||||
if (!toolDir) {
|
const ver = version.version;
|
||||||
const sourceDir = await core.group(`download xmake ${version}`, () => git.create(version.sha));
|
toolDir = toolCache.find('xmake', ver);
|
||||||
toolDir = await core.group(`install xmake ${version}`, async () => {
|
if (!toolDir) {
|
||||||
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
const sourceDir = await core.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha));
|
||||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||||
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
await install(sourceDir, binDir);
|
||||||
await io.rmRF(binDir);
|
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
||||||
await git.cleanup(version.sha);
|
await io.rmRF(binDir);
|
||||||
return cacheDir;
|
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(version.version, '2.3.1')) {
|
||||||
if (version.type !== 'tags' || semver.gt(ver, '2.3.1')) {
|
|
||||||
core.addPath(path.join(toolDir, 'bin'));
|
core.addPath(path.join(toolDir, 'bin'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
core.addPath(path.join(toolDir, 'share', 'xmake'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.unixInstall = unixInstall;
|
exports.unixInstall = unixInstall;
|
||||||
|
|||||||
Vendored
+75
-51
@@ -1,129 +1,153 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) {
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
||||||
if (!privateMap.has(receiver)) {
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||||
throw new TypeError("attempted to set private field on non-instance");
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||||
}
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||||
privateMap.set(receiver, value);
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||||
return value;
|
|
||||||
};
|
};
|
||||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) {
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||||
if (!privateMap.has(receiver)) {
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||||
throw new TypeError("attempted to get private field on non-instance");
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||||
}
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||||
return privateMap.get(receiver);
|
|
||||||
};
|
};
|
||||||
var _string;
|
var _GitVersionImpl_string;
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.selectVersion = void 0;
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
const git_1 = require("./git");
|
const git_1 = require("./git");
|
||||||
const interfaces_1 = require("./interfaces");
|
const interfaces_1 = require("./interfaces");
|
||||||
let VERSIONS;
|
const p = require("path");
|
||||||
async function getVersions() {
|
const DEFAULT_REPO = interfaces_1.Repo('xmake-io/xmake');
|
||||||
if (VERSIONS)
|
const VERSIONS = new Map();
|
||||||
return VERSIONS;
|
async function getVersions(repo) {
|
||||||
return (VERSIONS = await git_1.lsRemote());
|
const cache = VERSIONS.get(repo);
|
||||||
|
if (cache)
|
||||||
|
return cache;
|
||||||
|
const result = await git_1.lsRemote(repo);
|
||||||
|
VERSIONS.set(repo, result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
class VersionImpl {
|
class GitVersionImpl {
|
||||||
constructor(version, sha, type, toString) {
|
constructor(repo, version, sha, type, toString) {
|
||||||
|
this.repo = repo;
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.sha = sha;
|
this.sha = sha;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
_string.set(this, void 0);
|
_GitVersionImpl_string.set(this, void 0);
|
||||||
__classPrivateFieldSet(this, _string, toString);
|
__classPrivateFieldSet(this, _GitVersionImpl_string, toString, "f");
|
||||||
}
|
}
|
||||||
toString() {
|
toString() {
|
||||||
return __classPrivateFieldGet(this, _string);
|
return __classPrivateFieldGet(this, _GitVersionImpl_string, "f");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_string = new WeakMap();
|
_GitVersionImpl_string = new WeakMap();
|
||||||
async function selectBranch(branch) {
|
class LocalVersionImpl {
|
||||||
const versions = await getVersions();
|
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) {
|
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`);
|
throw new Error(`Branch ${branch} not found`);
|
||||||
}
|
}
|
||||||
async function selectPr(pr) {
|
async function selectPr(repo, pr) {
|
||||||
var _a;
|
var _a;
|
||||||
const versions = await getVersions();
|
const versions = await getVersions(repo);
|
||||||
if (pr in versions.pull) {
|
if (pr in versions.pull) {
|
||||||
const prheads = versions.pull[pr];
|
const prHeads = versions.pull[pr];
|
||||||
const sha = (_a = prheads.merge) !== null && _a !== void 0 ? _a : prheads.head;
|
const sha = (_a = prHeads.merge) !== null && _a !== void 0 ? _a : prHeads.head;
|
||||||
if (sha) {
|
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`);
|
throw new Error(`Pull requrest #${pr} not found`);
|
||||||
}
|
}
|
||||||
async function selectSemver(version) {
|
async function selectSemver(repo, version) {
|
||||||
// check version valid
|
|
||||||
const v = new semver.Range(version);
|
const v = new semver.Range(version);
|
||||||
if (!v) {
|
if (!v) {
|
||||||
throw new Error(`Invalid semver`);
|
throw new Error(`Invalid semver`);
|
||||||
}
|
}
|
||||||
const versions = await getVersions();
|
const versions = await getVersions(repo);
|
||||||
const ver = semver.maxSatisfying(Object.keys(versions.tags), v);
|
const ver = semver.maxSatisfying(Object.keys(versions.tags), v);
|
||||||
if (!ver) {
|
if (!ver) {
|
||||||
throw new Error(`No matched releases of xmake-version ${v.format()}`);
|
throw new Error(`No matched releases of xmake-version ${v.format()}`);
|
||||||
}
|
}
|
||||||
const sha = versions.tags[ver];
|
const sha = versions.tags[ver];
|
||||||
return new VersionImpl(ver, sha, 'tags', ver);
|
return new GitVersionImpl(repo, ver, sha, 'tags', ver);
|
||||||
}
|
}
|
||||||
async function selectSha(sha) {
|
async function selectSha(repo, sha) {
|
||||||
var _a;
|
var _a;
|
||||||
const shaValue = interfaces_1.Sha(sha);
|
const shaValue = interfaces_1.Sha(sha);
|
||||||
const versions = await getVersions();
|
const versions = await getVersions(repo);
|
||||||
for (const branch in versions.heads) {
|
for (const branch in versions.heads) {
|
||||||
if (versions.heads[branch] === shaValue) {
|
if (versions.heads[branch] === shaValue) {
|
||||||
return selectBranch(branch);
|
return selectBranch(repo, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const tag in versions.tags) {
|
for (const tag in versions.tags) {
|
||||||
if (versions.tags[tag] === shaValue) {
|
if (versions.tags[tag] === shaValue) {
|
||||||
return selectSemver(tag);
|
return selectSemver(repo, tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const pr in versions.pull) {
|
for (const pr in versions.pull) {
|
||||||
const prData = versions.pull[pr];
|
const prData = versions.pull[pr];
|
||||||
if (((_a = prData.merge) !== null && _a !== void 0 ? _a : prData.head) === shaValue) {
|
if (((_a = prData.merge) !== null && _a !== void 0 ? _a : prData.head) === shaValue) {
|
||||||
return selectPr(Number.parseInt(pr));
|
return selectPr(repo, Number.parseInt(pr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve(new VersionImpl(`sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`));
|
return Promise.resolve(new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`));
|
||||||
}
|
}
|
||||||
async function selectVersion(version) {
|
async function selectVersion(version) {
|
||||||
// get version string
|
|
||||||
version = (version !== null && version !== void 0 ? version : core.getInput('xmake-version')) || 'latest';
|
version = (version !== null && version !== void 0 ? version : core.getInput('xmake-version')) || 'latest';
|
||||||
if (version.toLowerCase() === 'latest')
|
if (version.toLowerCase() === 'latest')
|
||||||
version = '';
|
version = '';
|
||||||
|
let repo = DEFAULT_REPO;
|
||||||
let ret;
|
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@')) {
|
if (version.startsWith('branch@')) {
|
||||||
const branch = version.substr('branch@'.length);
|
const branch = version.substr('branch@'.length);
|
||||||
ret = await selectBranch(branch);
|
ret = await selectBranch(repo, branch);
|
||||||
}
|
}
|
||||||
// select pr
|
|
||||||
if (version.startsWith('pr@')) {
|
if (version.startsWith('pr@')) {
|
||||||
const pr = Number.parseInt(version.substr('pr@'.length));
|
const pr = Number.parseInt(version.substr('pr@'.length));
|
||||||
if (Number.isNaN(pr) || pr <= 0) {
|
if (Number.isNaN(pr) || pr <= 0) {
|
||||||
throw new Error(`Invalid pull requrest ${version.substr('pr@'.length)}, should be a positive integer`);
|
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@')) {
|
if (version.startsWith('sha@')) {
|
||||||
const sha = version.substr('sha@'.length);
|
const sha = version.substr('sha@'.length);
|
||||||
ret = await selectSha(sha);
|
ret = await selectSha(repo, sha);
|
||||||
}
|
}
|
||||||
// select version
|
|
||||||
if (semver.validRange(version)) {
|
if (semver.validRange(version)) {
|
||||||
ret = await selectSemver(version);
|
ret = await selectSemver(repo, version);
|
||||||
}
|
}
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
throw new Error(`Invalid input xmake-version ${core.getInput('xmake-version')}`);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
exports.selectVersion = selectVersion;
|
exports.selectVersion = selectVersion;
|
||||||
|
|||||||
Vendored
+17
-12
@@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.winInstall = void 0;
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const exec_1 = require("@actions/exec");
|
const exec_1 = require("@actions/exec");
|
||||||
const io = require("@actions/io");
|
const io = require("@actions/io");
|
||||||
@@ -7,13 +8,13 @@ const toolCache = require("@actions/tool-cache");
|
|||||||
const os = require("os");
|
const os = require("os");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
function getInstallerUrl(version) {
|
function getInstallerUrl(version, latest) {
|
||||||
const ver = version.version;
|
const ver = version.version;
|
||||||
switch (version.type) {
|
switch (version.type) {
|
||||||
case 'heads': {
|
case 'heads': {
|
||||||
// we only use appveyor ci artifacts for branch version
|
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
|
||||||
const arch = os.arch() === 'x64' ? 'x64' : 'x86';
|
const latestver = latest.version;
|
||||||
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}`;
|
return `https://github.com/xmake-io/xmake/releases/download/${latestver}/xmake-${ver}.${arch}.exe`;
|
||||||
}
|
}
|
||||||
case 'pull': {
|
case 'pull': {
|
||||||
throw new Error('PR builds for windows is not supported');
|
throw new Error('PR builds for windows is not supported');
|
||||||
@@ -22,34 +23,38 @@ function getInstallerUrl(version) {
|
|||||||
throw new Error('Sha builds for windows is not supported');
|
throw new Error('Sha builds for windows is not supported');
|
||||||
}
|
}
|
||||||
case 'tags': {
|
case 'tags': {
|
||||||
// we cannot use appveyor ci artifacts, the old version links may be broken.
|
|
||||||
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
|
const arch = os.arch() === 'x64' ? 'win64' : 'win32';
|
||||||
return semver.gt(ver, '2.2.6')
|
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}.${arch}.exe`
|
||||||
: `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.exe`;
|
: `https://github.com/xmake-io/xmake/releases/download/${ver}/xmake-${ver}.exe`;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
// check that we have tested all types
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
const _ = version.type;
|
const _ = version.type;
|
||||||
throw new Error('Unknown version type');
|
throw new Error('Unknown version type');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function winInstall(version) {
|
async function winInstall(version, latest) {
|
||||||
|
if (version.type === 'local' || latest.type === 'local') {
|
||||||
|
throw new Error('Local builds for windows is not supported');
|
||||||
|
}
|
||||||
const ver = version.version;
|
const ver = version.version;
|
||||||
let toolDir = toolCache.find('xmake', ver);
|
let toolDir = toolCache.find('xmake', ver);
|
||||||
if (!toolDir) {
|
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);
|
const url = getInstallerUrl(version, latest);
|
||||||
core.info(`downloading from ${url}`);
|
core.info(`downloading from ${url}`);
|
||||||
const file = await toolCache.downloadTool(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);
|
await io.mv(file, exe);
|
||||||
core.info(`downloaded to ${exe}`);
|
core.info(`downloaded to ${exe}`);
|
||||||
return 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}`);
|
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||||
core.info(`installing to ${binDir}`);
|
core.info(`installing to ${binDir}`);
|
||||||
await exec_1.exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
await exec_1.exec(`"${installer}" /NOADMIN /S /D=${binDir}`);
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
preset: 'ts-jest',
|
preset: 'ts-jest',
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
};
|
};
|
||||||
|
|||||||
+428
-542
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.
|
||||||
+70
-7
@@ -16,11 +16,14 @@ import * as core from '@actions/core';
|
|||||||
|
|
||||||
#### Inputs/Outputs
|
#### Inputs/Outputs
|
||||||
|
|
||||||
Action inputs can be read with `getInput`. Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
|
Action inputs can be read with `getInput` which returns a `string` or `getBooleanInput` which parses a boolean based on the [yaml 1.2 specification](https://yaml.org/spec/1.2/spec.html#id2804923). If `required` set to be false, the input should have a default value in `action.yml`.
|
||||||
|
|
||||||
|
Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const myInput = core.getInput('inputName', { required: true });
|
const myInput = core.getInput('inputName', { required: true });
|
||||||
|
const myBooleanInput = core.getBooleanInput('booleanInputName', { required: true });
|
||||||
|
const myMultilineInput = core.getMultilineInput('multilineInputName', { required: true });
|
||||||
core.setOutput('outputKey', 'outputVal');
|
core.setOutput('outputKey', 'outputVal');
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -62,11 +65,10 @@ catch (err) {
|
|||||||
// setFailed logs the message and sets a failing exit code
|
// setFailed logs the message and sets a failing exit code
|
||||||
core.setFailed(`Action failed with error ${err}`);
|
core.setFailed(`Action failed with error ${err}`);
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
|
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Logging
|
#### Logging
|
||||||
|
|
||||||
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
|
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
|
||||||
@@ -89,6 +91,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do stuff
|
// Do stuff
|
||||||
|
core.info('Output to the actions build log')
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.error(`Error ${err}, action may still succeed though`);
|
core.error(`Error ${err}, action may still succeed though`);
|
||||||
@@ -112,11 +115,70 @@ 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
|
#### Action state
|
||||||
|
|
||||||
You can use this library to save state and get state for sharing information between a given wrapper action:
|
You can use this library to save state and get state for sharing information between a given wrapper action:
|
||||||
|
|
||||||
|
**action.yml**:
|
||||||
|
|
||||||
**action.yml**
|
|
||||||
```yaml
|
```yaml
|
||||||
name: 'Wrapper action sample'
|
name: 'Wrapper action sample'
|
||||||
inputs:
|
inputs:
|
||||||
@@ -137,10 +199,11 @@ core.saveState("pidToKill", 12345);
|
|||||||
```
|
```
|
||||||
|
|
||||||
In action's `cleanup.js`:
|
In action's `cleanup.js`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
|
|
||||||
var pid = core.getState("pidToKill");
|
var pid = core.getState("pidToKill");
|
||||||
|
|
||||||
process.kill(pid);
|
process.kill(pid);
|
||||||
```
|
```
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
interface CommandProperties {
|
interface CommandProperties {
|
||||||
[key: string]: string;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
@@ -11,6 +11,6 @@ interface CommandProperties {
|
|||||||
* ::warning::This is the message
|
* ::warning::This is the message
|
||||||
* ::set-env name=MY_VAR::some value
|
* ::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 declare function issue(name: string, message?: string): void;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
+18
-4
@@ -1,13 +1,27 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.issue = exports.issueCommand = void 0;
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
|
const utils_1 = require("./utils");
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
@@ -62,13 +76,13 @@ class Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function escapeData(s) {
|
function escapeData(s) {
|
||||||
return (s || '')
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A');
|
.replace(/\n/g, '%0A');
|
||||||
}
|
}
|
||||||
function escapeProperty(s) {
|
function escapeProperty(s) {
|
||||||
return (s || '')
|
return utils_1.toCommandValue(s)
|
||||||
.replace(/%/g, '%25')
|
.replace(/%/g, '%25')
|
||||||
.replace(/\r/g, '%0D')
|
.replace(/\r/g, '%0D')
|
||||||
.replace(/\n/g, '%0A')
|
.replace(/\n/g, '%0A')
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"command.js","sourceRoot":"","sources":["../src/command.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAwB;AAQxB;;;;;;;;;GASG;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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"}
|
||||||
+42
-12
@@ -4,6 +4,8 @@
|
|||||||
export interface InputOptions {
|
export interface InputOptions {
|
||||||
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
|
/** Optional. Whether leading/trailing whitespace will be trimmed for the input. Defaults to true */
|
||||||
|
trimWhitespace?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
@@ -21,9 +23,9 @@ export declare enum ExitCode {
|
|||||||
/**
|
/**
|
||||||
* Sets env variable for this action and future actions in the job
|
* Sets env variable for this action and future actions in the job
|
||||||
* @param name the name of the variable to set
|
* @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
|
* Registers a secret which will get masked from logs
|
||||||
* @param secret value of the secret
|
* @param secret value of the secret
|
||||||
@@ -35,26 +37,54 @@ export declare function setSecret(secret: string): void;
|
|||||||
*/
|
*/
|
||||||
export declare function addPath(inputPath: string): void;
|
export declare function addPath(inputPath: string): void;
|
||||||
/**
|
/**
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* Gets the value of an input.
|
||||||
|
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
|
||||||
|
* Returns an empty string if the value is not defined.
|
||||||
*
|
*
|
||||||
* @param name name of the input to get
|
* @param name name of the input to get
|
||||||
* @param options optional. See InputOptions.
|
* @param options optional. See InputOptions.
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
export declare function getInput(name: string, options?: InputOptions): string;
|
export declare function getInput(name: string, options?: InputOptions): string;
|
||||||
|
/**
|
||||||
|
* Gets the values of an multiline input. Each value is also trimmed.
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns string[]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export declare function getMultilineInput(name: string, options?: InputOptions): string[];
|
||||||
|
/**
|
||||||
|
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
|
||||||
|
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
|
||||||
|
* The return value is also in boolean type.
|
||||||
|
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns boolean
|
||||||
|
*/
|
||||||
|
export declare function getBooleanInput(name: string, options?: InputOptions): boolean;
|
||||||
/**
|
/**
|
||||||
* Sets the value of an output.
|
* Sets the value of an output.
|
||||||
*
|
*
|
||||||
* @param name name of the output to set
|
* @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.
|
* Sets the action status to failed.
|
||||||
* When the action exits it will be with an exit code of 1
|
* When the action exits it will be with an exit code of 1
|
||||||
* @param message add error issue message
|
* @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
|
* Gets whether Actions Step Debug is on or not
|
||||||
*/
|
*/
|
||||||
@@ -66,14 +96,14 @@ export declare function isDebug(): boolean;
|
|||||||
export declare function debug(message: string): void;
|
export declare function debug(message: string): void;
|
||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* 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
|
* 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.
|
* Writes info to log with console.log.
|
||||||
* @param message info message
|
* @param message info message
|
||||||
@@ -104,9 +134,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.
|
* 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 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.
|
* Gets the value of an state set by this action's main execution.
|
||||||
*
|
*
|
||||||
|
|||||||
+103
-18
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,15 +27,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
||||||
const command_1 = require("./command");
|
const command_1 = require("./command");
|
||||||
|
const file_command_1 = require("./file-command");
|
||||||
|
const utils_1 = require("./utils");
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
/**
|
/**
|
||||||
@@ -39,11 +54,21 @@ var ExitCode;
|
|||||||
/**
|
/**
|
||||||
* Sets env variable for this action and future actions in the job
|
* Sets env variable for this action and future actions in the job
|
||||||
* @param name the name of the variable to set
|
* @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) {
|
function exportVariable(name, val) {
|
||||||
process.env[name] = val;
|
const convertedVal = utils_1.toCommandValue(val);
|
||||||
command_1.issueCommand('set-env', { name }, val);
|
process.env[name] = convertedVal;
|
||||||
|
const filePath = process.env['GITHUB_ENV'] || '';
|
||||||
|
if (filePath) {
|
||||||
|
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
||||||
|
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
||||||
|
file_command_1.issueCommand('ENV', commandValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
command_1.issueCommand('set-env', { name }, convertedVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.exportVariable = exportVariable;
|
exports.exportVariable = exportVariable;
|
||||||
/**
|
/**
|
||||||
@@ -59,12 +84,20 @@ exports.setSecret = setSecret;
|
|||||||
* @param inputPath
|
* @param inputPath
|
||||||
*/
|
*/
|
||||||
function addPath(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']}`;
|
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
||||||
}
|
}
|
||||||
exports.addPath = addPath;
|
exports.addPath = addPath;
|
||||||
/**
|
/**
|
||||||
* Gets the value of an input. The value is also trimmed.
|
* Gets the value of an input.
|
||||||
|
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
|
||||||
|
* Returns an empty string if the value is not defined.
|
||||||
*
|
*
|
||||||
* @param name name of the input to get
|
* @param name name of the input to get
|
||||||
* @param options optional. See InputOptions.
|
* @param options optional. See InputOptions.
|
||||||
@@ -75,19 +108,70 @@ function getInput(name, options) {
|
|||||||
if (options && options.required && !val) {
|
if (options && options.required && !val) {
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
throw new Error(`Input required and not supplied: ${name}`);
|
||||||
}
|
}
|
||||||
|
if (options && options.trimWhitespace === false) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
return val.trim();
|
return val.trim();
|
||||||
}
|
}
|
||||||
exports.getInput = getInput;
|
exports.getInput = getInput;
|
||||||
|
/**
|
||||||
|
* Gets the values of an multiline input. Each value is also trimmed.
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns string[]
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getMultilineInput(name, options) {
|
||||||
|
const inputs = getInput(name, options)
|
||||||
|
.split('\n')
|
||||||
|
.filter(x => x !== '');
|
||||||
|
return inputs;
|
||||||
|
}
|
||||||
|
exports.getMultilineInput = getMultilineInput;
|
||||||
|
/**
|
||||||
|
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
|
||||||
|
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
|
||||||
|
* The return value is also in boolean type.
|
||||||
|
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
|
||||||
|
*
|
||||||
|
* @param name name of the input to get
|
||||||
|
* @param options optional. See InputOptions.
|
||||||
|
* @returns boolean
|
||||||
|
*/
|
||||||
|
function getBooleanInput(name, options) {
|
||||||
|
const trueValue = ['true', 'True', 'TRUE'];
|
||||||
|
const falseValue = ['false', 'False', 'FALSE'];
|
||||||
|
const val = getInput(name, options);
|
||||||
|
if (trueValue.includes(val))
|
||||||
|
return true;
|
||||||
|
if (falseValue.includes(val))
|
||||||
|
return false;
|
||||||
|
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
|
||||||
|
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
||||||
|
}
|
||||||
|
exports.getBooleanInput = getBooleanInput;
|
||||||
/**
|
/**
|
||||||
* Sets the value of an output.
|
* Sets the value of an output.
|
||||||
*
|
*
|
||||||
* @param name name of the output to set
|
* @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) {
|
function setOutput(name, value) {
|
||||||
|
process.stdout.write(os.EOL);
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
command_1.issueCommand('set-output', { name }, value);
|
||||||
}
|
}
|
||||||
exports.setOutput = setOutput;
|
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
|
// Results
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
@@ -121,18 +205,18 @@ function debug(message) {
|
|||||||
exports.debug = debug;
|
exports.debug = debug;
|
||||||
/**
|
/**
|
||||||
* Adds an error issue
|
* 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) {
|
function error(message) {
|
||||||
command_1.issue('error', message);
|
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.error = error;
|
exports.error = error;
|
||||||
/**
|
/**
|
||||||
* Adds an warning issue
|
* 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) {
|
function warning(message) {
|
||||||
command_1.issue('warning', message);
|
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
||||||
}
|
}
|
||||||
exports.warning = warning;
|
exports.warning = warning;
|
||||||
/**
|
/**
|
||||||
@@ -190,8 +274,9 @@ exports.group = group;
|
|||||||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
* 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 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) {
|
function saveState(name, value) {
|
||||||
command_1.issueCommand('save-state', { 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,EAA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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;
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
"use strict";
|
||||||
|
// For internal use, subject to change.
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.issueCommand = void 0;
|
||||||
|
// 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;
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
"use strict";
|
||||||
|
// We use any as a valid input type
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.toCommandValue = void 0;
|
||||||
|
/**
|
||||||
|
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
||||||
|
* @param input input to sanitize into a string
|
||||||
|
*/
|
||||||
|
function toCommandValue(input) {
|
||||||
|
if (input === null || input === undefined) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
else if (typeof input === 'string' || input instanceof String) {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
return JSON.stringify(input);
|
||||||
|
}
|
||||||
|
exports.toCommandValue = toCommandValue;
|
||||||
|
//# 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",
|
"name": "@actions/core",
|
||||||
"version": "1.2.3",
|
"version": "1.4.0",
|
||||||
"description": "Actions core lib",
|
"description": "Actions core lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
"actions",
|
"actions",
|
||||||
"core"
|
"core"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/core",
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/core",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/core.js",
|
"main": "lib/core.js",
|
||||||
"types": "lib/core.d.ts",
|
"types": "lib/core.d.ts",
|
||||||
@@ -16,7 +16,8 @@
|
|||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib",
|
||||||
|
"!.DS_Store"
|
||||||
],
|
],
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
"directory": "packages/core"
|
"directory": "packages/core"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"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.
|
||||||
+14
-2
@@ -1,4 +1,5 @@
|
|||||||
import * as im from './interfaces';
|
import { ExecOptions, ExecOutput, ExecListeners } from './interfaces';
|
||||||
|
export { ExecOptions, ExecOutput, ExecListeners };
|
||||||
/**
|
/**
|
||||||
* Exec a command.
|
* Exec a command.
|
||||||
* Output will be streamed to the live console.
|
* Output will be streamed to the live console.
|
||||||
@@ -9,4 +10,15 @@ import * as im from './interfaces';
|
|||||||
* @param options optional exec options. See ExecOptions
|
* @param options optional exec options. See ExecOptions
|
||||||
* @returns Promise<number> exit code
|
* @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>;
|
||||||
|
/**
|
||||||
|
* Exec a command and get the output.
|
||||||
|
* Output will be streamed to the live console.
|
||||||
|
* Returns promise with the exit code and collected stdout and stderr
|
||||||
|
*
|
||||||
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||||||
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||||||
|
* @param options optional exec options. See ExecOptions
|
||||||
|
* @returns Promise<ExecOutput> exit code, stdout, and stderr
|
||||||
|
*/
|
||||||
|
export declare function getExecOutput(commandLine: string, args?: string[], options?: ExecOptions): Promise<ExecOutput>;
|
||||||
|
|||||||
+67
-1
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -9,7 +28,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const tr = require("./toolrunner");
|
exports.getExecOutput = exports.exec = void 0;
|
||||||
|
const string_decoder_1 = require("string_decoder");
|
||||||
|
const tr = __importStar(require("./toolrunner"));
|
||||||
/**
|
/**
|
||||||
* Exec a command.
|
* Exec a command.
|
||||||
* Output will be streamed to the live console.
|
* Output will be streamed to the live console.
|
||||||
@@ -34,4 +55,49 @@ function exec(commandLine, args, options) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.exec = exec;
|
exports.exec = exec;
|
||||||
|
/**
|
||||||
|
* Exec a command and get the output.
|
||||||
|
* Output will be streamed to the live console.
|
||||||
|
* Returns promise with the exit code and collected stdout and stderr
|
||||||
|
*
|
||||||
|
* @param commandLine command to execute (can include additional args). Must be correctly escaped.
|
||||||
|
* @param args optional arguments for tool. Escaping is handled by the lib.
|
||||||
|
* @param options optional exec options. See ExecOptions
|
||||||
|
* @returns Promise<ExecOutput> exit code, stdout, and stderr
|
||||||
|
*/
|
||||||
|
function getExecOutput(commandLine, args, options) {
|
||||||
|
var _a, _b;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let stdout = '';
|
||||||
|
let stderr = '';
|
||||||
|
//Using string decoder covers the case where a mult-byte character is split
|
||||||
|
const stdoutDecoder = new string_decoder_1.StringDecoder('utf8');
|
||||||
|
const stderrDecoder = new string_decoder_1.StringDecoder('utf8');
|
||||||
|
const originalStdoutListener = (_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout;
|
||||||
|
const originalStdErrListener = (_b = options === null || options === void 0 ? void 0 : options.listeners) === null || _b === void 0 ? void 0 : _b.stderr;
|
||||||
|
const stdErrListener = (data) => {
|
||||||
|
stderr += stderrDecoder.write(data);
|
||||||
|
if (originalStdErrListener) {
|
||||||
|
originalStdErrListener(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const stdOutListener = (data) => {
|
||||||
|
stdout += stdoutDecoder.write(data);
|
||||||
|
if (originalStdoutListener) {
|
||||||
|
originalStdoutListener(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const listeners = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.listeners), { stdout: stdOutListener, stderr: stdErrListener });
|
||||||
|
const exitCode = yield exec(commandLine, args, Object.assign(Object.assign({}, options), { listeners }));
|
||||||
|
//flush any remaining characters
|
||||||
|
stdout += stdoutDecoder.end();
|
||||||
|
stderr += stderrDecoder.end();
|
||||||
|
return {
|
||||||
|
exitCode,
|
||||||
|
stdout,
|
||||||
|
stderr
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getExecOutput = getExecOutput;
|
||||||
//# sourceMappingURL=exec.js.map
|
//# sourceMappingURL=exec.js.map
|
||||||
+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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAA4C;AAE5C,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,CA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ED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,IAAI,kCAAM,OAAO,KAAE,SAAS,IAAE,CAAA;QAEvE,gCAAgC;QAChC,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,CAAA;QAC7B,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,CAAA;QAE7B,OAAO;YACL,QAAQ;YACR,MAAM;YACN,MAAM;SACP,CAAA;;CACF;AA9CD,sCA8CC"}
|
||||||
+29
-7
@@ -24,12 +24,34 @@ export interface ExecOptions {
|
|||||||
ignoreReturnCode?: boolean;
|
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 */
|
/** 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;
|
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 */
|
/** optional. Listeners for output. Callback functions that will be called on these events */
|
||||||
listeners?: {
|
listeners?: ExecListeners;
|
||||||
stdout?: (data: Buffer) => void;
|
}
|
||||||
stderr?: (data: Buffer) => void;
|
/**
|
||||||
stdline?: (data: string) => void;
|
* Interface for the output of getExecOutput()
|
||||||
errline?: (data: string) => void;
|
*/
|
||||||
debug?: (data: string) => void;
|
export interface ExecOutput {
|
||||||
};
|
/**The exit code of the process */
|
||||||
|
exitCode: number;
|
||||||
|
/**The entire stdout of the process as a string */
|
||||||
|
stdout: string;
|
||||||
|
/**The entire stderr of the process as a string */
|
||||||
|
stderr: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The user defined listeners for an exec call
|
||||||
|
*/
|
||||||
|
export interface ExecListeners {
|
||||||
|
/** A call back for each buffer of stdout */
|
||||||
|
stdout?: (data: Buffer) => void;
|
||||||
|
/** A call back for each buffer of stderr */
|
||||||
|
stderr?: (data: Buffer) => void;
|
||||||
|
/** A call back for each line of stdout */
|
||||||
|
stdline?: (data: string) => void;
|
||||||
|
/** A call back for each line of stderr */
|
||||||
|
errline?: (data: string) => void;
|
||||||
|
/** A call back for each debug log */
|
||||||
|
debug?: (data: string) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
+45
-14
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -9,12 +28,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const os = require("os");
|
exports.argStringToArray = exports.ToolRunner = void 0;
|
||||||
const events = require("events");
|
const os = __importStar(require("os"));
|
||||||
const child = require("child_process");
|
const events = __importStar(require("events"));
|
||||||
const path = require("path");
|
const child = __importStar(require("child_process"));
|
||||||
const io = require("@actions/io");
|
const path = __importStar(require("path"));
|
||||||
const ioUtil = require("@actions/io/lib/io-util");
|
const io = __importStar(require("@actions/io"));
|
||||||
|
const ioUtil = __importStar(require("@actions/io/lib/io-util"));
|
||||||
|
const timers_1 = require("timers");
|
||||||
/* eslint-disable @typescript-eslint/unbound-method */
|
/* eslint-disable @typescript-eslint/unbound-method */
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
/*
|
/*
|
||||||
@@ -84,11 +105,12 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
s = s.substring(n + os.EOL.length);
|
s = s.substring(n + os.EOL.length);
|
||||||
n = s.indexOf(os.EOL);
|
n = s.indexOf(os.EOL);
|
||||||
}
|
}
|
||||||
strBuffer = s;
|
return s;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// streaming lines to console is best effort. Don't fail a build.
|
// streaming lines to console is best effort. Don't fail a build.
|
||||||
this._debug(`error processing line. Failed with error ${err}`);
|
this._debug(`error processing line. Failed with error ${err}`);
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_getSpawnFileName() {
|
_getSpawnFileName() {
|
||||||
@@ -370,7 +392,7 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
// if the tool is only a file name, then resolve it from the PATH
|
// if the tool is only a file name, then resolve it from the PATH
|
||||||
// otherwise verify it exists (add extension on Windows if necessary)
|
// otherwise verify it exists (add extension on Windows if necessary)
|
||||||
this.toolPath = yield io.which(this.toolPath, true);
|
this.toolPath = yield io.which(this.toolPath, true);
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||||||
this._debug(`exec tool: ${this.toolPath}`);
|
this._debug(`exec tool: ${this.toolPath}`);
|
||||||
this._debug('arguments:');
|
this._debug('arguments:');
|
||||||
for (const arg of this.args) {
|
for (const arg of this.args) {
|
||||||
@@ -384,9 +406,12 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
state.on('debug', (message) => {
|
state.on('debug', (message) => {
|
||||||
this._debug(message);
|
this._debug(message);
|
||||||
});
|
});
|
||||||
|
if (this.options.cwd && !(yield ioUtil.exists(this.options.cwd))) {
|
||||||
|
return reject(new Error(`The cwd: ${this.options.cwd} does not exist!`));
|
||||||
|
}
|
||||||
const fileName = this._getSpawnFileName();
|
const fileName = this._getSpawnFileName();
|
||||||
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
const cp = child.spawn(fileName, this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(this.options, fileName));
|
||||||
const stdbuffer = '';
|
let stdbuffer = '';
|
||||||
if (cp.stdout) {
|
if (cp.stdout) {
|
||||||
cp.stdout.on('data', (data) => {
|
cp.stdout.on('data', (data) => {
|
||||||
if (this.options.listeners && this.options.listeners.stdout) {
|
if (this.options.listeners && this.options.listeners.stdout) {
|
||||||
@@ -395,14 +420,14 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
if (!optionsNonNull.silent && optionsNonNull.outStream) {
|
||||||
optionsNonNull.outStream.write(data);
|
optionsNonNull.outStream.write(data);
|
||||||
}
|
}
|
||||||
this._processLineBuffer(data, stdbuffer, (line) => {
|
stdbuffer = this._processLineBuffer(data, stdbuffer, (line) => {
|
||||||
if (this.options.listeners && this.options.listeners.stdline) {
|
if (this.options.listeners && this.options.listeners.stdline) {
|
||||||
this.options.listeners.stdline(line);
|
this.options.listeners.stdline(line);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const errbuffer = '';
|
let errbuffer = '';
|
||||||
if (cp.stderr) {
|
if (cp.stderr) {
|
||||||
cp.stderr.on('data', (data) => {
|
cp.stderr.on('data', (data) => {
|
||||||
state.processStderr = true;
|
state.processStderr = true;
|
||||||
@@ -417,7 +442,7 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
: optionsNonNull.outStream;
|
: optionsNonNull.outStream;
|
||||||
s.write(data);
|
s.write(data);
|
||||||
}
|
}
|
||||||
this._processLineBuffer(data, errbuffer, (line) => {
|
errbuffer = this._processLineBuffer(data, errbuffer, (line) => {
|
||||||
if (this.options.listeners && this.options.listeners.errline) {
|
if (this.options.listeners && this.options.listeners.errline) {
|
||||||
this.options.listeners.errline(line);
|
this.options.listeners.errline(line);
|
||||||
}
|
}
|
||||||
@@ -458,7 +483,13 @@ class ToolRunner extends events.EventEmitter {
|
|||||||
resolve(exitCode);
|
resolve(exitCode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
if (this.options.input) {
|
||||||
|
if (!cp.stdin) {
|
||||||
|
throw new Error('child process missing stdin');
|
||||||
|
}
|
||||||
|
cp.stdin.end(this.options.input);
|
||||||
|
}
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -544,7 +575,7 @@ class ExecState extends events.EventEmitter {
|
|||||||
this._setResult();
|
this._setResult();
|
||||||
}
|
}
|
||||||
else if (this.processExited) {
|
else if (this.processExited) {
|
||||||
this.timeout = setTimeout(ExecState.HandleTimeout, this.delay, this);
|
this.timeout = timers_1.setTimeout(ExecState.HandleTimeout, this.delay, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_debug(message) {
|
_debug(message) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+5
-4
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/exec",
|
"name": "@actions/exec",
|
||||||
"version": "1.0.3",
|
"version": "1.1.0",
|
||||||
"description": "Actions exec lib",
|
"description": "Actions exec lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
"actions",
|
"actions",
|
||||||
"exec"
|
"exec"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/exec",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/exec.js",
|
"main": "lib/exec.js",
|
||||||
"types": "lib/exec.d.ts",
|
"types": "lib/exec.d.ts",
|
||||||
@@ -16,7 +16,8 @@
|
|||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"lib"
|
"lib",
|
||||||
|
"!.DS_Store"
|
||||||
],
|
],
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
@@ -27,7 +28,7 @@
|
|||||||
"directory": "packages/exec"
|
"directory": "packages/exec"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
|
|||||||
+14
-1
@@ -1,5 +1,18 @@
|
|||||||
## Releases
|
## 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
|
## 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.
|
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.
|
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
|
## 1.0.1 to 1.0.3
|
||||||
Adds proxy support.
|
Adds proxy support.
|
||||||
|
|||||||
+5
-2
@@ -6,7 +6,9 @@ class BasicCredentialHandler {
|
|||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
prepareRequest(options) {
|
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
|
// This handler cannot handle 401
|
||||||
canHandleAuthentication(response) {
|
canHandleAuthentication(response) {
|
||||||
@@ -42,7 +44,8 @@ class PersonalAccessTokenCredentialHandler {
|
|||||||
// currently implements pre-authorization
|
// currently implements pre-authorization
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
prepareRequest(options) {
|
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
|
// This handler cannot handle 401
|
||||||
canHandleAuthentication(response) {
|
canHandleAuthentication(response) {
|
||||||
|
|||||||
+7
-1
@@ -1,5 +1,5 @@
|
|||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import http = require("http");
|
import http = require('http');
|
||||||
import ifm = require('./interfaces');
|
import ifm = require('./interfaces');
|
||||||
export declare enum HttpCodes {
|
export declare enum HttpCodes {
|
||||||
OK = 200,
|
OK = 200,
|
||||||
@@ -23,6 +23,7 @@ export declare enum HttpCodes {
|
|||||||
RequestTimeout = 408,
|
RequestTimeout = 408,
|
||||||
Conflict = 409,
|
Conflict = 409,
|
||||||
Gone = 410,
|
Gone = 410,
|
||||||
|
TooManyRequests = 429,
|
||||||
InternalServerError = 500,
|
InternalServerError = 500,
|
||||||
NotImplemented = 501,
|
NotImplemented = 501,
|
||||||
BadGateway = 502,
|
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
|
* @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 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 {
|
export declare class HttpClientResponse implements ifm.IHttpClientResponse {
|
||||||
constructor(message: http.IncomingMessage);
|
constructor(message: http.IncomingMessage);
|
||||||
message: http.IncomingMessage;
|
message: http.IncomingMessage;
|
||||||
|
|||||||
+75
-38
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const url = require("url");
|
|
||||||
const http = require("http");
|
const http = require("http");
|
||||||
const https = require("https");
|
const https = require("https");
|
||||||
const pm = require("./proxy");
|
const pm = require("./proxy");
|
||||||
@@ -28,6 +27,7 @@ var HttpCodes;
|
|||||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
||||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
||||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
||||||
|
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
||||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
||||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
||||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
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
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
*/
|
*/
|
||||||
function getProxyUrl(serverUrl) {
|
function getProxyUrl(serverUrl) {
|
||||||
let proxyUrl = pm.getProxyUrl(url.parse(serverUrl));
|
let proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||||
return proxyUrl ? proxyUrl.href : '';
|
return proxyUrl ? proxyUrl.href : '';
|
||||||
}
|
}
|
||||||
exports.getProxyUrl = getProxyUrl;
|
exports.getProxyUrl = getProxyUrl;
|
||||||
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
|
const HttpRedirectCodes = [
|
||||||
const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
|
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 RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||||
const ExponentialBackoffCeiling = 10;
|
const ExponentialBackoffCeiling = 10;
|
||||||
const ExponentialBackoffTimeSlice = 5;
|
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 {
|
class HttpClientResponse {
|
||||||
constructor(message) {
|
constructor(message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
@@ -75,7 +94,7 @@ class HttpClientResponse {
|
|||||||
}
|
}
|
||||||
exports.HttpClientResponse = HttpClientResponse;
|
exports.HttpClientResponse = HttpClientResponse;
|
||||||
function isHttps(requestUrl) {
|
function isHttps(requestUrl) {
|
||||||
let parsedUrl = url.parse(requestUrl);
|
let parsedUrl = new URL(requestUrl);
|
||||||
return parsedUrl.protocol === 'https:';
|
return parsedUrl.protocol === 'https:';
|
||||||
}
|
}
|
||||||
exports.isHttps = isHttps;
|
exports.isHttps = isHttps;
|
||||||
@@ -178,18 +197,22 @@ class HttpClient {
|
|||||||
*/
|
*/
|
||||||
async request(verb, requestUrl, data, headers) {
|
async request(verb, requestUrl, data, headers) {
|
||||||
if (this._disposed) {
|
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);
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||||
// Only perform retries on reads since writes may not be idempotent.
|
// 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 numTries = 0;
|
||||||
let response;
|
let response;
|
||||||
while (numTries < maxTries) {
|
while (numTries < maxTries) {
|
||||||
response = await this.requestRaw(info, data);
|
response = await this.requestRaw(info, data);
|
||||||
// Check if it's an authentication challenge
|
// 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;
|
let authenticationHandler;
|
||||||
for (let i = 0; i < this.handlers.length; i++) {
|
for (let i = 0; i < this.handlers.length; i++) {
|
||||||
if (this.handlers[i].canHandleAuthentication(response)) {
|
if (this.handlers[i].canHandleAuthentication(response)) {
|
||||||
@@ -207,21 +230,32 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let redirectsRemaining = this._maxRedirects;
|
let redirectsRemaining = this._maxRedirects;
|
||||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
|
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
|
||||||
&& this._allowRedirects
|
this._allowRedirects &&
|
||||||
&& redirectsRemaining > 0) {
|
redirectsRemaining > 0) {
|
||||||
const redirectUrl = response.message.headers["location"];
|
const redirectUrl = response.message.headers['location'];
|
||||||
if (!redirectUrl) {
|
if (!redirectUrl) {
|
||||||
// if there's no location to redirect to, we won't
|
// if there's no location to redirect to, we won't
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let parsedRedirectUrl = url.parse(redirectUrl);
|
let parsedRedirectUrl = new URL(redirectUrl);
|
||||||
if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
|
if (parsedUrl.protocol == 'https:' &&
|
||||||
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.");
|
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
|
// we need to finish reading the response before reassigning response
|
||||||
// which will leak the open socket.
|
// which will leak the open socket.
|
||||||
await response.readBody();
|
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
|
// let's make the request with the new redirectUrl
|
||||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||||
response = await this.requestRaw(info, data);
|
response = await this.requestRaw(info, data);
|
||||||
@@ -272,8 +306,8 @@ class HttpClient {
|
|||||||
*/
|
*/
|
||||||
requestRawWithCallback(info, data, onResult) {
|
requestRawWithCallback(info, data, onResult) {
|
||||||
let socket;
|
let socket;
|
||||||
if (typeof (data) === 'string') {
|
if (typeof data === 'string') {
|
||||||
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
|
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||||
}
|
}
|
||||||
let callbackCalled = false;
|
let callbackCalled = false;
|
||||||
let handleResult = (err, res) => {
|
let handleResult = (err, res) => {
|
||||||
@@ -286,7 +320,7 @@ class HttpClient {
|
|||||||
let res = new HttpClientResponse(msg);
|
let res = new HttpClientResponse(msg);
|
||||||
handleResult(null, res);
|
handleResult(null, res);
|
||||||
});
|
});
|
||||||
req.on('socket', (sock) => {
|
req.on('socket', sock => {
|
||||||
socket = sock;
|
socket = sock;
|
||||||
});
|
});
|
||||||
// If we ever get disconnected, we want the socket to timeout eventually
|
// If we ever get disconnected, we want the socket to timeout eventually
|
||||||
@@ -301,10 +335,10 @@ class HttpClient {
|
|||||||
// res should have headers
|
// res should have headers
|
||||||
handleResult(err, null);
|
handleResult(err, null);
|
||||||
});
|
});
|
||||||
if (data && typeof (data) === 'string') {
|
if (data && typeof data === 'string') {
|
||||||
req.write(data, 'utf8');
|
req.write(data, 'utf8');
|
||||||
}
|
}
|
||||||
if (data && typeof (data) !== 'string') {
|
if (data && typeof data !== 'string') {
|
||||||
data.on('close', function () {
|
data.on('close', function () {
|
||||||
req.end();
|
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
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
*/
|
*/
|
||||||
getAgent(serverUrl) {
|
getAgent(serverUrl) {
|
||||||
let parsedUrl = url.parse(serverUrl);
|
let parsedUrl = new URL(serverUrl);
|
||||||
return this._getAgent(parsedUrl);
|
return this._getAgent(parsedUrl);
|
||||||
}
|
}
|
||||||
_prepareRequest(method, requestUrl, headers) {
|
_prepareRequest(method, requestUrl, headers) {
|
||||||
@@ -331,31 +365,34 @@ class HttpClient {
|
|||||||
const defaultPort = usingSsl ? 443 : 80;
|
const defaultPort = usingSsl ? 443 : 80;
|
||||||
info.options = {};
|
info.options = {};
|
||||||
info.options.host = info.parsedUrl.hostname;
|
info.options.host = info.parsedUrl.hostname;
|
||||||
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
|
info.options.port = info.parsedUrl.port
|
||||||
info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
? parseInt(info.parsedUrl.port)
|
||||||
|
: defaultPort;
|
||||||
|
info.options.path =
|
||||||
|
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||||||
info.options.method = method;
|
info.options.method = method;
|
||||||
info.options.headers = this._mergeHeaders(headers);
|
info.options.headers = this._mergeHeaders(headers);
|
||||||
if (this.userAgent != null) {
|
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);
|
info.options.agent = this._getAgent(info.parsedUrl);
|
||||||
// gives handlers an opportunity to participate
|
// gives handlers an opportunity to participate
|
||||||
if (this.handlers) {
|
if (this.handlers) {
|
||||||
this.handlers.forEach((handler) => {
|
this.handlers.forEach(handler => {
|
||||||
handler.prepareRequest(info.options);
|
handler.prepareRequest(info.options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
_mergeHeaders(headers) {
|
_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) {
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
||||||
}
|
}
|
||||||
return lowercaseKeys(headers || {});
|
return lowercaseKeys(headers || {});
|
||||||
}
|
}
|
||||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
_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;
|
let clientHeader;
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||||
@@ -390,10 +427,12 @@ class HttpClient {
|
|||||||
maxSockets: maxSockets,
|
maxSockets: maxSockets,
|
||||||
keepAlive: this._keepAlive,
|
keepAlive: this._keepAlive,
|
||||||
proxy: {
|
proxy: {
|
||||||
proxyAuth: proxyUrl.auth,
|
...((proxyUrl.username || proxyUrl.password) && {
|
||||||
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||||
|
}),
|
||||||
host: proxyUrl.hostname,
|
host: proxyUrl.hostname,
|
||||||
port: proxyUrl.port
|
port: proxyUrl.port
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
let tunnelAgent;
|
let tunnelAgent;
|
||||||
const overHttps = proxyUrl.protocol === 'https:';
|
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
|
// 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
|
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||||||
// we have to cast it to any and change it directly
|
// 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;
|
return agent;
|
||||||
}
|
}
|
||||||
@@ -481,14 +522,10 @@ class HttpClient {
|
|||||||
msg = contents;
|
msg = contents;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = "Failed request: (" + statusCode + ")";
|
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;
|
|
||||||
}
|
}
|
||||||
|
let err = new HttpClientError(msg, statusCode);
|
||||||
|
err.result = response.result;
|
||||||
reject(err);
|
reject(err);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+2
-3
@@ -1,6 +1,5 @@
|
|||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import http = require("http");
|
import http = require('http');
|
||||||
import url = require("url");
|
|
||||||
export interface IHeaders {
|
export interface IHeaders {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
@@ -27,7 +26,7 @@ export interface IHttpClientResponse {
|
|||||||
}
|
}
|
||||||
export interface IRequestInfo {
|
export interface IRequestInfo {
|
||||||
options: http.RequestOptions;
|
options: http.RequestOptions;
|
||||||
parsedUrl: url.Url;
|
parsedUrl: URL;
|
||||||
httpModule: any;
|
httpModule: any;
|
||||||
}
|
}
|
||||||
export interface IRequestOptions {
|
export interface IRequestOptions {
|
||||||
|
|||||||
-1
@@ -1,3 +1,2 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
;
|
|
||||||
|
|||||||
+11
-7
@@ -1,11 +1,14 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/http-client",
|
"name": "@actions/http-client",
|
||||||
"version": "1.0.6",
|
"version": "1.0.11",
|
||||||
"description": "Actions Http Client",
|
"description": "Actions Http Client",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rm -Rf ./_out && tsc && cp package*.json ./_out && cp *.md ./_out && cp LICENSE ./_out && cp actions.png ./_out",
|
"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": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -22,12 +25,13 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/actions/http-client#readme",
|
"homepage": "https://github.com/actions/http-client#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^24.0.25",
|
"@types/jest": "^25.1.4",
|
||||||
"@types/node": "^12.12.24",
|
"@types/node": "^12.12.31",
|
||||||
"jest": "^24.9.0",
|
"jest": "^25.1.0",
|
||||||
|
"prettier": "^2.0.4",
|
||||||
"proxy": "^1.0.1",
|
"proxy": "^1.0.1",
|
||||||
"ts-jest": "^24.3.0",
|
"ts-jest": "^25.2.1",
|
||||||
"typescript": "^3.7.4"
|
"typescript": "^3.8.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "0.0.6"
|
"tunnel": "0.0.6"
|
||||||
|
|||||||
+2
-4
@@ -1,4 +1,2 @@
|
|||||||
/// <reference types="node" />
|
export declare function getProxyUrl(reqUrl: URL): URL | undefined;
|
||||||
import * as url from 'url';
|
export declare function checkBypass(reqUrl: URL): boolean;
|
||||||
export declare function getProxyUrl(reqUrl: url.Url): url.Url | undefined;
|
|
||||||
export declare function checkBypass(reqUrl: url.Url): boolean;
|
|
||||||
|
|||||||
+8
-8
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const url = require("url");
|
|
||||||
function getProxyUrl(reqUrl) {
|
function getProxyUrl(reqUrl) {
|
||||||
let usingSsl = reqUrl.protocol === 'https:';
|
let usingSsl = reqUrl.protocol === 'https:';
|
||||||
let proxyUrl;
|
let proxyUrl;
|
||||||
@@ -9,15 +8,13 @@ function getProxyUrl(reqUrl) {
|
|||||||
}
|
}
|
||||||
let proxyVar;
|
let proxyVar;
|
||||||
if (usingSsl) {
|
if (usingSsl) {
|
||||||
proxyVar = process.env["https_proxy"] ||
|
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||||
process.env["HTTPS_PROXY"];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
proxyVar = process.env["http_proxy"] ||
|
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||||
process.env["HTTP_PROXY"];
|
|
||||||
}
|
}
|
||||||
if (proxyVar) {
|
if (proxyVar) {
|
||||||
proxyUrl = url.parse(proxyVar);
|
proxyUrl = new URL(proxyVar);
|
||||||
}
|
}
|
||||||
return proxyUrl;
|
return proxyUrl;
|
||||||
}
|
}
|
||||||
@@ -26,7 +23,7 @@ function checkBypass(reqUrl) {
|
|||||||
if (!reqUrl.hostname) {
|
if (!reqUrl.hostname) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || '';
|
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||||
if (!noProxy) {
|
if (!noProxy) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -47,7 +44,10 @@ function checkBypass(reqUrl) {
|
|||||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||||
}
|
}
|
||||||
// Compare request host against noproxy
|
// 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)) {
|
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
||||||
return true;
|
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.
|
||||||
+1
-11
@@ -9,17 +9,6 @@ export declare function isDirectory(fsPath: string, useStat?: boolean): Promise<
|
|||||||
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
* \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases).
|
||||||
*/
|
*/
|
||||||
export declare function isRooted(p: string): boolean;
|
export declare function isRooted(p: string): boolean;
|
||||||
/**
|
|
||||||
* Recursively create a directory at `fsPath`.
|
|
||||||
*
|
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
|
||||||
* path first, and backs up the path stack from there.
|
|
||||||
*
|
|
||||||
* @param fsPath The path to create
|
|
||||||
* @param maxDepth The maximum recursion depth
|
|
||||||
* @param depth The current recursion depth
|
|
||||||
*/
|
|
||||||
export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number): Promise<void>;
|
|
||||||
/**
|
/**
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
* Best effort attempt to determine whether a file exists and is executable.
|
||||||
* @param filePath file path to check
|
* @param filePath file path to check
|
||||||
@@ -27,3 +16,4 @@ export declare function mkdirP(fsPath: string, maxDepth?: number, depth?: number
|
|||||||
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
* @return if file exists and is executable, returns the file path. otherwise empty string.
|
||||||
*/
|
*/
|
||||||
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
export declare function tryGetExecutablePath(filePath: string, extensions: string[]): Promise<string>;
|
||||||
|
export declare function getCmdPath(): string;
|
||||||
|
|||||||
+28
-46
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -10,9 +29,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
};
|
};
|
||||||
var _a;
|
var _a;
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const assert_1 = require("assert");
|
exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0;
|
||||||
const fs = require("fs");
|
const fs = __importStar(require("fs"));
|
||||||
const path = require("path");
|
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;
|
_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';
|
exports.IS_WINDOWS = process.platform === 'win32';
|
||||||
function exists(fsPath) {
|
function exists(fsPath) {
|
||||||
@@ -53,49 +72,6 @@ function isRooted(p) {
|
|||||||
return p.startsWith('/');
|
return p.startsWith('/');
|
||||||
}
|
}
|
||||||
exports.isRooted = isRooted;
|
exports.isRooted = isRooted;
|
||||||
/**
|
|
||||||
* Recursively create a directory at `fsPath`.
|
|
||||||
*
|
|
||||||
* This implementation is optimistic, meaning it attempts to create the full
|
|
||||||
* path first, and backs up the path stack from there.
|
|
||||||
*
|
|
||||||
* @param fsPath The path to create
|
|
||||||
* @param maxDepth The maximum recursion depth
|
|
||||||
* @param depth The current recursion depth
|
|
||||||
*/
|
|
||||||
function mkdirP(fsPath, maxDepth = 1000, depth = 1) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
assert_1.ok(fsPath, 'a path argument must be provided');
|
|
||||||
fsPath = path.resolve(fsPath);
|
|
||||||
if (depth >= maxDepth)
|
|
||||||
return exports.mkdir(fsPath);
|
|
||||||
try {
|
|
||||||
yield exports.mkdir(fsPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
switch (err.code) {
|
|
||||||
case 'ENOENT': {
|
|
||||||
yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1);
|
|
||||||
yield exports.mkdir(fsPath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
let stats;
|
|
||||||
try {
|
|
||||||
stats = yield exports.stat(fsPath);
|
|
||||||
}
|
|
||||||
catch (err2) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
if (!stats.isDirectory())
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.mkdirP = mkdirP;
|
|
||||||
/**
|
/**
|
||||||
* Best effort attempt to determine whether a file exists and is executable.
|
* Best effort attempt to determine whether a file exists and is executable.
|
||||||
* @param filePath file path to check
|
* @param filePath file path to check
|
||||||
@@ -192,4 +168,10 @@ function isUnixExecutable(stats) {
|
|||||||
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
((stats.mode & 8) > 0 && stats.gid === process.getgid()) ||
|
||||||
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
((stats.mode & 64) > 0 && stats.uid === process.getuid()));
|
||||||
}
|
}
|
||||||
|
// Get the path of cmd.exe in windows
|
||||||
|
function getCmdPath() {
|
||||||
|
var _a;
|
||||||
|
return (_a = process.env['COMSPEC']) !== null && _a !== void 0 ? _a : `cmd.exe`;
|
||||||
|
}
|
||||||
|
exports.getCmdPath = getCmdPath;
|
||||||
//# sourceMappingURL=io-util.js.map
|
//# sourceMappingURL=io-util.js.map
|
||||||
+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,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C,KAAK,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAC1D,CAAA;AACH,CAAC;AAED,qCAAqC;AACrC,SAAgB,UAAU;;IACxB,aAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,mCAAI,SAAS,CAAA;AAC5C,CAAC;AAFD,gCAEC"}
|
||||||
+8
@@ -6,6 +6,8 @@ export interface CopyOptions {
|
|||||||
recursive?: boolean;
|
recursive?: boolean;
|
||||||
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
/** Optional. Whether to overwrite existing files in the destination. Defaults to true */
|
||||||
force?: boolean;
|
force?: boolean;
|
||||||
|
/** Optional. Whether to copy the source directory along with all the files. Only takes effect when recursive=true and copying a directory. Default is true*/
|
||||||
|
copySourceDirectory?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Interface for cp/mv options
|
* Interface for cp/mv options
|
||||||
@@ -54,3 +56,9 @@ export declare function mkdirP(fsPath: string): Promise<void>;
|
|||||||
* @returns Promise<string> path to tool
|
* @returns Promise<string> path to tool
|
||||||
*/
|
*/
|
||||||
export declare function which(tool: string, check?: boolean): Promise<string>;
|
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[]>;
|
||||||
|
|||||||
+108
-57
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -9,11 +28,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const childProcess = require("child_process");
|
exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0;
|
||||||
const path = require("path");
|
const assert_1 = require("assert");
|
||||||
|
const childProcess = __importStar(require("child_process"));
|
||||||
|
const path = __importStar(require("path"));
|
||||||
const util_1 = require("util");
|
const util_1 = require("util");
|
||||||
const ioUtil = require("./io-util");
|
const ioUtil = __importStar(require("./io-util"));
|
||||||
const exec = util_1.promisify(childProcess.exec);
|
const exec = util_1.promisify(childProcess.exec);
|
||||||
|
const execFile = util_1.promisify(childProcess.execFile);
|
||||||
/**
|
/**
|
||||||
* Copies a file or folder.
|
* Copies a file or folder.
|
||||||
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
* Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
|
||||||
@@ -24,14 +46,14 @@ const exec = util_1.promisify(childProcess.exec);
|
|||||||
*/
|
*/
|
||||||
function cp(source, dest, options = {}) {
|
function cp(source, dest, options = {}) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const { force, recursive } = readCopyOptions(options);
|
const { force, recursive, copySourceDirectory } = readCopyOptions(options);
|
||||||
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
|
const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null;
|
||||||
// Dest is an existing file, but not forcing
|
// Dest is an existing file, but not forcing
|
||||||
if (destStat && destStat.isFile() && !force) {
|
if (destStat && destStat.isFile() && !force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If dest is an existing directory, should copy inside.
|
// If dest is an existing directory, should copy inside.
|
||||||
const newDest = destStat && destStat.isDirectory()
|
const newDest = destStat && destStat.isDirectory() && copySourceDirectory
|
||||||
? path.join(dest, path.basename(source))
|
? path.join(dest, path.basename(source))
|
||||||
: dest;
|
: dest;
|
||||||
if (!(yield ioUtil.exists(source))) {
|
if (!(yield ioUtil.exists(source))) {
|
||||||
@@ -96,12 +118,22 @@ function rmRF(inputPath) {
|
|||||||
if (ioUtil.IS_WINDOWS) {
|
if (ioUtil.IS_WINDOWS) {
|
||||||
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
||||||
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
||||||
|
// Check for invalid characters
|
||||||
|
// https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
|
||||||
|
if (/[*"<>|]/.test(inputPath)) {
|
||||||
|
throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
|
const cmdPath = ioUtil.getCmdPath();
|
||||||
if (yield ioUtil.isDirectory(inputPath, true)) {
|
if (yield ioUtil.isDirectory(inputPath, true)) {
|
||||||
yield exec(`rd /s /q "${inputPath}"`);
|
yield exec(`${cmdPath} /s /c "rd /s /q "%inputPath%""`, {
|
||||||
|
env: { inputPath }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield exec(`del /f /a "${inputPath}"`);
|
yield exec(`${cmdPath} /s /c "del /f /a "%inputPath%""`, {
|
||||||
|
env: { inputPath }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -134,7 +166,7 @@ function rmRF(inputPath) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
yield exec(`rm -rf "${inputPath}"`);
|
yield execFile(`rm`, [`-rf`, `${inputPath}`]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
yield ioUtil.unlink(inputPath);
|
yield ioUtil.unlink(inputPath);
|
||||||
@@ -152,7 +184,8 @@ exports.rmRF = rmRF;
|
|||||||
*/
|
*/
|
||||||
function mkdirP(fsPath) {
|
function mkdirP(fsPath) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield ioUtil.mkdirP(fsPath);
|
assert_1.ok(fsPath, 'a path argument must be provided');
|
||||||
|
yield ioUtil.mkdir(fsPath, { recursive: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.mkdirP = mkdirP;
|
exports.mkdirP = mkdirP;
|
||||||
@@ -180,62 +213,80 @@ 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.`);
|
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 {
|
const matches = yield findInPath(tool);
|
||||||
// build the list of extensions to try
|
if (matches && matches.length > 0) {
|
||||||
const extensions = [];
|
return matches[0];
|
||||||
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}`);
|
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.which = which;
|
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) {
|
function readCopyOptions(options) {
|
||||||
const force = options.force == null ? true : options.force;
|
const force = options.force == null ? true : options.force;
|
||||||
const recursive = Boolean(options.recursive);
|
const recursive = Boolean(options.recursive);
|
||||||
return { force, recursive };
|
const copySourceDirectory = options.copySourceDirectory == null
|
||||||
|
? true
|
||||||
|
: Boolean(options.copySourceDirectory);
|
||||||
|
return { force, recursive, copySourceDirectory };
|
||||||
}
|
}
|
||||||
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
|
function cpDirRecursive(sourceDir, destDir, currentDepth, force) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+3
-3
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/io",
|
"name": "@actions/io",
|
||||||
"version": "1.0.2",
|
"version": "1.1.1",
|
||||||
"description": "Actions io lib",
|
"description": "Actions io lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
"actions",
|
"actions",
|
||||||
"io"
|
"io"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/io",
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/io",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/io.js",
|
"main": "lib/io.js",
|
||||||
"types": "lib/io.d.ts",
|
"types": "lib/io.d.ts",
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"directory": "packages/io"
|
"directory": "packages/io"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"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 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');
|
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 {
|
else {
|
||||||
const node12Path = await tc.downloadTool('https://nodejs.org/dist/v12.7.0/node-v12.7.0-linux-x64.tar.gz');
|
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');
|
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;
|
||||||
+128
@@ -0,0 +1,128 @@
|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports._readLinuxVersionFile = exports._getOsVersion = exports._findMatch = void 0;
|
||||||
|
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() === 'VERSION_ID' ||
|
||||||
|
parts[0].trim() === 'DISTRIB_RELEASE')) {
|
||||||
|
version = parts[1]
|
||||||
|
.trim()
|
||||||
|
.replace(/^"/, '')
|
||||||
|
.replace(/"$/, '');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
exports._getOsVersion = _getOsVersion;
|
||||||
|
function _readLinuxVersionFile() {
|
||||||
|
const lsbReleaseFile = '/etc/lsb-release';
|
||||||
|
const osReleaseFile = '/etc/os-release';
|
||||||
|
let contents = '';
|
||||||
|
if (fs.existsSync(lsbReleaseFile)) {
|
||||||
|
contents = fs.readFileSync(lsbReleaseFile).toString();
|
||||||
|
}
|
||||||
|
else if (fs.existsSync(osReleaseFile)) {
|
||||||
|
contents = fs.readFileSync(osReleaseFile).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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AqB;IACnC,MAAM,cAAc,GAAG,kBAAkB,CAAA;IACzC,MAAM,aAAa,GAAG,iBAAiB,CAAA;IACvC,IAAI,QAAQ,GAAG,EAAE,CAAA;IAEjB,IAAI,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;QACjC,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,QAAQ,EAAE,CAAA;KACtD;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;QACvC,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE,CAAA;KACrD;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC;AAZD,sDAYC"}
|
||||||
+20
-7
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,14 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.RetryHelper = void 0;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
/**
|
/**
|
||||||
* Internal class for retries
|
* Internal class for retries
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"retry-helper.js","sourceRoot":"","sources":["../src/retry-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AAErC;;GAEG;AACH,MAAa,WAAW;IAKtB,YAAY,WAAmB,EAAE,UAAkB,EAAE,UAAkB;QACrE,IAAI,WAAW,GAAG,CAAC,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;SACrE;QAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACxC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CA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,CACL,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;YACnE,IAAI,CAAC,UAAU,CAChB,CAAA;IACH,CAAC;IAEa,KAAK,CAAC,OAAe;;YACjC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,CAAC,CAAA;QACpE,CAAC;KAAA;CACF;AAxDD,kCAwDC"}
|
||||||
+32
-2
@@ -1,3 +1,5 @@
|
|||||||
|
import * as mm from './manifest';
|
||||||
|
import { IHeaders } from '@actions/http-client/interfaces';
|
||||||
export declare class HTTPError extends Error {
|
export declare class HTTPError extends Error {
|
||||||
readonly httpStatusCode: number | undefined;
|
readonly httpStatusCode: number | undefined;
|
||||||
constructor(httpStatusCode: number | undefined);
|
constructor(httpStatusCode: number | undefined);
|
||||||
@@ -7,9 +9,11 @@ export declare class HTTPError extends Error {
|
|||||||
*
|
*
|
||||||
* @param url url of tool to download
|
* @param url url of tool to download
|
||||||
* @param dest path to download tool
|
* @param dest path to download tool
|
||||||
|
* @param auth authorization header
|
||||||
|
* @param headers other headers
|
||||||
* @returns path to downloaded tool
|
* @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, headers?: IHeaders): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Extract a .7z file
|
* Extract a .7z file
|
||||||
*
|
*
|
||||||
@@ -34,7 +38,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.
|
* @param flags flags for the tar command to use for extraction. Defaults to 'xz' (extracting gzipped tars). Optional.
|
||||||
* @returns path to the destination directory
|
* @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
|
* Extract a zip
|
||||||
*
|
*
|
||||||
@@ -78,3 +91,20 @@ export declare function find(toolName: string, versionSpec: string, arch?: strin
|
|||||||
* @param arch optional arch. defaults to arch of computer
|
* @param arch optional arch. defaults to arch of computer
|
||||||
*/
|
*/
|
||||||
export declare function findAllVersions(toolName: string, arch?: string): string[];
|
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>;
|
||||||
|
/**
|
||||||
|
* Check if version string is explicit
|
||||||
|
*
|
||||||
|
* @param versionSpec version string to check
|
||||||
|
*/
|
||||||
|
export declare function isExplicitVersion(versionSpec: string): boolean;
|
||||||
|
/**
|
||||||
|
* Get the highest satisfiying semantic version in `versions` which satisfies `versionSpec`
|
||||||
|
*
|
||||||
|
* @param versions array of versions to evaluate
|
||||||
|
* @param versionSpec semantic version spec to satisfy
|
||||||
|
*/
|
||||||
|
export declare function evaluateVersions(versions: string[], versionSpec: string): string;
|
||||||
|
|||||||
+199
-34
@@ -1,4 +1,23 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
@@ -8,20 +27,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.evaluateVersions = exports.isExplicitVersion = exports.findFromManifest = exports.getManifestFromRepo = exports.findAllVersions = exports.find = exports.cacheFile = exports.cacheDir = exports.extractZip = exports.extractXar = exports.extractTar = exports.extract7z = exports.downloadTool = exports.HTTPError = void 0;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
|
const mm = __importStar(require("./manifest"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const httpm = __importStar(require("@actions/http-client"));
|
const httpm = __importStar(require("@actions/http-client"));
|
||||||
@@ -41,15 +55,18 @@ class HTTPError extends Error {
|
|||||||
}
|
}
|
||||||
exports.HTTPError = HTTPError;
|
exports.HTTPError = HTTPError;
|
||||||
const IS_WINDOWS = process.platform === 'win32';
|
const IS_WINDOWS = process.platform === 'win32';
|
||||||
|
const IS_MAC = process.platform === 'darwin';
|
||||||
const userAgent = 'actions/tool-cache';
|
const userAgent = 'actions/tool-cache';
|
||||||
/**
|
/**
|
||||||
* Download a tool from an url and stream it into a file
|
* Download a tool from an url and stream it into a file
|
||||||
*
|
*
|
||||||
* @param url url of tool to download
|
* @param url url of tool to download
|
||||||
* @param dest path to download tool
|
* @param dest path to download tool
|
||||||
|
* @param auth authorization header
|
||||||
|
* @param headers other headers
|
||||||
* @returns path to downloaded tool
|
* @returns path to downloaded tool
|
||||||
*/
|
*/
|
||||||
function downloadTool(url, dest) {
|
function downloadTool(url, dest, auth, headers) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
dest = dest || path.join(_getTempDirectory(), v4_1.default());
|
dest = dest || path.join(_getTempDirectory(), v4_1.default());
|
||||||
yield io.mkdirP(path.dirname(dest));
|
yield io.mkdirP(path.dirname(dest));
|
||||||
@@ -60,7 +77,7 @@ function downloadTool(url, dest) {
|
|||||||
const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
|
const maxSeconds = _getGlobal('TEST_DOWNLOAD_TOOL_RETRY_MAX_SECONDS', 20);
|
||||||
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
|
const retryHelper = new retry_helper_1.RetryHelper(maxAttempts, minSeconds, maxSeconds);
|
||||||
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
|
||||||
return yield downloadToolAttempt(url, dest || '');
|
return yield downloadToolAttempt(url, dest || '', auth, headers);
|
||||||
}), (err) => {
|
}), (err) => {
|
||||||
if (err instanceof HTTPError && err.httpStatusCode) {
|
if (err instanceof HTTPError && err.httpStatusCode) {
|
||||||
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
|
// Don't retry anything less than 500, except 408 Request Timeout and 429 Too Many Requests
|
||||||
@@ -76,7 +93,7 @@ function downloadTool(url, dest) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.downloadTool = downloadTool;
|
exports.downloadTool = downloadTool;
|
||||||
function downloadToolAttempt(url, dest) {
|
function downloadToolAttempt(url, dest, auth, headers) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (fs.existsSync(dest)) {
|
if (fs.existsSync(dest)) {
|
||||||
throw new Error(`Destination file path ${dest} already exists`);
|
throw new Error(`Destination file path ${dest} already exists`);
|
||||||
@@ -85,7 +102,14 @@ function downloadToolAttempt(url, dest) {
|
|||||||
const http = new httpm.HttpClient(userAgent, [], {
|
const http = new httpm.HttpClient(userAgent, [], {
|
||||||
allowRetries: false
|
allowRetries: false
|
||||||
});
|
});
|
||||||
const response = yield http.get(url);
|
if (auth) {
|
||||||
|
core.debug('set auth');
|
||||||
|
if (headers === undefined) {
|
||||||
|
headers = {};
|
||||||
|
}
|
||||||
|
headers.authorization = auth;
|
||||||
|
}
|
||||||
|
const response = yield http.get(url, headers);
|
||||||
if (response.message.statusCode !== 200) {
|
if (response.message.statusCode !== 200) {
|
||||||
const err = new HTTPError(response.message.statusCode);
|
const err = new HTTPError(response.message.statusCode);
|
||||||
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
core.debug(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||||
@@ -140,9 +164,10 @@ function extract7z(file, dest, _7zPath) {
|
|||||||
process.chdir(dest);
|
process.chdir(dest);
|
||||||
if (_7zPath) {
|
if (_7zPath) {
|
||||||
try {
|
try {
|
||||||
|
const logLevel = core.isDebug() ? '-bb1' : '-bb0';
|
||||||
const args = [
|
const args = [
|
||||||
'x',
|
'x',
|
||||||
'-bb1',
|
logLevel,
|
||||||
'-bd',
|
'-bd',
|
||||||
'-sccUTF-8',
|
'-sccUTF-8',
|
||||||
file
|
file
|
||||||
@@ -218,7 +243,16 @@ function extractTar(file, dest, flags = 'xz') {
|
|||||||
core.debug(versionOutput.trim());
|
core.debug(versionOutput.trim());
|
||||||
const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR');
|
const isGnuTar = versionOutput.toUpperCase().includes('GNU TAR');
|
||||||
// Initialize args
|
// 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 destArg = dest;
|
||||||
let fileArg = file;
|
let fileArg = file;
|
||||||
if (IS_WINDOWS && isGnuTar) {
|
if (IS_WINDOWS && isGnuTar) {
|
||||||
@@ -231,6 +265,7 @@ function extractTar(file, dest, flags = 'xz') {
|
|||||||
if (isGnuTar) {
|
if (isGnuTar) {
|
||||||
// Suppress warnings when using GNU tar to extract archives created by BSD tar
|
// Suppress warnings when using GNU tar to extract archives created by BSD tar
|
||||||
args.push('--warning=no-unknown-keyword');
|
args.push('--warning=no-unknown-keyword');
|
||||||
|
args.push('--overwrite');
|
||||||
}
|
}
|
||||||
args.push('-C', destArg, '-f', fileArg);
|
args.push('-C', destArg, '-f', fileArg);
|
||||||
yield exec_1.exec(`tar`, args);
|
yield exec_1.exec(`tar`, args);
|
||||||
@@ -238,6 +273,36 @@ function extractTar(file, dest, flags = 'xz') {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.extractTar = extractTar;
|
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
|
* Extract a zip
|
||||||
*
|
*
|
||||||
@@ -266,26 +331,61 @@ function extractZipWin(file, dest) {
|
|||||||
// build the powershell command
|
// build the powershell command
|
||||||
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
const escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
|
||||||
const escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
|
const 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}')`;
|
const pwshPath = yield io.which('pwsh', false);
|
||||||
// run powershell
|
//To match the file overwrite behavior on nix systems, we use the overwrite = true flag for ExtractToDirectory
|
||||||
const powershellPath = yield io.which('powershell');
|
//and the -Force flag for Expand-Archive as a fallback
|
||||||
const args = [
|
if (pwshPath) {
|
||||||
'-NoLogo',
|
//attempt to use pwsh with ExtractToDirectory, if this fails attempt Expand-Archive
|
||||||
'-Sta',
|
const pwshCommand = [
|
||||||
'-NoProfile',
|
`$ErrorActionPreference = 'Stop' ;`,
|
||||||
'-NonInteractive',
|
`try { Add-Type -AssemblyName System.IO.Compression.ZipFile } catch { } ;`,
|
||||||
'-ExecutionPolicy',
|
`try { [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`,
|
||||||
'Unrestricted',
|
`catch { if (($_.Exception.GetType().FullName -eq 'System.Management.Automation.MethodException') -or ($_.Exception.GetType().FullName -eq 'System.Management.Automation.RuntimeException') ){ Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force } else { throw $_ } } ;`
|
||||||
'-Command',
|
].join(' ');
|
||||||
command
|
const args = [
|
||||||
];
|
'-NoLogo',
|
||||||
yield exec_1.exec(`"${powershellPath}"`, args);
|
'-NoProfile',
|
||||||
|
'-NonInteractive',
|
||||||
|
'-ExecutionPolicy',
|
||||||
|
'Unrestricted',
|
||||||
|
'-Command',
|
||||||
|
pwshCommand
|
||||||
|
];
|
||||||
|
core.debug(`Using pwsh at path: ${pwshPath}`);
|
||||||
|
yield exec_1.exec(`"${pwshPath}"`, args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const powershellCommand = [
|
||||||
|
`$ErrorActionPreference = 'Stop' ;`,
|
||||||
|
`try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ;`,
|
||||||
|
`if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath '${escapedFile}' -DestinationPath '${escapedDest}' -Force }`,
|
||||||
|
`else {[System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}', $true) }`
|
||||||
|
].join(' ');
|
||||||
|
const args = [
|
||||||
|
'-NoLogo',
|
||||||
|
'-Sta',
|
||||||
|
'-NoProfile',
|
||||||
|
'-NonInteractive',
|
||||||
|
'-ExecutionPolicy',
|
||||||
|
'Unrestricted',
|
||||||
|
'-Command',
|
||||||
|
powershellCommand
|
||||||
|
];
|
||||||
|
const powershellPath = yield io.which('powershell', true);
|
||||||
|
core.debug(`Using powershell at path: ${powershellPath}`);
|
||||||
|
yield exec_1.exec(`"${powershellPath}"`, args);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function extractZipNix(file, dest) {
|
function extractZipNix(file, dest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const unzipPath = yield io.which('unzip');
|
const unzipPath = yield io.which('unzip', true);
|
||||||
yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest });
|
const args = [file];
|
||||||
|
if (!core.isDebug()) {
|
||||||
|
args.unshift('-q');
|
||||||
|
}
|
||||||
|
args.unshift('-o'); //overwrite with -o, otherwise a prompt is shown which freezes the run
|
||||||
|
yield exec_1.exec(`"${unzipPath}"`, args, { cwd: dest });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -367,9 +467,9 @@ function find(toolName, versionSpec, arch) {
|
|||||||
}
|
}
|
||||||
arch = arch || os.arch();
|
arch = arch || os.arch();
|
||||||
// attempt to resolve an explicit version
|
// attempt to resolve an explicit version
|
||||||
if (!_isExplicitVersion(versionSpec)) {
|
if (!isExplicitVersion(versionSpec)) {
|
||||||
const localVersions = findAllVersions(toolName, arch);
|
const localVersions = findAllVersions(toolName, arch);
|
||||||
const match = _evaluateVersions(localVersions, versionSpec);
|
const match = evaluateVersions(localVersions, versionSpec);
|
||||||
versionSpec = match;
|
versionSpec = match;
|
||||||
}
|
}
|
||||||
// check for the explicit version in the cache
|
// check for the explicit version in the cache
|
||||||
@@ -402,7 +502,7 @@ function findAllVersions(toolName, arch) {
|
|||||||
if (fs.existsSync(toolPath)) {
|
if (fs.existsSync(toolPath)) {
|
||||||
const children = fs.readdirSync(toolPath);
|
const children = fs.readdirSync(toolPath);
|
||||||
for (const child of children) {
|
for (const child of children) {
|
||||||
if (_isExplicitVersion(child)) {
|
if (isExplicitVersion(child)) {
|
||||||
const fullPath = path.join(toolPath, child, arch || '');
|
const fullPath = path.join(toolPath, child, arch || '');
|
||||||
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
if (fs.existsSync(fullPath) && fs.existsSync(`${fullPath}.complete`)) {
|
||||||
versions.push(child);
|
versions.push(child);
|
||||||
@@ -413,6 +513,51 @@ function findAllVersions(toolName, arch) {
|
|||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
exports.findAllVersions = findAllVersions;
|
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) {
|
function _createExtractFolder(dest) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
@@ -440,14 +585,26 @@ function _completeToolPath(tool, version, arch) {
|
|||||||
fs.writeFileSync(markerPath, '');
|
fs.writeFileSync(markerPath, '');
|
||||||
core.debug('finished caching tool');
|
core.debug('finished caching tool');
|
||||||
}
|
}
|
||||||
function _isExplicitVersion(versionSpec) {
|
/**
|
||||||
|
* Check if version string is explicit
|
||||||
|
*
|
||||||
|
* @param versionSpec version string to check
|
||||||
|
*/
|
||||||
|
function isExplicitVersion(versionSpec) {
|
||||||
const c = semver.clean(versionSpec) || '';
|
const c = semver.clean(versionSpec) || '';
|
||||||
core.debug(`isExplicit: ${c}`);
|
core.debug(`isExplicit: ${c}`);
|
||||||
const valid = semver.valid(c) != null;
|
const valid = semver.valid(c) != null;
|
||||||
core.debug(`explicit? ${valid}`);
|
core.debug(`explicit? ${valid}`);
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
function _evaluateVersions(versions, versionSpec) {
|
exports.isExplicitVersion = isExplicitVersion;
|
||||||
|
/**
|
||||||
|
* Get the highest satisfiying semantic version in `versions` which satisfies `versionSpec`
|
||||||
|
*
|
||||||
|
* @param versions array of versions to evaluate
|
||||||
|
* @param versionSpec semantic version spec to satisfy
|
||||||
|
*/
|
||||||
|
function evaluateVersions(versions, versionSpec) {
|
||||||
let version = '';
|
let version = '';
|
||||||
core.debug(`evaluating ${versions.length} versions`);
|
core.debug(`evaluating ${versions.length} versions`);
|
||||||
versions = versions.sort((a, b) => {
|
versions = versions.sort((a, b) => {
|
||||||
@@ -472,6 +629,7 @@ function _evaluateVersions(versions, versionSpec) {
|
|||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
exports.evaluateVersions = evaluateVersions;
|
||||||
/**
|
/**
|
||||||
* Gets RUNNER_TOOL_CACHE
|
* Gets RUNNER_TOOL_CACHE
|
||||||
*/
|
*/
|
||||||
@@ -497,4 +655,11 @@ function _getGlobal(key, defaultValue) {
|
|||||||
/* eslint-enable @typescript-eslint/no-explicit-any */
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
||||||
return value !== undefined ? value : defaultValue;
|
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
|
//# sourceMappingURL=tool-cache.js.map
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
Vendored
Regular → Executable
+6
-6
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/tool-cache",
|
"name": "@actions/tool-cache",
|
||||||
"version": "1.3.3",
|
"version": "1.7.1",
|
||||||
"description": "Actions tool-cache lib",
|
"description": "Actions tool-cache lib",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"github",
|
"github",
|
||||||
"actions",
|
"actions",
|
||||||
"exec"
|
"exec"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
"homepage": "https://github.com/actions/toolkit/tree/main/packages/tool-cache",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "lib/tool-cache.js",
|
"main": "lib/tool-cache.js",
|
||||||
"types": "lib/tool-cache.d.ts",
|
"types": "lib/tool-cache.d.ts",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"directory": "packages/tool-cache"
|
"directory": "packages/tool-cache"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
@@ -36,10 +36,10 @@
|
|||||||
"url": "https://github.com/actions/toolkit/issues"
|
"url": "https://github.com/actions/toolkit/issues"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.0",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.0",
|
"@actions/exec": "^1.0.0",
|
||||||
"@actions/http-client": "^1.0.3",
|
"@actions/http-client": "^1.0.8",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.1.1",
|
||||||
"semver": "^6.1.0",
|
"semver": "^6.1.0",
|
||||||
"uuid": "^3.3.2"
|
"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
|
# 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
|
## 7.1.0
|
||||||
|
|
||||||
* Add `require('semver/preload')` to load the entire module without using
|
* 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 semverGtr = require('semver/ranges/gtr')
|
||||||
const semverLtr = require('semver/ranges/ltr')
|
const semverLtr = require('semver/ranges/ltr')
|
||||||
const semverIntersects = require('semver/ranges/intersects')
|
const semverIntersects = require('semver/ranges/intersects')
|
||||||
|
const simplifyRange = require('semver/ranges/simplify')
|
||||||
|
const rangeSubset = require('semver/ranges/subset')
|
||||||
```
|
```
|
||||||
|
|
||||||
As a command-line utility:
|
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
|
of the tuple are accepted, but nothing that would be greater than the
|
||||||
provided tuple parts.
|
provided tuple parts.
|
||||||
|
|
||||||
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0-0`
|
||||||
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
* `1.2.3 - 2` := `>=1.2.3 <3.0.0-0`
|
||||||
|
|
||||||
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
#### 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.
|
numeric values in the `[major, minor, patch]` tuple.
|
||||||
|
|
||||||
* `*` := `>=0.0.0` (Any version satisfies)
|
* `*` := `>=0.0.0` (Any version satisfies)
|
||||||
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
* `1.x` := `>=1.0.0 <2.0.0-0` (Matching major version)
|
||||||
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
* `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
|
A partial version range is treated as an X-Range, so the special
|
||||||
character is in fact optional.
|
character is in fact optional.
|
||||||
|
|
||||||
* `""` (empty string) := `*` := `>=0.0.0`
|
* `""` (empty string) := `*` := `>=0.0.0`
|
||||||
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
* `1` := `1.x.x` := `>=1.0.0 <2.0.0-0`
|
||||||
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0-0`
|
||||||
|
|
||||||
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
||||||
|
|
||||||
Allows patch-level changes if a minor version is specified on the
|
Allows patch-level changes if a minor version is specified on the
|
||||||
comparator. Allows minor-level changes if not.
|
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.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` (Same as `1.2.x`)
|
* `~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` (Same as `1.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.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` (Same as `0.2.x`)
|
* `~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` (Same as `0.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` Note that prereleases in
|
* `~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
|
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
|
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
|
`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
|
`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.
|
additive (but non-breaking), according to commonly observed practices.
|
||||||
|
|
||||||
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
* `^1.2.3` := `>=1.2.3 <2.0.0-0`
|
||||||
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
* `^0.2.3` := `>=0.2.3 <0.3.0-0`
|
||||||
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
* `^0.0.3` := `>=0.0.3 <0.0.4-0`
|
||||||
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
* `^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
|
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
|
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
|
`1.2.4-beta.2` would not, because it is a prerelease of a
|
||||||
different `[major, minor, patch]` tuple.
|
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
|
`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.
|
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
|
number `0`, but will allow flexibility within that value, even if the
|
||||||
major and minor versions are both `0`.
|
major and minor versions are both `0`.
|
||||||
|
|
||||||
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
* `^1.2.x` := `>=1.2.0 <2.0.0-0`
|
||||||
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
* `^0.0.x` := `>=0.0.0 <0.1.0-0`
|
||||||
* `^0.0` := `>=0.0.0 <0.1.0`
|
* `^0.0` := `>=0.0.0 <0.1.0-0`
|
||||||
|
|
||||||
A missing `minor` and `patch` values will desugar to zero, but also
|
A missing `minor` and `patch` values will desugar to zero, but also
|
||||||
allow flexibility within those values, even if the major version is
|
allow flexibility within those values, even if the major version is
|
||||||
zero.
|
zero.
|
||||||
|
|
||||||
* `^1.x` := `>=1.0.0 <2.0.0`
|
* `^1.x` := `>=1.0.0 <2.0.0-0`
|
||||||
* `^0.x` := `>=0.0.0 <1.0.0`
|
* `^0.x` := `>=0.0.0 <1.0.0-0`
|
||||||
|
|
||||||
### Range Grammar
|
### Range Grammar
|
||||||
|
|
||||||
@@ -446,6 +448,16 @@ strings that they parse.
|
|||||||
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
||||||
the function called by `gtr` and `ltr`.)
|
the function called by `gtr` and `ltr`.)
|
||||||
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
* `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
|
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
|
greater than a range, less than a range, *or* satisfy a range! For
|
||||||
|
|||||||
+2
-6
@@ -5,12 +5,7 @@ class Comparator {
|
|||||||
return ANY
|
return ANY
|
||||||
}
|
}
|
||||||
constructor (comp, options) {
|
constructor (comp, options) {
|
||||||
if (!options || typeof options !== 'object') {
|
options = parseOptions(options)
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (comp instanceof Comparator) {
|
if (comp instanceof Comparator) {
|
||||||
if (comp.loose === !!options.loose) {
|
if (comp.loose === !!options.loose) {
|
||||||
@@ -132,6 +127,7 @@ class Comparator {
|
|||||||
|
|
||||||
module.exports = Comparator
|
module.exports = Comparator
|
||||||
|
|
||||||
|
const parseOptions = require('../internal/parse-options')
|
||||||
const {re, t} = require('../internal/re')
|
const {re, t} = require('../internal/re')
|
||||||
const cmp = require('../functions/cmp')
|
const cmp = require('../functions/cmp')
|
||||||
const debug = require('../internal/debug')
|
const debug = require('../internal/debug')
|
||||||
|
|||||||
+106
-44
@@ -1,12 +1,7 @@
|
|||||||
// hoisted class for cyclic dependency
|
// hoisted class for cyclic dependency
|
||||||
class Range {
|
class Range {
|
||||||
constructor (range, options) {
|
constructor (range, options) {
|
||||||
if (!options || typeof options !== 'object') {
|
options = parseOptions(options)
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (range instanceof Range) {
|
if (range instanceof Range) {
|
||||||
if (
|
if (
|
||||||
@@ -46,6 +41,24 @@ class Range {
|
|||||||
throw new TypeError(`Invalid SemVer Range: ${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()
|
this.format()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,11 +77,20 @@ class Range {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parseRange (range) {
|
parseRange (range) {
|
||||||
const loose = this.options.loose
|
|
||||||
range = range.trim()
|
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`
|
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
||||||
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]
|
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)
|
debug('hyphen replace', range)
|
||||||
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
||||||
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)
|
||||||
@@ -87,14 +109,33 @@ class Range {
|
|||||||
// ready to be split into comparators.
|
// ready to be split into comparators.
|
||||||
|
|
||||||
const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]
|
||||||
return range
|
const rangeList = range
|
||||||
.split(' ')
|
.split(' ')
|
||||||
.map(comp => parseComparator(comp, this.options))
|
.map(comp => parseComparator(comp, this.options))
|
||||||
.join(' ')
|
.join(' ')
|
||||||
.split(/\s+/)
|
.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
|
// in loose mode, throw out any that are not valid comparators
|
||||||
.filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
|
.filter(this.options.loose ? comp => !!comp.match(compRe) : () => true)
|
||||||
.map(comp => new Comparator(comp, this.options))
|
.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) {
|
intersects (range, options) {
|
||||||
@@ -143,6 +184,10 @@ class Range {
|
|||||||
}
|
}
|
||||||
module.exports = 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 Comparator = require('./comparator')
|
||||||
const debug = require('../internal/debug')
|
const debug = require('../internal/debug')
|
||||||
const SemVer = require('./semver')
|
const SemVer = require('./semver')
|
||||||
@@ -154,6 +199,9 @@ const {
|
|||||||
caretTrimReplace
|
caretTrimReplace
|
||||||
} = require('../internal/re')
|
} = 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
|
// take a set of comparators and determine whether there
|
||||||
// exists a version which can satisfy it
|
// exists a version which can satisfy it
|
||||||
const isSatisfiable = (comparators, options) => {
|
const isSatisfiable = (comparators, options) => {
|
||||||
@@ -191,11 +239,11 @@ const parseComparator = (comp, options) => {
|
|||||||
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
const isX = id => !id || id.toLowerCase() === 'x' || id === '*'
|
||||||
|
|
||||||
// ~, ~> --> * (any, kinda silly)
|
// ~, ~> --> * (any, kinda silly)
|
||||||
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.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
|
// ~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
|
// ~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
|
// ~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
|
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0-0
|
||||||
const replaceTildes = (comp, options) =>
|
const replaceTildes = (comp, options) =>
|
||||||
comp.trim().split(/\s+/).map((comp) => {
|
comp.trim().split(/\s+/).map((comp) => {
|
||||||
return replaceTilde(comp, options)
|
return replaceTilde(comp, options)
|
||||||
@@ -210,18 +258,18 @@ const replaceTilde = (comp, options) => {
|
|||||||
if (isX(M)) {
|
if (isX(M)) {
|
||||||
ret = ''
|
ret = ''
|
||||||
} else if (isX(m)) {
|
} 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)) {
|
} else if (isX(p)) {
|
||||||
// ~1.2 == >=1.2.0 <1.3.0
|
// ~1.2 == >=1.2.0 <1.3.0-0
|
||||||
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0`
|
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`
|
||||||
} else if (pr) {
|
} else if (pr) {
|
||||||
debug('replaceTilde pr', pr)
|
debug('replaceTilde pr', pr)
|
||||||
ret = `>=${M}.${m}.${p}-${pr
|
ret = `>=${M}.${m}.${p}-${pr
|
||||||
} <${M}.${+m + 1}.0`
|
} <${M}.${+m + 1}.0-0`
|
||||||
} else {
|
} else {
|
||||||
// ~1.2.3 == >=1.2.3 <1.3.0
|
// ~1.2.3 == >=1.2.3 <1.3.0-0
|
||||||
ret = `>=${M}.${m}.${p
|
ret = `>=${M}.${m}.${p
|
||||||
} <${M}.${+m + 1}.0`
|
} <${M}.${+m + 1}.0-0`
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('tilde return', ret)
|
debug('tilde return', ret)
|
||||||
@@ -230,11 +278,11 @@ const replaceTilde = (comp, options) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ^ --> * (any, kinda silly)
|
// ^ --> * (any, kinda silly)
|
||||||
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.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
|
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
|
||||||
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
|
||||||
// ^1.2.3 --> >=1.2.3 <2.0.0
|
// ^1.2.3 --> >=1.2.3 <2.0.0-0
|
||||||
// ^1.2.0 --> >=1.2.0 <2.0.0
|
// ^1.2.0 --> >=1.2.0 <2.0.0-0
|
||||||
const replaceCarets = (comp, options) =>
|
const replaceCarets = (comp, options) =>
|
||||||
comp.trim().split(/\s+/).map((comp) => {
|
comp.trim().split(/\s+/).map((comp) => {
|
||||||
return replaceCaret(comp, options)
|
return replaceCaret(comp, options)
|
||||||
@@ -243,6 +291,7 @@ const replaceCarets = (comp, options) =>
|
|||||||
const replaceCaret = (comp, options) => {
|
const replaceCaret = (comp, options) => {
|
||||||
debug('caret', comp, options)
|
debug('caret', comp, options)
|
||||||
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]
|
||||||
|
const z = options.includePrerelease ? '-0' : ''
|
||||||
return comp.replace(r, (_, M, m, p, pr) => {
|
return comp.replace(r, (_, M, m, p, pr) => {
|
||||||
debug('caret', comp, _, M, m, p, pr)
|
debug('caret', comp, _, M, m, p, pr)
|
||||||
let ret
|
let ret
|
||||||
@@ -250,40 +299,40 @@ const replaceCaret = (comp, options) => {
|
|||||||
if (isX(M)) {
|
if (isX(M)) {
|
||||||
ret = ''
|
ret = ''
|
||||||
} else if (isX(m)) {
|
} 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)) {
|
} else if (isX(p)) {
|
||||||
if (M === '0') {
|
if (M === '0') {
|
||||||
ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0`
|
ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`
|
||||||
} else {
|
} else {
|
||||||
ret = `>=${M}.${m}.0 <${+M + 1}.0.0`
|
ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`
|
||||||
}
|
}
|
||||||
} else if (pr) {
|
} else if (pr) {
|
||||||
debug('replaceCaret pr', pr)
|
debug('replaceCaret pr', pr)
|
||||||
if (M === '0') {
|
if (M === '0') {
|
||||||
if (m === '0') {
|
if (m === '0') {
|
||||||
ret = `>=${M}.${m}.${p}-${pr
|
ret = `>=${M}.${m}.${p}-${pr
|
||||||
} <${M}.${m}.${+p + 1}`
|
} <${M}.${m}.${+p + 1}-0`
|
||||||
} else {
|
} else {
|
||||||
ret = `>=${M}.${m}.${p}-${pr
|
ret = `>=${M}.${m}.${p}-${pr
|
||||||
} <${M}.${+m + 1}.0`
|
} <${M}.${+m + 1}.0-0`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = `>=${M}.${m}.${p}-${pr
|
ret = `>=${M}.${m}.${p}-${pr
|
||||||
} <${+M + 1}.0.0`
|
} <${+M + 1}.0.0-0`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug('no pr')
|
debug('no pr')
|
||||||
if (M === '0') {
|
if (M === '0') {
|
||||||
if (m === '0') {
|
if (m === '0') {
|
||||||
ret = `>=${M}.${m}.${p
|
ret = `>=${M}.${m}.${p
|
||||||
} <${M}.${m}.${+p + 1}`
|
}${z} <${M}.${m}.${+p + 1}-0`
|
||||||
} else {
|
} else {
|
||||||
ret = `>=${M}.${m}.${p
|
ret = `>=${M}.${m}.${p
|
||||||
} <${M}.${+m + 1}.0`
|
}${z} <${M}.${+m + 1}.0-0`
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = `>=${M}.${m}.${p
|
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}`
|
ret = `${gtlt + M}.${m}.${p}${pr}`
|
||||||
} else if (xm) {
|
} 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) {
|
} else if (xp) {
|
||||||
ret = `>=${M}.${m}.0${pr
|
ret = `>=${M}.${m}.0${pr
|
||||||
} <${M}.${+m + 1}.0${pr}`
|
} <${M}.${+m + 1}.0-0`
|
||||||
}
|
}
|
||||||
|
|
||||||
debug('xRange return', ret)
|
debug('xRange return', ret)
|
||||||
@@ -378,32 +430,42 @@ const replaceStars = (comp, options) => {
|
|||||||
return comp.trim().replace(re[t.STAR], '')
|
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])
|
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
||||||
// M, m, patch, prerelease, build
|
// M, m, patch, prerelease, build
|
||||||
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
// 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 - 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
|
// 1.2 - 3.4 => >=1.2.0 <3.5.0-0
|
||||||
const hyphenReplace = ($0,
|
const hyphenReplace = incPr => ($0,
|
||||||
from, fM, fm, fp, fpr, fb,
|
from, fM, fm, fp, fpr, fb,
|
||||||
to, tM, tm, tp, tpr, tb) => {
|
to, tM, tm, tp, tpr, tb) => {
|
||||||
if (isX(fM)) {
|
if (isX(fM)) {
|
||||||
from = ''
|
from = ''
|
||||||
} else if (isX(fm)) {
|
} else if (isX(fm)) {
|
||||||
from = `>=${fM}.0.0`
|
from = `>=${fM}.0.0${incPr ? '-0' : ''}`
|
||||||
} else if (isX(fp)) {
|
} else if (isX(fp)) {
|
||||||
from = `>=${fM}.${fm}.0`
|
from = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`
|
||||||
} else {
|
} else if (fpr) {
|
||||||
from = `>=${from}`
|
from = `>=${from}`
|
||||||
|
} else {
|
||||||
|
from = `>=${from}${incPr ? '-0' : ''}`
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isX(tM)) {
|
if (isX(tM)) {
|
||||||
to = ''
|
to = ''
|
||||||
} else if (isX(tm)) {
|
} else if (isX(tm)) {
|
||||||
to = `<${+tM + 1}.0.0`
|
to = `<${+tM + 1}.0.0-0`
|
||||||
} else if (isX(tp)) {
|
} else if (isX(tp)) {
|
||||||
to = `<${tM}.${+tm + 1}.0`
|
to = `<${tM}.${+tm + 1}.0-0`
|
||||||
} else if (tpr) {
|
} else if (tpr) {
|
||||||
to = `<=${tM}.${tm}.${tp}-${tpr}`
|
to = `<=${tM}.${tm}.${tp}-${tpr}`
|
||||||
|
} else if (incPr) {
|
||||||
|
to = `<${tM}.${tm}.${+tp + 1}-0`
|
||||||
} else {
|
} else {
|
||||||
to = `<=${to}`
|
to = `<=${to}`
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-6
@@ -2,15 +2,12 @@ const debug = require('../internal/debug')
|
|||||||
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
|
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require('../internal/constants')
|
||||||
const { re, t } = require('../internal/re')
|
const { re, t } = require('../internal/re')
|
||||||
|
|
||||||
|
const parseOptions = require('../internal/parse-options')
|
||||||
const { compareIdentifiers } = require('../internal/identifiers')
|
const { compareIdentifiers } = require('../internal/identifiers')
|
||||||
class SemVer {
|
class SemVer {
|
||||||
constructor (version, options) {
|
constructor (version, options) {
|
||||||
if (!options || typeof options !== 'object') {
|
options = parseOptions(options)
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version instanceof SemVer) {
|
if (version instanceof SemVer) {
|
||||||
if (version.loose === !!options.loose &&
|
if (version.loose === !!options.loose &&
|
||||||
version.includePrerelease === !!options.includePrerelease) {
|
version.includePrerelease === !!options.includePrerelease) {
|
||||||
|
|||||||
+2
-6
@@ -2,13 +2,9 @@ const {MAX_LENGTH} = require('../internal/constants')
|
|||||||
const { re, t } = require('../internal/re')
|
const { re, t } = require('../internal/re')
|
||||||
const SemVer = require('../classes/semver')
|
const SemVer = require('../classes/semver')
|
||||||
|
|
||||||
|
const parseOptions = require('../internal/parse-options')
|
||||||
const parse = (version, options) => {
|
const parse = (version, options) => {
|
||||||
if (!options || typeof options !== 'object') {
|
options = parseOptions(options)
|
||||||
options = {
|
|
||||||
loose: !!options,
|
|
||||||
includePrerelease: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version instanceof SemVer) {
|
if (version instanceof SemVer) {
|
||||||
return version
|
return version
|
||||||
|
|||||||
+2
@@ -43,4 +43,6 @@ module.exports = {
|
|||||||
gtr: require('./ranges/gtr'),
|
gtr: require('./ranges/gtr'),
|
||||||
ltr: require('./ranges/ltr'),
|
ltr: require('./ranges/ltr'),
|
||||||
intersects: require('./ranges/intersects'),
|
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.
|
// Star ranges basically just allow anything at all.
|
||||||
createToken('STAR', '(<|>)?=?\\s*\\*')
|
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",
|
"name": "semver",
|
||||||
"version": "7.1.3",
|
"version": "7.3.5",
|
||||||
"description": "The semantic version parser used by npm.",
|
"description": "The semantic version parser used by npm.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -11,20 +11,20 @@
|
|||||||
"postpublish": "git push origin --follow-tags"
|
"postpublish": "git push origin --follow-tags"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"tap": "^14.10.2"
|
"tap": "^14.10.7"
|
||||||
},
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"repository": "https://github.com/npm/node-semver",
|
"repository": "https://github.com/npm/node-semver",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "./bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"bin",
|
"bin/**/*.js",
|
||||||
"range.bnf",
|
"range.bnf",
|
||||||
"classes",
|
"classes/**/*.js",
|
||||||
"functions",
|
"functions/**/*.js",
|
||||||
"internal",
|
"internal/**/*.js",
|
||||||
"ranges",
|
"ranges/**/*.js",
|
||||||
"index.js",
|
"index.js",
|
||||||
"preload.js"
|
"preload.js"
|
||||||
],
|
],
|
||||||
@@ -34,5 +34,8 @@
|
|||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10"
|
"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) {
|
for (let i = 0; i < range.set.length; ++i) {
|
||||||
const comparators = range.set[i]
|
const comparators = range.set[i]
|
||||||
|
|
||||||
|
let setMin = null
|
||||||
comparators.forEach((comparator) => {
|
comparators.forEach((comparator) => {
|
||||||
// Clone to avoid manipulating the comparator's semver object.
|
// Clone to avoid manipulating the comparator's semver object.
|
||||||
const compver = new SemVer(comparator.semver.version)
|
const compver = new SemVer(comparator.semver.version)
|
||||||
@@ -33,8 +34,8 @@ const minVersion = (range, loose) => {
|
|||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
case '':
|
case '':
|
||||||
case '>=':
|
case '>=':
|
||||||
if (!minver || gt(minver, compver)) {
|
if (!setMin || gt(compver, setMin)) {
|
||||||
minver = compver
|
setMin = compver
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case '<':
|
case '<':
|
||||||
@@ -46,6 +47,8 @@ const minVersion = (range, loose) => {
|
|||||||
throw new Error(`Unexpected operation: ${comparator.operator}`)
|
throw new Error(`Unexpected operation: ${comparator.operator}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if (setMin && (!minver || gt(minver, setMin)))
|
||||||
|
minver = setMin
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minver && range.test(minver)) {
|
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 ">"')
|
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)) {
|
if (satisfies(version, range, options)) {
|
||||||
return false
|
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
-20
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "github-action-setup-xmake",
|
"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",
|
"description": "Set up your GitHub Actions workflow with a specific version of xmake",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"author": "OpportunityLiu",
|
"author": "OpportunityLiu",
|
||||||
@@ -14,30 +14,31 @@
|
|||||||
"rebuild": "yarn clean && yarn build",
|
"rebuild": "yarn clean && yarn build",
|
||||||
"clean": "rimraf dist",
|
"clean": "rimraf dist",
|
||||||
"lint": "eslint --fix src/**/*.ts",
|
"lint": "eslint --fix src/**/*.ts",
|
||||||
|
"format": "prettier --write .",
|
||||||
"test": "jest",
|
"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": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.1.3",
|
"@actions/core": "^1.4.0",
|
||||||
"@actions/exec": "^1.0.1",
|
"@actions/exec": "^1.1.0",
|
||||||
"@actions/io": "^1.0.1",
|
"@actions/io": "^1.1.1",
|
||||||
"@actions/tool-cache": "^1.1.2",
|
"@actions/tool-cache": "^1.7.1",
|
||||||
"semver": "^7.1.3"
|
"semver": "^7.3.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.1.4",
|
"@types/jest": "^26.0.24",
|
||||||
"@types/node": "^14.0.5",
|
"@types/node": "^16.3.2",
|
||||||
"@types/semver": "^7.1.0",
|
"@types/semver": "^7.3.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.26.0",
|
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
||||||
"@typescript-eslint/parser": "^2.26.0",
|
"@typescript-eslint/parser": "^4.28.3",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^7.30.0",
|
||||||
"eslint-config-prettier": "^6.10.1",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-prettier": "^3.1.2",
|
"eslint-plugin-prettier": "^3.4.0",
|
||||||
"jest": "^25.2.4",
|
"jest": "^27.0.6",
|
||||||
"prettier": "^2.0.2",
|
"prettier": "^2.3.2",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-jest": "^25.3.0",
|
"ts-jest": "^27.0.3",
|
||||||
"type-fest": "^0.14.0",
|
"type-fest": "^1.2.2",
|
||||||
"typescript": "^3.8.3"
|
"typescript": "^4.3.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,9 +1,10 @@
|
|||||||
import * as git from './git';
|
import * as git from './git';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
|
import { Repo } from './interfaces';
|
||||||
|
|
||||||
describe('lsRemote', () => {
|
describe('lsRemote', () => {
|
||||||
it('should return correct records', async () => {
|
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('heads');
|
||||||
expect(records).toHaveProperty('tags');
|
expect(records).toHaveProperty('tags');
|
||||||
expect(records).toHaveProperty('pull');
|
expect(records).toHaveProperty('pull');
|
||||||
|
|||||||
+18
-8
@@ -2,15 +2,17 @@ import { exec } from '@actions/exec';
|
|||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
import * as os from 'os';
|
import * as os from 'os';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { Sha, RefDic } from './interfaces';
|
import { Sha, RefDic, Repo } from './interfaces';
|
||||||
|
|
||||||
function makeOpt(ref: Sha): { cwd: string } {
|
function makeOpt(ref: Sha): { cwd: string } {
|
||||||
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
|
return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function lsRemote(): Promise<RefDic> {
|
const repoUrl = (repo: Repo): string => `https://github.com/${repo}.git`;
|
||||||
|
|
||||||
|
export async function lsRemote(repo: Repo): Promise<RefDic> {
|
||||||
let out = '';
|
let out = '';
|
||||||
await exec('git', ['ls-remote', 'https://github.com/xmake-io/xmake.git'], {
|
await exec('git', ['ls-remote', repoUrl(repo)], {
|
||||||
silent: true,
|
silent: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (d) => (out += d.toString()),
|
stdout: (d) => (out += d.toString()),
|
||||||
@@ -22,28 +24,36 @@ export async function lsRemote(): Promise<RefDic> {
|
|||||||
if (ref && tag && tag.startsWith('refs/')) {
|
if (ref && tag && tag.startsWith('refs/')) {
|
||||||
const tagPath = tag.split('/').splice(1);
|
const tagPath = tag.split('/').splice(1);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// 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++) {
|
for (let i = 0; i < tagPath.length - 1; i++) {
|
||||||
const seg = tagPath[i];
|
const seg = tagPath[i];
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
if (typeof ldata[seg] === 'object') {
|
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 {
|
} else {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
ldata = ldata[seg] = {};
|
ldata = ldata[seg] = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
ldata[tagPath[tagPath.length - 1]] = ref;
|
ldata[tagPath[tagPath.length - 1]] = ref;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function create(ref: Sha): Promise<string> {
|
export async function create(repo: Repo, ref: Sha): Promise<string> {
|
||||||
const opt = makeOpt(ref);
|
const opt = makeOpt(ref);
|
||||||
await io.rmRF(opt.cwd);
|
await io.rmRF(opt.cwd);
|
||||||
await io.mkdirP(opt.cwd);
|
await io.mkdirP(opt.cwd);
|
||||||
await exec('git', ['init'], opt);
|
await exec('git', ['init'], opt);
|
||||||
await exec('git', ['remote', 'add', 'origin', 'https://github.com/xmake-io/xmake.git'], 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',
|
||||||
|
['fetch', 'origin', '+refs/pull/*:refs/remotes/origin/pull/*', '+refs/heads/*:refs/remotes/origin/*'],
|
||||||
|
opt,
|
||||||
|
);
|
||||||
await exec('git', ['checkout', ref], opt);
|
await exec('git', ['checkout', ref], opt);
|
||||||
await exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
await exec('git', ['submodule', 'update', '--init', '--recursive'], opt);
|
||||||
return opt.cwd;
|
return opt.cwd;
|
||||||
|
|||||||
+8
-3
@@ -8,11 +8,16 @@ import { unixInstall } from './unix-install';
|
|||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const version = await selectVersion();
|
const version = await selectVersion();
|
||||||
if (os.platform() === 'win32' || os.platform() === 'cygwin') await winInstall(version);
|
if (os.platform() === 'win32' || os.platform() === 'cygwin') {
|
||||||
else await unixInstall(version);
|
const latest = await selectVersion('latest');
|
||||||
|
await winInstall(version, latest);
|
||||||
|
} else {
|
||||||
|
await unixInstall(version);
|
||||||
|
}
|
||||||
await exec('xmake --version');
|
await exec('xmake --version');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
const ex = error as Error;
|
||||||
|
core.setFailed(ex.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-1
@@ -7,6 +7,13 @@ export function Sha(sha: string): Sha {
|
|||||||
return sha as 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 = {
|
export type RefDic = {
|
||||||
/** branches */
|
/** branches */
|
||||||
heads: Record<string, Sha>;
|
heads: Record<string, Sha>;
|
||||||
@@ -26,8 +33,17 @@ export type RefDic = {
|
|||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface Version {
|
export interface GitVersion {
|
||||||
version: string;
|
version: string;
|
||||||
sha: Sha;
|
sha: Sha;
|
||||||
type: keyof RefDic | 'sha';
|
type: keyof RefDic | 'sha';
|
||||||
|
repo: Repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LocalVersion {
|
||||||
|
type: 'local';
|
||||||
|
path: string;
|
||||||
|
version: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Version = GitVersion | LocalVersion;
|
||||||
|
|||||||
+29
-13
@@ -8,23 +8,39 @@ import * as semver from 'semver';
|
|||||||
import * as git from './git';
|
import * as git from './git';
|
||||||
import { Version } from './interfaces';
|
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> {
|
export async function unixInstall(version: Version): Promise<void> {
|
||||||
const ver = version.version;
|
let toolDir: string;
|
||||||
let toolDir = toolCache.find('xmake', ver);
|
if (version.type !== 'local') {
|
||||||
if (!toolDir) {
|
const ver = version.version;
|
||||||
const sourceDir = await core.group(`download xmake ${version}`, () => git.create(version.sha));
|
toolDir = toolCache.find('xmake', ver);
|
||||||
toolDir = await core.group(`install xmake ${version}`, async () => {
|
if (!toolDir) {
|
||||||
await exec('make', ['build'], { cwd: sourceDir });
|
const sourceDir = await core.group(`download xmake ${String(version)}`, () =>
|
||||||
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
git.create(version.repo, version.sha),
|
||||||
await exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
);
|
||||||
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
|
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
|
||||||
await io.rmRF(binDir);
|
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
|
||||||
await git.cleanup(version.sha);
|
await install(sourceDir, binDir);
|
||||||
return cacheDir;
|
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.
|
// 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'));
|
core.addPath(path.join(toolDir, 'bin'));
|
||||||
} else {
|
} else {
|
||||||
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
core.addPath(path.join(toolDir, 'share', 'xmake')); // only for <= 2.3.1
|
||||||
|
|||||||
+313
-255
@@ -1,268 +1,282 @@
|
|||||||
jest.mock('./git', () => ({
|
jest.mock('./git', () => ({
|
||||||
lsRemote() {
|
lsRemote(repo: Repo) {
|
||||||
return {
|
if (repo === 'xmake-io/xmake')
|
||||||
heads: {
|
return {
|
||||||
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
heads: {
|
||||||
master: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
||||||
test: '18f0605f2e1764d4c07fa4f9fc24274275e1562c',
|
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',
|
|
||||||
},
|
},
|
||||||
'23': {
|
tags: {
|
||||||
head: 'c33fd5a8b3e7ff7692630bbc8f5d5b6166502493',
|
'v1.0.1': '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
||||||
merge: '9041fc8587c9b797440ec2f58deb4626de688010',
|
'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' },
|
pull: {
|
||||||
'28': {
|
'8': { head: '7e3ee3281df2b4caffebe25c87e871ba682dd701' },
|
||||||
head: 'a3a28f8abdfe8711b2e4d7496ade02e910070e9f',
|
'11': {
|
||||||
merge: '3bb5cf13cfa93ab186e7df168dce87718914696b',
|
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' },
|
if (repo === 'my/xmake')
|
||||||
'45': { head: '0a8ae5b98d2297bbad38fbf96cc78b373ac6f4ff' },
|
return {
|
||||||
'52': { head: 'c53c28bc7b0cd59ea984a3c687273aa47d608c2a' },
|
heads: {
|
||||||
'59': { head: '1e766da707d9b1075144303755f4e772fa33193d' },
|
dev: 'e3b63b2f0103855c940fa8683610cd02895450d1',
|
||||||
'61': {
|
master: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||||
head: '75df3c9a5dafac83a8227ce84b004d3450b10c38',
|
'patch-1': '77cd51991f8b9c76e54d668103a06ca6c597e64a',
|
||||||
merge: '08962c4c13c6eea78e3c840711b030d30afebeb4',
|
|
||||||
},
|
},
|
||||||
'63': { head: 'c3fc0841da49c875cadf225ed2da2dc624c1c72f' },
|
tags: {},
|
||||||
'65': {
|
pull: {},
|
||||||
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' },
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
import { selectVersion } from './versions';
|
import { selectVersion } from './versions';
|
||||||
|
import { Repo } from './interfaces';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
|
||||||
describe('selectVersion', () => {
|
describe('selectVersion', () => {
|
||||||
it('should return correct version for latest', async () => {
|
it('should return correct version for latest', async () => {
|
||||||
await expect(selectVersion('latest')).resolves.toEqual({
|
await expect(selectVersion('latest')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'v2.3.2',
|
version: 'v2.3.2',
|
||||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||||
type: 'tags',
|
type: 'tags',
|
||||||
@@ -271,10 +285,13 @@ describe('selectVersion', () => {
|
|||||||
it('should throw for no matched', async () => {
|
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('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('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 () => {
|
it('should return correct version for given', async () => {
|
||||||
await expect(selectVersion('v1.0.1')).resolves.toEqual({
|
await expect(selectVersion('v1.0.1')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'v1.0.1',
|
version: 'v1.0.1',
|
||||||
sha: '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
sha: '723ec3e970e17f48a601fe2a919b9802b5e516fa',
|
||||||
type: 'tags',
|
type: 'tags',
|
||||||
@@ -282,6 +299,7 @@ describe('selectVersion', () => {
|
|||||||
});
|
});
|
||||||
it('should return correct version for range', async () => {
|
it('should return correct version for range', async () => {
|
||||||
await expect(selectVersion('>=2')).resolves.toEqual({
|
await expect(selectVersion('>=2')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'v2.3.2',
|
version: 'v2.3.2',
|
||||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||||
type: 'tags',
|
type: 'tags',
|
||||||
@@ -290,6 +308,7 @@ describe('selectVersion', () => {
|
|||||||
|
|
||||||
it('should return correct branch', async () => {
|
it('should return correct branch', async () => {
|
||||||
await expect(selectVersion('branch@master')).resolves.toEqual({
|
await expect(selectVersion('branch@master')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'master',
|
version: 'master',
|
||||||
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||||
type: 'heads',
|
type: 'heads',
|
||||||
@@ -302,6 +321,7 @@ describe('selectVersion', () => {
|
|||||||
|
|
||||||
it('should return correct pr', async () => {
|
it('should return correct pr', async () => {
|
||||||
await expect(selectVersion('pr@708')).resolves.toEqual({
|
await expect(selectVersion('pr@708')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'pr#708',
|
version: 'pr#708',
|
||||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
||||||
type: 'pull',
|
type: 'pull',
|
||||||
@@ -313,11 +333,14 @@ describe('selectVersion', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw invalid pr', async () => {
|
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 () => {
|
it('should return branch of sha', async () => {
|
||||||
await expect(selectVersion('sha@efad01e547f30d66d90e486c91c3afa0dbaceed3')).resolves.toEqual({
|
await expect(selectVersion('sha@efad01e547f30d66d90e486c91c3afa0dbaceed3')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'master',
|
version: 'master',
|
||||||
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
sha: 'efad01e547f30d66d90e486c91c3afa0dbaceed3',
|
||||||
type: 'heads',
|
type: 'heads',
|
||||||
@@ -326,6 +349,7 @@ describe('selectVersion', () => {
|
|||||||
|
|
||||||
it('should return tag of sha', async () => {
|
it('should return tag of sha', async () => {
|
||||||
await expect(selectVersion('sha@31bacc4f76101e6a865ec254c48d8bcba456378f')).resolves.toEqual({
|
await expect(selectVersion('sha@31bacc4f76101e6a865ec254c48d8bcba456378f')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'v2.3.2',
|
version: 'v2.3.2',
|
||||||
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
sha: '31bacc4f76101e6a865ec254c48d8bcba456378f',
|
||||||
type: 'tags',
|
type: 'tags',
|
||||||
@@ -334,6 +358,7 @@ describe('selectVersion', () => {
|
|||||||
|
|
||||||
it('should return pr merge of sha', async () => {
|
it('should return pr merge of sha', async () => {
|
||||||
await expect(selectVersion('sha@2f93475049575ed5e44699daa378239bc141aad3')).resolves.toEqual({
|
await expect(selectVersion('sha@2f93475049575ed5e44699daa378239bc141aad3')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'pr#217',
|
version: 'pr#217',
|
||||||
sha: '2f93475049575ed5e44699daa378239bc141aad3',
|
sha: '2f93475049575ed5e44699daa378239bc141aad3',
|
||||||
type: 'pull',
|
type: 'pull',
|
||||||
@@ -342,6 +367,7 @@ describe('selectVersion', () => {
|
|||||||
|
|
||||||
it('should not return pr head of sha if merge present', async () => {
|
it('should not return pr head of sha if merge present', async () => {
|
||||||
await expect(selectVersion('sha@905a8607f3f31ab9efeb68684d40df8284683f3a')).resolves.toEqual({
|
await expect(selectVersion('sha@905a8607f3f31ab9efeb68684d40df8284683f3a')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'sha#905a8607f3f31ab9efeb68684d40df8284683f3a',
|
version: 'sha#905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||||
sha: '905a8607f3f31ab9efeb68684d40df8284683f3a',
|
sha: '905a8607f3f31ab9efeb68684d40df8284683f3a',
|
||||||
type: 'sha',
|
type: 'sha',
|
||||||
@@ -350,6 +376,7 @@ describe('selectVersion', () => {
|
|||||||
|
|
||||||
it('should return pr head of sha', async () => {
|
it('should return pr head of sha', async () => {
|
||||||
await expect(selectVersion('sha@af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a')).resolves.toEqual({
|
await expect(selectVersion('sha@af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'pr#708',
|
version: 'pr#708',
|
||||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90a',
|
||||||
type: 'pull',
|
type: 'pull',
|
||||||
@@ -358,6 +385,7 @@ describe('selectVersion', () => {
|
|||||||
|
|
||||||
it('should return correct normalized sha', async () => {
|
it('should return correct normalized sha', async () => {
|
||||||
await expect(selectVersion('sha@Af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b')).resolves.toEqual({
|
await expect(selectVersion('sha@Af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b')).resolves.toEqual({
|
||||||
|
repo: 'xmake-io/xmake',
|
||||||
version: 'sha#af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
version: 'sha#af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
||||||
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
sha: 'af28dba1f52990cb7b6c3c8f69f1f1bcf017c90b',
|
||||||
type: 'sha',
|
type: 'sha',
|
||||||
@@ -375,4 +403,34 @@ describe('selectVersion', () => {
|
|||||||
'Invalid sha value af28dba1f52990cb7b6c3c8f69f1f1bcf017c90g',
|
'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',
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user