test(compiler): auto create example index.wxml

This commit is contained in:
nemo-shen 2021-12-13 01:05:42 +08:00 committed by neverland
parent 5778acc088
commit 565d71eedb
56 changed files with 83 additions and 134 deletions

View File

@ -1,3 +1,4 @@
const fs = require('fs');
const gulp = require('gulp'); const gulp = require('gulp');
const path = require('path'); const path = require('path');
const less = require('gulp-less'); const less = require('gulp-less');
@ -16,8 +17,10 @@ const exampleConfig = path.resolve(__dirname, '../tsconfig.example.json');
const libDir = path.resolve(__dirname, '../lib'); const libDir = path.resolve(__dirname, '../lib');
const esDir = path.resolve(__dirname, '../dist'); const esDir = path.resolve(__dirname, '../dist');
const exampleDir = path.resolve(__dirname, '../example/dist'); const exampleDistDir = path.resolve(__dirname, '../example/dist');
const examplePagesDir = path.resolve(__dirname, '../example/pages');
const exampleAppJsonPath = path.resolve(__dirname, '../example/app.json');
const baseCssPath = path.resolve(__dirname, '../packages/common/index.wxss'); const baseCssPath = path.resolve(__dirname, '../packages/common/index.wxss');
const lessCompiler = (dist) => const lessCompiler = (dist) =>
@ -101,18 +104,34 @@ const tasks = [
}, {}); }, {});
tasks.buildExample = gulp.series( tasks.buildExample = gulp.series(
cleaner(exampleDir), cleaner(exampleDistDir),
gulp.parallel( gulp.parallel(
tsCompiler(exampleDir, exampleConfig), tsCompiler(exampleDistDir, exampleConfig),
lessCompiler(exampleDir), lessCompiler(exampleDistDir),
staticCopier(exampleDir), staticCopier(exampleDistDir),
() => () =>
gulp.src(`${icons}/**/*`).pipe(gulp.dest(`${exampleDir}/@vant/icons`)), gulp
.src(`${icons}/**/*`)
.pipe(gulp.dest(`${exampleDistDir}/@vant/icons`)),
() => { () => {
gulp.watch(`${src}/**/*.less`, lessCompiler(exampleDir)); const appJson = JSON.parse(fs.readFileSync(exampleAppJsonPath));
gulp.watch(`${src}/**/*.wxml`, copier(exampleDir, 'wxml')); appJson.pages.forEach((path) => {
gulp.watch(`${src}/**/*.wxs`, copier(exampleDir, 'wxs')); const component = path.replace(/(pages\/|\/index)/g, '');
gulp.watch(`${src}/**/*.json`, copier(exampleDir, 'json')); fs.writeFileSync(
`${examplePagesDir}/${component}/index.js`,
"import Page from '../../common/page';Page();"
);
fs.writeFileSync(
`${examplePagesDir}/${component}/index.wxml`,
`<van-${component}-demo />`
);
});
},
() => {
gulp.watch(`${src}/**/*.less`, lessCompiler(exampleDistDir));
gulp.watch(`${src}/**/*.wxml`, copier(exampleDistDir, 'wxml'));
gulp.watch(`${src}/**/*.wxs`, copier(exampleDistDir, 'wxs'));
gulp.watch(`${src}/**/*.json`, copier(exampleDistDir, 'json'));
} }
) )
); );

View File

