-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow choosing vue version on creation (and in presets) (#5637)
- Loading branch information
1 parent
7c2a36b
commit b1772ca
Showing
57 changed files
with
3,431 additions
and
3,969 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
node_modules | ||
template | ||
template-vue3 | ||
packages/test | ||
temp | ||
entry-wc.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
packages/@vue/cli-plugin-eslint/__tests__/eslintMigrator.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
packages/@vue/cli-plugin-eslint/__tests__/eslintVue3.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
jest.setTimeout(300000) | ||
|
||
const generateWithPlugin = require('@vue/cli-test-utils/generateWithPlugin') | ||
const createOutside = require('@vue/cli-test-utils/createUpgradableProject') | ||
|
||
test('Vue 3 base', async () => { | ||
const { pkg } = await generateWithPlugin([ | ||
{ | ||
id: '@vue/cli-service', | ||
apply: require('@vue/cli-service/generator'), | ||
options: { | ||
vueVersion: '3' | ||
} | ||
}, | ||
{ | ||
id: '@vue/cli-plugineslint', | ||
apply: require('../generator'), | ||
options: {} | ||
} | ||
]) | ||
|
||
expect(pkg.scripts.lint).toBeTruthy() | ||
expect(pkg.eslintConfig.extends).toEqual([ | ||
'plugin:vue/vue3-essential', 'eslint:recommended' | ||
]) | ||
}) | ||
|
||
test('Should allow fragments in Vue 3 projects', async () => { | ||
const { write, run } = await createOutside('eslint-vue3-fragment', { | ||
vueVersion: '3', | ||
plugins: { | ||
'@vue/cli-plugin-eslint': {} | ||
} | ||
}) | ||
await write('src/App.vue', `<template> | ||
<img alt="Vue logo" src="./assets/logo.png"> | ||
<HelloWorld msg="Welcome to Your Vue.js App"/> | ||
</template> | ||
<script> | ||
import HelloWorld from './components/HelloWorld.vue' | ||
export default { | ||
name: 'App', | ||
components: { | ||
HelloWorld | ||
} | ||
} | ||
</script> | ||
`) | ||
|
||
await run('vue-cli-service lint') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/@vue/cli-plugin-router/generator/injectUseRouter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = (file, api) => { | ||
const j = api.jscodeshift | ||
const root = j(file.source) | ||
|
||
const appRoots = root.find(j.CallExpression, (node) => { | ||
if (j.Identifier.check(node.callee) && node.callee.name === 'createApp') { | ||
return true | ||
} | ||
|
||
if ( | ||
j.MemberExpression.check(node.callee) && | ||
j.Identifier.check(node.callee.object) && | ||
node.callee.object.name === 'Vue' && | ||
j.Identifier.check(node.callee.property) && | ||
node.callee.property.name === 'createApp' | ||
) { | ||
return true | ||
} | ||
}) | ||
|
||
appRoots.replaceWith(({ node: createAppCall }) => { | ||
return j.callExpression( | ||
j.memberExpression(createAppCall, j.identifier('use')), | ||
[j.identifier('router')] | ||
) | ||
}) | ||
|
||
return root.toSource() | ||
} |
Oops, something went wrong.