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

inquirer-code-prompts

v0.0.3

Published

Inquirer prompts plugins related to Code / Parsing / AST / TypeScript / JavasScript

Downloads

92

Readme

inquirer-code-prompts

Code / Parsing / AST TypeScript / JavasScript related inquirer plugins prompts

Initially part of ts-refactor project, now as individual reusable tools.

AST Explorer

User is prompted with TypeScript code and is able to navigate the AST nodes with arrows, type AST selectors to filter them, scroll long code text like unix less command, and finally press enter to select one node. The prompt result will be the ts.Node instance.

import { astExplorer, AstExplorer } from 'inquirer-code-prompts'
import { registerPrompt } from 'inquirer'

registerPrompt('ast-explorer', AstExplorer as any)
async function test() {
  const code = `
class Animal {
  constructor(public name: string) { }
  move(distanceInMeters: number = 0) {
    console.log('hello');
  }
}
class Snake extends Animal {
  constructor(name: string) { super(name); }
  move(distanceInMeters = 5) {
    console.log("Slithering...");
    super.move(distanceInMeters);
  }
}
    `
  const selectedNode = await astExplorer({ code })
  console.log({ selectedNode: selectedNode.getText() });

TODO: while user types selectors, it has autocompletion for known node kinds.

less

Show long texts to the user supporting vertical scrolling and text wrap so they can read in peace. Use arrow to scroll and any other key to exit. It doesn't return anything.

import {less, Less} form 'inquirer-less'
registerPrompt('less', Less as any)
await less({text: `long text possible with ansi styles`})

Files diff

Show several file's diff inquirering by folder/file and seeing diff with color individual files or the whole thing.

Example to come.

TODO

general

less parametrize the paginator bottom text

jsxExplorer

  • navigation with mouse ?

  • should print a breadcrumb and basic info when navigating nodes with arrows.

  • should let me visit all childs with arrows withouth filter - should allow to ignore the selector. If user delete all text then it won't filter and let me nav with arrows (see next)

  • should support hierarchical navigation, I can enter inside childs, and nav outside to ancestors keys: right - left arrows go to next node in order of start/pos in the sourceFile. If there is a selector they go to next/prev matched node up-down arrows.

  • with control will let me temporarily ignore the selector and move freely. when control is keyup it modifies the selector to match the current node