{"id":13536297,"url":"https://github.com/NetanelBasal/vue-generate-component","last_synced_at":"2025-04-02T03:30:25.088Z","repository":{"id":57316426,"uuid":"75200497","full_name":"NetanelBasal/vue-generate-component","owner":"NetanelBasal","description":"Vue js component generator","archived":true,"fork":false,"pushed_at":"2020-06-04T15:25:02.000Z","size":386,"stargazers_count":223,"open_issues_count":9,"forks_count":79,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-09T23:06:33.043Z","etag":null,"topics":["components","generator","vuejs","vuejs2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NetanelBasal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-30T15:32:52.000Z","updated_at":"2024-06-01T15:33:35.000Z","dependencies_parsed_at":"2022-08-25T20:40:31.821Z","dependency_job_id":null,"html_url":"https://github.com/NetanelBasal/vue-generate-component","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fvue-generate-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fvue-generate-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fvue-generate-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NetanelBasal%2Fvue-generate-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NetanelBasal","download_url":"https://codeload.github.com/NetanelBasal/vue-generate-component/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246750727,"owners_count":20827773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["components","generator","vuejs","vuejs2"],"created_at":"2024-08-01T09:00:36.839Z","updated_at":"2025-04-02T03:30:24.828Z","avatar_url":"https://github.com/NetanelBasal.png","language":"JavaScript","funding_links":[],"categories":["辅助工具"],"sub_categories":[],"readme":"# Vue js component generator [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n\nCLI util for easy generate Vue js component\n\n## Installation\n\n```js\nnpm install -g vue-generate-component\n```\n\n## Usage\n\n```bash\nvgc --help\n```\n\n### Create new component\n\n```bash\nvgc footer\n```\n\nWill generate five files:\n\n**footer.js**\n\n```javascript\nexport default {\n  name: 'footer',\n  props: [],\n  mounted() {},\n  data() {\n    return {};\n  },\n  methods: {},\n  computed: {}\n};\n```\n\n**footer.spec.js**\n\n```javascript\nimport Vue from 'vue';\nimport FooterComponent from './index.vue';\n\n// Here are some Jasmine 2.0 tests, though you can\n// use any test runner / assertion library combo you prefer\ndescribe('FooterComponent', () =\u003e {\n  // Inspect the raw component options\n  it('has a created hook', () =\u003e {\n    // expect(typeof FooterComponent.created).toBe('function');\n  });\n  // Evaluate the results of functions in\n  // the raw component options\n  it('sets the correct default data', () =\u003e {\n    // expect(typeof FooterComponent.data).toBe('function')\n    // const defaultData = FooterComponent.data();\n    // expect(defaultData.message).toBe('hello!');\n  });\n  // Inspect the component instance on mount\n  it('correctly sets the message when created', () =\u003e {\n    // const vm = new Vue(FooterComponent).$mount();\n    // expect(vm.message).toBe('bye!');\n  });\n  // Mount an instance and inspect the render output\n  it('renders the correct message', () =\u003e {\n    // const Ctor = Vue.extend(FooterComponent);\n    // const vm = new Ctor().$mount();\n    // expect(vm.$el.textContent).toBe('bye!');\n  });\n});\n```\n\n**footer.html**\n\n```html\n\u003csection class=\"footer\"\u003e\n  \u003ch1\u003efooter Component\u003c/h1\u003e\n\u003c/section\u003e\n```\n\n**footer.scss**\n\n```css\n.footer {\n}\n```\n\n**index.vue**\n\n```html\n\u003ctemplate src=\"./footer.component.html\"\u003e\u003c/template\u003e\n\u003cscript src=\"./footer.component.js\"\u003e\u003c/script\u003e\n\u003cstyle src=\"./footer.component.scss\" scoped lang=\"scss\"\u003e\u003c/style\u003e\n```\n\n### Create new component single file\n\n```bash\nvgc -s home\n```\n\nwill generate one vue file:\n\n```javascript\n\u003ctemplate lang=\"html\"\u003e\n  \u003csection class=\"home\"\u003e\n    \u003ch1\u003ehome Component\u003c/h1\u003e\n  \u003c/section\u003e\n\u003c/template\u003e\n\n\u003cscript lang=\"js\"\u003e\n  export default  {\n    name: 'home',\n    props: [],\n    mounted() {\n\n    },\n    data() {\n      return {\n\n      }\n    },\n    methods: {\n\n    },\n    computed: {\n\n    }\n}\n\u003c/script\u003e\n\n\u003cstyle scoped lang=\"scss\"\u003e\n  .home {\n\n  }\n\u003c/style\u003e\n```\n\n### Create new component single file inside new folder\n\n```bash\nvgc -s home --folder\n```\n\n### Create new directive\n\n```bash\nvgc -d my-directive\n```\n\nwill generate:\n\n**my-directive.directive.js**\n\n```javascript\nimport Vue from 'vue';\n\nVue.directive('my-directive', {\n  bind() {},\n  // When the bound element is inserted into the DOM...\n  inserted(el) {\n    // el.focus();\n  },\n  update() {},\n  unbind() {}\n});\n```\n\n### If you want use postfix in file name, use -- postfix\n\n```bash\nvgc footer --postfix page\n```\n\nWill generate files with postfix:\n\n- footer.page.js\n- footer.page.css\n- footer.page.html\n- footer.page.spec.js\n\n### Change the default file types for html, style, script, and spec\n\n```bash\nsudo vgc --html jade --style less --script ts --spec ts\n```\n\n### Contribute\n\nIf you want to fix/improve the templates you're welcome to create a PR.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNetanelBasal%2Fvue-generate-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNetanelBasal%2Fvue-generate-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNetanelBasal%2Fvue-generate-component/lists"}