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-declassify-to-setup

v1.4.9

Published

A CLI tool that converts Vue 2 vue-property-decorator classes to Composition API / setup-API.

Downloads

95

Readme

Vue 2 vue-property-decorator to Vue 2/3 setup-api converter :rocket:

This Node.js-based tool is designed to automate the transformation of your Vue 2 scripts written with vue-property-decorator into Vue 3's Composition API format, also available for vue 2.7.

Converter

This script helps developers transition from Vue 2 to Vue 3 by transforming their scripts written with the vue-property-decorator into the Composition API format, using

Requirements

  1. Node.js installed on your machine. If not, you can download it from Node.js Official Website.
  2. Terminal window.

How To Use

Following these simple steps to convert your Vue 2 scripts:

npm install -g vue-declassify-to-setup
vue-convert --help

Usage

Convert a directory:

vue-convert -p "./src/components/"

Convert a file:

vue-convert -p "./filename.vue"

Features

This script is capable of converting a range of Vue and vue-property-decorator features, including:

  • Const
  • Objects
  • Arrays
  • Methods
  • Computed / Get
  • $refs
  • @Watch
  • @Emit
  • @Vmodel
  • @Prop
  • @PropSync
  • Interfaces
  • Imports
  • $vuetify, $slot, $set, $delete, $forceUpdate, $router, $route, $nextTick
  • And more...

Run help for more options:

vue-convert --help
  
      --help         Show help                                       
      --version      Show version number                               
  -p, --path         The path to the file or directory to convert
                                                            
  -d, --destination  Specify the path to the destination directory.
                     Defaults to the current path.                       
  -v, --vue          Set the Vue target version. By default, it is set to
                     2. Use 3 to convert to Vue 3. The difference is
                     related to v-model.                                 
  -n, --no-comment   Disable the inclusion of informative comments within
                     the JavaScript code for importing the modelWrapper.
  -r, --required     Set all the properties as required  

More example:

vue-convert --path . --destination "./exportfolder" --vue 3 -n

Disclaimer

Please note that this script is designed to work with a tab size of 2. If your editor uses a different tab size, adjust it accordingly before running the converter.

This version only supports double-quoted strings. Make sure the code is set up with double-quoted strings before running the converter.

"The provided script is to be used at your own risk. It was specifically designed and tested for a specific project in a particular environment, and may require manual adjustments when applied in different contexts. In this version, the "@Components" decorator is not converted as it's often unnecessary. Auto-linting is anticipated."

While this project focuses on achieving up to 95% conversion for a specific project, it might not address all decorator scenarios, making it potentially incomplete for certain requirements. Your understanding is appreciated.

Known issues

  1. If you write comments just before the tag, the system won't understand. It needs to see an end-bracket (}) right before the tag, not a comment.

  2. The script does not like comments after ; on one line.

Contributing

Your feedback and contributions are welcome! If you encounter any issues, have suggestions or improvements, feel free to share. I appreciate your support in making this tool more efficient and versatile.

Happy coding! :smile: