adjust setup

This commit is contained in:
Evan You
2017-12-27 13:09:16 -05:00
parent 1de71c5c0e
commit c263967d2c
8 changed files with 631 additions and 91 deletions
+6 -10
View File
@@ -5,25 +5,21 @@
## Development Setup
This project uses a monorepo setup that requires [Lerna](https://github.com/lerna/lerna) and [Yarn](https://yarnpkg.com).
This project uses a monorepo setup that requires using [Yarn](https://yarnpkg.com) because it relies on [Yarn workspaces](https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/).
``` sh
# install root dependencies
# install dependencies
yarn
# bootstrap packages
lerna bootstrap
# link `vue` executable
cd packages/@vue/cli
yarn link
# create a test project in /packages
# note the name must be "test" so that dependencies can be linked properly
# create test projects in /packages/test
cd -
cd packages
vue create test
cd test
cd packages/test
vue create test-app
cd test-app
yarn
yarn dev
```
+2 -2
View File
@@ -1,8 +1,8 @@
{
"private": true,
"workspaces": [
"packages/test",
"packages/@vue/*"
"packages/@vue/*",
"packages/test/*"
],
"scripts": {
"lint": "eslint --fix packages/**/*.js",
@@ -6,7 +6,7 @@ module.exports = function resolveClientEnv () {
// TODO load .env files
const env = { NODE_ENV }
const env = { NODE_ENV: JSON.stringify(NODE_ENV) }
Object.keys(process.env).forEach(key => {
if (prefixRE.test(key)) {
env[key] = JSON.stringify(process.env[key])
+16 -11
View File
@@ -13,11 +13,21 @@ const debug = require('debug')
const rcPath = path.join(os.homedir(), '.vuerc')
const isMode = _mode => ({ mode }) => _mode === mode
const hasYarn = (() => {
try {
execSync('yarnpkg --version', { stdio: 'ignore' })
return true
} catch (e) {
return false
}
})()
const defaultOptions = {
features: ['eslint', 'unit'],
eslint: 'eslint-only',
unit: 'mocha',
assertionLibrary: 'chai'
assertionLibrary: 'chai',
packageManager: hasYarn ? 'yarn' : 'npm'
}
module.exports = class Creator {
@@ -79,6 +89,10 @@ module.exports = class Creator {
this.files['package.json'] = JSON.stringify(this.pkg, null, 2)
// write file tree to disk
await writeFileTree(path, this.files)
if (options.packageManager) {
// TODO install deps
}
}
resolveIntroPrompts () {
@@ -125,7 +139,7 @@ module.exports = class Creator {
message: 'Save the preferences for future projects?'
}
]
if (hasYarn()) {
if (hasYarn) {
outroPrompts.unshift({
name: 'packageManager',
when: isMode('manual'),
@@ -220,12 +234,3 @@ module.exports = class Creator {
debug('files')(this.files)
}
}
function hasYarn () {
try {
execSync('yarnpkg --version', { stdio: 'ignore' })
return true
} catch (e) {
return false
}
}
@@ -1,5 +1,5 @@
import { shallow } from 'vue-test-utils'
<%_ if (options.assertionLibrary === 'expect') { _%>
<%_ if (options.assertionLibrary === 'expect' && options.unit !== 'jest') { _%>
import { expect } from 'expect'
<%_ } _%>
<%_ if (options.assertionLibrary === 'chai') { _%>
@@ -13,7 +13,7 @@ describe('Hello.vue', () => {
const wrapper = shallow(HelloWorld, {
context: { props: { msg } }
})
<%_ if (options.assertionLibrary === 'expect') { _%>
<%_ if (options.assertionLibrary === 'expect' || options.unit === 'jest') { _%>
expect(wrapper.text()).toBe(msg)
<%_ } else if (options.assertionLibrary === 'chai') { _%>
expect(wrapper.text()).to.equal(msg)
@@ -1,5 +1,4 @@
module.exports = (api, options) => {
options.assertionLibrary = 'expect'
api.renderFiles('./files')
api.extendPackage({
scripts: {
View File
+604 -64
View File
File diff suppressed because it is too large Load Diff