微信小程序 zanui web 文档 (#142)

* [new feature]微信小程序 zanui web 文档

* fix: 修复绝对路径问题,对UI小优化

* fix: update config
This commit is contained in:
刘建东 2018-03-19 14:09:13 +08:00 committed by Yao
parent 86dd3eeea0
commit 031ff697c6
55 changed files with 19901 additions and 10673 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ project.config.json
assets/icons/build
assets/icons/svg
example/dist
website/dist

89
doc.config.js Normal file
View File

@ -0,0 +1,89 @@
/* eslint-disable */
module.exports = {
header: {
logo: {
image: 'https://img.yzcdn.cn/public_files/2017/12/18/fd78cf6bb5d12e2a119d0576bedfd230.png',
title: 'ZanUI 小程序',
href: 'http://www.youzanyun.com/zanui'
},
nav: {
lang: {
text: 'En',
from: 'zh-CN',
to: 'en-US'
},
github: 'https://github.com/youzan/zanui-weapp'
}
},
footer: {
github: 'https://github.com/youzan/zanui-weapp',
nav: {
'React 组件库': 'https://www.youzanyun.com/zanui/zent',
'Vue 组件库': 'https://www.youzanyun.com/zanui/vant',
意见反馈: 'https://github.com/youzan/zanui-weapp/issues',
开发指南: 'https://github.com/youzan/zanui-weapp/blob/dev/.github/CONTRIBUTING.zh-CN.md',
加入我们: 'https://job.youzan.com'
}
},
plugins: [require('./website/plugins/wxapp-demo.js')],
docs: {
base: 'zanui',
default: 'icon',
category: [
{
base: 'base',
label: '基础',
include: {
icon: require('./packages/icon/README.md'),
btn: require('./packages/btn/README.md'),
helper: require('./packages/helper/README.md')
}
},
{
base: 'layout',
label: '布局',
include: {
row: require('./packages/row/README.md'),
cell: require('./packages/cell/README.md'),
card: require('./packages/card/README.md'),
panel: require('./packages/panel/README.md')
}
},
{
base: 'form',
label: '表单',
include: {
field: require('./packages/field/README.md'),
switch: require('./packages/switch/README.md'),
select: require('./packages/select/README.md'),
stepper: require('./packages/stepper/README.md')
}
},
{
base: 'view',
label: '展示',
include: {
tag: require('./packages/tag/README.md'),
badge: require('./packages/badge/README.md'),
capsule: require('./packages/capsule/README.md'),
noticebar: require('./packages/noticebar/README.md'),
steps: require('./packages/steps/README.md')
}
},
{
base: 'interactive',
label: '交互',
include: {
toast: require('./packages/toast/README.md'),
popup: require('./packages/popup/README.md'),
dialog: require('./packages/dialog/README.md'),
toptips: require('./packages/toptips/README.md'),
tab: require('./packages/tab/README.md'),
loadmore: require('./packages/loadmore/README.md'),
actionsheet: require('./packages/actionsheet/README.md')
}
}
],
include: {}
}
}

12932
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,9 @@
"icon": "sh scripts/build-icon.sh",
"dev": "node scripts/build-dev.js --color",
"build": "sh scripts/deploy.sh",
"deploy": "npm run build && superman cdn basic && gh-pages -d website/dist --remote youzan"
"watch:doc": "NODE_ENV=development wedoc run watch",
"build:doc": "NODE_ENV=production wedoc run build",
"deploy:doc": "npm run build:doc && superman cdn basic && gh-pages -d website/dist --remote youzan"
},
"repository": {
"type": "git",
@ -44,6 +46,7 @@
"shelljs": "^0.7.8"
},
"dependencies": {
"gh-pages": "^1.1.0"
"gh-pages": "^1.1.0",
"wedoc": "0.0.13"
}
}

View File

@ -1,18 +0,0 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs", "dynamic-import-node"]
}
}
}

View File

@ -1,9 +0,0 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

View File

