A new command has been added to the CLI package to search for components. This command fetches the registry and lists accessible components through the SearchBox component. The SearchBox component has also been updated to show a helper text and a new styled border for better user interaction.
25 lines
792 B
TypeScript
25 lines
792 B
TypeScript
import {Command} from '@oclif/core'
|
|
import {render} from 'ink'
|
|
import {SearchBox} from '../components/SearchBox.js'
|
|
import {getAvailableComponentNames, getRegistry} from '../helpers/registry.js'
|
|
import React from 'react'
|
|
|
|
export default class Search extends Command {
|
|
static override description = 'Search components.'
|
|
|
|
static override examples = ['<%= config.bin %> <%= command.id %>']
|
|
|
|
static override flags = {}
|
|
|
|
public async run(): Promise<void> {
|
|
const registryResult = await getRegistry()
|
|
if (!registryResult.ok) {
|
|
this.error(registryResult.message)
|
|
}
|
|
const registry = registryResult.registry
|
|
const componentNames = await getAvailableComponentNames(registry)
|
|
|
|
render(<SearchBox components={componentNames} helper={'Press Ctrl+C to quit'} />)
|
|
}
|
|
}
|