From 2cafc92e787aad4872371eaf8ed7e273090fcb00 Mon Sep 17 00:00:00 2001 From: BSKY Date: Thu, 26 Dec 2019 15:52:20 +0900 Subject: [PATCH] Format everything --- CHANGELOG.md | 10 ++++------ README.md | 8 ++++---- install/action.yml | 10 +++++----- lib/install/index.js | 8 +++----- lib/plugin-test/index.js | 32 +++++++++++++++++++++----------- lib/plugins-add/index.js | 22 ++++++++++------------ lib/setup/index.js | 14 ++++++++++---- plugin-test/action.yml | 10 +++++----- plugins-add/action.yml | 10 +++++----- setup/action.yml | 10 +++++----- 10 files changed, 72 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba4000b..dc72386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,20 +4,18 @@ Features -* Add `asdf-vm/actions/install` +- Add `asdf-vm/actions/install` Action for installing your plugins and tool-versions. -* Add `asdf-vm/actions/plugin-test` +- Add `asdf-vm/actions/plugin-test` Action for testing new asdf plugins. -* Add `asdf-vm/actions/plugin-add` +- Add `asdf-vm/actions/plugin-add` Lower lever action for installing the plugins from official repos. -* Add `asdf-vm/actions/setup` +- Add `asdf-vm/actions/setup` Lower level action for installing asdf itself. - - diff --git a/README.md b/README.md index 3c16754..22a334d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repo provides a collection of asdf related actions for use in your workflow These two actions are probaly the most useful: -* `asdf-vm/actions/install` - Install your `.tool-versions` plugins and tools. +- `asdf-vm/actions/install` - Install your `.tool-versions` plugins and tools. ```yaml steps: @@ -16,7 +16,7 @@ These two actions are probaly the most useful: See [action.yml](install/action.yml) inputs. -* `asdf-vm/actions/plugin-test` - Test your shiny new asdf plugin. +- `asdf-vm/actions/plugin-test` - Test your shiny new asdf plugin. ```yaml steps: @@ -35,10 +35,10 @@ These two actions are probaly the most useful: These actions are used internally by the above ones. And you wont need to use them directly, unless you actually want ;) -* `asdf-vm/actions/plugins-add` - Only install plugins, not tool versions. +- `asdf-vm/actions/plugins-add` - Only install plugins, not tool versions. See [action.yml](plugins-add/action.yml) inputs. -* `asdf-vm/actions/setup` - Just installs asdf itself. +- `asdf-vm/actions/setup` - Just installs asdf itself. See [action.yml](setup/action.yml) inputs. diff --git a/install/action.yml b/install/action.yml index ee673fa..b906e7a 100644 --- a/install/action.yml +++ b/install/action.yml @@ -1,9 +1,9 @@ -name: 'AsdfInstall' -description: 'Install your versioned tools with asdf' -author: 'Victor Borja ' +name: "AsdfInstall" +description: "Install your versioned tools with asdf" +author: "Victor Borja " runs: - using: 'node12' - main: 'index.js' + using: "node12" + main: "index.js" inputs: tool_versions: description: "If present, this value will be written to the .tool-versions file." diff --git a/lib/install/index.js b/lib/install/index.js index 381287e..7bfd230 100644 --- a/lib/install/index.js +++ b/lib/install/index.js @@ -1,17 +1,15 @@ import * as core from "@actions/core"; import * as exec from "@actions/exec"; -import * as path from "path"; import pluginsAdd from "../plugins-add"; - const toolsInstall = async () => { await pluginsAdd(); - const before = core.getInput("before_install", {required: false}); + const before = core.getInput("before_install", { required: false }); if (before) { - await exec.exec('bash', ['-c', before]); + await exec.exec("bash", ["-c", before]); } - await exec.exec('asdf', ['install']); + await exec.exec("asdf", ["install"]); }; export default toolsInstall; diff --git a/lib/plugin-test/index.js b/lib/plugin-test/index.js index 154edf2..9c27028 100644 --- a/lib/plugin-test/index.js +++ b/lib/plugin-test/index.js @@ -1,24 +1,34 @@ import * as core from "@actions/core"; import * as exec from "@actions/exec"; -import * as path from "path"; import setupAsdf from "../setup"; - const pluginTest = async () => { await setupAsdf(); - const command = core.getInput("command", {required: true}); - const version = core.getInput("version", {required: true}); - const plugin = (core.getInput("plugin", {required: false}) || process.env.GITHUB_REPOSITORY.split('/')[1]).replace('asdf-', ''); - const giturl = (core.getInput("giturl", {required: false}) || `https://github.com/${process.env.GITHUB_REPOSITORY}`); - const gitref = (core.getInput("gitref", {required: false}) || process.env.GITHUB_SHA); - await exec.exec('asdf', [ - 'plugin-test', - plugin, giturl, '--asdf-tool-version', version, '--asdf-plugin-gitref', gitref, command + const command = core.getInput("command", { required: true }); + const version = core.getInput("version", { required: true }); + const plugin = ( + core.getInput("plugin", { required: false }) || + process.env.GITHUB_REPOSITORY.split("/")[1] + ).replace("asdf-", ""); + const giturl = + core.getInput("giturl", { required: false }) || + `https://github.com/${process.env.GITHUB_REPOSITORY}`; + const gitref = + core.getInput("gitref", { required: false }) || process.env.GITHUB_SHA; + await exec.exec("asdf", [ + "plugin-test", + plugin, + giturl, + "--asdf-tool-version", + version, + "--asdf-plugin-gitref", + gitref, + command ]); }; const pluginTestAll = async () => { - core.startGroup('Test plugin'); + core.startGroup("Test plugin"); await pluginTest(); core.endGroup(); }; diff --git a/lib/plugins-add/index.js b/lib/plugins-add/index.js index c7a9fa5..68f2d05 100644 --- a/lib/plugins-add/index.js +++ b/lib/plugins-add/index.js @@ -1,29 +1,27 @@ import * as core from "@actions/core"; -import * as io from "@actions/io"; import * as exec from "@actions/exec"; -import * as path from "path"; -import {promises as fs} from 'fs'; +import { promises as fs } from "fs"; import setupAsdf from "../setup"; const pluginsAdd = async () => { await setupAsdf(); - let tool_versions = core.getInput("tool_versions", {required: false}); + let tool_versions = core.getInput("tool_versions", { required: false }); if (tool_versions) { - await fs.writeFile(".tool-versions", tool_versions, {encoding: 'utf8'}); + await fs.writeFile(".tool-versions", tool_versions, { encoding: "utf8" }); } else { - tool_versions = await fs.readFile(".tool-versions", {encoding: 'utf8'}); + tool_versions = await fs.readFile(".tool-versions", { encoding: "utf8" }); } - const pluginNames = - tool_versions.split("\n") - .map(x => x.replace(/#.*/, '').trim()) - .filter(x => x.length > 0) - .map(x => x.split(' ')[0]); + const pluginNames = tool_versions + .split("\n") + .map(x => x.replace(/#.*/, "").trim()) + .filter(x => x.length > 0) + .map(x => x.split(" ")[0]); await pluginNames.reduce(async (promise, pluginName) => { await promise; - return exec.exec('asdf', ["plugin-add", pluginName]); + return exec.exec("asdf", ["plugin-add", pluginName]); }, Promise.resolve()); }; diff --git a/lib/setup/index.js b/lib/setup/index.js index 6f7c5a3..a074a7e 100644 --- a/lib/setup/index.js +++ b/lib/setup/index.js @@ -4,17 +4,23 @@ import * as io from "@actions/io"; import * as path from "path"; const setupAsdf = async () => { - const asdfPath = await io.which('asdf', false); - if (asdfPath) { return; } + const asdfPath = await io.which("asdf", false); + if (asdfPath) { + return; + } const asdfDir = path.join(process.env.HOME, ".asdf"); core.exportVariable("ASDF_DIR", asdfDir); core.exportVariable("ASDF_DATA_DIR", asdfDir); core.addPath(`${asdfDir}/bin`); core.addPath(`${asdfDir}/shims`); core.info(`Clonning asdf into ASDF_DIR: ${asdfDir}`); - const branch = core.getInput("asdf_branch", {required: true}); + const branch = core.getInput("asdf_branch", { required: true }); await exec.exec("git", [ - "clone", "--depth", "1", "--branch", branch, + "clone", + "--depth", + "1", + "--branch", + branch, "https://github.com/asdf-vm/asdf.git", asdfDir ]); diff --git a/plugin-test/action.yml b/plugin-test/action.yml index 46649d8..05c4845 100644 --- a/plugin-test/action.yml +++ b/plugin-test/action.yml @@ -1,9 +1,9 @@ -name: 'TestPlugin' -description: 'Test your asdf plugin' -author: 'Victor Borja ' +name: "TestPlugin" +description: "Test your asdf plugin" +author: "Victor Borja " runs: - using: 'node12' - main: 'index.js' + using: "node12" + main: "index.js" inputs: command: description: "Command used to test your plugin tool. Something with --version or --help" diff --git a/plugins-add/action.yml b/plugins-add/action.yml index 8e6c7f3..390688a 100644 --- a/plugins-add/action.yml +++ b/plugins-add/action.yml @@ -1,9 +1,9 @@ -name: 'PluginsInstall' -description: 'Install the plugins listed on your .tool-versions file.' -author: 'Victor Borja ' +name: "PluginsInstall" +description: "Install the plugins listed on your .tool-versions file." +author: "Victor Borja " runs: - using: 'node12' - main: 'index.js' + using: "node12" + main: "index.js" inputs: asdf_branch: description: "asdf branch to clone" diff --git a/setup/action.yml b/setup/action.yml index b6d2a61..d090eda 100644 --- a/setup/action.yml +++ b/setup/action.yml @@ -1,9 +1,9 @@ -name: 'Setup asdf' -description: 'Install tools versioned with asdf' -author: 'Victor Borja ' +name: "Setup asdf" +description: "Install tools versioned with asdf" +author: "Victor Borja " runs: - using: 'node12' - main: 'index.js' + using: "node12" + main: "index.js" inputs: asdf_branch: description: "asdf branch to clone"