@ -1,6 +0,0 @@
/build/
/config/
/dist/
/*.js
/test/unit/coverage/
/src/components/vant-doc

View File

@ -1,29 +0,0 @@
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}

17
website/.gitignore vendored
View File

@ -1,17 +0,0 @@
.DS_Store
node_modules/
/dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/test/unit/coverage/
/test/e2e/reports/
selenium-debug.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln

View File

@ -1,10 +0,0 @@
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}

View File

@ -1,91 +0,0 @@
# doc-web-cli
一个简单易用的网页文档生成工具
> A Vue.js project
## Build Setup
``` bash
# 安装
npm install doc-web-cli -g
# 初始化配置文档
doc-web init
# 自动提取项目中的 markdown 文件
doc-web doc --config=your-config-path --out=your-website-path --docs=your-docs-path
# 生成网站
doc-web build --config=your-config-path --out=your-website-path --docs=your-docs-path
```
## 配置
- command
- init
- doc
- build
- config
{
UI: [
自定义的UI库会其他库
],
header: {
logo: {
image: 'https://img.yzcdn.cn/public_files/2017/12/18/fd78cf6bb5d12e2a119d0576bedfd230.png',
title: 'ZanUI',
href: 'http://www.youzanyun.com/zanui'
},
nav: {
lang: {
text: 'En',
from: 'zh-CN',
to: 'en-US'
},
github: 'https://github.com/youzan/vant'
}
},
footer: {
github: 'https://github.com/youzan/vant',
nav: {
'React 组件库': 'https://www.youzanyun.com/zanui/zent',
小程序组件库: 'https://github.com/youzan/zanui-weapp',
意见反馈: 'https://github.com/youzan/vant/issues',
开发指南: 'https://github.com/youzan/vant/blob/dev/.github/CONTRIBUTING.zh-CN.md',
加入我们: 'https://job.youzan.com'
}
},
docs: {
base: 'zanui',
category: [{
base: 'base',
label: '基础',
include: {
badge: import('../../packages/badge/README.md')
}
}],
include: {
badge: import('../../packages/badge/README.md')
}
}
/**
lang: {
'zn-ch': {
docs: {
base: 'zanui',
category: [{
base: 'base',
label: '基础',
include: {
badge: import('../../packages/badge/README.md')
}
}],
include: {
badge: import('../../packages/badge/README.md')
}
}
}
}
*/
}

View File

@ -1,25 +0,0 @@
const argv = require('yarns')
const path = require('path')
const shell = require('shelljs')
const file = require('./../build/file')
const buildDocConfig = require('./../build/doc')
const tplPath = path.resolve(__dirname, '../doc.config.js.tpl')
const websitePath = path.resolve(__dirname, '../')
const docsPath = path.resolve(__dirname, argv.docPath)
const configPath = path.join(process.cwd(), argv.config)
const outputPath = path.join(process.cwd(), argv.output || 'dist')
if (Object.hasPrototypeof(argv, 'init')) {
shell.cp(tplPath, configPath)
}
if (!argv.config) return console.log('config 参数必须')
if (!file.hasFile(configPath)) return console.log(`找不到文件:${configPath}`)
if (Object.hasPrototypeof(argv, 'doc')) {
buildDocConfig(docsPath, configPath)
}
if (Object.hasPrototypeof(argv, 'build')) {
//
}

View File

@ -1,41 +0,0 @@
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})

View File

@ -1,54 +0,0 @@
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}

View File

