Comparing version 0.1.7 to 0.1.8
import { Box } from "ink"; | ||
import React from "react"; | ||
import { Globals } from "./components/Global.js"; | ||
import { CommandInfo, Header, MainContainer, Plugins, Versions } from "./components/index.js"; | ||
import { CommandInfo, Header, MainContainer, Plugins, Versions, Info } from "./components/index.js"; | ||
import { BorderColor } from "./types.js"; | ||
@@ -11,3 +10,3 @@ export default function App() { | ||
React.createElement(Box, { flexDirection: "column", width: "50%" }, | ||
React.createElement(Globals, null), | ||
React.createElement(Info, null), | ||
React.createElement(Plugins, null)), | ||
@@ -14,0 +13,0 @@ React.createElement(Versions, null)), |
@@ -8,2 +8,3 @@ export * from './CommandInfo.js'; | ||
export * from './Versions.js'; | ||
export * from './Info.js'; | ||
export * from './NotFound.js'; |
@@ -8,2 +8,3 @@ export * from './CommandInfo.js'; | ||
export * from './Versions.js'; | ||
export * from './Info.js'; | ||
export * from './NotFound.js'; |
@@ -1,9 +0,29 @@ | ||
import { Box, Text } from "ink"; | ||
import Link from "ink-link"; | ||
import React from "react"; | ||
import { Box, Spacer, Text } from "ink"; | ||
import React, { useEffect } from "react"; | ||
import { useInfosStore } from "../stores/global.stores.js"; | ||
import { BorderColor } from "../types.js"; | ||
import { totalNumber } from "../utils/helpers.js"; | ||
import { Loader, NotFound, Title } from "./index.js"; | ||
export function Info() { | ||
return (React.createElement(Box, { width: "60%", minHeight: 5, justifyContent: "space-between", marginLeft: 10 }, | ||
React.createElement(Text, { color: "blue", bold: true }, "Tab: Change focus g: Set global version i: Install a version u: Install a version, q: To quit"), | ||
React.createElement(Link, { url: "https://github.com/rubiin/asdfui" }, | ||
React.createElement(Text, { color: "magenta" }, "Github")))); | ||
const getAllInfo = useInfosStore((state) => state.getAllInfo); | ||
const versions = useInfosStore((state) => state.versions); | ||
const loading = useInfosStore((state) => state.loading); | ||
useEffect(() => { | ||
// declare the data fetching function | ||
const fetchInfoData = () => { | ||
getAllInfo(); | ||
}; | ||
// call the function | ||
fetchInfoData(); | ||
}, []); | ||
return (React.createElement(Box, { borderStyle: "double", borderColor: BorderColor.UNFOCUSED, flexDirection: "column", minHeight: 20, paddingLeft: 2 }, | ||
React.createElement(Title, { title: totalNumber("Info", versions.length), color: BorderColor.UNFOCUSED }), | ||
loading && React.createElement(Loader, { text: "Fetching info" }), | ||
React.createElement(Box, { paddingY: 2, paddingX: 4, flexDirection: "column" }, versions.map((element, index) => { | ||
return (React.createElement(Box, { paddingY: 0.5, key: index }, | ||
React.createElement(Text, null, element.name), | ||
React.createElement(Spacer, null), | ||
React.createElement(Text, null, element.version))); | ||
})), | ||
!loading && versions.length === 0 && React.createElement(NotFound, { text: "No versions found" }))); | ||
} |
@@ -5,4 +5,4 @@ import { Select } from "@inkjs/ui"; | ||
import { usePluginsStore } from "../stores/plugin.store.js"; | ||
import { Loader, NotFound, Title } from "./index.js"; | ||
import { getBorderColorOnFocus, totalNumber } from "../utils/helpers.js"; | ||
import { Loader, NotFound, Title } from "./index.js"; | ||
export function Plugins() { | ||
@@ -9,0 +9,0 @@ const { isFocused } = useFocus({ id: "plugins", autoFocus: true }); |
@@ -1,8 +0,8 @@ | ||
import { GlobalVersions } from "../types.js"; | ||
interface GlobalVersionsState { | ||
versions: GlobalVersions[]; | ||
getAllGlobalVersions: () => void; | ||
import { Info } from "../types.js"; | ||
interface InfoState { | ||
versions: Info[]; | ||
getAllInfo: () => void; | ||
loading: boolean; | ||
} | ||
export declare const useGlobalsStore: import("zustand").UseBoundStore<import("zustand").StoreApi<GlobalVersionsState>>; | ||
export declare const useInfosStore: import("zustand").UseBoundStore<import("zustand").StoreApi<InfoState>>; | ||
export {}; |
import { create } from "zustand"; | ||
import { getGlobalToolVersions } from "../utils/asdf.js"; | ||
export const useGlobalsStore = create()((set) => ({ | ||
import { getInfo } from "../utils/asdf.js"; | ||
export const useInfosStore = create()((set) => ({ | ||
loading: false, | ||
versions: [], | ||
getAllGlobalVersions: async () => { | ||
getAllInfo: async () => { | ||
set((state) => ({ loading: !state.loading })); | ||
const response = await getGlobalToolVersions(); | ||
const response = await getInfo(); | ||
set({ versions: response }); | ||
@@ -10,0 +10,0 @@ set((state) => ({ loading: !state.loading })); |
@@ -10,5 +10,5 @@ export declare enum BorderColor { | ||
} | ||
export interface GlobalVersions { | ||
export interface Info { | ||
name: string; | ||
version: string; | ||
} |
import { Option } from "@inkjs/ui"; | ||
import { GlobalVersions } from "../types.js"; | ||
import { Info } from "../types.js"; | ||
export declare const getAllPlugins: () => Promise<Option[]>; | ||
@@ -7,2 +7,2 @@ export declare const getToolVersions: (name: string) => Promise<Option[]>; | ||
export declare const unInstallToolVersion: (name: string, version: string) => Promise<boolean>; | ||
export declare const getGlobalToolVersions: () => Promise<GlobalVersions[]>; | ||
export declare const getInfo: () => Promise<Info[]>; |
@@ -29,3 +29,3 @@ import { $ } from "execa"; | ||
}; | ||
export const getGlobalToolVersions = async () => { | ||
export const getInfo = async () => { | ||
try { | ||
@@ -32,0 +32,0 @@ const { stdout } = await $ `asdf current`; |
{ | ||
"name": "asdfui", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"bin": "dist/cli.js", | ||
@@ -49,3 +49,3 @@ "type": "module", | ||
"react": "^18.2.0", | ||
"zustand": "^4.4.4" | ||
"zustand": "^4.4.5" | ||
}, | ||
@@ -52,0 +52,0 @@ "devDependencies": { |
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
27048
43
634
Updatedzustand@^4.4.5