Socket
Socket
Sign inDemoInstall

@calidae/vue-generate-component

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@calidae/vue-generate-component

Vue js component generator


Version published
Weekly downloads
16
increased by166.67%
Maintainers
4
Weekly downloads
 
Created
Source

Vue js component generator

Developed upon the work of vue-generate-component.

CLI util for easy generate Vue component structure.

Installation

npm install -g @calidae/vue-generate-component

If you want to try it out without polluting your global npm, you can use npx:

npx @calidae/vue-generate-component [ARGUMENTS]

Usage

Create new component

vgc Footer

Will generate a folder called Footer in your current directory with three files:

index.js

import Footer from './Footer'

export default Footer

Footer.vue

<template>
  <div class="Footer">
    
  </div>
</template>

<script>
export default {
  name: 'Footer',
  data () {
    return {}
  }
}
</script>

<style lang="scss" scoped>

</style>

Footer.spec.js

import Footer from './index.js'
import { mount } from '@vue/test-utils'

describe('Footer.vue', () => {
  it('is a component', () => {
    const wrapper = mount(Footer)
    expect(wrapper.isVueInstance()).toBeTruthy()
  })

  it('renders main node', () => {
    const wrapper = mount(Footer)
    expect(wrapper.classes()).toContain('Footer')
  })

  it('renders a snapshot', () => {
    const wrapper = mount(Footer)
    expect(wrapper.html()).toMatchSnapshot('default')
  })
})

Creating a folder with Container Component

If you want to replicate the structure outlined above but adding a Container component, add the container flag:

vgc Footer --container

In addition to previously outlined files, this command will modify index.js:

index.js

import FooterContainer from './FooterContainer'

export default FooterContainer

and create 2 new files:

FooterContainer.vue

<template>
  <Footer />
</template>

<script>
import Footer from './Footer'

export default {
  name: 'FooterContainer',
  components: {
    Footer
  },
  data () {
    return {}
  }
}
</script>

FooterContainer.spec.js

import FooterContainer from './FooterContainer'
import { mount } from '@vue/test-utils'

describe('FooterContainer.vue', () => {
  it('is a component', () => {
    const wrapper = mount(FooterContainer)
    expect(wrapper.isVueInstance()).toBeTruthy()
  })

  it('renders a snapshot', () => {
    const wrapper = mount(FooterContainer)
    expect(wrapper.html()).toMatchSnapshot('default')
  })
})

Disclaimer

This project tries to solve tedious copy&paste operations from our daily workflow. Please notice that the generated files will require some external libraries such as Vue, @vue/test-utils or Sass loader configuration. Make sure these libraries are available in your project.

TODO

  1. Add tests(!)
  2. Add ability to define folder path (now it only creates a folder in the current directory)
  3. swig@1.4.2 is no longer maintained
  4. ...

Keywords

FAQs

Package last updated on 09 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc