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

scarfold

v0.0.7

Published

Nodejs utility for scaffolding custom templates

Downloads

1

Readme

Scarfold

Node CLI Utility for scaffolding source files from custom Handlebars templates

Installation

$ npm install -g scarfold

or

$ yarn global add scarfold

Quickstart

  1. scarfold init
  2. add custom scaffolding commands to scarfold.json
  3. Run generation scarfold <template> --var1 value1 --var2 value2

Command reference


scarfold <template> [...options] [...vars]

Generates rendered template with provided values in vars

--override - Disable checking whether destination file already exists. Beware of accidental data loss.


scarfold init

Creates basic scarfold.json and templates folder.


Template syntax

The templates use standard Handlebars.js syntax which can be found here. Also check out examples.

{{ variable }}                      // render a value
{{{ variable }}}                    // render unescaped
{{#if variable }}...{{/if}}         // condition
{{#unless variable }}...{{/unless}} // negated condition

Also scarfold provides Handlebars helpers for working with different case conventions. This allows usage of one variable for multiple purposes (e.g. class name, file name, variable name ...) These are:

  • camelCase (variableIdentifierInCamelCase)
  • pascalCase (VariableIdentifierInPascalCase)
  • noCase (as is, just remove dashes from provided var)

These helpers requires variable to be provided in-snake-case. Specifiyng parameter '--someVar some-variable-name' and using helper {{camelCase someVar}} will render value someVariableName.

Description

Each scaffolding command has "render" and "vars" properties.

render - defines how templates are projected to rendered files. In the example, template "textfile.txt" will be transformed to file "test/src/{{name}}.txt" (note paths can be also templated using standard Handlebars syntax).

vars - user defined parameters which can be supplied as command line arguments. These values will be passed to template engine.

Vars can also contain options default, if specified, the var will be considered optional and if not provided through CLI default value will be used.

Example configuration

This configuration defines following:

  • templateFolder - folder where users templates are stored (default: "templates")
  • scaffolding - user defined commands which will be used to generate templates.
  • scaffolding.textfile - scaffolding command

In example config "textfile" command is defined. user invokes this scaffolding command by scarfold textfile --name SomeName --status SomeStatus

{
  "templateFolder": "templates",
  "scaffolding": {
    "textfile": {
      "render": [
        {
          "template": "textfile.txt",
          "dest": "test/src/{{name}}.txt"
        },
        {
          "template": "textfile2.txt",
          "dest": "test/src/{{name}}2.txt"
        }
      ],
      "vars": {
        "name": { },
        "status": {
          "default": "simple"
        }
      }
    }
  }
}

Development

Compilation - yarn build

Dev compilation watcher - yarn dev

Run tests - yarn test

Todos

  • CI
  • var type coercion (typed parameter)
  • support arrays
  • support complex types ?
  • ???
  • profit