@ -1,89 +0,0 @@
let path = require('path')
let file = require('./file')
let fs = require('fs')
let esprima = require('esprima')
let estraverse = require('estraverse')
let escodegen = require('escodegen')
let commander = require('commander')
commander
.option('--docs <doc dirs>', '文档目录位置')
.option('--async', '文档加载方式')
.parse(process.argv)
const processDir = process.cwd()
const confFile = path.join(__dirname, '../src/doc.config.js')
const moduleType = commander.async ? '__import__' : '__require__'
let docDirs = commander.docs.split(',')
docDirs = Array.isArray(docDirs) ? docDirs : []
let mds = {}
docDirs.forEach(dir => {
let docDir = path.join(processDir, dir)
mds = Object.assign({}, mds, getDocFiles(docDir))
})
const code = parseASTToCode(mds, parseCodeToAST(confFile))
updateConfig(code, confFile)
function getDocFiles (docDir) {
const confDir = path.join(__dirname, '../src')
let mds = file.getFiles(docDir).filter(f => {
return file.getExtname(f) === 'md'
})
return mds.reduce((res, f) => {
let dir = path.dirname(f)
let relativePath = path.relative(confDir, f)
let key = dir.substr(dir.lastIndexOf('/') + 1)
res[key] = relativePath
return res
}, {})
}
function parseCodeToAST (confFile) {
let config = fs.readFileSync(confFile, 'utf-8').replace(/import/g, moduleType)
return esprima.parseScript(config)
}
function parseASTToCode (docs, ast) {
let keys = Object.keys(docs)
ast = estraverse.replace(ast, {
enter (node, parent) {
if (node.name === 'include') {
estraverse.replace(parent.value, {
enter (node, parent) {
if (node.type === 'Identifier' && parent.type === 'Property' && keys.indexOf(node.name) !== -1) {
let path = docs[node.name]
parent.value = esprima.parseScript(`${moduleType}('${path}')`).body[0]
delete docs[node.name]
}
}
})
}
}
})
ast = estraverse.replace(ast, {
enter (node, parent) {
if (node.name === 'docs') {
let properties = parent.value.properties.filter(prop => prop.key.name === 'include')
let newProperties = Object.keys(docs).map(key => `${key}: ${moduleType}('${docs[key]}')`)
if (newProperties.length) {
newProperties = 'props = {' + newProperties.join() + '}'
newProperties = esprima.parseScript(newProperties).body[0].expression.right.properties
properties[0].value.properties.push(...newProperties)
}
}
}
})
let reg = new RegExp(moduleType, 'g')
let code = escodegen.generate(ast).replace(reg, moduleType === '__import__' ? 'import' : 'require').replace(/;/g, '')
return code
}
function updateConfig (code, confFile) {
file.mkfile(confFile, code)
}

View File

@ -1,173 +0,0 @@
var hljs = require('highlight.js')
var cheerio = require('cheerio')
var markdown = require('markdown-it')
var Token = require('markdown-it/lib/token')
/**
* `<pre></pre>` => `<pre v-pre></pre>`
* `<code></code>` => `<code v-pre></code>`
* @param {string} str
* @return {string}
*/
var addVuePreviewAttr = function (str) {
return str.replace(/(<pre|<code)/g, '$1 v-pre')
}
/**
* renderHighlight
* @param {string} str
* @param {string} lang
*/
var renderHighlight = function (str, lang) {
let addtionLang = {wxml: 'html', wxss: 'css'}
lang = addtionLang[lang] ? addtionLang[lang] : lang
if (!(lang && hljs.getLanguage(lang))) {
return ''
}
return hljs.highlight(lang, str, true).value
}
/**
* html => vue file template
* @param {[type]} html [description]
* @return {[type]} [description]
*/
var renderVueTemplate = function (html, wrapper) {
var $ = cheerio.load(html, {
decodeEntities: false,
lowerCaseAttributeNames: false,
lowerCaseTags: false
})
$('style').remove()
$('script').remove()
let label = $('h1').text() || $('h2').text() || $('h3').text()
let template =
`
<${wrapper}>
${$.html()}
</${wrapper}>
`
return {template, label}
}
function markdownCompiler (source, opts) {
this.cacheable && this.cacheable()
var parser, preprocess
var vueMarkdownOptions = this.options.__vueMarkdownOptions__
var opts = Object.create(vueMarkdownOptions.__proto__) // inherit prototype
var preventExtract = false
opts = Object.assign(opts, vueMarkdownOptions) // assign attributes
if (opts.preventExtract) {
delete opts.preventExtract
preventExtract = true
}
if (typeof opts.render === 'function') {
parser = opts
} else {
opts = Object.assign(
{
preset: 'default',
html: true,
highlight: renderHighlight,
wrapper: 'section'
},
opts
)
var plugins = opts.use
preprocess = opts.preprocess
delete opts.use
delete opts.preprocess
if (opts.before && typeof opts.before === 'function') {
source = opts.before.call(this, source)
}
parser = markdown(opts.preset, opts)
// add ruler:extract script and style tags from html token content
!preventExtract &&
parser.core.ruler.push('extract_script_or_style', function replace (
state
) {
let tag_reg = new RegExp('<(script|style)(?:[^<]|<)+</\\1>', 'g')
let newTokens = []
state.tokens
.filter(token => token.type == 'fence' && token.info == 'html')
.forEach(token => {
let tokens = (token.content.match(tag_reg) || []).map(content => {
let t = new Token('html_block', '', 0)
t.content = content
return t
})
if (tokens.length > 0) {
newTokens.push.apply(newTokens, tokens)
}
})
state.tokens.push.apply(state.tokens, newTokens)
})
if (plugins) {
plugins.forEach(function (plugin) {
if (Array.isArray(plugin)) {
parser.use.apply(parser, plugin)
} else {
parser.use(plugin)
}
})
}
}
/**
* override default parser rules by adding v-pre attribute on 'code' and 'pre' tags
* @param {Array<string>} rules rules to override
*/
function overrideParserRules (rules) {
if (parser && parser.renderer && parser.renderer.rules) {
var parserRules = parser.renderer.rules
rules.forEach(function (rule) {
if (parserRules && parserRules[rule]) {
var defaultRule = parserRules[rule]
parserRules[rule] = function () {
return addVuePreviewAttr(defaultRule.apply(this, arguments))
}
}
})
}
}
overrideParserRules(['code_inline', 'code_block', 'fence'])
if (preprocess) {
source = preprocess.call(this, parser, source)
}
var content = parser.render(source)
var result = renderVueTemplate(content, opts.wrapper)
if (opts.after && typeof opts.after === 'function') {
result = opts.after.call(this, result)
}
if (opts.raw) {
return result
} else {
return 'module.exports = ' + JSON.stringify(result)
}
}
module.exports = function (source) {
this.cacheable()
this.options.__vueMarkdownOptions__ =
this.query || this.vueMarkdown || this.options.vueMarkdown || {}
var result = markdownCompiler.call(this, source)
return result
}

