This commit is contained in:
Opportunity
2020-07-17 11:55:08 +08:00
Unverified
parent fad1ce1d16
commit 00df9418a5
4 changed files with 31 additions and 37 deletions
+17 -20
View File
@@ -18,18 +18,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.unixInstall = void 0;
const core_1 = __importDefault(require("@actions/core"));
const core = __importStar(require("@actions/core"));
const exec_1 = require("@actions/exec");
const io_1 = __importDefault(require("@actions/io"));
const tool_cache_1 = __importDefault(require("@actions/tool-cache"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const semver_1 = __importDefault(require("semver"));
const io = __importStar(require("@actions/io"));
const toolCache = __importStar(require("@actions/tool-cache"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const semver = __importStar(require("semver"));
const git = __importStar(require("./git"));
async function install(sourceDir, binDir) {
await exec_1.exec('make', ['build'], { cwd: sourceDir });
@@ -39,31 +36,31 @@ async function unixInstall(version) {
let toolDir;
if (version.type !== 'local') {
const ver = version.version;
toolDir = tool_cache_1.default.find('xmake', ver);
toolDir = toolCache.find('xmake', ver);
if (!toolDir) {
const sourceDir = await core_1.default.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha));
toolDir = await core_1.default.group(`install xmake ${String(version)}`, async () => {
const binDir = path_1.default.join(os_1.default.tmpdir(), `xmake-${version.sha}`);
const sourceDir = await core.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha));
toolDir = await core.group(`install xmake ${String(version)}`, async () => {
const binDir = path.join(os.tmpdir(), `xmake-${version.sha}`);
await install(sourceDir, binDir);
const cacheDir = await tool_cache_1.default.cacheDir(binDir, 'xmake', ver);
await io_1.default.rmRF(binDir);
const cacheDir = await toolCache.cacheDir(binDir, 'xmake', ver);
await io.rmRF(binDir);
await git.cleanup(version.sha);
return cacheDir;
});
}
}
else {
toolDir = await core_1.default.group(`install local xmake at '${version.path}'`, async () => {
const binDir = path_1.default.join(os_1.default.tmpdir(), `xmake-${Date.now()}`);
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;
});
}
if (version.type !== 'tags' || semver_1.default.gt(version.version, '2.3.1')) {
core_1.default.addPath(path_1.default.join(toolDir, 'bin'));
if (version.type !== 'tags' || semver.gt(version.version, '2.3.1')) {
core.addPath(path.join(toolDir, 'bin'));
}
else {
core_1.default.addPath(path_1.default.join(toolDir, 'share', 'xmake'));
core.addPath(path.join(toolDir, 'share', 'xmake'));
}
}
exports.unixInstall = unixInstall;
+6 -9
View File
@@ -31,17 +31,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
}
return privateMap.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _string;
Object.defineProperty(exports, "__esModule", { value: true });
exports.selectVersion = void 0;
const core = __importStar(require("@actions/core"));
const semver_1 = __importDefault(require("semver"));
const semver = __importStar(require("semver"));
const git_1 = require("./git");
const interfaces_1 = require("./interfaces");
const path_1 = __importDefault(require("path"));
const p = __importStar(require("path"));
const DEFAULT_REPO = interfaces_1.Repo('xmake-io/xmake');
const VERSIONS = new Map();
async function getVersions(repo) {
@@ -70,7 +67,7 @@ class LocalVersionImpl {
constructor(path) {
this.path = path;
this.type = 'local';
this.path = path_1.default.resolve(path);
this.path = p.resolve(path);
}
}
async function selectBranch(repo, branch) {
@@ -93,12 +90,12 @@ async function selectPr(repo, pr) {
throw new Error(`Pull requrest #${pr} not found`);
}
async function selectSemver(repo, version) {
const v = new semver_1.default.Range(version);
const v = new semver.Range(version);
if (!v) {
throw new Error(`Invalid semver`);
}
const versions = await getVersions(repo);
const ver = semver_1.default.maxSatisfying(Object.keys(versions.tags), v);
const ver = semver.maxSatisfying(Object.keys(versions.tags), v);
if (!ver) {
throw new Error(`No matched releases of xmake-version ${v.format()}`);
}
@@ -159,7 +156,7 @@ async function selectVersion(version) {
const sha = version.substr('sha@'.length);
ret = await selectSha(repo, sha);
}
if (semver_1.default.validRange(version)) {
if (semver.validRange(version)) {
ret = await selectSemver(repo, version);
}
if (!ret) {
+6 -6
View File
@@ -1,10 +1,10 @@
import core from '@actions/core';
import * as core from '@actions/core';
import { exec } from '@actions/exec';
import io from '@actions/io';
import toolCache from '@actions/tool-cache';
import os from 'os';
import path from 'path';
import semver from 'semver';
import * as io from '@actions/io';
import * as toolCache from '@actions/tool-cache';
import * as os from 'os';
import * as path from 'path';
import * as semver from 'semver';
import * as git from './git';
import { Version } from './interfaces';
+2 -2
View File
@@ -1,8 +1,8 @@
import * as core from '@actions/core';
import semver from 'semver';
import * as semver from 'semver';
import { lsRemote } from './git';
import { RefDic, Sha, Version, Repo, GitVersion, LocalVersion } from './interfaces';
import p from 'path';
import * as p from 'path';
const DEFAULT_REPO = Repo('xmake-io/xmake');