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

sitevision-tools

v0.2.4

Published

Scaffolding and other miscellaneous tools for Sitevision development.

Downloads

9

Readme

Sitevision Tools

A command line interface with various utilities for Sitevision development.

Currently in development (v0.x.x) and might have breaking changes in minors until v1.

Commands

See Command Reference for sitevision-tools.

Usage

Example 1: Initialize and create a React component in a Sitevision webapp directory

Initialize sitevision-tools in a Sitevision webapp directory root and create a new react component with a stylesheet.

cd ~/projects/some-webapp
sitevision-tools init
sitevision-tools generate component "Product carousel" --styles

This will create the following files (depending on project configuration):

~/projects/some-webapp/src/components/ProductCarousel/ProductCarousel.js
~/projects/some-webapp/src/components/ProductCarousel/index.js
~/projects/some-webapp/src/components/ProductCarousel/ProductCarousel.scss

Example 2: Initialize Sitevision Tools for a Sitevision website project and create files for a script module

Initialize sitevision-tools in a directory containing source files for a Sitevision website project, and creates a directory with files for a script module.

cd ~/projects/a-sitevision-site
sitevision-tools init
sitevision-tools generate script "Social links menu" --styles --js --vars "menuRootMeta,iconFileMeta,iconIdMeta"

This will create the following files (depending on project configuration):

~/projects/a-sitevision-site/social-links-menu/social-links-menu-server.js
~/projects/a-sitevision-site/social-links-menu/social-links-menu.vm
~/projects/a-sitevision-site/social-links-menu/social-links-menu-client.js
~/projects/a-sitevision-site/social-links-menu/social-links-menu.css

And social-links-menu-server.js will also contain the following configuration object for the script variables:

/**
 * Contains configuration settings.
 * @type {Object}
 */
const settings = {
  menuRootMeta: (scriptVariables.menuRootMeta != null) ? scriptVariables.menuRootMeta : null,
  iconFileMeta: (scriptVariables.iconFileMeta != null) ? scriptVariables.iconFileMeta : null,
  iconIdMeta: (scriptVariables.iconIdMeta != null) ? scriptVariables.iconIdMeta : null,
};

Configuration

A configuration file is created with the command sitevision-tools init and is placed in the current working directory as .sitevision-toolsrc.json. Sitevision Tools uses cosmiconfig to find configuration files and the first found will determine the project root. Configurations found further up the structure will be merged in with the most specific values (configuration closest to project root) taking precedence. In this way, you can place generic configuration such as author name/email in your dev/projects folder and have more project specific configuration in your project root.

Please note that cosmiconfig does not load multiple configuration files from the same directory. So do make sure that only one configuration file exists in your directory.

Custom generators

Custom generators can easily be added through configuration. Simply add a generator in your configuration under the key path sitevision-tools.generators. The key used will be the name of the generator.

In most cases, your custom generators will most likely only generate files based of templates. When that is the case, you can use the signature for a SimpleGenerator (see src/types.ts).

When you need to do more than a SimpleGenerator allows, you will have to create a GeneratorWrapper. A GeneratorWrapper is a function which takes the GluegunToolbox as an argument and returns a Generator. A basic example of a GeneratorWrapper and a SimpleGenerator is provided below.

// ~/.sitevision-toolsrc.js

module.exports = {
  'sitevision-tools': {
    generators: {
      custom: (toolbox) => ({
        async run () {
          toolbox.print.info('This is a custom generator.')
          // Logic here
        },
        description: 'A description for the custom generator which will be shown in the list of available generators.',
        help: (toolbox) => {
          toolbox.print.info('Some helpful information about this custom generator.')
        },
      }),
      simple: {
        files: [
          {
            template: 'component.js.ejs',
            target: 'component/${name.pascal}/${name.pascal}.js',
            condition: (toolbox) => toolbox.parameters.options.include,
          },
        ],
        context: (data, toolbox) => ({ ...data, customOption: toolbox.parameters.options.foo }),
        dir: '~/.sitevision-tools/templates/simple',
        description: 'A simple custom generator.',
        help: 'Some helpful information about this generator.',
      }
    },
  }
}

The examples above will be available with:

sitevision-tools generate custom <name>
sitevision-tools generate simple <name> --include --foo