clean files

This commit is contained in:
Opportunity
2021-07-16 11:08:18 +08:00
Unverified
parent 28277cf90d
commit 1d3e0c37b9
8 changed files with 81 additions and 88 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ with:
### Prepare development environment ### Prepare development environment
```bash ```bash
yarn init yarn install
``` ```
### Draft a new release ### Draft a new release
Vendored
+9 -12
View File
@@ -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,7 +27,8 @@ 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] = {};
} }
} }
@@ -43,11 +44,7 @@ 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( await exec_1.exec('git', ['fetch', 'origin', '+refs/pull/*:refs/remotes/origin/pull/*', '+refs/heads/*:refs/remotes/origin/*'], opt);
'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;
+12 -10
View File
@@ -1,22 +1,24 @@
'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);
} }
+6 -4
View File
@@ -1,15 +1,17 @@
'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)) throw new Error(`Invalid sha value ${sha}`); if (!/^[a-f0-9]{40}$/g.test(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)) throw new Error(`Invalid repo value ${repo}`); if (!/^([^/#]+\/[^/#]+)$/g.test(repo))
throw new Error(`Invalid repo value ${repo}`);
return repo; return repo;
} }
exports.Repo = Repo; exports.Repo = Repo;
+15 -15
View File
@@ -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,9 +19,7 @@ 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)}`, () => const sourceDir = await core.group(`download xmake ${String(version)}`, () => git.create(version.repo, version.sha));
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);
@@ -31,7 +29,8 @@ 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);
@@ -40,7 +39,8 @@ 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'));
} }
} }
+27 -34
View File
@@ -1,34 +1,29 @@
'use strict'; "use strict";
var __classPrivateFieldSet = var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
(this && this.__classPrivateFieldSet) || if (kind === "m") throw new TypeError("Private method is not writable");
function (receiver, state, value, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (kind === 'm') throw new TypeError('Private method is not writable'); 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 === 'a' && !f) throw new TypeError('Private accessor was defined without a setter'); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
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 = var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
(this && this.__classPrivateFieldGet) || if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
function (receiver, state, kind, f) { 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");
if (kind === 'a' && !f) throw new TypeError('Private accessor was defined without a getter'); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
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) return cache; if (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;
@@ -40,10 +35,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();
@@ -106,13 +101,12 @@ async function selectSha(repo, sha) {
return selectPr(repo, Number.parseInt(pr)); return selectPr(repo, Number.parseInt(pr));
} }
} }
return Promise.resolve( return Promise.resolve(new GitVersionImpl(repo, `sha#${shaValue}`, shaValue, 'sha', `commit ${shaValue.substr(0, 8)}`));
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') version = ''; if (version.toLowerCase() === 'latest')
version = '';
let repo = DEFAULT_REPO; let repo = DEFAULT_REPO;
let ret; let ret;
if (version.startsWith('local#')) { if (version.startsWith('local#')) {
@@ -149,11 +143,10 @@ 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 { }
core.info( else {
`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` + core.info(`Selected xmake ${String(ret)} (commit: ${ret.sha.substr(0, 8)})` +
(repo !== DEFAULT_REPO ? ` of ${repo}` : ''), (repo !== DEFAULT_REPO ? ` of ${repo}` : ''));
);
} }
return ret; return ret;
} }
+9 -9
View File
@@ -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) {
-1
View File
@@ -8,7 +8,6 @@
"repository": "https://github.com/xmake-io/github-action-setup-xmake.git", "repository": "https://github.com/xmake-io/github-action-setup-xmake.git",
"homepage": "https://github.com/xmake-io/github-action-setup-xmake", "homepage": "https://github.com/xmake-io/github-action-setup-xmake",
"scripts": { "scripts": {
"init": "yarn install && yarn clean",
"watch": "tsc --watch", "watch": "tsc --watch",
"build": "tsc --build ./tsconfig.build.json", "build": "tsc --build ./tsconfig.build.json",
"rebuild": "yarn clean && yarn build", "rebuild": "yarn clean && yarn build",