vue3-migrate

This is a command-line tool that utilizes ChatGPT to automatically refactor Vue.js code from version 2 to version 3.
761 1
Install
npm install vue3-migrate
Latest Version:1.2.4
License:MIT
Last Updated:Aug 11, 2023
Links: GitHub  ·  npm
Maintainer: s00d

npm version npm downloads NPM license donate GitHub Repo stars

Vue.js Code Migration Tool

logo

This is a command-line tool that utilizes ChatGPT to automatically refactor Vue.js code from version 2 to version 3. It helps developers migrate their code by transforming it to use Typescript with the Composition API.

Usage

Installation

npm install -g vue3-migrate

Refactor a Single Vue File

To refactor a single Vue file, use the convert command:

$ vue3-migrate convert <filename> [options]

Replace <filename> with the path to the Vue file you want to refactor.

Options
  • -t, --token <token>: Specify the GPT token (required)
  • -m, --model <model>: Specify the GPT model to use (default: gpt-3.5-turbo-16k, optional)
  • -p, --prompt <prompt>: Specify the path to the prompt file (optional)
  • -mt, --max_tokens <max_tokens>: The GPT max tokens (default: 4096, optional).
  • -r, --replace: replace exist refactor files.

see help: vue3-migrate convert -h

Refactor All Vue Files in a Directory

To refactor all Vue files in a directory, use the directory command:

$ vue3-migrate directory <directory> [options]

Replace <directory> with the path to the directory containing the Vue files you want to refactor.

Options
  • -t, --token <token>: Specify the GPT token (required)
  • -m, --model <model>: Specify the GPT model to use (default: gpt-3.5-turbo-16k, optional)
  • -p, --prompt <prompt>: Specify the path to the prompt file (optional)
  • -t, --timeout <timeout>: The timeout option allows you to specify the timeout duration in milliseconds between each refactoring request when using the directory command. It determines the waiting time before sending the next request to the OpenAI API (default: 20 seconds, optional).
  • -mt, --max_tokens <max_tokens>: The GPT max tokens (default: 4096, optional).
  • -r, --replace: replace exist refactor files.

see help: vue3-migrate convert -h

Examples

Refactor a single Vue file:

$ vue3-migrate convert /path/MyView.vue --token=sk-...

Refactor all Vue files in a directory:

$ vue3-migrate directory /path/src/components --token=sk-...

Configuration

Before running the tool, make sure to set up the following:

  1. Obtain a GPT token from OpenAI. You can sign up for an API key at https://openai.com/.
  2. Create a prompt text file (md for example, default: prompt.md) that contains the instructions for the refactoring process. This file should specify the rules and guidelines for the refactoring.

Notes

  • The tool uses the OpenAI GPT API for code refactoring. Make sure you have a valid API key and appropriate permissions.
  • It's recommended to review the refactored code manually to ensure correctness and make any necessary adjustments.

License

This project is licensed under the MIT License.

Related Packages

@dullar/mercury

Advanced and highly reusable Mobile UI Components built on Vue2 & You can define...

8,553 6
@halobear/vue-upload

vue上传组件

460 1
vite-plugin-vue2

Vite plugin for Vue2

1,474,659 618
vue-jstree

a tree plugin for vue2

137,015 630
vite-plugin-git-revision

Vite plugin that generates VERSION and COMMITHASH files during build based on a...

21,961 11

Version History

Version Released License
1.2.4 MIT
1.2.3 MIT
1.2.2 MIT
1.2.1 MIT
1.1.4 MIT