View File

@ -1,101 +0,0 @@
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function (options) {
options = options || {}
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}

View File

@ -1,22 +0,0 @@
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap
module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

View File

@ -1,107 +0,0 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
const marked = require('marked')
marked.setOptions({
highlight: function (code) {
return require('highlight.js').highlightAuto(code).value
}
})
const getDemoTemplate = require('./demo.js')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src')
}
},
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.md$/,
loader: path.resolve(__dirname, './markdown-loader'),
options: {
before (source) {
return getDemoTemplate.call(this, source)
}
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}

View File

@ -1,95 +0,0 @@
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}))
resolve(devWebpackConfig)
}
})
})

View File

@ -1,150 +0,0 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = process.env.NODE_ENV === 'testing'
? require('../config/test.env')
: require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
publicPath: 'https://b.yzcdn.cn/zanui/weapp/',
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: process.env.NODE_ENV === 'testing'
? 'index.html'
: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig

View File

@ -1,7 +0,0 @@
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})

View File

@ -1,76 +0,0 @@
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: true
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}

View File

@ -1,4 +0,0 @@
'use strict'
module.exports = {
NODE_ENV: '"production"'
}

View File

@ -1,7 +0,0 @@
'use strict'
const merge = require('webpack-merge')
const devEnv = require('./dev.env')
module.exports = merge(devEnv, {
NODE_ENV: '"testing"'
})

View File

