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-generate-component-x

v1.2.3

Published

Vue js component generator. Supports creating files for vuex store, and actions

Downloads

23

Readme

Vue(X) generator Awesome

This tool is inspired and forked from https://github.com/NetanelBasal/vue-generate-component CLI util for easy generate Vue js component

Intro

This tool is created to help with scaffolding vue apps that uses vuex.It follows Angular Guidelines. It also uses Vue Class Component. However the generated files will not always satisfy everyone. that being said; please feel free to do the modifications that match your needs, and be sure you will still save some time 😉 Please feel free to contribute or just send your suggestions/feedback to [email protected]

ToDos [Progress]

  • Create pages [WIP]
  • Create single file components [OPEN]
  • Create directives [OPEN]
  • Avail more options for CLI for more convenience [OPEN]
  • Automate release cycle and sem versioning increment [OPEN]

Installation

npm install -D vue-generate-component-x

-- or --

npm install -g vue-generate-component-x

Usage

vgcx <OPTIONS> <NAME>

Options

[
  {
    name: 'help',
    type: Boolean,
    description: 'help'
  },
  {
    name: 'html',
    type: String,
    description: 'set the default html templates'
  },
  {
    name: 'all',
    type: String,
    description: 'set all files to typescript'
  },
  {
    name: 'script',
    type: String,
    description: 'set the default script language'
  },
  {
    name: 'test',
    type: String,
    description: 'set the default test language'
  },
  {
    name: 'style',
    type: String,
    description: 'set the default style file'
  },
  {
    name: 'postfix',
    type: String,
    description: 'create postfix in file name'
  },
  {
    name: 'classExtension',
    type: String,
    description: 'if provided will replace default extension for pages with whatever name provided to this option'
  },
  {
    name: 'dest',
    type: String,
    description: 'destination path to move genrated folder inside'
  }
]

Create new Page

vgcx --script ts --postfix page --dest "/path/to" my-page-name

Will generate a page folder with following structure:

|-- path
    |-- to
        |-- my-page
            |-- index.vue
            |-- my-page.page.html
            |-- my-page.page.scss
            |-- my-page.page.ts
            |-- store
            |   |-- my-page.actions.ts
            |   |-- my-page.getters.js
            |   |-- my-page.mutations.ts
            |   |-- my-page.store.ts
            |-- __tests__
                |-- my-page.test.ts

index.vue

<template src="./my-page.page.html"></template>
<script src="./my-page.page.ts" lang="ts"></script>
<style src="./my-page.page.scss" scoped lang="scss"></style>

my-page.page.html

<section id="my-page" class="page">
  <h1>my-page Component</h1>
</section>

my-page.page.scss

#my-page {

}

my-page.page.ts

import Vue from 'vue';
import Component from 'vue-class-component';

@Component({
  components: {
  },
  name: 'my-page',
})

export default class MyPagePage extends Vue {
  
}

store/my-page.actions.ts

import { Commit } from 'vuex';
import { myPageMutations } from './my-page.mutations';
import { myPageStore } from './my-page.store';

export const namespace = 'myPageStore';

export const myPageActions = {

} 

export const myPageActionsMap = {

} 

store/my-page.mutations.ts

import { myPageState } from './my-page.store';

export const namespace = 'myPageStore';

export const myPageMutations = {

} 

export const myPageMutationsMap = {

} 

store/my-page.getters.ts

import { MyPageState } from  './my-page.store.ts';

export const myPageGetters = {

};

store/my-page.store.ts

import { myPageGetters } from  './my-page.getters';
import { myPageMutationsMap } from  './my-page.mutations';
import { myPageActionsMap } from './my-page.actions';

export interface MyPageState {

}

export const myPageState: MyPageState = {

};

export const myPageStore = {
  state: myPageState,
  getters: {...myPageGetters},
  actions: { ...myPageActionsMap },
  mutations: { ...myPageMutationsMap },
}

__tests__/my-page.test.ts

import Vue from 'vue';
import { mount } from '@vue/test-utils'
import MyPage from './my-page.ts';

describe('MyPage', () => {
  test('is a Vue instance', () => {
    const wrapper = mount(MyPage)
    expect(wrapper.isVueInstance()).toBeTruthy()
  })
})

Advanced Usage

This template serves a specific approach when building vue app, specifically when using vuex actions, mutations, getters, and store. The reason for creating maps for actions and mutations is to enable auto complete when you import them anywhere.

Example:

actions.ts

export const namespace = 'myNameSpace';

export const myActions = {
  DO_SOME_ACTION: `${namespace}/DO_SOME_ACTION`,
};


export const myActionsMap = {
   [myActions.DO_SOME_ACTION]({ commit }: { commit: Commit }) {

     // you can commit mutations here to change state
     console.log('Action Was Called')

  }
}

mutations.ts

export const myMutations = {
  mutateMyState: 'mutateMyState',
}

export const myMutationsMap = {
  [myMutations.mutateMyState](state: MyPageState, payload: Payload) {
    state.someKey = payload;
  },
}

page.ts

import {myActions} from 'actions';

/* Once you import actions or mutations you will be able to use them directly inside your componet 
Also the auto complete will work as expected (should be very useful in large applications)
i.e
myActions. ++++ should open suggestion menu ++++
*/

export default class MyPage extends Vue {
  created(){
    /* store here can be page store or global app store that combines all modules:
       https://vuex.vuejs.org/guide/modules.html
    */
        store.dispatch(myActions.DO_SOME_ACTION);
  }
}

Made with ❤️ by Mohamed Taher <[email protected]>