format code
This commit is contained in:
Vendored
+12
-9
@@ -1,10 +1,10 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
exports.cleanup = exports.create = exports.lsRemote = void 0;
|
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');
|
||||||
const path = require("path");
|
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}`) };
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,7 @@ async function lsRemote(repo) {
|
|||||||
const seg = tagPath[i];
|
const seg = tagPath[i];
|
||||||
if (typeof ldata[seg] === 'object') {
|
if (typeof ldata[seg] === 'object') {
|
||||||
ldata = ldata[seg];
|
ldata = ldata[seg];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ldata = ldata[seg] = {};
|
ldata = ldata[seg] = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,7 +43,11 @@ async function create(repo, ref) {
|
|||||||
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', repoUrl(repo)], 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);
|
||||||
return opt.cwd;
|
return opt.cwd;
|
||||||
|
|||||||
Vendored
+10
-12
@@ -1,24 +1,22 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
const core = require("@actions/core");
|
const core = require('@actions/core');
|
||||||
const exec_1 = require("@actions/exec");
|
const exec_1 = require('@actions/exec');
|
||||||
const os = require("os");
|
const os = require('os');
|
||||||
const versions_1 = require("./versions");
|
const versions_1 = require('./versions');
|
||||||
const win_install_1 = require("./win-install");
|
const win_install_1 = require('./win-install');
|
||||||
const unix_install_1 = require("./unix-install");
|
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') {
|
||||||
const latest = await versions_1.selectVersion('latest');
|
const latest = await versions_1.selectVersion('latest');
|
||||||
await win_install_1.winInstall(version, latest);
|
await win_install_1.winInstall(version, latest);
|
||||||
}
|
} else {
|
||||||
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) {
|
|
||||||
const ex = error;
|
const ex = error;
|
||||||
core.setFailed(ex.message);
|
core.setFailed(ex.message);
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+4
-6
@@ -1,17 +1,15 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
exports.Repo = exports.Sha = void 0;
|
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)) throw new Error(`Invalid sha value ${sha}`);
|
||||||
throw new Error(`Invalid sha value ${sha}`);
|
|
||||||
return sha;
|
return sha;
|
||||||
}
|
}
|
||||||
exports.Sha = Sha;
|
exports.Sha = Sha;
|
||||||
function Repo(repo) {
|
function Repo(repo) {
|
||||||
repo = repo.trim();
|
repo = repo.trim();
|
||||||
if (!/^([^/#]+\/[^/#]+)$/g.test(repo))
|
if (!/^([^/#]+\/[^/#]+)$/g.test(repo)) throw new Error(`Invalid repo value ${repo}`);
|
||||||
throw new Error(`Invalid repo value ${repo}`);
|
|
||||||
return repo;
|
return repo;
|
||||||
}
|
}
|
||||||
exports.Repo = Repo;
|
exports.Repo = Repo;
|
||||||
|
|||||||
Vendored
+15
-15
@@ -1,14 +1,14 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
exports.unixInstall = void 0;
|
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');
|
||||||
const toolCache = require("@actions/tool-cache");
|
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');
|
||||||
const git = require("./git");
|
const git = require('./git');
|
||||||
async function install(sourceDir, binDir) {
|
async function install(sourceDir, binDir) {
|
||||||
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
await exec_1.exec('make', ['build'], { cwd: sourceDir });
|
||||||
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir });
|
||||||
@@ -19,7 +19,9 @@ async function unixInstall(version) {
|
|||||||
const ver = version.version;
|
const ver = version.version;
|
||||||
toolDir = toolCache.find('xmake', ver);
|
toolDir = toolCache.find('xmake', ver);
|
||||||
if (!toolDir) {
|
if (!toolDir) {
|
||||||
const sourceDir = await core.group(`download xmake ${String(version)}`, () => git.create(version.repo, 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 () => {
|
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}`);
|
||||||
await install(sourceDir, binDir);
|
await install(sourceDir, binDir);
|
||||||
@@ -29,8 +31,7 @@ async function unixInstall(version) {
|
|||||||
return cacheDir;
|
return cacheDir;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
toolDir = await core.group(`install local xmake at '${version.path}'`, async () => {
|
toolDir = await core.group(`install local xmake at '${version.path}'`, async () => {
|
||||||
const binDir = path.join(os.tmpdir(), `xmake-${Date.now()}`);
|
const binDir = path.join(os.tmpdir(), `xmake-${Date.now()}`);
|
||||||
await install(version.path, binDir);
|
await install(version.path, binDir);
|
||||||
@@ -39,8 +40,7 @@ async function unixInstall(version) {
|
|||||||
}
|
}
|
||||||
if (version.type !== 'tags' || semver.gt(version.version, '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'));
|
core.addPath(path.join(toolDir, 'share', 'xmake'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+34
-27
@@ -1,29 +1,34 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
var __classPrivateFieldSet =
|
||||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
(this && this.__classPrivateFieldSet) ||
|
||||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
function (receiver, state, value, kind, f) {
|
||||||
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");
|
if (kind === 'm') throw new TypeError('Private method is not writable');
|
||||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
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');
|
||||||
|
return kind === 'a' ? f.call(receiver, value) : f ? (f.value = value) : state.set(receiver, value), value;
|
||||||
};
|
};
|
||||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
var __classPrivateFieldGet =
|
||||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
(this && this.__classPrivateFieldGet) ||
|
||||||
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");
|
function (receiver, state, kind, f) {
|
||||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
if (kind === 'a' && !f) throw new TypeError('Private accessor was defined without a getter');
|
||||||
|
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);
|
||||||
};
|
};
|
||||||
var _GitVersionImpl_string;
|
var _GitVersionImpl_string;
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
exports.selectVersion = void 0;
|
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');
|
||||||
const p = require("path");
|
const p = require('path');
|
||||||
const DEFAULT_REPO = interfaces_1.Repo('xmake-io/xmake');
|
const DEFAULT_REPO = interfaces_1.Repo('xmake-io/xmake');
|
||||||
const VERSIONS = new Map();
|
const VERSIONS = new Map();
|
||||||
async function getVersions(repo) {
|
async function getVersions(repo) {
|
||||||
const cache = VERSIONS.get(repo);
|
const cache = VERSIONS.get(repo);
|
||||||
if (cache)
|
if (cache) return cache;
|
||||||
return cache;
|
|
||||||
const result = await git_1.lsRemote(repo);
|
const result = await git_1.lsRemote(repo);
|
||||||
VERSIONS.set(repo, result);
|
VERSIONS.set(repo, result);
|
||||||
return result;
|
return result;
|
||||||
@@ -35,10 +40,10 @@ class GitVersionImpl {
|
|||||||
this.sha = sha;
|
this.sha = sha;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
_GitVersionImpl_string.set(this, void 0);
|
_GitVersionImpl_string.set(this, void 0);
|
||||||
__classPrivateFieldSet(this, _GitVersionImpl_string, toString, "f");
|
__classPrivateFieldSet(this, _GitVersionImpl_string, toString, 'f');
|
||||||
}
|
}
|
||||||
toString() {
|
toString() {
|
||||||
return __classPrivateFieldGet(this, _GitVersionImpl_string, "f");
|
return __classPrivateFieldGet(this, _GitVersionImpl_string, 'f');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_GitVersionImpl_string = new WeakMap();
|
_GitVersionImpl_string = new WeakMap();
|
||||||
@@ -101,12 +106,13 @@ async function selectSha(repo, sha) {
|
|||||||
return selectPr(repo, Number.parseInt(pr));
|
return selectPr(repo, Number.parseInt(pr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve(new GitVersionImpl(repo, `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) {
|
||||||
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 repo = DEFAULT_REPO;
|
||||||
let ret;
|
let ret;
|
||||||
if (version.startsWith('local#')) {
|
if (version.startsWith('local#')) {
|
||||||
@@ -143,10 +149,11 @@ async function selectVersion(version) {
|
|||||||
}
|
}
|
||||||
if (ret.type === 'local') {
|
if (ret.type === 'local') {
|
||||||
core.info(`Use local xmake at '${ret.path}'`);
|
core.info(`Use local xmake at '${ret.path}'`);
|
||||||
}
|
} else {
|
||||||
else {
|
core.info(
|
||||||
core.info(`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` +
|
`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` +
|
||||||
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''));
|
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+9
-9
@@ -1,13 +1,13 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
exports.winInstall = void 0;
|
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');
|
||||||
const toolCache = require("@actions/tool-cache");
|
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, latest) {
|
function getInstallerUrl(version, latest) {
|
||||||
const ver = version.version;
|
const ver = version.version;
|
||||||
switch (version.type) {
|
switch (version.type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user