Skip to content

Commit

Permalink
refactor: replace jscodeshift with vue-codemod (#5629)
Browse files Browse the repository at this point in the history
  • Loading branch information
sodatea committed Jul 1, 2020
1 parent 8600585 commit 7f56846
Show file tree
Hide file tree
Showing 6 changed files with 854 additions and 127 deletions.
1 change: 0 additions & 1 deletion packages/@vue/cli-service/package.json
Expand Up @@ -105,7 +105,6 @@
}
},
"devDependencies": {
"@vue/compiler-sfc": "^3.0.0-beta.14",
"fibers": ">= 3.1.1 <5.0.0",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
Expand Down
10 changes: 5 additions & 5 deletions packages/@vue/cli/lib/Generator.js
Expand Up @@ -6,7 +6,7 @@ const sortObject = require('./util/sortObject')
const writeFileTree = require('./util/writeFileTree')
const inferRootOptions = require('./util/inferRootOptions')
const normalizeFilePaths = require('./util/normalizeFilePaths')
const runCodemod = require('./util/runCodemod')
const { runTransformation } = require('vue-codemod')
const {
semver,

Expand Down Expand Up @@ -277,19 +277,19 @@ module.exports = class Generator {
let imports = this.imports[file]
imports = imports instanceof Set ? Array.from(imports) : imports
if (imports && imports.length > 0) {
files[file] = runCodemod(
require('./util/codemods/injectImports'),
files[file] = runTransformation(
{ path: file, source: files[file] },
require('./util/codemods/injectImports'),
{ imports }
)
}

let injections = this.rootOptions[file]
injections = injections instanceof Set ? Array.from(injections) : injections
if (injections && injections.length > 0) {
files[file] = runCodemod(
require('./util/codemods/injectOptions'),
files[file] = runTransformation(
{ path: file, source: files[file] },
require('./util/codemods/injectOptions'),
{ injections }
)
}
Expand Down
6 changes: 3 additions & 3 deletions packages/@vue/cli/lib/GeneratorAPI.js
Expand Up @@ -5,7 +5,7 @@ const deepmerge = require('deepmerge')
const resolve = require('resolve')
const { isBinaryFileSync } = require('isbinaryfile')
const mergeDeps = require('./util/mergeDeps')
const runCodemod = require('./util/runCodemod')
const { runTransformation } = require('vue-codemod')
const stringifyJS = require('./util/stringifyJS')
const ConfigTransform = require('./ConfigTransform')
const { semver, error, getPluginLink, toShortPluginId, loadModule } = require('@vue/cli-shared-utils')
Expand Down Expand Up @@ -395,12 +395,12 @@ class GeneratorAPI {
return
}

files[normalizedPath] = runCodemod(
codemod,
files[normalizedPath] = runTransformation(
{
path: this.resolve(normalizedPath),
source: files[normalizedPath]
},
codemod,
options
)
})
Expand Down
30 changes: 0 additions & 30 deletions packages/@vue/cli/lib/util/runCodemod.js

This file was deleted.

4 changes: 1 addition & 3 deletions packages/@vue/cli/package.json
Expand Up @@ -24,7 +24,6 @@
"access": "public"
},
"dependencies": {
"@babel/preset-env": "^7.9.6",
"@vue/cli-shared-utils": "^4.4.6",
"@vue/cli-ui": "^4.4.6",
"@vue/cli-ui-addon-webpack": "^4.4.6",
Expand All @@ -45,7 +44,6 @@
"isbinaryfile": "^4.0.6",
"javascript-stringify": "^1.6.0",
"js-yaml": "^3.13.1",
"jscodeshift": "^0.10.0",
"leven": "^3.1.0",
"lodash.clonedeep": "^4.5.0",
"lru-cache": "^5.1.1",
Expand All @@ -56,7 +54,7 @@
"slash": "^3.0.0",
"validate-npm-package-name": "^3.0.0",
"vue": "^2.6.11",
"vue-jscodeshift-adapter": "^2.1.0",
"vue-codemod": "^0.0.4",
"yaml-front-matter": "^3.4.1"
},
"engines": {
Expand Down

0 comments on commit 7f56846

Please sign in to comment.