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

command-line-publish

v1.1.0

Published

Convert `command-line-usage` JSON or JavaScript ESM into HTML or SVG files

Downloads

105

Readme

command-line-publish

Tool to convert command-line-args/command-line-usage JSON arrays to SVG or HTML.

Install

npm install -D command-line-publish

CLI Usage

command-line-publish <args>

or:

clp --format=html --config="jsWithSectionsExport.js" "cli.html"
clp --format=svg --config="jsonWithSectionsProperty.json" "cli.svg"

And here is the documentation generated by our use of command-line-publish on itself.

First as HTML:

And then as embeddable SVG (not copy-pasteable on the README, but it is if you click the image or visit the file directly):

cli.svg

After using the commands to generate, you can:

  • Link to the HTML, e.g., as we did above: [cli.html](https://brettz9.github.io/command-line-publish/cli.html)
  • Embed the SVG, e.g., as we did above: ![cli.svg](https://brettz9.github.io/command-line-publish/cli.svg) (If you are not on Github Pages, you may, in the case of SVG, also use the form: ![cli.svg](https://raw.githubusercontent.com/brettz9/command-line-publish/master/cli.svg?sanitize=true) (Applying for HTML will only show the raw source.))

Note that we have configured this repository's master branch to have its contents served from Github Pages.

Programmatic usage

import {html, svg} from 'command-line-publish';

// This JavaScript (or JSON) file must export a `sections` property,
//  and for easier reusability, it is recommended that ths same file
//  define a `definitions` property for use by `command-line-args`
import {sections} from './path/to/config-file.js';

// The options objects are optional
svg(sections, {target: 'cli.svg', ansiToSvgOptions: {}});
html(sections, {target: 'cli.html', ansiToHtmlOptions: {}});

Here is a sampling of our own config file:

import {readFile} from 'fs/promises';

const pkg = JSON.parse(
  await readFile(new URL('../package.json', import.meta.url))
);

const optionDefinitions = [
  {
    name: 'target', alias: 't', type: String, defaultOption: true,
    description: 'The file path target to which to write the result',
    typeLabel: '{underline file-path}'
  },
  // ... snipped
  {
    name: 'help', alias: 'h', type: Boolean,
    description: 'Display this help guide'
  }
];

const cliSections = [
  {
    // We're now actually letting `command-line-basics auto-generate the
    //  `header` now
    header: pkg.name,
    // Add italics: `{italic textToItalicize}`
    content: pkg.description +
      '\n\n{italic clp -c="configPath" [--format=svg|html] target}'
  },
  {
    // We're now actually letting `command-line-basics auto-generate the
    //  `header` now
    header: 'Options',
    optionList: optionDefinitions
  }
];

export {optionDefinitions as definitions, cliSections as sections};

See also