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

vue-gue

v0.2.0

Published

Vue component generator

Downloads

8

Readme

Gue Build Status Coverage Status

Vue js component generator

Demo

Features

  • 📜 Generate Vue component
  • 🧰 Generate test file for the component
  • ⚙️ Dynamic path for component
  • 📁 Configurable root directory for components and tests
  • 📝 Custom templates for components and test

Installing

Note that this package is published under name of vue-gue

npm i -g vue-gue

Getting started

Head over to root of your project in terminal, say you want to create a component named footer:

gue footer

This will generate footer component in ./src/components/footer.vue

Change directory of component

You can define a directory which you want your component to be generated in.

gue tab ./menu

This will generate tab component in ./menu/tab.vue

Consider behavior of directory parameter when you have a config file and you don't. details
For a consistent way to change root directory of components see config.

Generate test file

Now if you want a component and also it's corresponding unit test file you can do:

gue footer -u

This will generate footer component in ./src/components/footer.vue and also a test file in ./tests/unit/footer.js

To change any of these directories see config

Usage

General usage is like:

$ gue --help

  Usage: gue <componentName> [direcroty] [options]

  Options:
    -u, --unit             create unit test of the component too
    -t, --template <name>  define which template to use
    -h, --help             output usage information
  • <componentName> is mandatory.
  • [directory] is optional, and is a relative path. If you have a config file this will be a subdirectory of your componentRoot If you don't, then this will lead to generation of component in exact direcroty
  • [options] are optional, available options are -u which will generate test file, and -t which is used to define which template for components to use.

Config file

Gue accepts a config file to change default settings. In root directory of project make a file gue.json, and Gue will automatically recognize and use it.

Options

Here are available options for config file:

  • componentRoot: root directory which components will be generated in. should be relative path.
  • componentSource: path to custom component template. Or an object to define multiple templates.
  • unitRoot: directory which test will be generated in. should be a relative path.
  • unitSource: path to custom test file template.

An example of a config file with all options:

{
  "componentRoot":"./front-end/src/components",
  "unitRoot":"./front-end/test",
  "componentSource":"./myTemplates/myVueTemplate.vue",
  "unitSource":"./myTemplates/myTestTemplate.js"
}

Now if you run gue to create a clock component in your project, it'll generate it in ./front-end/src/components/clock.vue. If you run following command in the same project:

gue title ./header

Will generate ./front-end/src/components/header/title.vue

Custom templates

As said you can use custom templates in Gue, define path to them with componentSource and unitSource so that Gue will use them instead of it's default ones.

Variables

In your component template you can use variable <%NAME%> and Gue will replace it with name of component when generating. And also in test template you use <%NAME%> and <%PATH%> which will be replaced with path where component is located, relative to path of test file. Here is an example of custom component template:

<template>
  <div class="app">
    Hey I'm a component generated with Gue, my name is <%NAME%>
  </div>
</template>

export default {
name: "<%NAME%>",
data() {
  return {
    someData: "a sample"
  }
}
<style scoped>
</style>

To see other examples look at templates folder.

Using multiple custom templates

You can use multiple custom templates. So componentSource can be object (multiple templates) or a string (single template). Multiple templates can be created like:

{
  "componentSource": {
    "component"  :  "./tmps/component.vue",
    "page"  :  "./tmps/page.vue"
  }
}

And when using Gue you have to tell it which component template to use:

gue menu -t component
gue setting ./pages -t page

You can define one of your templates as default one, so that you don't have to type -t every time. Default component can be specified with :default postfix:

{
  "componentSource": {
    "component:default"  :  "./tmps/component.vue",
    "page"  :  "./tmps/page.vue"
  }
}

Now if you type any command without -t, component template will be used.

gue foo 

Will use component template to generate foo component. No need of -t component