-
-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathget-vue-version.js
51 lines (41 loc) · 1.32 KB
/
get-vue-version.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* This file is part of the Symfony Webpack Encore package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
'use strict';
/**
* @import WebpackConfig from '../WebpackConfig'
*/
const packageHelper = require('../package-helper');
const semver = require('semver');
const logger = require('../logger');
/**
* @param {WebpackConfig} webpackConfig
* @returns {number|string|null}
*/
module.exports = function(webpackConfig) {
if (webpackConfig.vueOptions.version !== null) {
return webpackConfig.vueOptions.version;
}
// detect installed version
const vueVersion = packageHelper.getPackageVersion('vue');
if (null === vueVersion) {
// 2 is the current default version to recommend
return 3;
}
if (semver.satisfies(vueVersion, '^3.0.0-beta.1')) {
return 3;
}
if (semver.satisfies(vueVersion, '^1')) {
throw new Error('vue version 1 is not supported.');
}
if (semver.satisfies(vueVersion, '^2')) {
throw new Error('vue version 2 is not supported.');
}
logger.warning(`Your version of vue "${vueVersion}" is newer than this version of Encore supports and may or may not function properly.`);
return 3;
};