@calidae/vue-generate-component
v1.2.0
Published
Vue js component generator
Downloads
28
Readme
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 vue component file:
Footer.vue
<template>
<div class="footer">
Footer component
</div>
</template>
<script>
export default {
name: 'Footer',
data () {
return {}
}
}
</script>
<style scoped></style>
Creating a index.js to simplify the import statements
If you want to create a index.js to simplify the import statements simply add the --index
flag or use the alias -i
vgc Footer --index
vgc Footer -i
index.js
import Footer from './Footer'
export default Footer
Creating a boilerplate test file
If you want to create a **.spec.js test file as a boilerplate where start wrtiting your own tests simply add the --test
flag or use the alias -t
vgc Footer --test
vgc Footer -t
Footer.spec.js
import Footer from './index.js'
import { mount } from '@vue/test-utils'
describe('Footer.vue', () => {
it('renders main node', () => {
const wrapper = mount(Footer)
expect(wrapper.classes()).toContain('Footer')
})
})
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
- Add tests(!)
- Add ability to define folder path (now it only creates a folder in the current directory)
- [email protected] is no longer maintained
- ...