Skip to content

Commit

Permalink
fix(ui): 增加单元测试命令 测试覆盖率统计 ide高亮支持 优化cli代码可读性
Browse files Browse the repository at this point in the history
affects: @varlet/cli, @varlet/ui
  • Loading branch information
齐皓 authored and 齐皓 committed Feb 23, 2021
1 parent 68e9ff5 commit 91882c6
Show file tree
Hide file tree
Showing 376 changed files with 87,269 additions and 470 deletions.
14 changes: 4 additions & 10 deletions packages/varlet-cli/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ var build_1 = require("./commands/build");
var compile_1 = require("./commands/compile");
var create_1 = require("./commands/create");
var jest_1 = require("./commands/jest");
commander_1.command('dev')
.description('Run varlet development environment')
.action(dev_1.dev);
commander_1.command('build')
.description('Build varlet site for production')
.action(build_1.build);
commander_1.command('dev').description('Run varlet development environment').action(dev_1.dev);
commander_1.command('build').description('Build varlet site for production').action(build_1.build);
commander_1.command('compile')
.description('Compile varlet components library code')
.option('-w, --watch', 'Watch files change auto compile')
.action(compile_1.compile);
commander_1.command('create <name>')
.description('Create a component directory')
.action(create_1.create);
commander_1.command('create <name>').description('Create a component directory').action(create_1.create);
commander_1.command('jest')
.option('-c, --component [componentName]', 'Run Jest in component directory')
.description('Run Jest in work directory')
.option('-w, --watch', 'Watch files change auto jest')
.action(jest_1.jest);
commander_1.parse();
9 changes: 7 additions & 2 deletions packages/varlet-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"files": [
"lib",
"site",
"src/shims-vue.d.ts",
"src/shims-md.d.ts",
"../varlet-ui/shims-vue.d.ts",
"../varlet-ui/shims-md.d.ts",
"tsconfig.json",
"varlet.default.config.js"
],
Expand All @@ -41,6 +41,7 @@
"@varlet/markdown-loader": "^0.7.0",
"@vue/compiler-sfc": "^3.0.2",
"autoprefixer": "9",
"babel-jest": "^26.6.3",
"babel-loader": "^8.1.0",
"chalk": "^4.1.0",
"chokidar": "^3.4.3",
Expand All @@ -57,13 +58,16 @@
"jest": "^26.6.3",
"less": "^3.12.2",
"less-loader": "^7.0.2",
"lodash": "^4.17.21",
"ora": "^5.1.0",
"portfinder": "^1.0.28",
"postcss": "7",
"postcss-loader": "^4.0.4",
"slash": "^3.0.0",
"style-loader": "^2.0.0",
"ts-jest": "^26.5.1",
"typescript": "^4.1.3",
"vue-jest": "^5.0.0-alpha.8",
"vue-loader": "16",
"vue-router": "4.0.0-rc.1",
"webpack": "^5.23.0",
Expand All @@ -76,6 +80,7 @@
"@types/fs-extra": "^9.0.2",
"@types/hash-sum": "^1.0.0",
"@types/jest": "^26.0.15",
"@types/lodash": "^4.14.168",
"@types/mini-css-extract-plugin": "^1.2.0",
"@types/webpack-dev-server": "^3.11.1"
},
Expand Down
11 changes: 3 additions & 8 deletions packages/varlet-cli/site/pc/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,17 @@ import { createApp } from 'vue'
import { createRouter, createWebHashHistory } from 'vue-router'
import App from './App.vue'
import '@varlet/touch-emulator'
import routes from './routes'
// @ts-ignore
import routes from '@pc-routes'
// @ts-ignore
import config from '@config'

const defaultConfig = require('../../varlet.default.config.js')

const mergeConfig = {
...defaultConfig,
...config,
}
const router = createRouter({
history: createWebHashHistory(),
routes,
})

const app = createApp(App as any)

