Skip to content

Commit

Permalink
fix(setup-asdf): update plugin url to support some community version
Browse files Browse the repository at this point in the history
  • Loading branch information
kamontat committed Jun 14, 2024
1 parent 6c6ddae commit 071139d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions actions/setup-asdf/src/apis/asdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { join } from "node:path"
import { readFile } from "node:fs/promises"
import { AppContext } from "@kcws/github-actions"

import { getPluginUrl } from "./constants"
import app from "../app"

export const asdfPluginList = async (context: AppContext<typeof app>) => {
Expand All @@ -21,9 +22,11 @@ export const asdfPluginList = async (context: AppContext<typeof app>) => {
export const asdfPluginAdd = async (
context: AppContext<typeof app>,
plugin: string,
pluginUrl: string = "https://github.com/kc-workspace/asdf-{0}.git"
pluginUrl?: string
) => {
const repo = context.use("log").format(pluginUrl, plugin)
const repo = context
.use("log")
.format(getPluginUrl(plugin, pluginUrl), plugin)
await context.use("exec").run("asdf", "plugin", "add", plugin, repo)
}

Expand Down
15 changes: 15 additions & 0 deletions actions/setup-asdf/src/apis/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const getPluginUrl = (plugin: string, pluginUrl?: string) => {
if (typeof pluginUrl === "string" && pluginUrl.length > 0) return pluginUrl

switch (plugin) {
case "nodejs":
case "ruby":
return "https://github.com/asdf-vm/asdf-{0}.git"
case "python":
return "https://github.com/asdf-community/asdf-{0}.git"
case "java":
return "https://github.com/halcyon/asdf-{0}.git"
default:
return "https://github.com/kc-workspace/asdf-{0}.git"
}
}

0 comments on commit 071139d

Please sign in to comment.