@ -1,8 +1,7 @@
const path = require('path')
const fs = require('fs')
const file = require('./file')
const demoPath = path.join(__dirname, '../../example/pages')
const demoPath = path.join(__dirname, '../example/pages')
function getDemoFiles (demoDir) {
if (!file.hasFile(demoDir)) return {}
let files = file.getFiles(demoDir)

View File

@ -1,59 +0,0 @@
module.exports = {
header: {
logo: {
image: 'https://img.yzcdn.cn/public_files/2017/12/18/fd78cf6bb5d12e2a119d0576bedfd230.png',
title: 'ZanUI',
href: 'http://www.youzanyun.com/zanui'
},
nav: {
lang: {
text: 'En',
from: 'zh-CN',
to: 'en-US'
},
github: 'https://github.com/youzan/vant'
}
},
footer: {
github: 'https://github.com/youzan/vant',
nav: {
'React 组件库': 'https://www.youzanyun.com/zanui/zent',
小程序组件库: 'https://github.com/youzan/zanui-weapp',
意见反馈: 'https://github.com/youzan/vant/issues',
开发指南: 'https://github.com/youzan/vant/blob/dev/.github/CONTRIBUTING.zh-CN.md',
加入我们: 'https://job.youzan.com'
}
},
docs: {
base: 'zanui',
category: [{
base: 'base',
label: '基础',
include: {
badge: import('../../packages/badge/README.md')
}
}],
include: {
badge: import('../../packages/badge/README.md')
}
}
/**
lang: {
'zn-ch': {
docs: {
base: 'zanui',
category: [{
base: 'base',
label: '基础',
include: {
badge: import('../../packages/badge/README.md')
}
}],
include: {
badge: import('../../packages/badge/README.md')
}
}
}
}
*/
}

View File

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>website</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

View File

@ -1,100 +0,0 @@
{
"name": "doc-web-cli",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "liujiandong <liujiandong@youzan.com>",
"bin": {
"gen-doc": "./bin/gen-doc"
},
"private": true,
"scripts": {
"dev": "npm run build:config && npm run lint && webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"build:config": "node build/doc.js --docs ../packages",
"start": "npm run dev",
"unit": "jest --config test/unit/jest.conf.js --coverage",
"e2e": "node test/e2e/runner.js",
"test": "npm run unit && npm run e2e",
"lint": "eslint --fix --ext .js,.vue src test/unit test/e2e/specs",
"build": "node build/build.js"
},
"dependencies": {
"markdown-loader": "^2.0.2",
"shelljs": "^0.7.8",
"vant-doc": "^1.0.1",
"vue": "^2.5.2",
"vue-router": "^3.0.1",
"yargs": "^10.1.1",
"escodegen": "^1.9.0",
"esprima": "^4.0.0",
"estraverse": "^4.2.0"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-jest": "^21.0.2",
"babel-loader": "^7.1.1",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chalk": "^2.0.1",
"chromedriver": "^2.27.2",
"copy-webpack-plugin": "^4.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.9",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"jest": "^22.0.4",
"jest-serializer-vue": "^0.3.0",
"nightwatch": "^0.9.12",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.10",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"style-loader": "^0.19.1",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-jest": "^1.0.2",
"vue-loader": "^13.3.0",
"vue-markdown-loader": "^2.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}

View File

@ -2,7 +2,7 @@
<div class="demo" :class="activeCodeType">
<h3 v-if="types.length">示例代码</h3>
<div class="demo-view-qrcode">
<img src="https://camo.githubusercontent.com/b3e6c0c62d421ef5df9d7e9b8366e6287c0464b7/68747470733a2f2f696d672e797a63646e2e636e2f7075626c69635f66696c65732f323031372f31302f33302f35353464643934306562316132363964346163393133336537386165333231662e6a70673f696d61676556696577322f322f772f3330302f682f333030" />
<img src="https://img.yzcdn.cn/public_files/2017/10/30/554dd940eb1a269d4ac9133e78ae321f.jpg?imageView2/2/w/300/h/300" />
<div>微信扫一扫</div>
</div>
<!-- <div class="code-type-tabs">

View File

@ -4,6 +4,9 @@
top: 0;
z-index: 2;
}
.van-doc-header__top-nav-item .van-doc-header__top-nav-lang {
display: none;
}
.van-doc-footer {
position: relative
}

View File

@ -1,44 +0,0 @@
<template>
<div id="app">
<doc-header :config="config.header" active="移动端" />
<section class="doc-body">
<div class="doc-menus">
<side-menu :menus="config.routes || []" />
</div>
<router-view class="doc-content" />
</section>
<doc-footer :config="config.footer" />
</div>
</template>
<script>
export default {
name: 'App',
computed: {
config () {
return this.$root.getConfig()
}
}
}
</script>
<style scoped>
.doc-body {
display: flex;
}
@media (min-width: 1024px) {
.doc-body {
display: flex;
width: 1024px;
margin: 0 auto;
}
}
.doc-menus {
width: 200px;
}
.doc-content {
flex: 1;
padding: 15px;
}
</style>

View File

@ -1,110 +0,0 @@
body, ul {
margin: 0;
padding: 0;
}
a {
text-decoration: none;
}
code {
display: block;
font-size: 13px;
overflow-x: auto;
font-weight: 400;
line-height: 22px;
border-radius: 6px;
margin-bottom: 25px;
position: relative;
word-break: break-all;
white-space: pre-wrap;
background-color: #f5f7fa;
color: #455a64;
padding: 18px 10px 18px 20px;
font-family: "Source Code Pro", "Monaco", "Inconsolata", monospace;
}
code::after {
top: 5px;
right: 10px;
position: absolute;
color: #ccc;
font-size: 12px;
}
pre {
margin: 0;
}
pre + pre {
margin-top: -10px;
}
code.language-html::after {
content: 'HTML';
}
code.language-javascript::after {
content: 'JS';
}
code.language-css::after {
content: 'CSS';
}
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #fff;
}
.hljs-subst {
color: #455a64;
}
.hljs-string,
.hljs-meta,
.hljs-symbol,
.hljs-template-tag,
.hljs-template-variable,
.hljs-addition {
color: #756bb1;
}
.hljs-comment,
.hljs-quote {
color: #999;
}
.hljs-number,
.hljs-regexp,
.hljs-literal,
.hljs-bullet,
.hljs-link {
color: #31a354;
}
.hljs-deletion,
.hljs-variable {
color: #88f;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-title,
.hljs-section,
.hljs-built_in,
.hljs-doctag,
.hljs-type,
.hljs-tag,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class,
.hljs-strong {
color: #1976d2;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-attribute {
color: #e6550d;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -1,71 +0,0 @@
import Vue from 'vue'
import Router from 'vue-router'
import config from '../doc.config'
import Documentation from '@/components/Documentation'
Vue.use(Router)
if (config.plugins && Array.isArray(config.plugins)) {
config.plugins.forEach(plugin => Vue.use(plugin.default || plugin))
}
function flatten (arr) {
while (arr.some(item => Array.isArray(item))) {
arr = [].concat(...arr)
}
return arr
}
function join (...rest) {
return ('/' + rest.join('/')).replace('//', '/')
}
function genRouter (docConf) {
let routes = []
let base = docConf.base || '/'
if (docConf.category && Array.isArray(docConf.category)) {
docConf.category.forEach((category) => {
let route = {}
route.path = join(base, category.base)
route.name = category.label
route.component = Documentation
route.children = genRouter(category).map(route => {
route.path = join(base, route.path)
return route
})
routes.push(route)
})
}
let keys = Object.keys(docConf.include)
keys.forEach(key => {
let route = {}
let isPromise = !!docConf.include[key].then
route.path = join(base, key)
route.name = key
Object.defineProperty(route, '__label', {value: isPromise ? key : docConf.include[key].label})
route.component = Documentation
routes.push(route)
Vue.component(
`x-${key}`,
() => isPromise ? docConf.include[key] : Promise.resolve(docConf.include[key])
)
})
return routes
}
let routes = []
if (config.lang) {
routes = flatten(Object.keys(config.lang).map(key => {
config.lang[key].docs.base = join(key, config.lang[key].docs.base)
let routes = genRouter(config.lang[key].docs)
config.lang[key].routes = routes
return routes
}))
} else {
routes = genRouter(config.docs)
config.routes = routes
}
export default {
config,
router: new Router({ routes })
}

View File

@ -1,32 +0,0 @@
<template>
<doc-container>
<doc-content>
<component :is="component"></component>
</doc-content>
</doc-container>
</template>
<script>
import Vue from 'vue'
export default {
data () {
return {
component: null
}
},
created () {
this.hasComponent(`x-${this.$route.name}`)
},
watch: {
'$route' ({name}) {
this.hasComponent(`x-${name}`)
}
},
methods: {
hasComponent (name) {
if (Vue.component(name)) {
this.component = name
}
}
}
}
</script>

View File

@ -1,33 +0,0 @@
<template>
<nav class="menu-item" :class="{active: menu.name === $route.name}">
<router-link v-if="!menu.children" :to="{path: menu.path}">{{menu.__label || menu.name}}</router-link>
<a class="no-href" v-if="menu.children">{{menu.__label || menu.name}}</a>
<menu-item :menu="menu" :key="menu.path" v-for="menu in menu.children"></menu-item>
</nav>
</template>
<script>
export default {
name: 'menu-item',
props: ['menu']
}
</script>
<style scoped>
.menu-item a {
margin: 0;
display: block;
color: #455a64;
font-size: 16px;
padding: 8px 20px;
line-height: 24px;
transition: all .3s;
}
.menu-item a.no-href {
color: #455a64bd;
}
.menu-item.active {
color: #38f;
background-color: #f5f7fa;
}
</style>

View File

@ -1,28 +0,0 @@
<template>
<aside class="side-menus" v-if="menus.length">
<menu-item :menu="menu" v-for="menu in menus" :key="menu.path"></menu-item>
</aside>
</template>
<script>
import MenuItem from './MenuItem'
export default {
name: 'SideMneu',
props: ['menus'],
components: {MenuItem}
}
</script>
<style scoped>
.side-menus {
padding: 15px;
width: 200px;
padding: 20px 0;
min-width: 240px;
max-width: 240px;
}
.side-menus .side-menus {
padding-left: 15px;
}
</style>

View File

@ -1,90 +0,0 @@
module.exports = {
header: {
logo: {
image: 'https://img.yzcdn.cn/public_files/2017/12/18/fd78cf6bb5d12e2a119d0576bedfd230.png',
title: 'ZanUI 小程序',
href: 'http://www.youzanyun.com/zanui'
},
nav: {
lang: {
text: 'En',
from: 'zh-CN',
to: 'en-US'
},
github: 'https://github.com/youzan/zanui-weapp'
}
},
footer: {
github: 'https://github.com/youzan/zanui-weapp',
nav: {
'React 组件库': 'https://www.youzanyun.com/zanui/zent',
'Vue 组件库': 'https://www.youzanyun.com/zanui/vant',
意见反馈: 'https://github.com/youzan/zanui-weapp/issues',
开发指南: 'https://github.com/youzan/zanui-weapp/blob/dev/.github/CONTRIBUTING.zh-CN.md',
加入我们: 'https://job.youzan.com'
}
},
plugins: [
require('./plugins/wxapp-demo'),
require('./plugins/vant-doc')
],
docs: {
base: 'zanui',
category: [
{
base: 'base',
label: '基础',
include: {
icon: require('../../packages/icon/README.md'),
btn: require('../../packages/btn/README.md'),
helper: require('../../packages/helper/README.md')
}
},
{
base: 'layout',
label: '布局',
include: {
row: require('../../packages/row/README.md'),
cell: require('../../packages/cell/README.md'),
card: require('../../packages/card/README.md'),
panel: require('../../packages/panel/README.md')
}
},
{
base: 'form',
label: '表单',
include: {
field: require('../../packages/field/README.md'),
switch: require('../../packages/switch/README.md'),
select: require('../../packages/select/README.md'),
stepper: require('../../packages/stepper/README.md')
}
},
{
base: 'view',
label: '展示',
include: {
tag: require('../../packages/tag/README.md'),
badge: require('../../packages/badge/README.md'),
capsule: require('../../packages/capsule/README.md'),
noticebar: require('../../packages/noticebar/README.md'),
steps: require('../../packages/steps/README.md')
}
},
{
base: 'interactive',
label: '交互',
include: {
toast: require('../../packages/toast/README.md'),
popup: require('../../packages/popup/README.md'),
dialog: require('../../packages/dialog/README.md'),
toptips: require('../../packages/toptips/README.md'),
tab: require('../../packages/tab/README.md'),
loadmore: require('../../packages/loadmore/README.md'),
actionsheet: require('../../packages/actionsheet/README.md')
}
}
],
include: {}
}
}

View File

@ -1,26 +0,0 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import boot from './boot'
import SideMenu from '@/components/SideMenu'
import '@/assets/base.css'
Vue.config.productionTip = false
Vue.component('side-menu', SideMenu)
/* eslint-disable no-new */
new Vue({
el: '#app',
router: boot.router,
methods: {
getConfig (lang) {
if (!lang && !boot.config.lang) {
return boot.config
}
return boot.config.lang[lang]
}
},
components: { App },
template: '<App/>'
})

View File

@ -1,14 +0,0 @@
import {
Header,
Footer,
Content,
Container
} from 'vant-doc'
export default {
install (vue) {
vue.component('doc-container', Container)
vue.component('doc-content', Content)
vue.component('doc-header', Header)
vue.component('doc-footer', Footer)
}
}

View File

@ -1,27 +0,0 @@
// A custom Nightwatch assertion.
// The assertion name is the filename.
// Example usage:
//
// browser.assert.elementCount(selector, count)
//
// For more information on custom assertions see:
// http://nightwatchjs.org/guide#writing-custom-assertions
exports.assertion = function (selector, count) {
this.message = 'Testing if element <' + selector + '> has count: ' + count
this.expected = count
this.pass = function (val) {
return val === this.expected
}
this.value = function (res) {
return res.value
}
this.command = function (cb) {
var self = this
return this.api.execute(function (selector) {
return document.querySelectorAll(selector).length
}, [selector], function (res) {
cb.call(self, res)
})
}
}

View File

@ -1,46 +0,0 @@
require('babel-register')
var config = require('../../config')
// http://nightwatchjs.org/gettingstarted#settings-file
module.exports = {
src_folders: ['test/e2e/specs'],
output_folder: 'test/e2e/reports',
custom_assertions_path: ['test/e2e/custom-assertions'],
selenium: {
start_process: true,
server_path: require('selenium-server').path,
host: '127.0.0.1',
port: 4444,
cli_args: {
'webdriver.chrome.driver': require('chromedriver').path
}
},
test_settings: {
default: {
selenium_port: 4444,
selenium_host: 'localhost',
silent: true,
globals: {
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
}
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true,
acceptSslCerts: true
}
},
firefox: {
desiredCapabilities: {
browserName: 'firefox',
javascriptEnabled: true,
acceptSslCerts: true
}
}
}
}

View File

@ -1,48 +0,0 @@
// 1. start the dev server using production config
process.env.NODE_ENV = 'testing'
const webpack = require('webpack')
const DevServer = require('webpack-dev-server')
const webpackConfig = require('../../build/webpack.prod.conf')
const devConfigPromise = require('../../build/webpack.dev.conf')
let server
devConfigPromise.then(devConfig => {
const devServerOptions = devConfig.devServer
const compiler = webpack(webpackConfig)
server = new DevServer(compiler, devServerOptions)
const port = devServerOptions.port
const host = devServerOptions.host
return server.listen(port, host)
})
.then(() => {
// 2. run the nightwatch test suite against it
// to run in additional browsers:
// 1. add an entry in test/e2e/nightwatch.conf.js under "test_settings"
// 2. add it to the --env flag below
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
// For more information on Nightwatch's config file, see
// http://nightwatchjs.org/guide#settings-file
let opts = process.argv.slice(2)
if (opts.indexOf('--config') === -1) {
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
}
if (opts.indexOf('--env') === -1) {
opts = opts.concat(['--env', 'chrome'])
}
const spawn = require('cross-spawn')
const runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
runner.on('exit', function (code) {
server.close()
process.exit(code)
})
runner.on('error', function (err) {
server.close()
throw err
})
})

View File

@ -1,19 +0,0 @@
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL
browser
.url(devServer)
.waitForElementVisible('#app', 5000)
.assert.elementPresent('.hello')
.assert.containsText('h1', 'Welcome to Your Vue.js App')
.assert.elementCount('img', 1)
.end()
}
}

