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

meow-inquirer

v1.0.1

Published

The `meow-inquirer` package combines the CLI-argument-parsing capabilities of [`meow`](https://www.npmjs.com/package/meow) and user-prompting capabilities of [`inquirer`](https://www.npmjs.com/package/inquirer) packages. The current implementation is quit

Downloads

3

Readme

Meow-Inquirer

The meow-inquirer package combines the CLI-argument-parsing capabilities of meow and user-prompting capabilities of inquirer packages. The current implementation is quite opinionated as it also provides some uncustomizable printing functionality. The runtime validation framework is also currently fixed to be @effect/schema. Both of the opinions may (likely) become customizable later.

The philosophy behind this package is to define one place where the shape of the input is defined in an somewhat abstract way. This shape is then given to this package, and it will collect what it can from CLI arguments, and prompt for the rest from user. As a result, the user of this package receives the validated object, and thus can proceed to actual purpose of the code (s)he is writing.

Usage

Most of the times using createCLIArgsAndCollectInput is the way to use this library:

import * as mi from "meow-inquirer";
import * as S from "@effect/schema/Schema";

const inputSpec = {
  // This simple example just has one parameter
  parameter: {
    // This is the parameter validation spec (as opposed to specifying message to be printed to user, see library docs for more info)
    type: mi.TYPE_VALIDATE,
    // The properties of inputSpec will be iterated using orderNumber provided here
    orderNumber: 0,
    // The final type of the parameter
    schema: S.string,
    // The type of 'prompt' is DistinctQuestion from "inquirer" module
    prompt: {
      type: "input",
      message: "Please enter value for parameter",
    },
  }
}
// This line is important!
// It will make custom type out of shape of 'inputSpec', while still making sure that it adhers to InputSpec of "meow-inquirer" library!
as const satisfies mi.InputSpec;

// Calling this will use "meow" library to parse the CLI arguments,
// and print auto-generated help message and exit if `--help` specified.
// Otherwise, the "parameter" CLI flag is attempted to be extracted.
// If it is not passed, the user will be prompted for its value using "prompt"
// object as shown above.
// Finally, a validated object of type { parameter: string } is returned, along with package root directory.
const { validatedInput, packageRoot } = await mi.createCLIArgsAndCollectInput({
  // The input specification declared above
  inputSpec,
  // The import.meta of this module
  importMeta: import.meta,
  // We don't use dynamic values in this simple example
  getDynamicValueInput: () => undefined,
  // For this simple example, it is enough to return schema-validated input as-is
  inputValidator: (input) => Promise.resolve(input),
});

For more complex examples, feel free to check documentation of InputSpec type, take a look how it is used in @ty-ras/start library here and here, or just explore the library by examining JSDoc and code via npm package.