From 1a0b59142aa8797810ca90705290d960a4ee6d1e Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 29 Nov 2019 15:41:18 +0800 Subject: [PATCH] refactor: use dependencies from @vue/cli-share-utils whenver possible --- package.json | 2 +- .../cli-plugin-e2e-nightwatch/package.json | 1 - .../@vue/cli-service/bin/vue-cli-service.js | 3 +-- packages/@vue/cli-service/lib/PluginAPI.js | 3 +-- packages/@vue/cli-service/lib/Service.js | 3 +-- .../lib/commands/build/formatStats.js | 2 +- .../cli-service/lib/commands/build/index.js | 2 +- .../@vue/cli-service/lib/commands/help.js | 2 +- .../@vue/cli-service/lib/commands/inspect.js | 3 +-- .../@vue/cli-service/lib/commands/serve.js | 2 +- packages/@vue/cli-service/lib/config/css.js | 3 +-- .../@vue/cli-service/lib/util/prepareProxy.js | 2 +- .../@vue/cli-service/lib/util/prepareURLs.js | 2 +- .../lib/util/resolveLoaderError.js | 2 +- packages/@vue/cli-service/package.json | 2 -- packages/@vue/cli-shared-utils/package.json | 2 +- .../apollo-server/connectors/dependencies.js | 3 +-- .../cli-ui/apollo-server/connectors/git.js | 3 +-- .../apollo-server/connectors/plugins.js | 2 +- .../cli-ui/apollo-server/connectors/tasks.js | 3 +-- .../@vue/cli-ui/apollo-server/util/logger.js | 2 +- packages/@vue/cli-ui/package.json | 3 --- .../@vue/cli-ui/ui-defaults/suggestions.js | 3 +-- packages/@vue/cli/bin/vue.js | 3 +-- packages/@vue/cli/lib/Creator.js | 13 ++++++++----- packages/@vue/cli/lib/Generator.js | 11 +++++++++-- packages/@vue/cli/lib/GeneratorAPI.js | 3 +-- packages/@vue/cli/lib/MigratorAPI.js | 2 +- packages/@vue/cli/lib/Upgrader.js | 7 ++++--- packages/@vue/cli/lib/add.js | 9 ++++++--- packages/@vue/cli/lib/create.js | 3 +-- packages/@vue/cli/lib/inspect.js | 2 +- packages/@vue/cli/lib/invoke.js | 10 +++++++--- packages/@vue/cli/lib/promptModules/linter.js | 3 +-- packages/@vue/cli/lib/promptModules/router.js | 2 +- .../cli/lib/util/ProjectPackageManager.js | 19 ++++++++++++------- packages/@vue/cli/lib/util/clearConsole.js | 14 ++++++++++---- .../@vue/cli/lib/util/confirmIfGitDirty.js | 8 +++++--- .../@vue/cli/lib/util/enhanceErrorMessages.js | 2 +- packages/@vue/cli/lib/util/executeCommand.js | 3 +-- packages/@vue/cli/lib/util/features.js | 3 +-- packages/@vue/cli/lib/util/getVersions.js | 2 +- packages/@vue/cli/lib/util/loadCommand.js | 3 +-- packages/@vue/cli/lib/util/mergeDeps.js | 3 +-- packages/@vue/cli/lib/util/shouldUseTaobao.js | 10 +++++++--- .../@vue/cli/lib/util/tryGetNewerRange.js | 2 +- packages/@vue/cli/package.json | 5 ----- 47 files changed, 102 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index 0396fb361f..5341c1a71c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/@vue/cli-plugin-e2e-nightwatch/package.json b/packages/@vue/cli-plugin-e2e-nightwatch/package.json index b28452b4c9..94bd12b7d6 100644 --- a/packages/@vue/cli-plugin-e2e-nightwatch/package.json +++ b/packages/@vue/cli-plugin-e2e-nightwatch/package.json @@ -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": { diff --git a/packages/@vue/cli-service/bin/vue-cli-service.js b/packages/@vue/cli-service/bin/vue-cli-service.js index bb780fa01a..0bed6ac2eb 100755 --- a/packages/@vue/cli-service/bin/vue-cli-service.js +++ b/packages/@vue/cli-service/bin/vue-cli-service.js @@ -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)) { diff --git a/packages/@vue/cli-service/lib/PluginAPI.js b/packages/@vue/cli-service/lib/PluginAPI.js index be42a515b5..adc4f700e0 100644 --- a/packages/@vue/cli-service/lib/PluginAPI.js +++ b/packages/@vue/cli-service/lib/PluginAPI.js @@ -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 diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index e055b0a2fb..9f3436b2a0 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -1,7 +1,6 @@ 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') @@ -9,7 +8,7 @@ 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') diff --git a/packages/@vue/cli-service/lib/commands/build/formatStats.js b/packages/@vue/cli-service/lib/commands/build/formatStats.js index f683e214c8..f963e7de79 100644 --- a/packages/@vue/cli-service/lib/commands/build/formatStats.js +++ b/packages/@vue/cli-service/lib/commands/build/formatStats.js @@ -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, diff --git a/packages/@vue/cli-service/lib/commands/build/index.js b/packages/@vue/cli-service/lib/commands/build/index.js index 78db52dcdd..dad9428d1b 100644 --- a/packages/@vue/cli-service/lib/commands/build/index.js +++ b/packages/@vue/cli-service/lib/commands/build/index.js @@ -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 { diff --git a/packages/@vue/cli-service/lib/commands/help.js b/packages/@vue/cli-service/lib/commands/help.js index 68e5bedd7e..a88bf257f9 100644 --- a/packages/@vue/cli-service/lib/commands/help.js +++ b/packages/@vue/cli-service/lib/commands/help.js @@ -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') diff --git a/packages/@vue/cli-service/lib/commands/inspect.js b/packages/@vue/cli-service/lib/commands/inspect.js index 8213cf85db..8995a778dd 100644 --- a/packages/@vue/cli-service/lib/commands/inspect.js +++ b/packages/@vue/cli-service/lib/commands/inspect.js @@ -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() diff --git a/packages/@vue/cli-service/lib/commands/serve.js b/packages/@vue/cli-service/lib/commands/serve.js index e5b42daadd..6d4c274576 100644 --- a/packages/@vue/cli-service/lib/commands/serve.js +++ b/packages/@vue/cli-service/lib/commands/serve.js @@ -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') diff --git a/packages/@vue/cli-service/lib/config/css.js b/packages/@vue/cli-service/lib/config/css.js index 9eb7929932..8ed83f57c2 100644 --- a/packages/@vue/cli-service/lib/config/css.js +++ b/packages/@vue/cli-service/lib/config/css.js @@ -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) { diff --git a/packages/@vue/cli-service/lib/util/prepareProxy.js b/packages/@vue/cli-service/lib/util/prepareProxy.js index 0b525d7487..76e8ab7fe6 100644 --- a/packages/@vue/cli-service/lib/util/prepareProxy.js +++ b/packages/@vue/cli-service/lib/util/prepareProxy.js @@ -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 = { diff --git a/packages/@vue/cli-service/lib/util/prepareURLs.js b/packages/@vue/cli-service/lib/util/prepareURLs.js index 66793c465d..8917e38150 100644 --- a/packages/@vue/cli-service/lib/util/prepareURLs.js +++ b/packages/@vue/cli-service/lib/util/prepareURLs.js @@ -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') diff --git a/packages/@vue/cli-service/lib/util/resolveLoaderError.js b/packages/@vue/cli-service/lib/util/resolveLoaderError.js index 80ae97b331..4d43eff724 100644 --- a/packages/@vue/cli-service/lib/util/resolveLoaderError.js +++ b/packages/@vue/cli-service/lib/util/resolveLoaderError.js @@ -1,4 +1,4 @@ -const chalk = require('chalk') +const { chalk } = require('@vue/cli-shared-utils') const rules = [ { diff --git a/packages/@vue/cli-service/package.json b/packages/@vue/cli-service/package.json index 9ad50bed99..0ec2bb44ce 100644 --- a/packages/@vue/cli-service/package.json +++ b/packages/@vue/cli-service/package.json @@ -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", @@ -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", diff --git a/packages/@vue/cli-shared-utils/package.json b/packages/@vue/cli-shared-utils/package.json index 5dc5f8eeaf..a9ff19ba3a 100644 --- a/packages/@vue/cli-shared-utils/package.json +++ b/packages/@vue/cli-shared-utils/package.json @@ -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", diff --git a/packages/@vue/cli-ui/apollo-server/connectors/dependencies.js b/packages/@vue/cli-ui/apollo-server/connectors/dependencies.js index 83900f1853..9d1061a515 100644 --- a/packages/@vue/cli-ui/apollo-server/connectors/dependencies.js +++ b/packages/@vue/cli-ui/apollo-server/connectors/dependencies.js @@ -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') diff --git a/packages/@vue/cli-ui/apollo-server/connectors/git.js b/packages/@vue/cli-ui/apollo-server/connectors/git.js index 819e5f428c..a5fe41b1e2 100644 --- a/packages/@vue/cli-ui/apollo-server/connectors/git.js +++ b/packages/@vue/cli-ui/apollo-server/connectors/git.js @@ -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 [] diff --git a/packages/@vue/cli-ui/apollo-server/connectors/plugins.js b/packages/@vue/cli-ui/apollo-server/connectors/plugins.js index 2ec05454a0..b74d3bcbe7 100644 --- a/packages/@vue/cli-ui/apollo-server/connectors/plugins.js +++ b/packages/@vue/cli-ui/apollo-server/connectors/plugins.js @@ -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 diff --git a/packages/@vue/cli-ui/apollo-server/connectors/tasks.js b/packages/@vue/cli-ui/apollo-server/connectors/tasks.js index a4431baa5c..7796c9efd2 100644 --- a/packages/@vue/cli-ui/apollo-server/connectors/tasks.js +++ b/packages/@vue/cli-ui/apollo-server/connectors/tasks.js @@ -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 diff --git a/packages/@vue/cli-ui/apollo-server/util/logger.js b/packages/@vue/cli-ui/apollo-server/util/logger.js index 9ec2fb6240..66ed0ff442 100644 --- a/packages/@vue/cli-ui/apollo-server/util/logger.js +++ b/packages/@vue/cli-ui/apollo-server/util/logger.js @@ -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 diff --git a/packages/@vue/cli-ui/package.json b/packages/@vue/cli-ui/package.json index ae3c02102f..22ec644f9b 100644 --- a/packages/@vue/cli-ui/package.json +++ b/packages/@vue/cli-ui/package.json @@ -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", @@ -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", diff --git a/packages/@vue/cli-ui/ui-defaults/suggestions.js b/packages/@vue/cli-ui/ui-defaults/suggestions.js index 3ba5bb5448..8b310a57fd 100644 --- a/packages/@vue/cli-ui/ui-defaults/suggestions.js +++ b/packages/@vue/cli-ui/ui-defaults/suggestions.js @@ -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') diff --git a/packages/@vue/cli/bin/vue.js b/packages/@vue/cli/bin/vue.js index a65c2f8c1d..958258798d 100755 --- a/packages/@vue/cli/bin/vue.js +++ b/packages/@vue/cli/bin/vue.js @@ -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') diff --git a/packages/@vue/cli/lib/Creator.js b/packages/@vue/cli/lib/Creator.js index 50ab76c4d7..e965ae1a87 100644 --- a/packages/@vue/cli/lib/Creator.js +++ b/packages/@vue/cli/lib/Creator.js @@ -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') @@ -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') diff --git a/packages/@vue/cli/lib/Generator.js b/packages/@vue/cli/lib/Generator.js index c1d18f32fc..71cbbee8f8 100644 --- a/packages/@vue/cli/lib/Generator.js +++ b/packages/@vue/cli/lib/Generator.js @@ -1,6 +1,5 @@ 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') @@ -8,7 +7,15 @@ 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') diff --git a/packages/@vue/cli/lib/GeneratorAPI.js b/packages/@vue/cli/lib/GeneratorAPI.js index 36cbe1313d..640f220858 100644 --- a/packages/@vue/cli/lib/GeneratorAPI.js +++ b/packages/@vue/cli/lib/GeneratorAPI.js @@ -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' diff --git a/packages/@vue/cli/lib/MigratorAPI.js b/packages/@vue/cli/lib/MigratorAPI.js index 1c6dd45226..74c3e60112 100644 --- a/packages/@vue/cli/lib/MigratorAPI.js +++ b/packages/@vue/cli/lib/MigratorAPI.js @@ -1,4 +1,4 @@ -const semver = require('semver') +const { semver } = require('@vue/cli-shared-utils') const GeneratorAPI = require('./GeneratorAPI') class MigratorAPI extends GeneratorAPI { diff --git a/packages/@vue/cli/lib/Upgrader.js b/packages/@vue/cli/lib/Upgrader.js index 31ce20bec0..f447344d2b 100644 --- a/packages/@vue/cli/lib/Upgrader.js +++ b/packages/@vue/cli/lib/Upgrader.js @@ -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, diff --git a/packages/@vue/cli/lib/add.js b/packages/@vue/cli/lib/add.js index 2e92cbd51c..ca2a70a8f8 100644 --- a/packages/@vue/cli/lib/add.js +++ b/packages/@vue/cli/lib/add.js @@ -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 { diff --git a/packages/@vue/cli/lib/create.js b/packages/@vue/cli/lib/create.js index c757b6c20c..ef4a00af69 100644 --- a/packages/@vue/cli/lib/create.js +++ b/packages/@vue/cli/lib/create.js @@ -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) { diff --git a/packages/@vue/cli/lib/inspect.js b/packages/@vue/cli/lib/inspect.js index 3fd11489aa..05fd2c4c9c 100644 --- a/packages/@vue/cli/lib/inspect.js +++ b/packages/@vue/cli/lib/inspect.js @@ -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() diff --git a/packages/@vue/cli/lib/invoke.js b/packages/@vue/cli/lib/invoke.js index 7c4ac836fd..0238927f49 100644 --- a/packages/@vue/cli/lib/invoke.js +++ b/packages/@vue/cli/lib/invoke.js @@ -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') diff --git a/packages/@vue/cli/lib/promptModules/linter.js b/packages/@vue/cli/lib/promptModules/linter.js index b1dcc1241c..69dfbc794a 100644 --- a/packages/@vue/cli/lib/promptModules/linter.js +++ b/packages/@vue/cli/lib/promptModules/linter.js @@ -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', diff --git a/packages/@vue/cli/lib/promptModules/router.js b/packages/@vue/cli/lib/promptModules/router.js index 2cdc1d239c..1dd84ebcc7 100644 --- a/packages/@vue/cli/lib/promptModules/router.js +++ b/packages/@vue/cli/lib/promptModules/router.js @@ -1,4 +1,4 @@ -const chalk = require('chalk') +const { chalk } = require('@vue/cli-shared-utils') module.exports = cli => { cli.injectFeature({ diff --git a/packages/@vue/cli/lib/util/ProjectPackageManager.js b/packages/@vue/cli/lib/util/ProjectPackageManager.js index 0a7856779a..4ffcf82023 100644 --- a/packages/@vue/cli/lib/util/ProjectPackageManager.js +++ b/packages/@vue/cli/lib/util/ProjectPackageManager.js @@ -1,21 +1,26 @@ const fs = require('fs-extra') const path = require('path') -const execa = require('execa') const minimist = require('minimist') -const semver = require('semver') const LRU = require('lru-cache') -const chalk = require('chalk') const { + chalk, + execa, + semver, + hasYarn, hasProjectYarn, hasPnpm3OrLater, hasPnpmVersionOrLater, - hasProjectPnpm -} = require('@vue/cli-shared-utils/lib/env') -const { isOfficialPlugin, resolvePluginId } = require('@vue/cli-shared-utils/lib/pluginResolution') -const { log, warn } = require('@vue/cli-shared-utils/lib/logger') + hasProjectPnpm, + + isOfficialPlugin, + resolvePluginId, + + log, + warn +} = require('@vue/cli-shared-utils') const { loadOptions } = require('../options') const getPackageJson = require('./getPackageJson') diff --git a/packages/@vue/cli/lib/util/clearConsole.js b/packages/@vue/cli/lib/util/clearConsole.js index af4f9689a1..b328e43c9b 100644 --- a/packages/@vue/cli/lib/util/clearConsole.js +++ b/packages/@vue/cli/lib/util/clearConsole.js @@ -1,8 +1,14 @@ -const chalk = require('chalk') -const execa = require('execa') -const semver = require('semver') const getVersions = require('./getVersions') -const { clearConsole, hasYarn, hasPnpm3OrLater } = require('@vue/cli-shared-utils') +const { + chalk, + execa, + semver, + + clearConsole, + + hasYarn, + hasPnpm3OrLater +} = require('@vue/cli-shared-utils') async function getInstallationCommand () { if (hasYarn()) { diff --git a/packages/@vue/cli/lib/util/confirmIfGitDirty.js b/packages/@vue/cli/lib/util/confirmIfGitDirty.js index dd3aae2920..b9db1fbc49 100644 --- a/packages/@vue/cli/lib/util/confirmIfGitDirty.js +++ b/packages/@vue/cli/lib/util/confirmIfGitDirty.js @@ -1,7 +1,9 @@ -const execa = require('execa') const inquirer = require('inquirer') - -const { warn, hasProjectGit } = require('@vue/cli-shared-utils') +const { + execa, + warn, + hasProjectGit +} = require('@vue/cli-shared-utils') module.exports = async function confirmIfGitDirty (context) { if (process.env.VUE_CLI_SKIP_DIRTY_GIT_PROMPT || process.env.VUE_CLI_API_MODE) { diff --git a/packages/@vue/cli/lib/util/enhanceErrorMessages.js b/packages/@vue/cli/lib/util/enhanceErrorMessages.js index 60952f7fb0..2f380c04a4 100644 --- a/packages/@vue/cli/lib/util/enhanceErrorMessages.js +++ b/packages/@vue/cli/lib/util/enhanceErrorMessages.js @@ -1,5 +1,5 @@ const program = require('commander') -const chalk = require('chalk') +const { chalk } = require('@vue/cli-shared-utils') module.exports = (methodName, log) => { program.Command.prototype[methodName] = function (...args) { diff --git a/packages/@vue/cli/lib/util/executeCommand.js b/packages/@vue/cli/lib/util/executeCommand.js index 154ba2bf8d..51774da7f7 100644 --- a/packages/@vue/cli/lib/util/executeCommand.js +++ b/packages/@vue/cli/lib/util/executeCommand.js @@ -1,6 +1,5 @@ -const chalk = require('chalk') +const { chalk, execa } = require('@vue/cli-shared-utils') const EventEmitter = require('events') -const execa = require('execa') const readline = require('readline') const debug = require('debug')('vue-cli:install') diff --git a/packages/@vue/cli/lib/util/features.js b/packages/@vue/cli/lib/util/features.js index 916952ba01..da165987b4 100644 --- a/packages/@vue/cli/lib/util/features.js +++ b/packages/@vue/cli/lib/util/features.js @@ -1,5 +1,4 @@ -const chalk = require('chalk') -const { toShortPluginId } = require('@vue/cli-shared-utils') +const { chalk, toShortPluginId } = require('@vue/cli-shared-utils') exports.getFeatures = (preset) => { const features = [] diff --git a/packages/@vue/cli/lib/util/getVersions.js b/packages/@vue/cli/lib/util/getVersions.js index 068dffc91e..4a765fae88 100644 --- a/packages/@vue/cli/lib/util/getVersions.js +++ b/packages/@vue/cli/lib/util/getVersions.js @@ -1,4 +1,4 @@ -const semver = require('semver') +const { semver } = require('@vue/cli-shared-utils') const PackageManager = require('./ProjectPackageManager') const { loadOptions, saveOptions } = require('../options') diff --git a/packages/@vue/cli/lib/util/loadCommand.js b/packages/@vue/cli/lib/util/loadCommand.js index 1253bbcb69..175ee76d63 100644 --- a/packages/@vue/cli/lib/util/loadCommand.js +++ b/packages/@vue/cli/lib/util/loadCommand.js @@ -10,8 +10,7 @@ module.exports = function loadCommand (commandName, moduleName) { return require('import-global')(moduleName) } catch (err2) { if (isNotFoundError(err2)) { - const chalk = require('chalk') - const { hasYarn, hasPnpm3OrLater } = require('@vue/cli-shared-utils') + const { chalk, hasYarn, hasPnpm3OrLater } = require('@vue/cli-shared-utils') let installCommand = `npm install -g` if (hasYarn()) { installCommand = `yarn global add` diff --git a/packages/@vue/cli/lib/util/mergeDeps.js b/packages/@vue/cli/lib/util/mergeDeps.js index 61bd8c6d43..4bbc17bc54 100644 --- a/packages/@vue/cli/lib/util/mergeDeps.js +++ b/packages/@vue/cli/lib/util/mergeDeps.js @@ -1,5 +1,4 @@ -const semver = require('semver') -const { warn } = require('@vue/cli-shared-utils') +const { semver, warn } = require('@vue/cli-shared-utils') const tryGetNewerRange = require('./tryGetNewerRange') diff --git a/packages/@vue/cli/lib/util/shouldUseTaobao.js b/packages/@vue/cli/lib/util/shouldUseTaobao.js index 011c362baf..3defc238f8 100644 --- a/packages/@vue/cli/lib/util/shouldUseTaobao.js +++ b/packages/@vue/cli/lib/util/shouldUseTaobao.js @@ -1,6 +1,10 @@ -const chalk = require('chalk') -const execa = require('execa') -const { hasYarn, request } = require('@vue/cli-shared-utils') +const { + chalk, + execa, + request, + + hasYarn +} = require('@vue/cli-shared-utils') const inquirer = require('inquirer') const registries = require('./registries') const { loadOptions, saveOptions } = require('../options') diff --git a/packages/@vue/cli/lib/util/tryGetNewerRange.js b/packages/@vue/cli/lib/util/tryGetNewerRange.js index 529432bc1a..3cb794beb8 100644 --- a/packages/@vue/cli/lib/util/tryGetNewerRange.js +++ b/packages/@vue/cli/lib/util/tryGetNewerRange.js @@ -1,4 +1,4 @@ -const semver = require('semver') +const { semver } = require('@vue/cli-shared-utils') const leadRE = /^(~|\^|>=?)/ const rangeToVersion = r => r.replace(leadRE, '').replace(/x/g, '0') diff --git a/packages/@vue/cli/package.json b/packages/@vue/cli/package.json index 8f55fbc8f4..8e2c85d504 100644 --- a/packages/@vue/cli/package.json +++ b/packages/@vue/cli/package.json @@ -29,7 +29,6 @@ "@vue/cli-ui-addon-webpack": "^4.1.1", "@vue/cli-ui-addon-widgets": "^4.1.1", "boxen": "^4.1.0", - "chalk": "^2.4.1", "cmd-shim": "^3.0.3", "commander": "^2.20.0", "debug": "^4.1.0", @@ -38,7 +37,6 @@ "download-git-repo": "^1.0.2", "ejs": "^2.7.1", "envinfo": "^7.5.0", - "execa": "^1.0.0", "fs-extra": "^7.0.1", "globby": "^9.2.0", "import-global": "^0.1.0", @@ -51,10 +49,7 @@ "lru-cache": "^5.1.1", "minimist": "^1.2.0", "recast": "^0.18.1", - "request": "^2.87.0", - "request-promise-native": "^1.0.8", "resolve": "^1.13.1", - "semver": "^6.1.0", "shortid": "^2.2.15", "slash": "^3.0.0", "validate-npm-package-name": "^3.0.0",