Comparing version 0.1.16 to 0.1.17
@@ -22,3 +22,4 @@ import { Title } from "../components/index.js"; | ||
const isLoading = useVersionsStore((state) => state.isLoading); | ||
const versions = useVersionsStore((state) => state.versions); | ||
const availableVersions = useVersionsStore((state) => state.availableVersions); | ||
const installedVersions = useVersionsStore((state) => state.installedVersions); | ||
useEffect(() => { | ||
@@ -29,7 +30,7 @@ const fetchToolsVersionsData = async () => { | ||
getAvailabeVersions(currentlySelected.label); | ||
setSelectedVersion(versions[0] ?? undefined); | ||
setSelectedVersion(availableVersions[0] ?? undefined); | ||
}; | ||
const fetchLocalToolsVersionsData = async () => { | ||
getInstalledVersions(currentlySelected.label); | ||
setSelectedVersion(versions[0] ?? undefined); | ||
setSelectedVersion(availableVersions[0] ?? undefined); | ||
}; | ||
@@ -77,4 +78,4 @@ if (!isLocal) { | ||
return (React.createElement(Box, { borderStyle: "double", borderColor: getBorderColorOnFocus(isFocused), flexDirection: "column", width: "70%", minHeight: 20, paddingLeft: 4 }, | ||
React.createElement(Title, { label: totalNumber("Versions", versions.length), color: getBorderColorOnFocus(isFocused) }), | ||
React.createElement(VersionsDisplay, { setSelectedVersion: handleState, isOnline: isOnline, isFocused: isFocused, isLoading: isLoading, isLocal: isLocal, versions: versions, pluginName: currentlySelected.label }))); | ||
React.createElement(Title, { label: totalNumber("Versions", availableVersions.length), color: getBorderColorOnFocus(isFocused) }), | ||
React.createElement(VersionsDisplay, { setSelectedVersion: handleState, isOnline: isOnline, isFocused: isFocused, isLoading: isLoading, isLocal: isLocal, versions: isLocal ? installedVersions : availableVersions, pluginName: currentlySelected.label }))); | ||
} |
@@ -0,5 +1,6 @@ | ||
import { listInstalledToolsVersions, listToolsVersions } from "../utils/index.js"; | ||
import { create } from "zustand"; | ||
import { listToolsVersions, listInstalledToolsVersions } from "../utils/index.js"; | ||
export const useVersionsStore = create()((set) => ({ | ||
versions: [], | ||
availableVersions: [], | ||
installedVersions: [], | ||
isLoading: false, | ||
@@ -9,3 +10,3 @@ getAvailabeVersions: async (name) => { | ||
const response = await listToolsVersions(name); | ||
set({ versions: response }); | ||
set({ availableVersions: response }); | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
@@ -16,5 +17,5 @@ }, | ||
const response = await listInstalledToolsVersions(name); | ||
set({ versions: response }); | ||
set({ installedVersions: response }); | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
}, | ||
})); |
import { $ } from "execa"; | ||
import { formatPluginData, sanitizeData } from "./helpers.js"; | ||
import fs from "node:fs"; | ||
import os from "node:os"; | ||
import readLine from "node:readline"; | ||
export const listAllPlugins = async () => { | ||
@@ -74,3 +77,13 @@ try { | ||
const sanitizedData = sanitizeData(stdout); | ||
return formatPluginData(sanitizedData.map((value) => value.trim().replace("*", ""))).reverse(); | ||
const values = formatPluginData(sanitizedData.map((value) => value.trim().replace("*", ""))).reverse(); | ||
const globalVersion = await getGlobalVersionForTool(name); | ||
if (globalVersion) { | ||
return values.map((value) => { | ||
if (value.label === globalVersion) { | ||
value.label += " 🌎"; | ||
} | ||
return value; | ||
}); | ||
} | ||
return values; | ||
} | ||
@@ -81,1 +94,17 @@ catch (error) { | ||
}; | ||
export async function getGlobalVersionForTool(searchTerm) { | ||
const filePath = `${os.homedir()}/.tool-versions`; | ||
return new Promise((resolve, reject) => { | ||
let result = undefined; | ||
let lineReader = readLine.createInterface({ | ||
input: fs.createReadStream(filePath), | ||
}); | ||
lineReader.on(`line`, function (line) { | ||
if (line.includes(searchTerm)) { | ||
result = line.split(" ")[1]; | ||
} | ||
}); | ||
lineReader.on("close", () => resolve(result)); | ||
lineReader.on("error", reject); | ||
}); | ||
} |
{ | ||
"name": "asdfui", | ||
"version": "0.1.16", | ||
"version": "0.1.17", | ||
"bin": "dist/cli.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19548
25
433