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-class-transformer

v1.0.5

Published

CLI to transform your vanilla Vue.js components to a Typescript class based syntax.

Downloads

5

Readme

Vue Class Transformer is a Nodejs CLI that transform your Vanilla Vue.js components to Typescript class based components,
following the syntax provided by the awesome vue-property-decorator library.

Table of content

Usage

Install it globally using npm or yarn

# With npm
$ npm install -g vue-class-transformer
# With Yarn
$ yarn global add vue-class-transformer
# You should have access to the `vct` command
$ vct components/my-component.vue
<template>
  <h1>Hello world</h1>
</template>

<script>
import Vue from 'vue'

export default Vue.extend({
  name: 'MyComponent',
  components: { TextField },
  data () {
    return {
      isOpen: false,
      query: '',
    }
  },
  props: {
    loading: {
      type: Boolean,
      default: false,
    }
  },
  computed: {
    hasQuery: {
      get (): boolean {
        return !!this.query
      }
    }
  },
  watch: {
    loading: function(newVal, oldVal) {
      console.log(newVal)
    },
  },
  methods: {
    close () {
      this.isOpen = false
    }
  }
})
</script>
<template>
  <h1>Hello world</h1>
</template>

<script lang="ts">
import { Vue, Component, Watch, Prop } from 'vue-property-decorator';
import { TextField } from "~/components/test-field.vue";

@Component<MyComponent>({
  components: { TextField },
})
export default class MyComponent extends Vue {
  isOpen = false
  query = ''

  get hasQuery(): boolean {
    return !!this.query;
  }

  @Prop({ type: Boolean, default: false })
  loading!: boolean;

  @Watch('loading')
  onLoadingUpdate(newVal, oldVal) {
    console.log(newVal);
  }

  close() {
    this.isOpen = false;
  }
}
</script>

Disclaimer

This project is still under development and is likely to raise errors on usages. Feel free to open a GitHub issue for any bug encountered!

I'm a humble developer just like you, not a genius / robot.
Any help or feedback is more than welcome :)

Documentation

The Typescript transformation supposes you will use the library vue-property-decorator (or its nuxt variant nuxt-property-decorator).

Select components

You should only select .vue files.
It will work even if your SFC imports an external script like so: <script src="./index.js" />

  # Transform a single component
  vct ./components/index.vue

  # Select all .vue files under the components/ folder (deep search).
  vct ./components/**/*.vue

CLI Options

| Name | Alias | Default value | Description | |------|-------|---------------|-------------| | version | | | Print the cli version. | | nuxt | -n | false | Import the class properties from nuxt-property-decorators instead of vue-property-decorators | | force | -f | false | Transform the script in place, do not create a new file | | output | -o | ./generated | Specify the transformed components output folder | | verbose | -v | false | Trigger verbose mode. Display script details. | | order | | "data props computed watcher hooks methods other" | Specify the order of the component properties on the transformed script.Currently, if you omit one of the section, it won't be present on the converted component script. |

Examples with options

  # Use the nuxt library and write the transformed components in a new transformed/ folder.
  vct -n -o ./components/transformed/ ./components/*.vue

  # Write the transformed components in the existing files
  # and specify the order of the class properties.
  # Do not forget to use the -- at the end to separate the order parameters and the files glob argument.
  vct -f --order data hooks watcher computed methods other -- components/*.vue

Roadmap (Fancy Todos)

  • !!! Add more unit tests (edge cases, normal cases, typescript vanilla syntax etc.)
  • !! Keep directory tree for output files (don't create everything under generated/ or same name files will override themselves)