Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新依赖 #1

Merged
merged 17 commits into from
Apr 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const npmName = readlineSync.question(
)
// const componentName = readlineSync.question('What is the kebab-case tag name for your component? ('+kebabcase(npmName)+') ', {
// defaultInput: kebabcase(npmName),
// });
// })

const componentName = kebabcase(npmName)

Expand All @@ -61,7 +61,7 @@ const vars = {
npmName,
componentName,
componentNamePascal,
licenseYear: new Date().getFullYear()
licenseYear: new Date().getFullYear()
}

const testFileName = 'index.test.js'
Expand Down Expand Up @@ -103,6 +103,12 @@ newFiles.storybookConfig = replaceVars(
.toString(),
vars
)
newFiles.storybookWebpack = replaceVars(
fs
.readFileSync(path.join(__dirname, 'templates', 'storybook.webpack.js'))
.toString(),
vars
)
newFiles.story = replaceVars(
fs.readFileSync(path.join(__dirname, 'templates', 'story.js')).toString(),
vars
Expand All @@ -115,6 +121,12 @@ newFiles.readme = replaceVars(
fs.readFileSync(path.join(__dirname, 'templates', 'README.md')).toString(),
vars
)
newFiles.styleguide = replaceVars(
fs
.readFileSync(path.join(__dirname, 'templates', 'styleguide.config.js'))
.toString(),
vars
)

// output files
const paths = {
Expand All @@ -124,9 +136,11 @@ const paths = {
component: path.join(savePath, 'src', componentName + '.vue'),
testjs: path.join(savePath, 'test', testFileName),
storybookConfig: path.join(savePath, '.storybook', 'config.js'),
storybookWebpack: path.join(savePath, '.storybook', 'webpack.config.js'),
story: path.join(savePath, 'stories', 'index.js'),
license: path.join(savePath, 'LICENSE'),
readme: path.join(savePath, 'README.md'),
license: path.join(savePath, 'LICENSE'),
readme: path.join(savePath, 'README.md'),
styleguide: path.join(savePath, 'styleguide.config.js')
}

Object.keys(paths).forEach(key => {
Expand All @@ -138,8 +152,7 @@ const copyFiles = [
'.editorconfig',
'.prettierignore',
'.prettierrc',
'.babelrc',
'styleguide.config.js'
'.babelrc'
]

copyFiles.forEach(file => {
Expand Down
7 changes: 3 additions & 4 deletions templates/.babelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"presets": [
["env", { "modules": false }]
["@babel/env", { "modules": false }]
],
"env": {
"test": {
"presets": [
["env", { "targets": { "node": "current" }}]
["@babel/env", { "targets": { "node": "current" }}]
]
}
},
"plugins": [
["transform-runtime", {
"polyfill": false,
["@babel/transform-runtime", {
"regenerator": true
}]
]
Expand Down
6 changes: 4 additions & 2 deletions templates/build/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// rollup.config.js
import vue from 'rollup-plugin-vue'
import babel from 'rollup-plugin-babel'
import uglify from 'rollup-plugin-uglify-es'
import commonjs from 'rollup-plugin-commonjs'
import { terser } from 'rollup-plugin-terser'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import minimist from 'minimist'

const argv = minimist(process.argv.slice(2))
Expand All @@ -13,6 +14,7 @@ const config = {
exports: 'named'
},
plugins: [
commonjs(),
vue({
css: true,
compileTemplate: true
Expand All @@ -26,7 +28,7 @@ const config = {

// Only minify browser (iife) version
if (argv.format === 'iife') {
config.plugins.push(uglify())
config.plugins.push(terser())
}

export default config
37 changes: 21 additions & 16 deletions templates/package-json
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,32 @@
"dependencies": {},

"devDependencies": {
"minimist": "^1.2.0",
"rollup": "^0.57.1",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-uglify-es": "0.0.1",
"rollup-plugin-vue": "^3.0.0",
"vue": "^2.5.16",
"vue-template-compiler": "^2.5.16",
"@babel/core": "^7.4.3",
"@babel/plugin-transform-runtime": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@storybook/vue": "^5.0.6",
"@vue/test-utils": "^1.0.0-beta.16",
"babel-jest": "^24.7.1",
"babel-loader": "^8.0.5",
"babel-preset-vue": "^2.0.2",
"husky": "^0.14.3",
"jest": "^23.1.0",
"minimist": "^1.2.0",
"prettier": "1.12.1",
"pretty-quick": "^1.4.1",
"@vue/test-utils": "^1.0.0-beta.16",
"babel-jest": "^23.0.1",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"jest": "^23.1.0",
"vue-jest": "^2.6.0",
"vue-styleguidist": "1.7.7",
"webpack": "^3.10.0",
"rollup": "^1.9.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-terser": "^4.0.4",
"rollup-plugin-vue": "^4.7.2",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2",
"@storybook/vue": "^3.4.10"
"vue": "^2.5.16",
"vue-jest": "^3.0.4",
"vue-loader": "^15.7.0",
"vue-styleguidist": "^3.11.4",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"vue-template-compiler": "^2.5.16",
"webpack": "^4.29.6"
},

"publishConfig": {
Expand Down
8 changes: 8 additions & 0 deletions templates/storybook.webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = ({ config }) => {
config.module.rules.push({
test: /\.styl(us)?$/,
loader: 'stylus-loader'
})

return config
}
11 changes: 10 additions & 1 deletion templates/styleguide.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { VueLoaderPlugin } = require('vue-loader')

module.exports = {
components: 'src/*.vue',
ribbon: {
Expand All @@ -18,9 +20,16 @@ module.exports = {
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'stylus-loader']
},
{
test: /\.styl(us)?$/,
loader: 'stylus-loader'
}
]
}
},
plugins: [
new VueLoaderPlugin()
]
},
showUsage: true,
showCode: true,
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
readline-sync@^1.4.9:
version "1.4.9"
resolved "https://registry.yarnpkg.com/readline-sync/-/readline-sync-1.4.9.tgz#3eda8e65f23cd2a17e61301b1f0003396af5ecda"
integrity sha1-PtqOZfI80qF+YTAbHwADOWr17No=