npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@radic/console-input

v1.13.1

Published

const filePath = await Ask.fileTree('A simple way to ask questions. Uses inquirer, integrates 10+ peer deps third party prompts.')

Downloads

15

Readme



Console Input

  • Based on inquirer.
  • Includes a lot of optional extra prompts, if the relevant peerDependency is installed
  • Main purpose is to fire 'one-off' questions like:
const path = await Input.fileTree('Select the file to delete', '/')

Toc

Installation

yarn add @radic/console-input

Third party prompts

Third party prompts are peerDependencies so you'll have to install them yourself if you'd like to use em. Automatically integrated if installed.

- path:   inquirer-path
- fuzzypath:   inquirer-fuzzy-path
- directory:   inquirer-directory
- autocomplete:   inquirer-autocomplete-prompt
- datetime:   inquirer-datepicker
- maxlength-input:   @matti-o7/inquirer-maxlength-input-prompt
- file-path:   inquirer-file-path
- file-tree-selection:   inquirer-file-tree-selection-prompt
- file-selector:   inquirer-file-selector-prompt
- color:   inquirer-chalk-pipe
- suggest:   inquirer-prompt-suggest
- table:   inquirer-table-prompt

Full API

Created and/or modified all type definitions for each package it's options as can be checked in types/inquirer.d.ts

export declare class Input {
    static get inquirer(): inquirer.Inquirer;
    static get Separator(): typeof inquirer.Separator;
    static get prompt(): inquirer.PromptModule;
    static register(name: string, prompt: PromptConstructor): typeof Input;
    static question(question: DistinctQuestion): Promise<any>;
    static input(message: string, defaultValue?: string, question?: Partial<InputQuestion>): Promise<any>;
    static color(message: string, defaultValue?: string, question?: Partial<ColorQuestion>): Promise<any>;
    static suggest(message: string, suggestions: string[], defaultValue?: string, question?: Partial<SuggestQuestion>): Promise<any>;
    static table(message: string, columns: TableQuestion['columns'], rows?: TableQuestion['rows'], defaultValue?: string, question?: Partial<TableQuestion>): Promise<any>;
    static confirm(message: string, defaultValue?: boolean, question?: Partial<ConfirmQuestion>): Promise<any>;
    static checkbox(message: string, choices: DistinctChoice<CheckboxChoiceMap>[], defaultChoice?: any, question?: Partial<CheckboxQuestion>): Promise<any>;
    static list(message: string, choices: DistinctChoice<ListChoiceMap>[], defaultChoice?: any, question?: Partial<ListQuestion>): Promise<any>;
    static autocomplete(message: string, source: (answersSoFar: Answers, input: string) => Promise<Array<string>>, question?: Partial<AutocompleteQuestion>): Promise<any>;
    static datetime(message: string, question?: Partial<DatepickerQuestion>): Promise<any>;
    static maxinputlength(message: string, maxLength: number, question?: Partial<MaxinputQuestion>): Promise<any>;
    static path(message: string, question?: Partial<PathQuestion>): Promise<any>;
    static directory(message: string, basePath?: string, question?: Partial<DirectoryQuestion>): Promise<any>;
    static fuzzypath(message: string, def?: string, question?: Partial<FuzzypathQuestion>): Promise<any>;
    static filePath(message: string, basePath?: string, question?: Partial<FilePathQuestion>): Promise<any>;
    static fsTree(message: string, root?: string, question?: Partial<FileTreePathSelectorQuestion>): Promise<any>;
    static fileTree(message: string, root?: string, question?: Partial<FileTreePathSelectorQuestion>): Promise<any>;
    static directoryTree(message: string, root?: string, question?: Partial<FileTreePathSelectorQuestion>): Promise<any>;
    static editorChoices: Array<{
        name: string;
        value: string;
    }>;
    static editorDefaultChoice: string;
    static editor(message: string, question: Partial<EditorQuestion>): Promise<any>;
    static edit(content: string, options?: IFileOptions): Promise<unknown>;
}

Some examples

if(await Input.confirm('Are you sure', true)){
    console.log('yes');
}
let choice = await Input.checkbox('Pick your foods', ['apples','pears','bananas']);
let choice = await Input.checkbox('Pick your food', [
    { checked: true,        key    : 'apples',        value  : 'Apples',    },
    Input.Separator(1),
    { checked: true,        key    : 'cheese',        value  : 'Cheese',    },
]);
let files = await ask.filetree('Pick the files you wish to delete', '/path/to/root', {
    multiple: true,
    root: '/path/to/root' // you can override parameters again in the options if you'd like
})
files.forEach(filePath => rm('-rf', filePath))