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

cortojs

v1.21.1

Published

corto ===

Downloads

10

Readme

corto

Boilerplate app snippets

Quick start

# Inits a new corto
corto init --directory ./my-template

# Add a corto file
cat <<README > ./my-template/README.md
{{ def.name }}
===

{{ def.about }}
README

# Installs new corto
corto install \
  --from ./my-template \
  --target ./foo \
  --def.name project \
  --def.about 'a cool project'

# Verifies interpolation worked
cat ./foo/README.md
project
===

a cool project

You can configure stuff like default values and hooks:

  • via cli arguments
  • via a config file (default is a corto.json file inside the template's folder)

If both are used, cli arguments gets precedence but not exclusivity, meaning configurations will be merged.

Install

# Install from local directory
corto install /path/to/templates
# Install git from http
corto install http://github.com/corto/parceljs
# Install git from ssh
corto install [email protected]:corto/parceljs

Options

We use clipop for declaring options

corto install <corto>              
  # Permits copying inside already existing directories
  --allow-exists      boolean 
  # Permits copying over non-empty directories
  --allow-non-empty   boolean  
  # Path to a json file with corto config
  --config            string   
  # Dictionnary of substitutions
  --def               object<string>
  # Dictionnary of extra
  --extra             object<string>
  # Do not apply configuration from corto.json
  --ignore-config     boolean  
  # Hooks (view below)
  --hooks             object  
  # Dictionnary of options
  --opt               object<string>
  # Regular expression to use for interpolation
  --pattern           string
  # Strategy used for stumbling upon existing locations
  --strategy          string
  # Fine grain strategies
  --strategies        object<string>[]
  # Output verbosity
  --verbose           boolean

corto.json

All these properties (except config) can saved inside a corto.json. Just camel case option names:

{
  "corto": {
    "name": "mycorto",
    "version": "1.0.0"
  },
  "allowExists": false,
  "pattern": "<(.+)>",
  "required": {
    "field": true
  },
  "def": {
    "name": "some default name"
  },
  "hooks": {
    "pre": [
      "git init"
    ],
    "post": [
      "git add .",
      "git commit -am First",
      "npm install"
    ]
  }
}

Hooks

Hooks can be applied before everything (pre) or after everything (post)

Hook literal commands

Hooks are commands that are run inside the target directory, for example:

npm install

Hook template commands

You can also use templating:

{
  "opt": {
    "packageManager": "npm" // default package manager
  },
  "schema": {
    "packageManager": {
      "oneOf": ["npm", "yarn"] // setting accepted package managers
    }
  },
  "hooks": {
    "post": [
      // install node dependencies
      "{{ opt.packageManager }} install"
    ]
  }
}
corto install ./my-corto --opt.packageManager yarn # will use yarn instead of npm

Command interface

There is a limitation to string literals: they don't encapsulate between-quotes content, so the following command:

do-something --command 'do something cool'

will be run such as:

"do-something" "--command" "do" "something" "cool"

To work around that problem, you can use the command interface (templating allowed):

{
  "opt": {
    "score": 0
  },
  "hooks": {
    "post": [
      {
        "command": "do-something",
        "args": [
          "--command",
          "do something cool"
        ],
        "condition": "opt.score > 100" // optional
      }
    ]
  }
}

Loop support

{
  "opt": {
    "path": "a/bc/d/d/e/f"
  },
  "hooks": {
    "pre": [
      {
        "for": "opt.path.split('/')",
        "each": "mkdir {{ item }}"
      }
    ]
  }
}

Basic fs support