From 6b8624669f3899a8198c9f9dc68999b4ea79abac Mon Sep 17 00:00:00 2001 From: zyy Date: Thu, 26 Sep 2019 17:15:29 +0800 Subject: [PATCH 1/5] feat: support custom package manager --- packages/@vue/cli/lib/util/ProjectPackageManager.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/@vue/cli/lib/util/ProjectPackageManager.js b/packages/@vue/cli/lib/util/ProjectPackageManager.js index 4699e1d4d9..18e3cead9c 100644 --- a/packages/@vue/cli/lib/util/ProjectPackageManager.js +++ b/packages/@vue/cli/lib/util/ProjectPackageManager.js @@ -13,6 +13,7 @@ const { hasProjectPnpm } = require('@vue/cli-shared-utils/lib/env') const { isOfficialPlugin, resolvePluginId } = require('@vue/cli-shared-utils/lib/pluginResolution') +const { warn } = require('@vue/cli-shared-utils/lib/logger') const { loadOptions } = require('../options') const getPackageJson = require('./getPackageJson') @@ -76,7 +77,8 @@ class PackageManager { } if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) { - throw new Error(`Unknown package manager: ${this.bin}`) + warn(`Unknown package manager: ${this.bin}`) + PACKAGE_MANAGER_CONFIG[this.bin] = PACKAGE_MANAGER_CONFIG.npm } } From dccfb748b641882eb64337ffb6444dc2aecc410d Mon Sep 17 00:00:00 2001 From: zyy Date: Thu, 26 Sep 2019 21:52:52 +0800 Subject: [PATCH 2/5] feat: refine warning msg for unknown package manager --- packages/@vue/cli/lib/util/ProjectPackageManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vue/cli/lib/util/ProjectPackageManager.js b/packages/@vue/cli/lib/util/ProjectPackageManager.js index 18e3cead9c..afa8afd1d0 100644 --- a/packages/@vue/cli/lib/util/ProjectPackageManager.js +++ b/packages/@vue/cli/lib/util/ProjectPackageManager.js @@ -77,7 +77,7 @@ class PackageManager { } if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) { - warn(`Unknown package manager: ${this.bin}`) + warn(`Unknown package manager: ${this.bin}. It may not be well supported and we are now treating it like npm but potential errors could happen.\n`) PACKAGE_MANAGER_CONFIG[this.bin] = PACKAGE_MANAGER_CONFIG.npm } } From c8d377e29b349d7d992d498def4bbc9e3865c7b4 Mon Sep 17 00:00:00 2001 From: zyy Date: Thu, 26 Sep 2019 21:57:05 +0800 Subject: [PATCH 3/5] feat: refine blank lines --- packages/@vue/cli/lib/util/ProjectPackageManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli/lib/util/ProjectPackageManager.js b/packages/@vue/cli/lib/util/ProjectPackageManager.js index afa8afd1d0..cddef4af25 100644 --- a/packages/@vue/cli/lib/util/ProjectPackageManager.js +++ b/packages/@vue/cli/lib/util/ProjectPackageManager.js @@ -13,7 +13,7 @@ const { hasProjectPnpm } = require('@vue/cli-shared-utils/lib/env') const { isOfficialPlugin, resolvePluginId } = require('@vue/cli-shared-utils/lib/pluginResolution') -const { warn } = require('@vue/cli-shared-utils/lib/logger') +const { log, warn } = require('@vue/cli-shared-utils/lib/logger') const { loadOptions } = require('../options') const getPackageJson = require('./getPackageJson') @@ -77,7 +77,8 @@ class PackageManager { } if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) { - warn(`Unknown package manager: ${this.bin}. It may not be well supported and we are now treating it like npm but potential errors could happen.\n`) + log() + warn(`Unknown package manager: ${this.bin}. It may not be well supported and we are now treating it like npm but potential errors could happen.`) PACKAGE_MANAGER_CONFIG[this.bin] = PACKAGE_MANAGER_CONFIG.npm } } From f4996e9834bdc438a7f360ee07bada7b28bc8069 Mon Sep 17 00:00:00 2001 From: zyy Date: Fri, 27 Sep 2019 10:26:12 +0800 Subject: [PATCH 4/5] feat: refine warning msg for unknown package manager --- packages/@vue/cli/lib/util/ProjectPackageManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vue/cli/lib/util/ProjectPackageManager.js b/packages/@vue/cli/lib/util/ProjectPackageManager.js index cddef4af25..87f261e015 100644 --- a/packages/@vue/cli/lib/util/ProjectPackageManager.js +++ b/packages/@vue/cli/lib/util/ProjectPackageManager.js @@ -78,7 +78,7 @@ class PackageManager { if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) { log() - warn(`Unknown package manager: ${this.bin}. It may not be well supported and we are now treating it like npm but potential errors could happen.`) + warn(`Unknown package manager: ${this.bin}. Currently we only support one of [${SUPPORTED_PACKAGE_MANAGERS.join(', ')}]. ${this.bin} may not be well supported and we are now treating it like npm but potential errors could happen. See if you can use '--registry' instead.`) PACKAGE_MANAGER_CONFIG[this.bin] = PACKAGE_MANAGER_CONFIG.npm } } From 87e1e3f715c086513a98e4e6b14cbb57a5c446c5 Mon Sep 17 00:00:00 2001 From: zyy Date: Sun, 29 Sep 2019 10:29:25 +0800 Subject: [PATCH 5/5] feat: refine warning msg for unknown package manager --- packages/@vue/cli/lib/util/ProjectPackageManager.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/@vue/cli/lib/util/ProjectPackageManager.js b/packages/@vue/cli/lib/util/ProjectPackageManager.js index 87f261e015..2242137e5b 100644 --- a/packages/@vue/cli/lib/util/ProjectPackageManager.js +++ b/packages/@vue/cli/lib/util/ProjectPackageManager.js @@ -5,6 +5,7 @@ const execa = require('execa') const minimist = require('minimist') const semver = require('semver') const LRU = require('lru-cache') +const chalk = require('chalk') const { hasYarn, @@ -78,7 +79,11 @@ class PackageManager { if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) { log() - warn(`Unknown package manager: ${this.bin}. Currently we only support one of [${SUPPORTED_PACKAGE_MANAGERS.join(', ')}]. ${this.bin} may not be well supported and we are now treating it like npm but potential errors could happen. See if you can use '--registry' instead.`) + warn( + `The package manager ${chalk.red(this.bin)} is ${chalk.red('not officially supported')}.\n` + + `It will be treated like ${chalk.cyan('npm')}, but compatibility issues may occur.\n` + + `See if you can use ${chalk.cyan('--registry')} instead.` + ) PACKAGE_MANAGER_CONFIG[this.bin] = PACKAGE_MANAGER_CONFIG.npm } }