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-service-bay

v0.2.2

Published

Your One-Stop Solution for Vue.js Refactoring

Downloads

1,128

Readme

Vue Service Bay

Overview

Meet Vue Service Bay—your go-to micro-utility for effortless, bulk modifications in Vue.js components. Say goodbye to tedious, manual refactoring and accelerate your development pipeline with this lightweight yet powerful tool.

Motivation

Refactoring generally follows one of two approaches: incremental or wholesale. The approach you choose depends on your project. For instance, if you need to apply a new design system across your entire codebase all at once, this tool is invaluable. Machines can execute simple tasks far faster and more accurately than humans. Automating your refactoring tasks with this library will significantly improve efficiency and accuracy. This repository provides a tool for applying such refactoring to Vue.js components.

How the Migration Works

The following flowchart simplifies the interaction between this repository and your workflow:

flowchart LR
    subgraph Vue Service Bay
    v1[Read Vue file]-->v2[Split by section]
    v2[Split by section]-->v3[Parse to AST]
    v4[AST to Vue file]
    end
    subgraph User land's code
    v3-->u1[Manipulate AST]
    u1-->v4
    end

Even if you're new to manipulating AST (Abstract Syntax Trees), this repository provides plenty of examples to get you started.

Playground

To try out this tool, clone the repository:

git clone [email protected]:flyle-io/vue-service-bay.git
cd vue-service-bay
npm install
cd packages/examples
node migration/index.js
# Check the migration results however you like!
git difftool

How to Use

Installation

Install Vue Service Bay as a dev dependency:

npm i -D vue-service-bay

The -D flag installs the package as a development dependency.

Create a Migration Runner File

First, you'll need to create a migration runner script. For more details, please refer to the index.js in our examples.

Implement the Runner Script

Next, you'll need to implement specific migration logic. See our examples for more details:

Run the Migration Runner

Execute your migration runner script:

node index.js

COLUMN: How to read AST effectively

ASTs are complicated and bizarre for the first-time viewer. On the other hand, if you can master ASTs, they can be a great weapon for refactoring and other language processing programming. Here, we will explain how to understand AST in a simple way.

First, programming languages are often treated as an Abstract Syntax Tree (AST) for ease of understanding; an AST is a data structure widely used by compilers to represent the structure of program code.

This library also uses ASTs for refactoring. Simply put, a program is turned into an AST, and then the AST is manipulated and written back into the program again.

Fortunately, there are tools out there to easily understand AST. That is AST Explorer.

Using AST Explorer, we can automatically jump to the corresponding AST by clicking anywhere. This makes it easy to find out information about the Node we want to process and its surrounding Nodes, including its parent.

Lastly, we will explain how to view ASTs for each language.

HTML

We use htmlparser2 for our HTML parser. At the time of the original implementation of this library, htmlparser2 was the only major parser that could correctly write ASTs back to HTML.

To view ASTs parsed by htmlparser2, select the HTML language and htmlparser2 in the AST Explorer.

JavaScript / TypeScript

We use recast for our JavaScript / TypeScript parser. At the time of the original implementation of this library, acorn was the only major parser that could correctly write ASTs back to HTML. We first tried acorn but could not adopt it because acorn ignores comments. We also wanted to support TypeScript, so we finally chose recast. We also parse JavaScript as TypeScript. This is because TypeScript is a superset of JavaScript.

To view ASTs parsed by recast, select the JavaScript language and recast in the AST Explorer. And Press config button and select typescript as parser.

CSS / SCSS

We use postcss for our CSS / SCSS parser.

To view ASTs parsed by PostCSS, select the CSS and postcss in the AST Explorer.

Supported Languages

Vue Service Bay can be used with any language for migrations that do not require AST manipulation. However, if you're using AST, the following languages are currently supported. If you'd like to add support for other languages, feel free to submit a PR.

<template>

  • [x] HTML
  • [ ] JSX
  • [ ] Pug

<Script>

  • [x] JavaScript
  • [x] TypeScript
  • [ ] CoffeeScript

<Style>

  • [x] CSS
  • [x] SCSS
  • [ ] SASS
  • [ ] LESS
  • [ ] Stylus
  • [ ] PostCSS

How to Contribute

We Welcome Your Contributions

We are always open to issues and pull requests. Your contributions help make VueServiceBay a better tool for everyone.

Please Note

While we welcome issues and pull requests, active maintenance time is limited. If you have feature requests or require substantial changes, submitting a pull request is strongly advised.

Reporting Bugs

  • Check if the bug has already been reported in the issues.
  • If not, create a new issue with a descriptive title and provide as much information as possible.

Suggesting Enhancements

  • For feature requests, it's best to submit a pull request with your proposed changes. Limited maintenance resources may prevent us from implementing new features based solely on issues.