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

vip-cli

v1.0.3

Published

A simple CLI for scaffolding Vue.js projects in VIPS.

Downloads

37

Readme

vip-cli Build Status npm package

A simple CLI for scaffolding Vue.js projects in VIPS, extended from vue-cli by yyx.

Installation

Prerequisites: Node.js and Git.

$ npm install -g vip-cli

Usage

$ vip init <template-name> <project-name>

Example:

$ vip init vips vip-project
$ cd vip-project
$ npm install
$ npm run dev

The above command pulls the template from vip-fe-sh/template-vips, prompts for some information, and generates the project at ./vip-project/.

VIPS Templates

Current available templates include:

  • vips - A full-featured Webpack setup with hot-reload, linting, css extraction, vue-resource & vuex.

  • vipsr - A full-featured Webpack setup with hot-reload, linting, css extraction, vue-resource, vuex & vue-router.

Official Templates

The purpose of official Vue project templates are to provide opinionated, battery-included development tooling setups so that users can get started with actual app code as fast as possible. However, these templates are un-opinionated in terms of how you structure your app code and what libraries you use in addition to Vue.js.

All official project templates are repos in the vuejs-templates organization. When a new template is added to the organization, you will be able to run vip init <template-name> <project-name> to use that template. You can also run vip list to see all available official templates.

Current available templates include:

  • webpack - A full-featured Webpack + vue-loader setup with hot reload, linting, testing & css extraction.

  • webpack-simple - A simple Webpack + vue-loader setup for quick prototyping.

  • browserify - A full-featured Browserify + vueify setup with hot-reload, linting & unit testing.

  • browserify-simple - A simple Browserify + vueify setup for quick prototyping.

  • simple - The simplest possible Vue setup in a single HTML file

Custom Templates

It's unlikely to make everyone happy with the official templates. You can simply fork an official template and then use it via vip-cli with:

vip init username/repo my-project

Where username/repo is the GitHub repo shorthand for your fork.

The shorthand repo notation is passed to download-git-repo so you can also use things like bitbucket:username/repo for a Bitbucket repo and username/repo#branch for tags or branches.

If you would like to download from a private repository use the --clone flag and the cli will use git clone so your SSH keys are used.

Local Templates

Instead of a GitHub repo, you can also use a template on your local file system:

vip init ~/fs/path/to-custom-template my-project

Writing Custom Templates from Scratch

  • A template repo must have a template directory that holds the template files.

  • A template repo may have a metadata file for the template which can be either a meta.js or meta.json file. It can contain the following fields:

    • prompts: used to collect user options data;

    • filters: used to conditional filter files to render.

    • completeMessage: the message to be displayed to the user when the template has been generated. You can include custom instruction here.

prompts

The prompts field in the metadata file should be an object hash containing prompts for the user. For each entry, the key is the variable name and the value is an Inquirer.js question object. Example:

{
  "prompts": {
    "name": {
      "type": "string",
      "required": true,
      "message": "Project name"
    }
  }
}

After all prompts are finished, all files inside template will be rendered using Handlebars, with the prompt results as the data.

Conditional Prompts

A prompt can be made conditional by adding a when field, which should be a JavaScript expression evaluated with data collected from previous prompts. For example:

{
  "prompts": {
    "lint": {
      "type": "confirm",
      "message": "Use a linter?"
    },
    "lintConfig": {
      "when": "lint",
      "type": "list",
      "message": "Pick a lint config",
      "choices": [
        "standard",
        "airbnb",
        "none"
      ]
    }
  }
}

The prompt for lintConfig will only be triggered when the user answered yes to the lint prompt.

Pre-registered Handlebars Helpers

Two commonly used Handlebars helpers, if_eq and unless_eq are pre-registered:

{{#if_eq lintConfig "airbnb"}};{{/if_eq}}
Custom Handlebars Helpers

You may want to register additional Handlebars helpers using the helpers property in the metadata file. The object key is the helper name:

module.exports = {
  helpers: {
    lowercase: str => str.toLowerCase()
  }
}

Upon registration, they can be used as follows:

{{ lowercase name }}

File filters

The filters field in the metadata file should be an object hash containing file filtering rules. For each entry, the key is a minimatch glob pattern and the value is a JavaScript expression evaluated in the context of prompt answers data. Example:

{
  "filters": {
    "test/**/*": "needTests"
  }
}

Files under test will only be generated if the user answered yes to the prompt for needTests.

Note that the dot option for minimatch is set to true so glob patterns would also match dotfiles by default.

License

MIT