@ -63,122 +63,57 @@
}, },
"usingComponents": { "usingComponents": {
"demo-block": "./components/demo-block/index", "demo-block": "./components/demo-block/index",
"van-action-sheet": "./dist/action-sheet/index",
"van-action-sheet-demo": "./dist/action-sheet/demo/index", "van-action-sheet-demo": "./dist/action-sheet/demo/index",
"van-area": "./dist/area/index",
"van-area-demo": "./dist/area/demo/index", "van-area-demo": "./dist/area/demo/index",
"van-button": "./dist/button/index",
"van-button-demo": "./dist/button/demo/index", "van-button-demo": "./dist/button/demo/index",
"van-card": "./dist/card/index",
"van-card-demo": "./dist/card/demo/index", "van-card-demo": "./dist/card/demo/index",
"van-cell": "./dist/cell/index",
"van-cell-demo": "./dist/cell/demo/index", "van-cell-demo": "./dist/cell/demo/index",
"van-cell-group": "./dist/cell-group/index",
"van-checkbox": "./dist/checkbox/index",
"van-checkbox-demo": "./dist/checkbox/demo/index", "van-checkbox-demo": "./dist/checkbox/demo/index",
"van-checkbox-group": "./dist/checkbox-group/index",
"van-col": "./dist/col/index",
"van-col-demo": "./dist/col/demo/index", "van-col-demo": "./dist/col/demo/index",
"van-count-down": "./dist/count-down/index",
"van-count-down-demo": "./dist/count-down/demo/index", "van-count-down-demo": "./dist/count-down/demo/index",
"van-dialog": "./dist/dialog/index",
"van-dialog-demo": "./dist/dialog/demo/index", "van-dialog-demo": "./dist/dialog/demo/index",
"van-divider": "./dist/divider/index",
"van-divider-demo": "./dist/divider/demo/index", "van-divider-demo": "./dist/divider/demo/index",
"van-empty": "./dist/empty/index",
"van-empty-demo": "./dist/empty/demo/index", "van-empty-demo": "./dist/empty/demo/index",
"van-field": "./dist/field/index",
"van-field-demo": "./dist/field/demo/index", "van-field-demo": "./dist/field/demo/index",
"van-goods-action": "./dist/goods-action/index",
"van-goods-action-demo": "./dist/goods-action/demo/index", "van-goods-action-demo": "./dist/goods-action/demo/index",
"van-goods-action-icon": "./dist/goods-action-icon/index",
"van-goods-action-button": "./dist/goods-action-button/index",
"van-icon": "./dist/icon/index",
"van-icon-demo": "./dist/icon/demo/index", "van-icon-demo": "./dist/icon/demo/index",
"van-image": "./dist/image/index",
"van-image-demo": "./dist/image/demo/index", "van-image-demo": "./dist/image/demo/index",
"van-loading": "./dist/loading/index",
"van-loading-demo": "./dist/loading/demo/index", "van-loading-demo": "./dist/loading/demo/index",
"van-nav-bar": "./dist/nav-bar/index",
"van-nav-bar-demo": "./dist/nav-bar/demo/index", "van-nav-bar-demo": "./dist/nav-bar/demo/index",
"van-notice-bar": "./dist/notice-bar/index",
"van-notice-bar-demo": "./dist/notice-bar/demo/index", "van-notice-bar-demo": "./dist/notice-bar/demo/index",
"van-notify": "./dist/notify/index",
"van-notify-demo": "./dist/notify/demo/index", "van-notify-demo": "./dist/notify/demo/index",
"van-panel": "./dist/panel/index",
"van-panel-demo": "./dist/panel/demo/index", "van-panel-demo": "./dist/panel/demo/index",
"van-popup": "./dist/popup/index",
"van-popup-demo": "./dist/popup/demo/index", "van-popup-demo": "./dist/popup/demo/index",
"van-progress": "./dist/progress/index",
"van-progress-demo": "./dist/progress/demo/index", "van-progress-demo": "./dist/progress/demo/index",
"van-radio": "./dist/radio/index",
"van-radio-demo": "./dist/radio/demo/index", "van-radio-demo": "./dist/radio/demo/index",
"van-radio-group": "./dist/radio-group/index",
"van-row": "./dist/row/index",
"van-search": "./dist/search/index",
"van-search-demo": "./dist/search/demo/index", "van-search-demo": "./dist/search/demo/index",
"van-sidebar": "./dist/sidebar/index",
"van-sidebar-demo": "./dist/sidebar/demo/index", "van-sidebar-demo": "./dist/sidebar/demo/index",
"van-sidebar-item": "./dist/sidebar-item/index",
"van-slider": "./dist/slider/index",
"van-slider-demo": "./dist/slider/demo/index", "van-slider-demo": "./dist/slider/demo/index",
"van-stepper": "./dist/stepper/index",
"van-stepper-demo": "./dist/stepper/demo/index", "van-stepper-demo": "./dist/stepper/demo/index",
"van-steps": "./dist/steps/index",
"van-steps-demo": "./dist/steps/demo/index", "van-steps-demo": "./dist/steps/demo/index",
"van-sticky": "./dist/sticky/index",
"van-sticky-demo": "./dist/sticky/demo/index", "van-sticky-demo": "./dist/sticky/demo/index",
"van-submit-bar": "./dist/submit-bar/index",
"van-submit-bar-demo": "./dist/submit-bar/demo/index", "van-submit-bar-demo": "./dist/submit-bar/demo/index",
"van-swipe-cell": "./dist/swipe-cell/index",
"van-swipe-cell-demo": "./dist/swipe-cell/demo/index", "van-swipe-cell-demo": "./dist/swipe-cell/demo/index",
"van-uploader": "./dist/uploader/index",
"van-uploader-demo": "./dist/uploader/demo/index", "van-uploader-demo": "./dist/uploader/demo/index",
"van-switch": "./dist/switch/index",
"van-switch-demo": "./dist/switch/demo/index", "van-switch-demo": "./dist/switch/demo/index",
"van-tab": "./dist/tab/index",
"van-tab-demo": "./dist/tab/demo/index", "van-tab-demo": "./dist/tab/demo/index",
"van-tabs": "./dist/tabs/index",
"van-tabbar": "./dist/tabbar/index",
"van-tabbar-demo": "./dist/tabbar/demo/index", "van-tabbar-demo": "./dist/tabbar/demo/index",
"van-tabbar-item": "./dist/tabbar-item/index",
"van-tag": "./dist/tag/index",
"van-tag-demo": "./dist/tag/demo/index", "van-tag-demo": "./dist/tag/demo/index",
"van-toast": "./dist/toast/index",
"van-toast-demo": "./dist/toast/demo/index", "van-toast-demo": "./dist/toast/demo/index",
"van-transition": "./dist/transition/index",
"van-transition-demo": "./dist/transition/demo/index", "van-transition-demo": "./dist/transition/demo/index",
"van-tree-select": "./dist/tree-select/index",
"van-tree-select-demo": "./dist/tree-select/demo/index", "van-tree-select-demo": "./dist/tree-select/demo/index",
"van-datetime-picker": "./dist/datetime-picker/index",
"van-datetime-picker-demo": "./dist/datetime-picker/demo/index", "van-datetime-picker-demo": "./dist/datetime-picker/demo/index",
"van-rate": "./dist/rate/index",
"van-rate-demo": "./dist/rate/demo/index", "van-rate-demo": "./dist/rate/demo/index",
"van-collapse": "./dist/collapse/index",
"van-collapse-demo": "./dist/collapse/demo/index", "van-collapse-demo": "./dist/collapse/demo/index",
"van-collapse-item": "./dist/collapse-item/index",
"van-picker": "./dist/picker/index",
"van-picker-demo": "./dist/picker/demo/index", "van-picker-demo": "./dist/picker/demo/index",
"van-overlay": "./dist/overlay/index",
"van-overlay-demo": "./dist/overlay/demo/index", "van-overlay-demo": "./dist/overlay/demo/index",
"van-circle": "./dist/circle/index",
"van-circle-demo": "./dist/circle/demo/index", "van-circle-demo": "./dist/circle/demo/index",
"van-index-bar": "./dist/index-bar/index",
"van-index-bar-demo": "./dist/index-bar/demo/index", "van-index-bar-demo": "./dist/index-bar/demo/index",
"van-index-anchor": "./dist/index-anchor/index",
"van-grid": "./dist/grid/index",
"van-grid-demo": "./dist/grid/demo/index", "van-grid-demo": "./dist/grid/demo/index",
"van-grid-item": "./dist/grid-item/index",
"van-dropdown-menu": "./dist/dropdown-menu/index",
"van-dropdown-menu-demo": "./dist/dropdown-menu/demo/index", "van-dropdown-menu-demo": "./dist/dropdown-menu/demo/index",
"van-dropdown-item": "./dist/dropdown-item/index",
"van-skeleton": "./dist/skeleton/index",
"van-skeleton-demo": "./dist/skeleton/demo/index", "van-skeleton-demo": "./dist/skeleton/demo/index",
"van-calendar": "./dist/calendar/index",
"van-calendar-demo": "./dist/calendar/demo/index", "van-calendar-demo": "./dist/calendar/demo/index",
"van-share-sheet": "./dist/share-sheet/index",
"van-share-sheet-demo": "./dist/share-sheet/demo/index", "van-share-sheet-demo": "./dist/share-sheet/demo/index",
"van-config-provider": "./dist/config-provider/index",
"van-config-provider-demo": "./dist/config-provider/demo/index" "van-config-provider-demo": "./dist/config-provider/demo/index"
}, },
"sitemapLocation": "sitemap.json" "sitemapLocation": "sitemap.json"

