Comparing version 0.1.10 to 0.1.12
@@ -1,14 +0,7 @@ | ||
import { $ } from "execa"; | ||
import { listToolsVersions, listInstalledToolsVersions } from "./utils/asdf.js"; | ||
try { | ||
const { stdout } = await $ `asdf current`; | ||
const text = stdout.trim(); | ||
const lines = text.trim().split('\n'); | ||
const extractedFields = lines.map(line => { | ||
const fields = line.trim().split(/\s+/); | ||
if (fields.length >= 2) { | ||
return { name: fields[0], version: fields[1] }; | ||
} | ||
return null; // Handle lines with fewer than 2 fields | ||
}); | ||
console.log(extractedFields); | ||
const res = await listInstalledToolsVersions("erlang"); | ||
const res2 = await listToolsVersions("erlang"); | ||
console.log(res); | ||
console.log(res2); | ||
} | ||
@@ -15,0 +8,0 @@ catch (error) { |
import { Box } from "ink"; | ||
import React from "react"; | ||
import { CommandInfo, Header, MainContainer, Plugins, Versions, Info } from "./components/index.js"; | ||
import { CommandInfo, Header, PanesContainer } from "./components/index.js"; | ||
import { BorderColor } from "./types.js"; | ||
import { Versions, Info, Plugins } from "./panes/index.js"; | ||
export default function App() { | ||
return (React.createElement(React.Fragment, null, | ||
React.createElement(Header, null), | ||
React.createElement(MainContainer, { borderColor: BorderColor.UNFOCUSED }, | ||
React.createElement(PanesContainer, { borderColor: BorderColor.UNFOCUSED }, | ||
React.createElement(Box, { flexDirection: "column", width: "50%" }, | ||
@@ -10,0 +11,0 @@ React.createElement(Info, null), |
import { Box, Text, useFocus } from "ink"; | ||
import Link from "ink-link"; | ||
import React from "react"; | ||
import { getCommandInfo } from "../utils/helpers.js"; | ||
import { getCommandInfo } from "../utils/index.js"; | ||
export function CommandInfo() { | ||
@@ -6,0 +6,0 @@ useFocus({ isActive: false }); |
@@ -7,3 +7,3 @@ import { AlertProps } from "@inkjs/ui"; | ||
} | ||
export declare const CustomAlert: (opts: CustomAlertProps) => React.JSX.Element; | ||
export declare const CustomAlert: React.FC<CustomAlertProps>; | ||
export {}; |
import React from "react"; | ||
export declare const Header: React.FunctionComponent; | ||
export declare const Header: () => React.JSX.Element; |
export * from './CommandInfo.js'; | ||
export * from './MainContainer.js'; | ||
export * from './PanesContainer.js'; | ||
export * from './Loader.js'; | ||
export * from './Header.js'; | ||
export * from './Plugins.js'; | ||
export * from './Title.js'; | ||
export * from './Versions.js'; | ||
export * from './Info.js'; | ||
export * from './CustomSelectItem.js'; | ||
export * from './CustomAlert.js'; |
export * from './CommandInfo.js'; | ||
export * from './MainContainer.js'; | ||
export * from './PanesContainer.js'; | ||
export * from './Loader.js'; | ||
export * from './Header.js'; | ||
export * from './Plugins.js'; | ||
export * from './Title.js'; | ||
export * from './Versions.js'; | ||
export * from './Info.js'; | ||
export * from './CustomSelectItem.js'; | ||
export * from './CustomAlert.js'; |
export * from './plugin.store.js'; | ||
export * from './version.store.js'; | ||
export * from './global.store.js'; |
export * from './plugin.store.js'; | ||
export * from './version.store.js'; | ||
export * from './global.store.js'; |
import { Option } from "@inkjs/ui"; | ||
interface PluginState { | ||
plugins: Option[]; | ||
isLoading: boolean; | ||
currentlySelected: Option; | ||
getAllLocalPlugins: () => void; | ||
selectPlugin: (plugin: Option) => void; | ||
loading: boolean; | ||
} | ||
export declare const usePluginsStore: import("zustand").UseBoundStore<import("zustand").StoreApi<PluginState>>; | ||
export {}; |
import { create } from "zustand"; | ||
import { getAllPlugins } from "../utils/asdf.js"; | ||
import { listtAllPlugins } from "../utils/index.js"; | ||
export const usePluginsStore = create()((set) => ({ | ||
plugins: [], | ||
isLoading: false, | ||
currentlySelected: { | ||
@@ -11,4 +12,4 @@ value: "", | ||
getAllLocalPlugins: async () => { | ||
set((state) => ({ loading: !state.loading })); | ||
const response = await getAllPlugins(); | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
const response = await listtAllPlugins(); | ||
set({ plugins: response }); | ||
@@ -21,5 +22,4 @@ set({ currentlySelected: response.length > 0 ? response[0] : | ||
}); | ||
set((state) => ({ loading: !state.loading })); | ||
}, | ||
loading: false | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
} | ||
})); |
import { Option } from "@inkjs/ui"; | ||
interface VersionState { | ||
versions: Option[]; | ||
getAlVersions: (name: string) => void; | ||
loading: boolean; | ||
isLoading: boolean; | ||
getAvailabeVersions: (name: string) => void; | ||
getInstalledVersions: (name: string) => void; | ||
} | ||
export declare const useVersionsStore: import("zustand").UseBoundStore<import("zustand").StoreApi<VersionState>>; | ||
export {}; |
import { create } from "zustand"; | ||
import { getToolVersions } from "../utils/asdf.js"; | ||
import { listToolsVersions, listInstalledToolsVersions } from "../utils/index.js"; | ||
export const useVersionsStore = create()((set) => ({ | ||
versions: [], | ||
getAlVersions: async (name) => { | ||
set((state) => ({ loading: !state.loading })); | ||
const response = await getToolVersions(name); | ||
isLoading: false, | ||
getAvailabeVersions: async (name) => { | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
const response = await listToolsVersions(name); | ||
set({ versions: response }); | ||
set((state) => ({ loading: !state.loading })); | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
}, | ||
loading: false | ||
getInstalledVersions: async (name) => { | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
const response = await listInstalledToolsVersions(name); | ||
set({ versions: response }); | ||
set((state) => ({ isLoading: !state.isLoading })); | ||
} | ||
})); |
@@ -10,5 +10,10 @@ export declare enum BorderColor { | ||
} | ||
export interface Info { | ||
export interface VersionInfo { | ||
name: string; | ||
version: string; | ||
} | ||
export type Item<V> = { | ||
key?: string; | ||
label: string; | ||
value: V; | ||
}; |
import { Option } from "@inkjs/ui"; | ||
import { Info } from "../types.js"; | ||
export declare const getAllPlugins: () => Promise<Option[]>; | ||
export declare const getToolVersions: (name: string) => Promise<Option[]>; | ||
export declare const installToolVersion: (name: string, version: string) => Promise<boolean>; | ||
export declare const unInstallToolVersion: (name: string, version: string) => Promise<boolean>; | ||
export declare const getInfo: () => Promise<Info[]>; | ||
import { VersionInfo } from "../types.js"; | ||
export declare const listtAllPlugins: () => Promise<Option[]>; | ||
export declare const listToolsVersions: (name: string) => Promise<Option[]>; | ||
export declare const installToolVersion: ({ name, version }: VersionInfo) => Promise<boolean>; | ||
export declare const uninstallToolVersion: ({ name, version }: VersionInfo) => Promise<boolean>; | ||
export declare const getInfo: () => Promise<VersionInfo[]>; | ||
export declare const checkIfVersionInstalled: () => void; | ||
export declare const listInstalledToolsVersions: (name: string) => Promise<{ | ||
label: string; | ||
value: string; | ||
}[]>; |
import { $ } from "execa"; | ||
import { formatPluginData } from "./helpers.js"; | ||
export const getAllPlugins = async () => { | ||
import { formatPluginData, sanitizeData } from "./helpers.js"; | ||
export const listtAllPlugins = async () => { | ||
try { | ||
const { stdout } = await $ `asdf plugin list`; | ||
return formatPluginData(stdout); | ||
const sanitizedData = sanitizeData(stdout); | ||
return formatPluginData(sanitizedData); | ||
} | ||
@@ -12,6 +13,7 @@ catch (error) { | ||
}; | ||
export const getToolVersions = async (name) => { | ||
export const listToolsVersions = async (name) => { | ||
try { | ||
const { stdout } = await $ `asdf list all ${name}`; | ||
return formatPluginData(stdout).reverse(); | ||
const sanitizedData = sanitizeData(stdout); | ||
return formatPluginData(sanitizedData).reverse(); | ||
} | ||
@@ -22,9 +24,19 @@ catch (error) { | ||
}; | ||
export const installToolVersion = async (name, version) => { | ||
await $ `asdf install ${name} ${version}`; | ||
return true; | ||
export const installToolVersion = async ({ name, version }) => { | ||
try { | ||
await $ `asdf install ${name} ${version}`; | ||
return true; | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
}; | ||
export const unInstallToolVersion = async (name, version) => { | ||
await $ `asdf uninstall ${name} ${version}`; | ||
return true; | ||
export const uninstallToolVersion = async ({ name, version }) => { | ||
try { | ||
await $ `asdf uninstall ${name} ${version}`; | ||
return true; | ||
} | ||
catch (error) { | ||
return false; | ||
} | ||
}; | ||
@@ -35,4 +47,4 @@ export const getInfo = async () => { | ||
const text = stdout.trim(); | ||
const lines = text.trim().split('\n'); | ||
const extractedFields = lines.map(line => { | ||
const lines = sanitizeData(text); | ||
const extractedFields = lines.map((line) => { | ||
const fields = line.trim().split(/\s+/); | ||
@@ -47,1 +59,13 @@ return { name: fields[0], version: fields[1] }; | ||
}; | ||
export const checkIfVersionInstalled = () => { | ||
}; | ||
export const listInstalledToolsVersions = async (name) => { | ||
try { | ||
const { stdout } = await $ `asdf list ${name}`; | ||
const sanitizedData = sanitizeData(stdout); | ||
return formatPluginData(sanitizedData.map(value => value.trim().replace("*", ""))); | ||
} | ||
catch (error) { | ||
return []; | ||
} | ||
}; |
import { BorderColor } from "../types.js"; | ||
export declare const getBorderColorOnFocus: (isFocused: boolean) => BorderColor; | ||
export declare function formatPluginData(data: string): { | ||
export declare function sanitizeData(data: string): string[]; | ||
export declare function formatPluginData(data: string[]): { | ||
label: string; | ||
@@ -5,0 +6,0 @@ value: string; |
import { BorderColor } from "../types.js"; | ||
export const getBorderColorOnFocus = (isFocused) => (isFocused ? BorderColor.FOCUSED : BorderColor.UNFOCUSED); | ||
export function sanitizeData(data) { | ||
return data.trim().split("\n"); | ||
} | ||
export function formatPluginData(data) { | ||
return data.trim().split("\n").map((element) => ({ | ||
return data.map((element) => ({ | ||
label: element, | ||
@@ -6,0 +9,0 @@ value: element, |
{ | ||
"name": "asdfui", | ||
"version": "0.1.10", | ||
"version": "0.1.12", | ||
"bin": "dist/cli.js", | ||
"type": "module", | ||
"description": "NestJS + MikroORM blog example with batteries included", | ||
"description": "Experimental TUI for asdf vm", | ||
"author": { | ||
@@ -30,4 +30,4 @@ "email": "roobin.bhandari@gmail.com", | ||
"scripts": { | ||
"build": "tsc", | ||
"dev": "tsc --watch", | ||
"build": "tsc && tsc-alias", | ||
"dev": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")", | ||
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint '{src,test}/**/*.ts' --cache", | ||
@@ -48,12 +48,15 @@ "lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint '{src,test}/**/*.ts' --cache --fix", | ||
"ink-link": "^3.0.0", | ||
"ink-select-input": "^5.0.0", | ||
"install": "^0.13.0", | ||
"is-online": "^10.0.0", | ||
"react": "^18.2.0", | ||
"zustand": "^4.4.5" | ||
"zustand": "^4.4.6" | ||
}, | ||
"devDependencies": { | ||
"@rubiin/eslint-config": "^1.9.2", | ||
"@rubiin/eslint-config": "^1.9.4", | ||
"@sindresorhus/tsconfig": "^5.0.0", | ||
"@types/react": "^18.2.33", | ||
"@types/react": "^18.2.34", | ||
"bumpp": "^9.2.0", | ||
"chalk": "^5.3.0", | ||
"concurrently": "^8.2.2", | ||
"eslint": "^8.52.0", | ||
@@ -63,4 +66,5 @@ "prettier": "^3.0.3", | ||
"ts-node": "^10.9.1", | ||
"tsc-alias": "^1.8.8", | ||
"typescript": "^5.2.2" | ||
} | ||
} |
@@ -18,5 +18,6 @@ # asdfui | ||
Raodmap: | ||
- [] mark installed versions with installed | ||
- [] clear screen on launch | ||
- [] install selected versions | ||
- [] uninstall selected version | ||
- [] mark installed versions with installed | ||
- [] set selected version as global |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
50
23
22558
11
12
529
1
+ Addedink-select-input@^5.0.0
+ Addedinstall@^0.13.0
+ Addedarr-rotate@1.0.0(transitive)
+ Addedink-select-input@5.0.0(transitive)
+ Addedinstall@0.13.0(transitive)
+ Addedlodash.isequal@4.5.0(transitive)
Updatedzustand@^4.4.6