View File

@ -1,7 +0,0 @@
{
"env": {
"jest": true
},
"globals": {
}
}

View File

@ -1,30 +0,0 @@
const path = require('path')
module.exports = {
rootDir: path.resolve(__dirname, '../../'),
moduleFileExtensions: [
'js',
'json',
'vue'
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
transform: {
'^.+\\.js$': '<rootDir>/node_modules/babel-jest',
'.*\\.(vue)$': '<rootDir>/node_modules/vue-jest'
},
testPathIgnorePatterns: [
'<rootDir>/test/e2e'
],
snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
setupFiles: ['<rootDir>/test/unit/setup'],
mapCoverage: true,
coverageDirectory: '<rootDir>/test/unit/coverage',
collectCoverageFrom: [
'src/**/*.{js,vue}',
'!src/main.js',
'!src/router/index.js',
'!**/node_modules/**'
]
}

View File

@ -1,3 +0,0 @@
import Vue from 'vue'
Vue.config.productionTip = false

View File

@ -1,11 +0,0 @@
import Vue from 'vue'
import HelloWorld from '@/components/HelloWorld'
describe('HelloWorld.vue', () => {
it('should render correct contents', () => {
const Constructor = Vue.extend(HelloWorld)
const vm = new Constructor().$mount()
expect(vm.$el.querySelector('.hello h1').textContent)
.toEqual('Welcome to Your Vue.js App')
})
})

File diff suppressed because it is too large Load Diff

20
wedoc.js Normal file
View File

@ -0,0 +1,20 @@
const path = require('path')
const getDemoTemplate = require('./website/demo')
module.exports = {
async: false,
config: path.resolve(__dirname, 'doc.config.js'),
docs: [ path.resolve(__dirname, 'packages') ],
out: path.resolve(__dirname, 'website/dist'),
markdown: {
before (source) {
return getDemoTemplate.call(this, source)
}
},
webpack: {
output: {
publicPath: process.argv[process.argv.length - 1] === 'build' ? 'https://b.yzcdn.cn/zanui/weapp' : '/',
filename: '[name].[hash].js'
}
}
}

7399
yarn.lock

File diff suppressed because it is too large Load Diff