Skip to content

Commit

Permalink
refactor: use dependencies from @vue/cli-share-utils whenver possible
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Nov 29, 2019
1 parent 3873d02 commit 1a0b591
Show file tree
Hide file tree
Showing 47 changed files with 102 additions and 95 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"memfs": "^3.0.1",
"minimist": "^1.2.0",
"prettier": ">= 1.13.0",
"request": "^2.83.0",
"request": "^2.87.0",
"request-promise-native": "^1.0.8",
"rimraf": "^3.0.0",
"semver": "^6.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/@vue/cli-plugin-e2e-nightwatch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"dependencies": {
"@vue/cli-shared-utils": "^4.1.1",
"deepmerge": "^3.2.0",
"execa": "^1.0.0",
"nightwatch": "^1.3.1"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-service/bin/vue-cli-service.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env node

const semver = require('semver')
const { error } = require('@vue/cli-shared-utils')
const { semver, error } = require('@vue/cli-shared-utils')
const requiredVersion = require('../package.json').engines.node

if (!semver.satisfies(process.version, requiredVersion)) {
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-service/lib/PluginAPI.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require('path')
const hash = require('hash-sum')
const semver = require('semver')
const { matchesPluginId } = require('@vue/cli-shared-utils')
const { semver, matchesPluginId } = require('@vue/cli-shared-utils')

// Note: if a plugin-registered command needs to run in a specific default mode,
// the plugin needs to expose it via `module.exports.defaultModes` in the form
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-service/lib/Service.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const fs = require('fs')
const path = require('path')
const debug = require('debug')
const chalk = require('chalk')
const readPkg = require('read-pkg')
const merge = require('webpack-merge')
const Config = require('webpack-chain')
const PluginAPI = require('./PluginAPI')
const dotenv = require('dotenv')
const dotenvExpand = require('dotenv-expand')
const defaultsDeep = require('lodash.defaultsdeep')
const { warn, error, isPlugin, resolvePluginId, loadModule } = require('@vue/cli-shared-utils')
const { chalk, warn, error, isPlugin, resolvePluginId, loadModule } = require('@vue/cli-shared-utils')

const { defaults, validate } = require('./options')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module.exports = function formatStats (stats, dir, api) {
const fs = require('fs')
const path = require('path')
const zlib = require('zlib')
const chalk = require('chalk')
const ui = require('cliui')({ width: 80 })
const { chalk } = require('@vue/cli-shared-utils')

const json = stats.toJson({
hash: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/commands/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ module.exports = (api, options) => {
async function build (args, api, options) {
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const { chalk } = require('@vue/cli-shared-utils')
const formatStats = require('./formatStats')
const validateWebpackConfig = require('../../util/validateWebpackConfig')
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/commands/help.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const chalk = require('chalk')
const { chalk } = require('@vue/cli-shared-utils')
const padEnd = require('string.prototype.padend')
const getPadLength = require('../util/getPadLength')

Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-service/lib/commands/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ module.exports = (api, options) => {
}
},
args => {
const chalk = require('chalk')
const { get } = require('@vue/cli-shared-utils')
const { chalk, get } = require('@vue/cli-shared-utils')
const { toString } = require('webpack-chain')
const { highlight } = require('cli-highlight')
const config = api.resolveWebpackConfig()
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = (api, options) => {
const isProduction = process.env.NODE_ENV === 'production'

const url = require('url')
const chalk = require('chalk')
const { chalk } = require('@vue/cli-shared-utils')
const webpack = require('webpack')
const WebpackDevServer = require('webpack-dev-server')
const portfinder = require('portfinder')
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-service/lib/config/css.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('fs')
const path = require('path')
const semver = require('semver')
const { warn, pauseSpinner, resumeSpinner } = require('@vue/cli-shared-utils')
const { semver, warn, pauseSpinner, resumeSpinner } = require('@vue/cli-shared-utils')

const findExisting = (context, files) => {
for (const file of files) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/util/prepareProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
const fs = require('fs')
const url = require('url')
const path = require('path')
const chalk = require('chalk')
const { chalk } = require('@vue/cli-shared-utils')
const address = require('address')

const defaultConfig = {
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/util/prepareURLs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

const url = require('url')
const chalk = require('chalk')
const { chalk } = require('@vue/cli-shared-utils')
const address = require('address')
const defaultGateway = require('default-gateway')

Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-service/lib/util/resolveLoaderError.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const chalk = require('chalk')
const { chalk } = require('@vue/cli-shared-utils')

const rules = [
{
Expand Down
2 changes: 0 additions & 2 deletions packages/@vue/cli-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"browserslist": "^4.7.3",
"cache-loader": "^4.1.0",
"case-sensitive-paths-webpack-plugin": "^2.2.0",
"chalk": "^2.4.2",
"cli-highlight": "^2.1.4",
"clipboardy": "^2.0.0",
"cliui": "^5.0.0",
Expand All @@ -66,7 +65,6 @@
"portfinder": "^1.0.25",
"postcss-loader": "^3.0.0",
"read-pkg": "^5.1.1",
"semver": "^6.1.0",
"slash": "^3.0.0",
"source-map-url": "^0.4.0",
"ssri": "^7.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-shared-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"homepage": "https://github.com/vuejs/vue-cli/tree/dev/packages/@vue/cli-shared-utils#readme",
"dependencies": {
"@hapi/joi": "^15.0.1",
"chalk": "^2.4.1",
"chalk": "^2.4.2",
"execa": "^1.0.0",
"launch-editor": "^2.2.1",
"lru-cache": "^5.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const fs = require('fs')
const path = require('path')
const LRU = require('lru-cache')
const semver = require('semver')
const chalk = require('chalk')
const { chalk, semver } = require('@vue/cli-shared-utils')
// Connectors
const cwd = require('./cwd')
const folders = require('./folders')
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-ui/apollo-server/connectors/git.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const execa = require('execa')
const path = require('path')
const fs = require('fs-extra')
const parseDiff = require('../util/parse-diff')
// Connectors
const cwd = require('./cwd')
// Utils
const { hasProjectGit } = require('@vue/cli-shared-utils')
const { execa, hasProjectGit } = require('@vue/cli-shared-utils')

async function getNewFiles (context) {
if (!hasProjectGit(cwd.get())) return []
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/apollo-server/connectors/plugins.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')
const fs = require('fs-extra')
const LRU = require('lru-cache')
const chalk = require('chalk')
const { chalk } = require('@vue/cli-shared-utils')
// Context
const getContext = require('../context')
// Subs
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-ui/apollo-server/connectors/tasks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const execa = require('execa')
const chalk = require('chalk')
const { chalk, execa } = require('@vue/cli-shared-utils')
// Subs
const channels = require('../channels')
// Connectors
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli-ui/apollo-server/util/logger.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const chalk = require('chalk')
const { chalk } = require('@vue/cli-shared-utils')

exports.log = (...args) => {
if (!process.env.VUE_APP_CLI_UI_DEBUG) return
Expand Down
3 changes: 0 additions & 3 deletions packages/@vue/cli-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
"dependencies": {
"@akryum/winattr": "^3.0.0",
"@vue/cli-shared-utils": "^4.1.1",
"chalk": "^2.4.1",
"clone": "^2.1.1",
"deepmerge": "^3.2.0",
"execa": "^1.0.0",
"express-history-api-fallback": "^2.2.1",
"fkill": "^6.1.0",
"fs-extra": "^7.0.1",
Expand All @@ -58,7 +56,6 @@
"portfinder": "^1.0.25",
"prismjs": "^1.16.0",
"rss-parser": "^3.7.3",
"semver": "^6.1.0",
"shortid": "^2.2.15",
"typescript": "^3.4.5",
"vue-cli-plugin-apollo": "^0.21.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli-ui/ui-defaults/suggestions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const semver = require('semver')
const { loadModule } = require('@vue/cli-shared-utils')
const { semver, loadModule } = require('@vue/cli-shared-utils')
const invoke = require('@vue/cli/lib/invoke')
const add = require('@vue/cli/lib/add')

Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli/bin/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
// Check node version before requiring/doing anything else
// The user may be on a very old node version

const chalk = require('chalk')
const semver = require('semver')
const { chalk, semver } = require('@vue/cli-shared-utils')
const requiredVersion = require('../package.json').engines.node
const didYouMean = require('didyoumean')

Expand Down
13 changes: 8 additions & 5 deletions packages/@vue/cli/lib/Creator.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const path = require('path')
const chalk = require('chalk')
const debug = require('debug')
const execa = require('execa')
const inquirer = require('inquirer')
const semver = require('semver')
const EventEmitter = require('events')
const Generator = require('./Generator')
const cloneDeep = require('lodash.clonedeep')
Expand All @@ -27,16 +24,22 @@ const {
} = require('./options')

const {
chalk,
execa,
semver,

log,
warn,
error,
logWithSpinner,
stopSpinner,

hasGit,
hasProjectGit,
hasYarn,
hasPnpm3OrLater,
hasPnpmVersionOrLater,
logWithSpinner,
stopSpinner,

exit,
loadModule
} = require('@vue/cli-shared-utils')
Expand Down
11 changes: 9 additions & 2 deletions packages/@vue/cli/lib/Generator.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
const ejs = require('ejs')
const debug = require('debug')
const semver = require('semver')
const GeneratorAPI = require('./GeneratorAPI')
const PackageManager = require('./util/ProjectPackageManager')
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 { toShortPluginId, matchesPluginId, loadModule, isPlugin } = require('@vue/cli-shared-utils')
const {
semver,

isPlugin,
toShortPluginId,
matchesPluginId,

loadModule
} = require('@vue/cli-shared-utils')
const ConfigTransform = require('./ConfigTransform')

const logger = require('@vue/cli-shared-utils/lib/logger')
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli/lib/GeneratorAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ const path = require('path')
const merge = require('deepmerge')
const resolve = require('resolve')
const { isBinaryFileSync } = require('isbinaryfile')
const semver = require('semver')
const mergeDeps = require('./util/mergeDeps')
const runCodemod = require('./util/runCodemod')
const stringifyJS = require('./util/stringifyJS')
const ConfigTransform = require('./ConfigTransform')
const { getPluginLink, toShortPluginId, loadModule } = require('@vue/cli-shared-utils')
const { semver, getPluginLink, toShortPluginId, loadModule } = require('@vue/cli-shared-utils')

const isString = val => typeof val === 'string'
const isFunction = val => typeof val === 'function'
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli/lib/MigratorAPI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const semver = require('semver')
const { semver } = require('@vue/cli-shared-utils')
const GeneratorAPI = require('./GeneratorAPI')

class MigratorAPI extends GeneratorAPI {
Expand Down
7 changes: 4 additions & 3 deletions packages/@vue/cli/lib/Upgrader.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const fs = require('fs')
const path = require('path')
const chalk = require('chalk')
const execa = require('execa')
const semver = require('semver')
const {
chalk,
execa,
semver,

log,
done,

Expand Down
9 changes: 6 additions & 3 deletions packages/@vue/cli/lib/add.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const chalk = require('chalk')
const semver = require('semver')
const invoke = require('./invoke')
const inquirer = require('inquirer')
const { resolveModule, loadModule } = require('@vue/cli-shared-utils')
const {
chalk,
semver,
resolveModule,
loadModule
} = require('@vue/cli-shared-utils')

const PackageManager = require('./util/ProjectPackageManager')
const {
Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli/lib/create.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const fs = require('fs-extra')
const path = require('path')
const chalk = require('chalk')
const inquirer = require('inquirer')
const Creator = require('./Creator')
const { clearConsole } = require('./util/clearConsole')
const { getPromptModules } = require('./util/createTools')
const { error, stopSpinner, exit } = require('@vue/cli-shared-utils')
const { chalk, error, stopSpinner, exit } = require('@vue/cli-shared-utils')
const validateProjectName = require('validate-npm-package-name')

async function create (projectName, options) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@vue/cli/lib/inspect.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const fs = require('fs')
const path = require('path')
const execa = require('execa')
const resolve = require('resolve')
const { execa } = require('@vue/cli-shared-utils')

module.exports = function inspect (paths, args) {
const cwd = process.cwd()
Expand Down
10 changes: 7 additions & 3 deletions packages/@vue/cli/lib/invoke.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
const fs = require('fs-extra')
const path = require('path')
const execa = require('execa')
const chalk = require('chalk')
const inquirer = require('inquirer')
const {
chalk,
execa,

log,
error,
hasProjectGit,
logWithSpinner,
stopSpinner,

hasProjectGit,

resolvePluginId,

loadModule
} = require('@vue/cli-shared-utils')

Expand Down
3 changes: 1 addition & 2 deletions packages/@vue/cli/lib/promptModules/linter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = cli => {
const chalk = require('chalk')
const { hasGit } = require('@vue/cli-shared-utils')
const { chalk, hasGit } = require('@vue/cli-shared-utils')

cli.injectFeature({
name: 'Linter / Formatter',
Expand Down
Loading

0 comments on commit 1a0b591

Please sign in to comment.