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

@eliyya/inquirer-fs-selector

v0.3.2

Published

Inquerer file selector prompt.

Downloads

3

Readme

license node-current version unpacked-size downloads

preview

Installation

npm install inquirer-file-selector

Usage

import fileSelector from 'inquirer-file-selector'

const filePath = await fileSelector({
  message: 'Select a file:',
  ...
})

Options

| Option | Type | Required | Description | |--------|------|----------|-------------| | message | string | ✔ | The message to display in the prompt. | | dir | boolena | ✔ | Allow select dir. | | path | string | | The path to the directory where it will be started. Default: process.cwd() | | pageSize | number | | The maximum number of items to display in the list. Default: 10 | | match | (file: Item) => boolean | | A function to filter the files. If not provided, all files will be included. | | hideNonMatch | boolean | | If true, the list will be filtered to show only files that match the match function. Default: false | | disabledLabel | string | | The label to display when a file is disabled. Default: (not allowed) | | allowCancel | boolean | | If true, the prompt will allow the user to cancel the selection. Default: false | | cancelText | string | | The message to display when the user cancels the selection. Default: Canceled. | | emptyText | string | | The message that will be displayed when the directory is empty. Default: Directory is empty. | | theme | See Theming | | The theme to use for the file selector. | | ~~canceledLabel~~ | ~~string~~ | | Deprecated: Use cancelText instead. Will be removed in the next major version. | | ~~noFilesFound~~ | ~~string~~ | | Deprecated: Use emptyText instead. Will be removed in the next major version. |

Theming

You can theme a prompt by passing a theme object option. The theme object only need to includes the keys you wish to modify, we'll fallback on the defaults for the rest.

type FileSelectorTheme = {
  icon: {
    /**
     * The prefix to use for the line.
     * @default isLast => isLast ? └── : ├──
     */
    linePrefix: (isLast: boolean) => string
  }
  style: {
    /**
     * The style to use for the disabled items.
     * @default chalk.dim
     */
    disabled: (text: string) => string
    /**
     * The style to use for the active item.
     * @default chalk.cyan
     */
    active: (text: string) => string
    /**
     * The style to use for the cancel text.
     * @default chalk.red
     */
    cancelText: (text: string) => string
    /**
     * Alias for `emptyText`.
     * @deprecated Use `emptyText` instead. Will be removed in the next major version.
     */
    noFilesFound?: (text: string) => string
    /**
     * The style to use for the empty text.
     * @default chalk.red
     */
    emptyText: (text: string) => string
    /**
     * The style to use for items of type directory.
     * @default chalk.yellow
     */
    directory: (text: string) => string
    /**
     * The style to use for items of type file.
     * @default chalk.white
     */
    file: (text: string) => string
    /**
     * The style to use for the current directory header.
     * @default chalk.magenta
     */
    currentDir: (text: string) => string
    /**
     * The style to use for the key bindings help.
     * @default chalk.white
     */
    help: (text: string) => string
    /**
     * The style to use for the keys in the key bindings help.
     * @default chalk.cyan
     */
    key: (text: string) => string
  }
}

Examples

For examples look in the examples/ directory. You can execute the examples using node.

cd examples/
node <example-name>.js

[!NOTE] Before running the examples, make sure you have installed the dependencies with npm install and compiled the project with npm run build.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am "feat: my new feature"
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

[!NOTE] The commit message should follow the Conventional Commits specification.

Copyright & License

© 2024 Brian Fernandez

This project is licensed under the MIT license. See the file LICENSE for details.