mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-03-06 06:18:38 -06:00
move all deps to dependencies instead of devDependencies
This commit is contained in:
@@ -42,7 +42,7 @@ Both utilize a plugin-based architecture.
|
||||
|
||||
### Plugin
|
||||
|
||||
Plugins are locally installed into the project as devDependencies. `@vue/cli-service`'s [built-in commands][5] and [config modules][6] are also all implemented as plugins. This repo also contains a number of plugins that are published as individual packages.
|
||||
Plugins are locally installed into the project as dependencies. `@vue/cli-service`'s [built-in commands][5] and [config modules][6] are also all implemented as plugins. This repo also contains a number of plugins that are published as individual packages.
|
||||
|
||||
A plugin should export a function which receives two arguments:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module.exports = api => {
|
||||
api.extendPackage({
|
||||
devDependencies: {
|
||||
dependencies: {
|
||||
'@vue/babel-preset-app': '^3.0.0-alpha.1'
|
||||
},
|
||||
babel: {
|
||||
|
||||
@@ -11,7 +11,7 @@ test('base', async () => {
|
||||
expect(pkg.eslintConfig).toEqual({
|
||||
extends: ['plugin:vue/essential', 'eslint:recommended']
|
||||
})
|
||||
expect(pkg.devDependencies).toHaveProperty('eslint-plugin-vue')
|
||||
expect(pkg.dependencies).toHaveProperty('eslint-plugin-vue')
|
||||
})
|
||||
|
||||
test('airbnb', async () => {
|
||||
@@ -27,8 +27,8 @@ test('airbnb', async () => {
|
||||
expect(pkg.eslintConfig).toEqual({
|
||||
extends: ['plugin:vue/essential', '@vue/airbnb']
|
||||
})
|
||||
expect(pkg.devDependencies).toHaveProperty('eslint-plugin-vue')
|
||||
expect(pkg.devDependencies).toHaveProperty('@vue/eslint-config-airbnb')
|
||||
expect(pkg.dependencies).toHaveProperty('eslint-plugin-vue')
|
||||
expect(pkg.dependencies).toHaveProperty('@vue/eslint-config-airbnb')
|
||||
})
|
||||
|
||||
test('standard', async () => {
|
||||
@@ -44,8 +44,8 @@ test('standard', async () => {
|
||||
expect(pkg.eslintConfig).toEqual({
|
||||
extends: ['plugin:vue/essential', '@vue/standard']
|
||||
})
|
||||
expect(pkg.devDependencies).toHaveProperty('eslint-plugin-vue')
|
||||
expect(pkg.devDependencies).toHaveProperty('@vue/eslint-config-standard')
|
||||
expect(pkg.dependencies).toHaveProperty('eslint-plugin-vue')
|
||||
expect(pkg.dependencies).toHaveProperty('@vue/eslint-config-standard')
|
||||
})
|
||||
|
||||
test('lint on save', async () => {
|
||||
|
||||
@@ -6,17 +6,21 @@ module.exports = (api, { config, lintOn }) => {
|
||||
eslintConfig: {
|
||||
extends: ['plugin:vue/essential']
|
||||
},
|
||||
devDependencies: {
|
||||
dependencies: {
|
||||
'eslint-plugin-vue': '^4.1.0'
|
||||
}
|
||||
}
|
||||
|
||||
if (config === 'airbnb') {
|
||||
pkg.eslintConfig.extends.push('@vue/airbnb')
|
||||
pkg.devDependencies['@vue/eslint-config-airbnb'] = '^0.1.0'
|
||||
Object.assign(pkg.dependencies, {
|
||||
'@vue/eslint-config-airbnb': '^3.0.0-alpha.1'
|
||||
})
|
||||
} else if (config === 'standard') {
|
||||
pkg.eslintConfig.extends.push('@vue/standard')
|
||||
pkg.devDependencies['@vue/eslint-config-standard'] = '^0.1.0'
|
||||
Object.assign(pkg.dependencies, {
|
||||
'@vue/eslint-config-standard': '^3.0.0-alpha.1'
|
||||
})
|
||||
} else if (config === 'prettier') {
|
||||
// TODO
|
||||
} else {
|
||||
@@ -31,9 +35,9 @@ module.exports = (api, { config, lintOn }) => {
|
||||
}
|
||||
|
||||
if (lintOn === 'commit') {
|
||||
Object.assign(pkg.devDependencies, {
|
||||
pkg.devDependencies = {
|
||||
'lint-staged': '^6.0.0'
|
||||
})
|
||||
}
|
||||
pkg.gitHooks = {
|
||||
'pre-commit': 'lint-staged'
|
||||
}
|
||||
|
||||
0
packages/@vue/cli-plugin-typescript/index.js
Normal file
0
packages/@vue/cli-plugin-typescript/index.js
Normal file
@@ -4,7 +4,7 @@ module.exports = (api, options) => {
|
||||
scripts: {
|
||||
test: 'vue-cli-service test'
|
||||
},
|
||||
devDependencies: {
|
||||
dependencies: {
|
||||
'vue-test-utils': '^1.0.0-beta.9'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -16,7 +16,7 @@ test('base', async () => {
|
||||
])
|
||||
|
||||
expect(pkg.scripts.test).toBeTruthy()
|
||||
expect(pkg.devDependencies).toHaveProperty('vue-test-utils')
|
||||
expect(pkg.dependencies).toHaveProperty('vue-test-utils')
|
||||
expect(files['test/unit/.eslintrc']).toMatch('"mocha": true')
|
||||
expect(files['test/unit/HelloWorld.spec.js']).toMatch('// assert wrapper.text() equals msg')
|
||||
})
|
||||
@@ -33,7 +33,7 @@ test('chai', async () => {
|
||||
])
|
||||
|
||||
expect(pkg.scripts.test).toBeTruthy()
|
||||
expect(pkg.devDependencies).toHaveProperty('vue-test-utils')
|
||||
expect(pkg.dependencies).toHaveProperty('vue-test-utils')
|
||||
|
||||
const spec = files['test/unit/HelloWorld.spec.js']
|
||||
expect(spec).toMatch(`import { expect } from 'chai'`)
|
||||
@@ -52,7 +52,7 @@ test('expect', async () => {
|
||||
])
|
||||
|
||||
expect(pkg.scripts.test).toBeTruthy()
|
||||
expect(pkg.devDependencies).toHaveProperty('vue-test-utils')
|
||||
expect(pkg.dependencies).toHaveProperty('vue-test-utils')
|
||||
|
||||
const spec = files['test/unit/HelloWorld.spec.js']
|
||||
expect(spec).toMatch(`import expect from 'expect'`)
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
module.exports = (api, options) => {
|
||||
api.render('./template')
|
||||
|
||||
const devDependencies = {
|
||||
const dependencies = {
|
||||
'vue-test-utils': '^1.0.0-beta.9'
|
||||
}
|
||||
if (options.assertionLibrary === 'chai') {
|
||||
devDependencies.chai = '^4.1.2'
|
||||
dependencies.chai = '^4.1.2'
|
||||
} else if (options.assertionLibrary === 'expect') {
|
||||
devDependencies.expect = '^22.0.3'
|
||||
dependencies.expect = '^22.0.3'
|
||||
}
|
||||
|
||||
api.extendPackage({
|
||||
devDependencies,
|
||||
dependencies,
|
||||
scripts: {
|
||||
test: 'vue-cli-service test'
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ test('env loading', () => {
|
||||
|
||||
test('loading plugins from package.json', () => {
|
||||
mockPkg({
|
||||
devDependencies: {
|
||||
dependencies: {
|
||||
'bar': '^1.0.0',
|
||||
'@vue/cli-plugin-babel': '^3.0.0-alpha.1',
|
||||
'vue-cli-plugin-foo': '^1.0.0'
|
||||
|
||||
@@ -12,9 +12,7 @@ module.exports = (api, options) => {
|
||||
'build': 'vue-cli-service build'
|
||||
},
|
||||
dependencies: {
|
||||
'vue': '^2.5.13'
|
||||
},
|
||||
devDependencies: {
|
||||
'vue': '^2.5.13',
|
||||
'vue-template-compiler': '^2.5.13'
|
||||
},
|
||||
'postcss': {
|
||||
@@ -62,7 +60,7 @@ module.exports = (api, options) => {
|
||||
}
|
||||
|
||||
api.extendPackage({
|
||||
devDependencies: deps[options.cssPreprocessor]
|
||||
dependencies: deps[options.cssPreprocessor]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ exports.defaults = {
|
||||
plugins: {
|
||||
'@vue/cli-plugin-babel': {},
|
||||
'@vue/cli-plugin-eslint': { config: 'base', lintOn: 'save' },
|
||||
'@vue/cli-plugin-unit-mocha-webpack': { assertionLibrary: 'chai' }
|
||||
'@vue/cli-plugin-unit-mocha-webpack': { assertionLibrary: 'chai' },
|
||||
'@vue/cli-plugin-pwa': {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,11 +79,11 @@ module.exports = async function installDeps (targetDir, command, deps, cliRegist
|
||||
if (command === 'npm') {
|
||||
args.push('install', '--loglevel', 'error')
|
||||
if (deps) {
|
||||
args.push('--save-dev')
|
||||
args.push('--save')
|
||||
}
|
||||
} else if (command === 'yarn') {
|
||||
if (deps) {
|
||||
args.push('add', '--dev')
|
||||
args.push('add')
|
||||
}
|
||||
} else {
|
||||
throw new Error(`unknown package manager: ${command}`)
|
||||
|
||||
@@ -6,9 +6,10 @@ const mkdirp = require('mkdirp')
|
||||
|
||||
module.exports = function setupDevProject (targetDir, deps) {
|
||||
const pkg = require(path.resolve(targetDir, 'package.json'))
|
||||
pkg.dependencies = {}
|
||||
pkg.devDependencies = {}
|
||||
deps.forEach(dep => {
|
||||
pkg.devDependencies[dep] = require(path.resolve(
|
||||
pkg.dependencies[dep] = require(path.resolve(
|
||||
__dirname,
|
||||
'../../../../',
|
||||
dep,
|
||||
|
||||
Reference in New Issue
Block a user