10000 fix: add pnpm v4 support by B4rtware · Pull Request #4677 · vuejs/vue-cli · GitHub
[go: up one dir, main page]

Skip to content

fix: add pnpm v4 support #4677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: add pnpm v4 support
in pnpm v4 the option '--loglevel' is no longer available instead '--reporter' is used.
  • Loading branch information
B4rtware committed Oct 11, 2019
commit 51beafcc12d46a3ebba46530faa6f4f5e656ba75
20 changes: 20 additions & 0 deletions packages/@vue/cli-shared-utils/lib/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ exports.hasProjectGit = (cwd) => {

let _hasPnpm
let _hasPnpm3orLater
let _hasPnpm4OrLater
const _pnpmProjects = new LRU({
max: 10,
maxAge: 1000
Expand Down Expand Up @@ -107,6 +108,25 @@ exports.hasPnpm3OrLater = () => {
}
}

exports.hasPnpm4OrLater = () => {
if (process.env.VUE_CLI_TEST) {
return true
}
if (_hasPnpm3orLater != null) {
return _hasPnpm4orLater
}
try {
const pnpmVersion = execSync('pnpm --version', {
stdio: ['pipe', 'pipe', 'ignore']
}).toString()
_hasPnpm = true
_hasPnpm4orLater = semver.gte(pnpmVersion, '4.0.0')
return _hasPnpm4orLater
} catch (e) {
return (_hasPnpm4orLater = false)
}
}

exports.hasProjectPnpm = (cwd) => {
if (_pnpmProjects.has(cwd)) {
return checkPnpm(_pnpmProjects.get(cwd))
Expand Down
E3F2
20 changes: 14 additions & 6 deletions packages/@vue/cli/lib/util/ProjectPackageManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {
hasYarn,
hasProjectYarn,
hasPnpm3OrLater,
hasPnpm4OrLater,
hasProjectPnpm
} = require('@vue/cli-shared-utils/lib/env')
const { isOfficialPlugin, resolvePluginId } = require('@vue/cli-shared-utils/lib/pluginResolution')
Expand All @@ -32,19 +33,26 @@ const isTestOrDebug = process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG

const TAOBAO_DIST_URL = 'https://npm.taobao.org/dist'
const SUPPORTED_PACKAGE_MANAGERS = ['yarn', 'pnpm', 'npm']
const PACKAGE_MANAGER_PNPMv4_CONFIG = {
install: ['install', '--reporter', 'silent', '--shamefully-hoist'],
add: ['install', '--reporter', 'silent', '--shamefully-hoist'],
upgrade: ['update', '--reporter', 'silent'],
remove: ['uninstall', '--reporter', 'silent']
}
const PACKAGE_MANAGER_PNPMv3_CONFIG = {
install: ['install', '--loglevel', 'error', '--shamefully-flatten'],
add: ['install', '--loglevel', 'error', '--shamefully-flatten'],
upgrade: ['update', '--loglevel', 'error'],
remove: ['uninstall', '--loglevel', 'error']
}
const PACKAGE_MANAGER_CONFIG = {
npm: {
install: ['install', '--loglevel', 'error'],
add: ['install', '--loglevel', 'error'],
upgrade: ['update', '--loglevel', 'error'],
remove: ['uninstall', '--loglevel', 'error']
},
pnpm: {
install: ['install', '--loglevel', 'error', '--shamefully-flatten'],
add: ['install', '--loglevel', 'error', '--shamefully-flatten'],
upgrade: ['update', '--loglevel', 'error'],
remove: ['uninstall', '--loglevel', 'error']
},
pnpm: hasPnpm4OrLater ? PACKAGE_MANAGER_PNPMv4_CONFIG : PACKAGE_MANAGER_PNPMv3_CONFIG,
yarn: {
install: [],
add: ['add'],
Expand Down
0