app.config.globalProperties.$config = mergeConfig
app.config.globalProperties.$config = config
app.use(router).mount('#app')
273 changes: 273 additions & 0 deletions packages/varlet-cli/site/site.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"namespace": "var",
"host": "0.0.0.0",
"title": "varlet",
"port": 8080,
"pc": {
"title": "Varlet 组件库示例",
"description": "Varlet 组件库示例",
"logo": "https://cn.vuejs.org/images/logo.png",
"header": {
"i18nButton": {
"zh_CN": "En",
"en_US": "中文"
},
"logo": "https://cn.vuejs.org/images/logo.png",
"search": {
"zh_CN": "搜索文档...",
"en_US": "Search..."
}
},
"menu": [
{
"text": {
"zh_CN": "快速开始"
},
"isTitle": true
},
{
"text": {
"zh_CN": "组件"
},
"isTitle": true
},
{
"text": {
"zh_CN": "Ripple 水波指令",
"en_US": "Ripple"
},
"doc": "ripple"
},
{
"text": {
"zh_CN": "Skeleton 骨架屏",
"en_US": "Skeleton"
},
"doc": "skeleton"
},
{
"text": {
"zh_CN": "Loading 加载",
"en_US": "Loading"
},
"doc": "loading"
},
{
"text": {
"zh_CN": "Button 按钮",
"en_US": "Button"
},
"doc": "button"
},
{
"text": {
"zh_CN": "Popup 弹出层",
"en_US": "Popup"
},
"doc": "popup"
},
{
"text": {
"zh_CN": "Snackbar 消息条",
"en_US": "Snackbar"
},
"doc": "snackbar"
},
{
"text": {
"zh_CN": "Progress 进度条",
"en_US": "Progress"
},
"doc": "progress"
},
{
"text": {
"zh_CN": "PullRefresh 下拉刷新",
"en_US": "PullRefresh"
},
"doc": "pull-refresh"
},
{
"text": {
"zh_CN": "Chip 标签",
"en_US": "Chip"
},
"doc": "chip"
},
{
"text": {
"zh_CN": "Badge 徽标",
"en_US": "Badge"
},
"doc": "badge"
},
{
"text": {
"zh_CN": "ExpansionPanels 拓展面板",
"en_US": "ExpansionPanels"
},
"doc": "Expansion-panels"
},
{
"text": {
"zh_CN": "Tabs 选项卡",
"en_US": "Tabs"
},
"doc": "tabs"
},
{
"text": {
"zh_CN": "List 无限滚动列表",
"en_US": "List"
},
"doc": "list"
},
{
"text": {
"zh_CN": "Sticky 粘性布局",
"en_US": "Sticky"
},
"doc": "sticky"
},
{
"text": {
"zh_CN": "Menu 菜单",
"en_US": "Menu"
},
"doc": "menu"
},
{
"text": {
"zh_CN": "Lazy 懒加载",
"en_US": "Lazy"
},
"doc": "lazy"
},
{
"text": {
"zh_CN": "Dialog 对话框",
"en_US": "Dialog"
},
"doc": "dialog"
},
{
"text": {
"zh_CN": "Image 图片",
"en_US": "Image"
},
"doc": "image"
},
{
"text": {
"zh_CN": "Icon 图标",
"en_US": "Icon"
},
"doc": "icon"
},
{
"text": {
"zh_CN": "Rate 评分",
"en_US": "Rate"
},
"doc": "rate"
},
{
"text": {
"zh_CN": "Input 输入框",
"en_US": "Input"
},
"doc": "input"
},
{
"text": {
"zh_CN": "Select 选择框",
"en_US": "Select"
},
"doc": "select"
},
{
"text": {
"zh_CN": "Radio 单选框",
"en_US": "Radio"
},
"doc": "radio"
},
{
"text": {
"zh_CN": "Checkbox 复选框",
"en_US": "Checkbox"
},
"doc": "checkbox"
},
{
"text": {
"zh_CN": "IndexBar 索引栏",
"en_US": "IndexBar"
},
"doc": "index-bar"
},
{
"text": {
"zh_CN": "Switch 开关",
"en_US": "Switch"
},
"doc": "switch"
},
{
"text": {
"zh_CN": "Slider 滑块",
"en_US": "slider"
},
"doc": "slider"
},
{
"text": {
"zh_CN": "Swipe 轮播",
"en_US": "Swipe"
},
"doc": "swipe"
},
{
"text": {
"zh_CN": "DatePicker 日期选择器",
"en_US": "DatePicker"
},
"doc": "date-picker"
},
{
"text": {
"zh_CN": "BackTop 回到顶部",
"en_US": "BackTop"
},
"doc": "back-top"
},
{
"text": {
"zh_CN": "Cell 单元格",
"en_US": "Cell"
},
"doc": "cell"
},
{
"text": {
"zh_CN": "Uploader 文件上传",
"en_US": "Uploader"
},
"doc": "uploader"
},
{
"text": {
"zh_CN": "Picker 多列选择器",
"en_US": "Picker"
},
"doc": "picker"
}
],
"language": "zh_CN"
},
"mobile": {
"title": "Varlet 组件库示例",
"description": "Varlet 组件库示例",
"logo": "https://cn.vuejs.org/images/logo.png"
}
}
10 changes: 5 additions & 5 deletions packages/varlet-cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import webpack from 'webpack'
import logger from '../shared/logger'
import { buildMobileSiteRoutes, buildPcSiteRoutes } from '../compiler/compileRoutes'
import { getBuildConfig } from '../config/webpack.build.config'
import { VARLET_CONFIG } from '../shared/constant'
import { ensureConfigFile } from '../shared/fsUtils'
import { ensureDirSync } from 'fs-extra'
import { SRC_DIR } from '../shared/constant'

export async function build() {
ensureConfigFile(VARLET_CONFIG)
ensureDirSync(SRC_DIR)

await Promise.all([buildMobileSiteRoutes(), buildPcSiteRoutes()])

const config = getBuildConfig()

webpack(config, (err, stats: any) => {
webpack(config, (err, stats) => {
err && logger.error(err.toString())
stats?.hasErrors() && logger.error(stats)
stats?.hasErrors() && logger.error(stats.toString())
})
}
Loading

0 comments on commit 91882c6

Please sign in to comment.