• Stars
    star
    220
  • Rank 174,831 (Top 4 %)
  • Language
    JavaScript
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vue js component generator

Vue js component generator Awesome

CLI util for easy generate Vue js component

Installation

npm install -g vue-generate-component

Usage

vgc --help

Create new component

vgc footer

Will generate five files:

footer.js

export default {
  name: 'footer',
  props: [],
  mounted() {},
  data() {
    return {};
  },
  methods: {},
  computed: {}
};

footer.spec.js

import Vue from 'vue';
import FooterComponent from './index.vue';

// Here are some Jasmine 2.0 tests, though you can
// use any test runner / assertion library combo you prefer
describe('FooterComponent', () => {
  // Inspect the raw component options
  it('has a created hook', () => {
    // expect(typeof FooterComponent.created).toBe('function');
  });
  // Evaluate the results of functions in
  // the raw component options
  it('sets the correct default data', () => {
    // expect(typeof FooterComponent.data).toBe('function')
    // const defaultData = FooterComponent.data();
    // expect(defaultData.message).toBe('hello!');
  });
  // Inspect the component instance on mount
  it('correctly sets the message when created', () => {
    // const vm = new Vue(FooterComponent).$mount();
    // expect(vm.message).toBe('bye!');
  });
  // Mount an instance and inspect the render output
  it('renders the correct message', () => {
    // const Ctor = Vue.extend(FooterComponent);
    // const vm = new Ctor().$mount();
    // expect(vm.$el.textContent).toBe('bye!');
  });
});

footer.html

<section class="footer">
  <h1>footer Component</h1>
</section>

footer.scss

.footer {
}

index.vue

<template src="./footer.component.html"></template>
<script src="./footer.component.js"></script>
<style src="./footer.component.scss" scoped lang="scss"></style>

Create new component single file

vgc -s home

will generate one vue file:

<template lang="html">
  <section class="home">
    <h1>home Component</h1>
  </section>
</template>

<script lang="js">
  export default  {
    name: 'home',
    props: [],
    mounted() {

    },
    data() {
      return {

      }
    },
    methods: {

    },
    computed: {

    }
}
</script>

<style scoped lang="scss">
  .home {

  }
</style>

Create new component single file inside new folder

vgc -s home --folder

Create new directive

vgc -d my-directive

will generate:

my-directive.directive.js

import Vue from 'vue';

Vue.directive('my-directive', {
  bind() {},
  // When the bound element is inserted into the DOM...
  inserted(el) {
    // el.focus();
  },
  update() {},
  unbind() {}
});

If you want use postfix in file name, use -- postfix

vgc footer --postfix page

Will generate files with postfix:

  • footer.page.js
  • footer.page.css
  • footer.page.html
  • footer.page.spec.js

Change the default file types for html, style, script, and spec

sudo vgc --html jade --style less --script ts --spec ts

Contribute

If you want to fix/improve the templates you're welcome to create a PR.

More Repositories

1

helpful-decorators

Helpful decorators for typescript projects
TypeScript
397
star
2

ngx-auto-unsubscribe

Class decorator that will automatically unsubscribe from observables
TypeScript
346
star
3

ngrx-generator

ngrx templates generator
TypeScript
131
star
4

ng-file-upload

TypeScript
52
star
5

paginate-array

Array pagination
JavaScript
41
star
6

angular2-take-until-destroy

Declarative way to unsubscribe from observables when the component destroyed
TypeScript
38
star
7

ng-suspense

TypeScript
36
star
8

nb-choices

Angular wrapper for choices.js, vanilla, lightweight, configurable select box/text input plugin
TypeScript
33
star
9

ng-select

TypeScript
23
star
10

transloco-with-nx-libs

inline loaders
TypeScript
21
star
11

akita-ng-forms-manager

😍 Manage Angular forms with Akita
TypeScript
21
star
12

ng2cli

Angular 2 cli generator
JavaScript
18
star
13

ngrx-todos-full

ngrx-todos-full
TypeScript
18
star
14

cyrun

cypress run that lets you select files or folders to run
JavaScript
15
star
15

ngx-event-modifiers

Event Modifiers for Angular Applications https://netbasal.com/implementing-event-modifiers-in-angular-87e1a07969ce
TypeScript
14
star
16

ivy-lazy-components

TypeScript
13
star
17

ngx-stop-propagation

✋ Stop propagation for everyday events with Angular directives 🎩
JavaScript
13
star
18

ngx-mobx

Mobx decorators for Angular Applications
TypeScript
13
star
19

angular-forms-unsaved-changes

TypeScript
10
star
20

angular2-storage-sync

Angular2 decorator to sync properties automatically from/to LocalStorage or SessionStorage
JavaScript
9
star
21

spectator-cli

Spectator templates generator
Smarty
8
star
22

ngrx-todos

Todo app with ngrx/store and ngrx/effects
TypeScript
8
star
23

ng-accordion-tutorial

TypeScript
7
star
24

ngx-text-equality-validator

Angular, compare text fields validator - useful for password match fields
JavaScript
6
star
25

akita-vue

TypeScript
5
star
26

rxjs-event-emitter

Event Emitter based on RxJS
TypeScript
4
star
27

akita-cli

JavaScript
4
star
28

akita-ng-devtools

TypeScript
4
star
29

ngrx-chat-client

TypeScript
3
star
30

angular2-shave

Angular 2 wrapper directive for shave - A modern javascript plugin for truncating text within a html element
JavaScript
3
star
31

transloco-ssr

TypeScript
3
star
32

angular2-text-equality-validator

Angular 2 compare text fields validator - useful for password match fields
TypeScript
3
star
33

ng-autocomplete

TypeScript
3
star
34

angular2-package-starter

Easy to use package starter for Angular 2
TypeScript
2
star
35

react-elf-movies

TypeScript
2
star
36

transloco-plugins-playground

TypeScript
2
star
37

efi-lum

TypeScript
2
star
38

ng-webpack-playground

TypeScript
2
star
39

ngrx-chat-server

JavaScript
2
star
40

akita-multi-active

TypeScript
1
star
41

audioCodesNetanel

CSS
1
star
42

ngx-in-view

JavaScript
1
star
43

circleci

TypeScript
1
star
44

zillow

zillow
JavaScript
1
star
45

paginate-array-ts

Pagination for arrays in javascript
TypeScript
1
star
46

transloco-keys-manager-playground

TypeScript
1
star
47

6to5boilerplate

6to5boilerplate
JavaScript
1
star
48

angular-fakeasync

HTML
1
star
49

polls

polls
JavaScript
1
star
50

akita-auth

TypeScript
1
star