diff --git a/README.md b/README.md index 4032f3b..158d6ff 100644 --- a/README.md +++ b/README.md @@ -64,4 +64,4 @@ git tag v1 git push origin master git push --tags --force -``` \ No newline at end of file +``` diff --git a/dist/git.js b/dist/git.js index afe12ed..a176300 100644 --- a/dist/git.js +++ b/dist/git.js @@ -1,10 +1,10 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); exports.cleanup = exports.create = exports.lsRemote = void 0; -const exec_1 = require("@actions/exec"); -const io = require("@actions/io"); -const os = require("os"); -const path = require("path"); +const exec_1 = require('@actions/exec'); +const io = require('@actions/io'); +const os = require('os'); +const path = require('path'); function makeOpt(ref) { return { cwd: path.join(os.tmpdir(), `xmake-git-${ref}`) }; } @@ -27,8 +27,7 @@ async function lsRemote(repo) { const seg = tagPath[i]; if (typeof ldata[seg] === 'object') { ldata = ldata[seg]; - } - else { + } else { ldata = ldata[seg] = {}; } } @@ -44,7 +43,11 @@ async function create(repo, ref) { await io.mkdirP(opt.cwd); await exec_1.exec('git', ['init'], 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', ['submodule', 'update', '--init', '--recursive'], opt); return opt.cwd; diff --git a/dist/index.js b/dist/index.js index c6454d4..c98be19 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,24 +1,22 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const core = require("@actions/core"); -const exec_1 = require("@actions/exec"); -const os = require("os"); -const versions_1 = require("./versions"); -const win_install_1 = require("./win-install"); -const unix_install_1 = require("./unix-install"); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); +const core = require('@actions/core'); +const exec_1 = require('@actions/exec'); +const os = require('os'); +const versions_1 = require('./versions'); +const win_install_1 = require('./win-install'); +const unix_install_1 = require('./unix-install'); async function run() { try { const version = await versions_1.selectVersion(); if (os.platform() === 'win32' || os.platform() === 'cygwin') { const latest = await versions_1.selectVersion('latest'); await win_install_1.winInstall(version, latest); - } - else { + } else { await unix_install_1.unixInstall(version); } await exec_1.exec('xmake --version'); - } - catch (error) { + } catch (error) { const ex = error; core.setFailed(ex.message); } diff --git a/dist/interfaces.js b/dist/interfaces.js index d98d5e6..9c9a7ad 100644 --- a/dist/interfaces.js +++ b/dist/interfaces.js @@ -1,17 +1,15 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); exports.Repo = exports.Sha = void 0; function Sha(sha) { sha = sha.trim().toLowerCase(); - if (!/^[a-f0-9]{40}$/g.test(sha)) - throw new Error(`Invalid sha value ${sha}`); + if (!/^[a-f0-9]{40}$/g.test(sha)) throw new Error(`Invalid sha value ${sha}`); return sha; } exports.Sha = Sha; function Repo(repo) { repo = repo.trim(); - if (!/^([^/#]+\/[^/#]+)$/g.test(repo)) - throw new Error(`Invalid repo value ${repo}`); + if (!/^([^/#]+\/[^/#]+)$/g.test(repo)) throw new Error(`Invalid repo value ${repo}`); return repo; } exports.Repo = Repo; diff --git a/dist/unix-install.js b/dist/unix-install.js index 52d83f2..d221226 100644 --- a/dist/unix-install.js +++ b/dist/unix-install.js @@ -1,14 +1,14 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); exports.unixInstall = void 0; -const core = require("@actions/core"); -const exec_1 = require("@actions/exec"); -const io = require("@actions/io"); -const toolCache = require("@actions/tool-cache"); -const os = require("os"); -const path = require("path"); -const semver = require("semver"); -const git = require("./git"); +const core = require('@actions/core'); +const exec_1 = require('@actions/exec'); +const io = require('@actions/io'); +const toolCache = require('@actions/tool-cache'); +const os = require('os'); +const path = require('path'); +const semver = require('semver'); +const git = require('./git'); async function install(sourceDir, binDir) { await exec_1.exec('make', ['build'], { cwd: sourceDir }); await exec_1.exec('make', ['install', `prefix=${binDir}`], { cwd: sourceDir }); @@ -19,7 +19,9 @@ async function unixInstall(version) { const ver = version.version; toolDir = toolCache.find('xmake', ver); if (!toolDir) { - const sourceDir = await core.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha)); + 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); @@ -29,8 +31,7 @@ async function unixInstall(version) { return cacheDir; }); } - } - else { + } 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); @@ -39,8 +40,7 @@ async function unixInstall(version) { } if (version.type !== 'tags' || semver.gt(version.version, '2.3.1')) { core.addPath(path.join(toolDir, 'bin')); - } - else { + } else { core.addPath(path.join(toolDir, 'share', 'xmake')); } } diff --git a/dist/versions.js b/dist/versions.js index af602e5..f92a72b 100644 --- a/dist/versions.js +++ b/dist/versions.js @@ -1,29 +1,34 @@ -"use strict"; -var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - 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) { - 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); -}; +'use strict'; +var __classPrivateFieldSet = + (this && this.__classPrivateFieldSet) || + function (receiver, state, value, kind, f) { + if (kind === 'm') throw new TypeError('Private method is not writable'); + 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) { + 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; -Object.defineProperty(exports, "__esModule", { value: true }); +Object.defineProperty(exports, '__esModule', { value: true }); exports.selectVersion = void 0; -const core = require("@actions/core"); -const semver = require("semver"); -const git_1 = require("./git"); -const interfaces_1 = require("./interfaces"); -const p = require("path"); +const core = require('@actions/core'); +const semver = require('semver'); +const git_1 = require('./git'); +const interfaces_1 = require('./interfaces'); +const p = require('path'); const DEFAULT_REPO = interfaces_1.Repo('xmake-io/xmake'); const VERSIONS = new Map(); async function getVersions(repo) { const cache = VERSIONS.get(repo); - if (cache) - return cache; + if (cache) return cache; const result = await git_1.lsRemote(repo); VERSIONS.set(repo, result); return result; @@ -35,10 +40,10 @@ class GitVersionImpl { this.sha = sha; this.type = type; _GitVersionImpl_string.set(this, void 0); - __classPrivateFieldSet(this, _GitVersionImpl_string, toString, "f"); + __classPrivateFieldSet(this, _GitVersionImpl_string, toString, 'f'); } toString() { - return __classPrivateFieldGet(this, _GitVersionImpl_string, "f"); + return __classPrivateFieldGet(this, _GitVersionImpl_string, 'f'); } } _GitVersionImpl_string = new WeakMap(); @@ -101,12 +106,13 @@ async function selectSha(repo, sha) { 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) { version = (version !== null && version !== void 0 ? version : core.getInput('xmake-version')) || 'latest'; - if (version.toLowerCase() === 'latest') - version = ''; + if (version.toLowerCase() === 'latest') version = ''; let repo = DEFAULT_REPO; let ret; if (version.startsWith('local#')) { @@ -143,10 +149,11 @@ async function selectVersion(version) { } 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}` : '')); + } else { + core.info( + `Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` + + (repo !== DEFAULT_REPO ? ` of ${repo}` : ''), + ); } return ret; } diff --git a/dist/win-install.js b/dist/win-install.js index 073c18d..fe89bff 100644 --- a/dist/win-install.js +++ b/dist/win-install.js @@ -1,13 +1,13 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +'use strict'; +Object.defineProperty(exports, '__esModule', { value: true }); exports.winInstall = void 0; -const core = require("@actions/core"); -const exec_1 = require("@actions/exec"); -const io = require("@actions/io"); -const toolCache = require("@actions/tool-cache"); -const os = require("os"); -const path = require("path"); -const semver = require("semver"); +const core = require('@actions/core'); +const exec_1 = require('@actions/exec'); +const io = require('@actions/io'); +const toolCache = require('@actions/tool-cache'); +const os = require('os'); +const path = require('path'); +const semver = require('semver'); function getInstallerUrl(version, latest) { const ver = version.version; switch (version.type) {