View File

@ -1 +1 @@
<van-action-sheet-demo /> <van-action-sheet-demo />

View File

@ -1 +1 @@
<van-area-demo /> <van-area-demo />

View File

@ -1 +1 @@
<van-button-demo /> <van-button-demo />

View File

@ -1 +1 @@
<van-calendar-demo /> <van-calendar-demo />

View File

@ -1 +1 @@
<van-card-demo /> <van-card-demo />

View File

@ -1 +1 @@
<van-cell-demo /> <van-cell-demo />

View File

@ -1 +1 @@
<van-checkbox-demo /> <van-checkbox-demo />

View File

@ -1 +1 @@
<van-circle-demo /> <van-circle-demo />

View File

@ -1 +1 @@
<van-col-demo /> <van-col-demo />

View File

@ -1 +1 @@
<van-collapse-demo /> <van-collapse-demo />

View File

@ -1 +1 @@
<van-config-provider-demo /> <van-config-provider-demo />

View File

@ -1 +1 @@
<van-count-down-demo /> <van-count-down-demo />

View File

@ -1,8 +1,3 @@
import list from '../../config';
import Page from '../../common/page'; import Page from '../../common/page';
Page({ Page();
data: {
list
},
});

View File

@ -1 +1 @@
<demo-home list="{{ list }}" /> <van-dashboard-demo />

