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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-symfony-console

v0.0.8

Published

Symfony Console Component ported to Node

Readme

Node Symfony Console

This is a straight port of Symfony's Console Component v5.1. Augmented with the spinner functionality largely inspired by alecrabbit/php-console-spinner

Although fully functional, this is very much WIP.

Usage

Eventually we will write ported documentation. For now follow Console Component v5.1 documentation and translate the examples to JS.

 // Most used classes are accessible as direct imports
const {
 Terminal,
 Application,
 SingleCommandApplication,
 Command,
 Question,
 ConfirmationQuestion,
 ChoiceQuestion,
 ProgressBar,
 ProgressIndicator,
 Table,
 TableStyle,
 Output,
 Input,
 InputArgument,
 InputOption,
 Spinner,
 SpinnerFrames} = require('node-symfony-console');
// All of the underlying classes can be accessed throught the console export. Follow the
// original PhP namespace class paths.

const { console }    = require('node-symfony-console');

// PHP Class \Symfony\Component\Console\Helper\HelperSet
const HelperSet      = console.helper.HelperSet;     

// PHP Class \Symfony\Component\Console\Tester\CommandTester
const CommmandTester = console.tester.CommandTester; 

Hello World Example

Create a command

const { Command, InputArgument, ConfirmationQuestion } = require('node-symfony-console');

class GreetCommand extends Command {
  static get defaultName() {
    return 'foo:helloworld';
  }

  configure() {
    this
      // the short description shown while running "node bin/console list"
      .setDescription(`Print hello world`)
      // the full command description shown when running the command with
      // the "--help" option
      .setHelp('Print hello world, pass argument')
      .addArgument('name', InputArgument.REQUIRED, 'Who do you want to greet?')
      .addArgument('last_name', InputArgument.OPTIONAL, 'Your last name?');
  }

  async execute(input, output) {
  
      // Do something asynchronous like an API call or 
      // asking a question
      const q = new ConfirmationQuestion('<info>Are you leaving</info> (y/n): ');
      const leaving = await this.getHelper('question').ask( input, output, q);
      
      let greet = `${leaving?'Good Bye':'Hi'} ${input.getArgument('name')}`;
      const lastName = input.getArgument('last_name');
      
      if (lastName) {
        greet = `${greet} ${lastName}`;
      }
  
      output.writeln(`${greet}!`);
      return 1;
    }
}

module.exports = GreetCommand;

Create a application and include the command. This can be any file IE: bin/console.js

const {Application} = require('node-symfony-console');
const GreetCommand = require('./GreetCommand');

const application = new Application();
application.add(new GreetCommand());
application.run();

Run the command:

$ node bin/console.js
Console Tool

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  help            Displays help for a command
  list            Lists commands
 foo
  foo:helloworld  Print hello world

$ node bin/console.js foo:helloworld Jeroen
Are you leaving (y/n): n
Hi jeroen!

$ node bin/console.js foo:helloworld Jeroen "de Lau"
Are you leaving (y/n): y
Good Bye Jeroen de Lau!

Known omissions and limitations

Porting changes:

  • Interfaces have been removed
  • Abstract classes have been converted to regular classes
  • PhP associative arrays do not always translate well to JS {} or []
  • Itterable support is spotty, WIP
  • Node requires not separate multibyte support for most situations, in general these functions were stripped
  • Terminal Capability detection was quite specific to PhP, tested on Mac, on other terminals millage may vary
  • Exception classes have been renamed to Error
  • Not all Exceptions types have been ported, instead using generic throw Error
  • Verbosity constants can be found in Output const {Output} = require('node-symfony-console')

Omissions: Following have not (yet) been ported

Contributing

Contributions are welcome! Most of the tests have been written in JS.

Resources

Credits

This library is converted from Symfony's Console Component: Find sources and license at https://github.com/symfony/component

This library uses code from the spinner library Find sources and license at https://github.com/alecrabbit/php-console-spinner