Skip to content
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

fix: add pnpm v4 support #4677

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions packages/@vue/cli-shared-utils/lib/env.js
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) {
B4rtware marked this conversation as resolved.
Show resolved Hide resolved
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
20 changes: 14 additions & 6 deletions packages/@vue/cli/lib/util/ProjectPackageManager.js
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_PNPM4_CONFIG = {
install: ['install', '--reporter', 'silent', '--shamefully-hoist'],
add: ['install', '--reporter', 'silent', '--shamefully-hoist'],
upgrade: ['update', '--reporter', 'silent'],
remove: ['uninstall', '--reporter', 'silent']
}
const PACKAGE_MANAGER_PNPM3_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_PNPM4_CONFIG : PACKAGE_MANAGER_PNPM3_CONFIG,
yarn: {
install: [],
add: ['add'],
Expand Down