View File

@ -1 +1 @@
<van-datetime-picker-demo /> <van-datetime-picker-demo />

View File

@ -1 +1 @@
<van-dialog-demo /> <van-dialog-demo />

View File

@ -1 +1 @@
<van-divider-demo /> <van-divider-demo />

View File

@ -1 +1 @@
<van-dropdown-menu-demo /> <van-dropdown-menu-demo />

View File

@ -1 +1 @@
<van-empty-demo /> <van-empty-demo />

View File

@ -1 +1 @@
<van-field-demo /> <van-field-demo />

View File

@ -1 +1 @@
<van-goods-action-demo /> <van-goods-action-demo />

View File

@ -1 +1 @@
<van-grid-demo /> <van-grid-demo />

View File

@ -1 +1 @@
<van-icon-demo /> <van-icon-demo />

View File

@ -1 +1 @@
<van-image-demo /> <van-image-demo />

View File

@ -1 +1 @@
<van-index-bar-demo /> <van-index-bar-demo />

View File

@ -1 +1 @@
<van-loading-demo /> <van-loading-demo />

View File

@ -1 +1 @@
<van-nav-bar-demo /> <van-nav-bar-demo />

View File

@ -1 +1 @@
<van-notice-bar-demo /> <van-notice-bar-demo />

View File

@ -1 +1 @@
<van-notify-demo /> <van-notify-demo />

View File

@ -1 +1 @@
<van-overlay-demo /> <van-overlay-demo />

View File

@ -1 +1 @@
<van-panel-demo /> <van-panel-demo />

View File

@ -1 +1 @@
<van-picker-demo /> <van-picker-demo />

View File

@ -1 +1 @@
<van-popup-demo /> <van-popup-demo />

View File

@ -1 +1 @@
<van-progress-demo /> <van-progress-demo />

View File

@ -1 +1 @@
<van-radio-demo /> <van-radio-demo />

View File

@ -1 +1 @@
<van-rate-demo /> <van-rate-demo />

View File

@ -1 +1 @@
<van-search-demo /> <van-search-demo />

View File

@ -1 +1 @@
<van-share-sheet-demo /> <van-share-sheet-demo />

View File

@ -1 +1 @@
<van-sidebar-demo /> <van-sidebar-demo />

View File

@ -1 +1 @@
<van-skeleton-demo /> <van-skeleton-demo />

View File

@ -1 +1 @@
<van-slider-demo /> <van-slider-demo />

View File

@ -1 +1 @@
<van-stepper-demo /> <van-stepper-demo />

View File

@ -1 +1 @@
<van-steps-demo /> <van-steps-demo />

View File

@ -1 +1 @@
<van-sticky-demo /> <van-sticky-demo />

View File

@ -1 +1 @@
<van-submit-bar-demo /> <van-submit-bar-demo />

View File

@ -1 +1 @@
<van-swipe-cell-demo /> <van-swipe-cell-demo />

View File

@ -1 +1 @@
<van-switch-demo /> <van-switch-demo />

View File

@ -1 +1 @@
<van-tab-demo /> <van-tab-demo />

View File

@ -1 +1 @@
<van-tabbar-demo /> <van-tabbar-demo />

View File

@ -1 +1 @@
<van-tag-demo /> <van-tag-demo />

View File

@ -1 +1 @@
<van-toast-demo /> <van-toast-demo />

View File

@ -1 +1 @@
<van-transition-demo /> <van-transition-demo />

View File

@ -1 +1 @@
<van-tree-select-demo /> <van-tree-select-demo />

View File

@ -1 +1 @@
<van-uploader-demo /> <van-uploader-demo />