JSPM

inquirer-code-prompts

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q39733F
  • License MIT

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

Package Exports

  • inquirer-code-prompts

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inquirer-code-prompts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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.