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

vitis

v1.0.1

Published

Static analysis across multiple repositories via plugins

Downloads

5

Readme

logo

vitis

Static analysis across multiple repositories via plugins.

Usage

$> npx vitis --foo-plugin --bar-plugin

Options

  • --compact - print the table in a more compact form
  • --json - print output as JSON instead of a table
  • --repos - folder containing repositories to analyze (default: ./repos)
  • --plugins - folder containing the available plugins (default: ./plugins)

The default directory structure would look like this:

/your-application
├── plugins
|  ├── packageName.js
|  ├── serverlessName.js
|  └── myOtherPlugin.js
├── repos
|  ├── my-first-repo
|  ├── my-second-repo
|  ├── my-third-repo
|  ├── my-fourth-repo
|  └── my-fifth-repo

Plugins

Plugins that are available in the plugins folder can be called as flags, ex. --my-plugin. For flag --my-plugin, the tool will look for a plugin named myPlugin.js in the ./plugins folder (or folder specified by the --plugins /path/to/somewhere flag).

Plugins will be called on each repository, and will receive an object with the following properties:

  • dir - the current directory
  • package - the contents of package.json, if it exists
  • serverless - the contents of serverless.yml (in JS object form), if it exists

Example:

module.exports = ({ dir, package, serverless }) => {
  // do something with the directory name, the package.json file,
  // or the serverless.yml contents.
  return 'hi';
};

The plugin should return a value to be displayed in the results table. If an error is thrown when evaluating a cell, that cell will contain err as the display value.

Note: there are no plugins included out of the box, you must create them yourself. However, there are some examples below to help you get started.

Examples

One of the simplest plugins is --package-name, which returns the name field from package.json. In ./plugins/packageName.js:

module.exports = ({ package }) => package ? package.name : 'N/A';

And the serverless version, --serverless-name:

module.exports = ({ serverless }) => serverless ? serverless.service : 'N/A';

When running both of these commands:

$> vitis --package-name --serverless-name

...you'll be able to quickly identify mismatches in your naming conventions and practices (perhaps they should match for searchability).

Other common yet simple plugins would be to return certain fields for all repositories for comparison, such as the version of a particular dependency (in reactVersion.js):

module.exports = ({ package }) => {
  if (!package) return 'N/A';

  const dependencies = package.dependencies || {};
  return dependencies['react'] || 'N/A';
};

which would print something like ^16.12.0.

Or return a particular serverless field, for maintenance purposes (awsNodeVersion.js):

module.exports = ({ serverless }) => {
  if (!serverless) return 'N/A';

  const provider = serverless.provider || {};
  return provider.runtime || 'N/A';
};

which would print something like nodejs12.x.

Security

Only run plugins you understand and trust.