diff --git a/.cid/tiny-vue.yml b/.cid/tiny-vue.yml new file mode 100644 index 000000000..7afc96fa2 --- /dev/null +++ b/.cid/tiny-vue.yml @@ -0,0 +1,193 @@ +version: 0.1.0 +name: tiny-vue +language: nodejs + +# 构建工具 +dependencies: + base: + nodejs: best + +# 构建机器 +machine: + standard: + euler: + - default + +# 构建脚本 +scripts: + - sh build.sh + +# 构建产物 +artifacts: + npm_deploy: + - config_path: ./dist/${componentName}/package.json + # - config_path: ./dist/alert/package.json + # - config_path: ./dist/action-menu/package.json + # - config_path: ./dist/button/package.json + # - config_path: ./dist/vue/package.json + # - config_path: ./dist/action-sheet/package.json + # - config_path: ./dist/amount/package.json + # - config_path: ./dist/area/package.json + # - config_path: ./dist/autocomplete/package.json + # - config_path: ./dist/avatar/package.json + # - config_path: ./dist/badge/package.json + # - config_path: ./dist/breadcrumb/package.json + # - config_path: ./dist/breadcrumb-item/package.json + # - config_path: ./dist/bulletin-board/package.json + # - config_path: ./dist/button-group/package.json + # - config_path: ./dist/calendar/package.json + # - config_path: ./dist/card-template/package.json + # - config_path: ./dist/carousel/package.json + # - config_path: ./dist/carousel-item/package.json + # - config_path: ./dist/cascader/package.json + # - config_path: ./dist/cascader-menu/package.json + # - config_path: ./dist/cascader-node/package.json + # - config_path: ./dist/cascader-panel/package.json + # - config_path: ./dist/chart/package.json + # - config_path: ./dist/chart/autonavi-map/package.json + # - config_path: ./dist/chart/baidu-map/package.json + # - config_path: ./dist/chart/chart-bar/package.json + # - config_path: ./dist/chart/chart-boxplot/package.json + # - config_path: ./dist/chart/chart-candle/package.json + # - config_path: ./dist/chart/chart-core/package.json + # - config_path: ./dist/chart/chart-funnel/package.json + # - config_path: ./dist/chart/chart-gauge/package.json + # - config_path: ./dist/chart/chart-graph/package.json + # - config_path: ./dist/chart/chart-heatmap/package.json + # - config_path: ./dist/chart/chart-histogram/package.json + # - config_path: ./dist/chart/chart-line/package.json + # - config_path: ./dist/chart/chart-liquidfill/package.json + # - config_path: ./dist/chart/chart-map/package.json + # - config_path: ./dist/chart/chart-pie/package.json + # - config_path: ./dist/chart/chart-radar/package.json + # - config_path: ./dist/chart/chart-ring/package.json + # - config_path: ./dist/chart/chart-sankey/package.json + # - config_path: ./dist/chart/chart-scatter/package.json + # - config_path: ./dist/chart/chart-sunburst/package.json + # - config_path: ./dist/chart/chart-tree/package.json + # - config_path: ./dist/chart/chart-waterfall/package.json + # - config_path: ./dist/chart/chart-wordcloud/package.json + # - config_path: ./dist/checkbox/package.json + # - config_path: ./dist/checkbox-button/package.json + # - config_path: ./dist/checkbox-group/package.json + # - config_path: ./dist/col/package.json + # - config_path: ./dist/collapse/package.json + # - config_path: ./dist/collapse-item/package.json + # - config_path: ./dist/collapse-transition/package.json + # - config_path: ./dist/common/package.json + # - config_path: ./dist/company/package.json + # - config_path: ./dist/container/package.json + # - config_path: ./dist/country/package.json + # - config_path: ./dist/credit-card/package.json + # - config_path: ./dist/credit-card-form/package.json + # - config_path: ./dist/crop/package.json + # - config_path: ./dist/currency/package.json + # - config_path: ./dist/date-panel/package.json + # - config_path: ./dist/date-picker/package.json + # - config_path: ./dist/date-range/package.json + # - config_path: ./dist/date-table/package.json + # - config_path: ./dist/dept/package.json + # - config_path: ./dist/detail-page/package.json + # - config_path: ./dist/dialog-box/package.json + # - config_path: ./dist/drop-roles/package.json + # - config_path: ./dist/drop-times/package.json + # - config_path: ./dist/dropdown/package.json + # - config_path: ./dist/dropdown-item/package.json + # - config_path: ./dist/dropdown-menu/package.json + # - config_path: ./dist/espace/package.json + # - config_path: ./dist/exception/package.json + # - config_path: ./dist/file-upload/package.json + # - config_path: ./dist/floatbar/package.json + # - config_path: ./dist/form/package.json + # - config_path: ./dist/form-item/package.json + # - config_path: ./dist/fullscreen/package.json + # - config_path: ./dist/fall-menu/package.json + # - config_path: ./dist/grid/package.json + # - config_path: ./dist/grid-column/package.json + # - config_path: ./dist/grid-manager/package.json + # - config_path: ./dist/grid-toolbar/package.json + # - config_path: ./dist/hrapprover/package.json + # - config_path: ./dist/icon/package.json + # - config_path: ./dist/image/package.json + # - config_path: ./dist/image-viewer/package.json + # - config_path: ./dist/input/package.json + # - config_path: ./dist/ip-address/package.json + # - config_path: ./dist/layout/package.json + # - config_path: ./dist/link/package.json + # - config_path: ./dist/link-menu/package.json + # - config_path: ./dist/list/package.json + # - config_path: ./dist/loading/package.json + # - config_path: ./dist/locale/package.json + # - config_path: ./dist/locales/package.json + # - config_path: ./dist/logon-user/package.json + # - config_path: ./dist/logout/package.json + # - config_path: ./dist/milestone/package.json + # - config_path: ./dist/mini-picker/package.json + # - config_path: ./dist/modal/package.json + # - config_path: ./dist/month-range/package.json + # - config_path: ./dist/month-table/package.json + # - config_path: ./dist/nav-bar/package.json + # - config_path: ./dist/nav-menu/package.json + # - config_path: ./dist/notify/package.json + # - config_path: ./dist/numeric/package.json + # - config_path: ./dist/option/package.json + # - config_path: ./dist/option-group/package.json + # - config_path: ./dist/pager/package.json + # - config_path: ./dist/pager-item/package.json + # - config_path: ./dist/panel/package.json + # - config_path: ./dist/picker/package.json + # - config_path: ./dist/picker-column/package.json + # - config_path: ./dist/pop-upload/package.json + # - config_path: ./dist/popeditor/package.json + # - config_path: ./dist/popover/package.json + # - config_path: ./dist/popup/package.json + # - config_path: ./dist/progress/package.json + # - config_path: ./dist/pull-refresh/package.json + # - config_path: ./dist/radio/package.json + # - config_path: ./dist/radio-button/package.json + # - config_path: ./dist/radio-group/package.json + # - config_path: ./dist/rate/package.json + # - config_path: ./dist/roles/package.json + # - config_path: ./dist/row/package.json + # - config_path: ./dist/scroll-text/package.json + # - config_path: ./dist/scrollbar/package.json + # - config_path: ./dist/search/package.json + # - config_path: ./dist/select/package.json + # - config_path: ./dist/select-dropdown/package.json + # - config_path: ./dist/slide-bar/package.json + # - config_path: ./dist/slider/package.json + # - config_path: ./dist/split/package.json + # - config_path: ./dist/steps/package.json + # - config_path: ./dist/svg-icon/package.json + # - config_path: ./dist/switch/package.json + # - config_path: ./dist/tab-item/package.json + # - config_path: ./dist/tabbar/package.json + # - config_path: ./dist/tabbar-item/package.json + # - config_path: ./dist/table/package.json + # - config_path: ./dist/tabs/package.json + # - config_path: ./dist/tag/package.json + # - config_path: ./dist/text-popup/package.json + # - config_path: ./dist/time/package.json + # - config_path: ./dist/time-line/package.json + # - config_path: ./dist/time-panel/package.json + # - config_path: ./dist/time-picker/package.json + # - config_path: ./dist/time-range/package.json + # - config_path: ./dist/time-select/package.json + # - config_path: ./dist/time-spinner/package.json + # - config_path: ./dist/toggle-menu/package.json + # - config_path: ./dist/tooltip/package.json + # - config_path: ./dist/top-box/package.json + # - config_path: ./dist/transfer/package.json + # - config_path: ./dist/transfer-panel/package.json + # - config_path: ./dist/tree/package.json + # - config_path: ./dist/tree-menu/package.json + # - config_path: ./dist/upload/package.json + # - config_path: ./dist/upload-dragger/package.json + # - config_path: ./dist/upload-list/package.json + # - config_path: ./dist/user/package.json + # - config_path: ./dist/user-account/package.json + # - config_path: ./dist/user-contact/package.json + # - config_path: ./dist/user-head/package.json + # - config_path: ./dist/user-link/package.json + # - config_path: ./dist/wizard/package.json + # - config_path: ./dist/year-table/package.json diff --git a/.husky/_/husky.sh b/.husky/_/husky.sh new file mode 100644 index 000000000..cec959a6b --- /dev/null +++ b/.husky/_/husky.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh +if [ -z "$husky_skip_init" ]; then + debug () { + if [ "$HUSKY_DEBUG" = "1" ]; then + echo "husky (debug) - $1" + fi + } + + readonly hook_name="$(basename -- "$0")" + debug "starting $hook_name..." + + if [ "$HUSKY" = "0" ]; then + debug "HUSKY env variable is set to 0, skipping hook" + exit 0 + fi + + if [ -f ~/.huskyrc ]; then + debug "sourcing ~/.huskyrc" + . ~/.huskyrc + fi + + readonly husky_skip_init=1 + export husky_skip_init + sh -e "$0" "$@" + exitCode="$?" + + if [ $exitCode != 0 ]; then + echo "husky - $hook_name hook exited with code $exitCode (error)" + fi + + if [ $exitCode = 127 ]; then + echo "husky - command not found in PATH=$PATH" + fi + + exit $exitCode +fi diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af21989..c37466e2b 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npx lint-staged +npx lint-staged \ No newline at end of file diff --git a/build.sh b/build.sh index 1a9a5d599..543be349c 100644 --- a/build.sh +++ b/build.sh @@ -2,12 +2,19 @@ if [ ! $version ]; then npm version 0.1.0-`date "+%Y%m%d%H%M%S"`; -else npm version ${version}; +else npm version $version; fi -npm run bootstrap -npm run build:vue3 -npm run release3 +npm install + +if [ ! $componentName ]; +then + npm run build:vue$vueVersion +else + npm run buildfuxi:vue$vueVersion +fi + +npm run releasefuxi$vueVersion if [ $? -ne 0 ] then diff --git a/build/build-entry-app.js b/build/build-entry-app.js index 480a72e1b..3a8e893d9 100644 --- a/build/build-entry-app.js +++ b/build/build-entry-app.js @@ -50,6 +50,5 @@ const buildFullRuntime = (buildType) => { fs.writeFileSync(outputPath, output) utils.logGreen(`npm run build:entry done. [${outputDir}/${buildType}.js]`) -} - -;['core', 'base', 'chart'].forEach(buildFullRuntime) +}; +['core', 'base', 'chart'].forEach(buildFullRuntime) diff --git a/build/build-entry.js b/build/build-entry.js index 43e5f5248..b0112b3e5 100644 --- a/build/build-entry.js +++ b/build/build-entry.js @@ -138,7 +138,7 @@ const createEntry = (mode) => { }) fs.writeFileSync(OUTPUT_PATH, output) -} -;['all', 'pc', 'mobile'].forEach(createEntry) +}; +['all', 'pc', 'mobile'].forEach(createEntry) utils.logGreen(`npm run build:entry done. [${outputDir}/index.js,${outputDir}/pc.js,${outputDir}/mobile.js]`) diff --git a/build/build-icon.js b/build/build-icon.js index 04c9546f7..31e6b6bde 100644 --- a/build/build-icon.js +++ b/build/build-icon.js @@ -32,7 +32,7 @@ const inputOptions = { // 如果打包文件中包含 jsx 语法, commonjs 必须放置在 babel 配置下面,否则会报错 PLUGIN_ERROR commonjs() ], - external: (deps) => /^@opentiny[\\/]-vue-common/.test(deps) + external: (deps) => /^@huawei[\\/]tiny-vue-common/.test(deps) } const outputOptions = { @@ -49,7 +49,7 @@ const build = (components) => { if (component.path === 'index.js') { inputs.external = (deps) => !deps.includes('index.js') } else { - inputs.external = (deps) => /^@opentiny[\\/]vue-common/.test(deps) + inputs.external = (deps) => /^@huawei[\\/]tiny-vue-common/.test(deps) } rollup diff --git a/build/build-ui.js b/build/build-ui.js index 4a4f2444b..2a46f5633 100644 --- a/build/build-ui.js +++ b/build/build-ui.js @@ -22,9 +22,9 @@ const replaceConstant = { 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) } -if (process.env.tiny_mode === 'pc') { +if (process.env.TINY_MODE === 'pc') { outputOptions.format = 'umd' - replaceConstant['process.env.TINY_MODE'] = JSON.stringify(process.env.tiny_mode) + replaceConstant['process.env.TINY_MODE'] = JSON.stringify(process.env.TINY_MODE) } /** diff --git a/build/build-version.js b/build/build-version.js index 867e89579..c94a77e9c 100644 --- a/build/build-version.js +++ b/build/build-version.js @@ -16,7 +16,7 @@ const TAG = process.argv[3] === 'false' ? '' : process.argv[3] const packages = path.join(ROOT_PATH, 'packages') const pkgJsonFileName = 'package.json' const { logGreen } = require('./utils') -const tinyVueReg = /@opentiny\// +const tinyVueReg = /@huawei\// const targetVersion = process.argv[2] || JSON.parse(fs.readFileSync(path.join(ROOT_PATH, pkgJsonFileName)).toString()).version diff --git a/build/config.js b/build/config.js index f4e824c32..0c73447a7 100644 --- a/build/config.js +++ b/build/config.js @@ -8,10 +8,26 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve') const { pathJoin } = require('./utils') const { getAllModules } = require('./module-utils') -const external = ['vue', './pc', './mobile', '@vue/composition-api', '@opentiny/vue-common', '@opentiny/vue-locale', '@opentiny/vue-renderless'] +const external = [ + 'vue', + 'quill', + './pc', + 'echarts', + 'echarts-amap', + './mobile', + '@vue/composition-api', + 'echarts-liquidfill', + 'echarts-wordcloud', + '@opentiny/vue-common', + '@opentiny/vue-locale', + '@opentiny/vue-renderless' +] const globals = { vue: 'Vue', + 'echarts-amap': 'echarts.amap', + 'echarts-liquidfill': 'echarts-liquidfill', + 'echarts-wordcloud': 'echarts-wordcloud', '@vue/composition-api': 'vueCompositionApi', '@opentiny/vue-common': 'TinyVueCommon', '@opentiny/vue-locale': 'TinyVueLocale', @@ -35,9 +51,9 @@ components.forEach((item) => { globals[item.libName] = item.global // TinyTodo if (isComponent) { - if (fs.existsSync(pathJoin('../../vue-theme3'))) { - aliasList[`@opentiny/vue-theme/${item.LowerName}/index.css`] = pathJoin(`../../vue-theme3/style/${item.LowerName}/index.css`) - aliasList[`@opentiny/vue-theme/${item.LowerName}/index.js`] = pathJoin(`../../vue-theme3/style/${item.LowerName}/index.js`) + if (fs.existsSync(pathJoin('../../tiny-vue-theme'))) { + aliasList[`@opentiny/vue-theme/${item.LowerName}/index.css`] = pathJoin(`../../tiny-vue-theme/src/${item.LowerName}/index.css`) + aliasList[`@opentiny/vue-theme/${item.LowerName}/index.js`] = pathJoin(`../../tiny-vue-theme/src/${item.LowerName}/index.js`) } external.push(item.libName + '/index.js') } else { @@ -47,7 +63,8 @@ components.forEach((item) => { exports.aliasList = aliasList -exports.external = (deps) => external.includes(deps) || /^@opentiny[\\/](vue-renderless|vue-theme|vue-common|vue-icon)|cropperjs/.test(deps) +exports.external = (deps) => + external.includes(deps) || /^@huawei[\\/](tiny-vue-renderless|tiny-vue-theme|tiny-vue-common|tiny-vue-icon)|echarts|cropperjs|quill/.test(deps) exports.globals = globals diff --git a/build/module-utils.js b/build/module-utils.js index 166ff3454..7a4dc3539 100644 --- a/build/module-utils.js +++ b/build/module-utils.js @@ -197,7 +197,7 @@ const getSortModules = ({ filterIntercept, isSort = true }) => { component.parentDir = componentName // libPath: 'packages/todo/dist/pc.js' 组件输出路径 component.libPath = component.path.replace('/index.js', '/src/index.js').replace('/src/', '/dist/lib/').replace('.vue', '.js') - // libName: '@opentiny/vue/todo/pc' + // libName: '@huawei/vue/todo/pc' component.libName = component.libPath .replace('packages/', '') .replace('/index', '') diff --git a/build/release-ui.js b/build/release-ui.js index 8c3219e4c..58d71fcc8 100644 --- a/build/release-ui.js +++ b/build/release-ui.js @@ -4,8 +4,8 @@ const fs = require('fs-extra') const path = require('path') const { execSync } = require('child_process') -const utils = require('./utils') -const { logGreen } = require('./utils') +const utils = require('../build/utils') +const { logGreen } = require('../build/utils') const sourcePkg = 'packages' const packages = 'dist' @@ -17,6 +17,7 @@ const NPM_WAREHOUSE = process.env.NPM_WAREHOUSE const targetVersion = utils.getTinyVersion('themeVersion') const targetVersionArr = targetVersion.split('.') const themeVersionDependencies = `~${targetVersionArr[0]}.${targetVersionArr[1]}.0` +const typings = 'typings' const packPackages = (p, packagePath) => { execSync('npm pack -q', { cwd: path.join(packages, p) }) @@ -63,6 +64,9 @@ const dealPackage = (p, packageJSON) => { } } packageJSON.dependencies = Object.assign(packageJSON.dependencies || {}, dependencies) + if (VERSION_TAG.startsWith('3')) { + packageJSON.types = 'index.d.ts' + } packageJSON.sideEffects = false packageJSON.version = VERSION_TAG } @@ -116,6 +120,41 @@ const dealFile = (componentDir, distDir) => { } } +// chart文件夹处理 + +const releaseChart = (componentDir, item) => { + fs.readdirSync(componentDir).forEach((child) => { + const stat = fs.statSync(path.join(componentDir, child)) + + if (stat.isDirectory()) { + const distPath = path.join(sourcePkg, item, child, packages) + const packageJson = path.join(sourcePkg, item, child, packageName) + + const typingsPath = path.join(typings, item, child) + + if (fs.existsSync(typingsPath) && VERSION_TAG.startsWith('3')) { + fs.copySync(typingsPath, path.join(packages, item), { + overwrite: true + }) + } + + if (fs.existsSync(distPath)) { + fs.copySync(distPath, path.join(packages, item, child), { + overwrite: true + }) + fs.copySync(packageJson, path.join(packages, item, child, packageName), { + overwrite: true + }) + } else { + fs.copySync(componentDir, path.join(packages, item, child), { + overwrite: true + }) + } + release(path.join(item, child)) + } + }) +} + // 读取packages文件夹下的所有组件,并执行copy操作 const releaseAll = () => { fs.readdirSync(path.join(sourcePkg)).forEach((item) => { @@ -125,6 +164,13 @@ const releaseAll = () => { if (stat.isDirectory()) { const distPath = path.join(sourcePkg, item, packages) const packageJson = path.join(sourcePkg, item, packageName) + const typingsPath = path.join(typings, item) + + if (fs.existsSync(typingsPath) && VERSION_TAG.startsWith('3')) { + fs.copySync(typingsPath, path.join(packages, item), { + overwrite: true + }) + } if (fs.existsSync(distPath)) { fs.copySync(distPath, path.join(packages, item), { @@ -134,6 +180,7 @@ const releaseAll = () => { overwrite: true }) } else { + // 如果packags包里面没有dist目录,则copy整个目录,比如common local等适配层 fs.copySync(componentDir, path.join(packages, item), { overwrite: true }) @@ -143,6 +190,9 @@ const releaseAll = () => { } release(item) + if (item === 'chart') { + releaseChart(componentDir, item) + } } }) diff --git a/build/release.js b/build/release.js index b9dbdc562..3d4d6deb8 100644 --- a/build/release.js +++ b/build/release.js @@ -4,21 +4,18 @@ const fs = require('fs-extra') const path = require('path') const semver = require('semver') -const { execSync } = require('child_process') const sourcePkg = 'packages' const source = 'dist' const packageName = 'package.json' +const typings = 'typings' const packagePath = path.join(source, packageName) const packageJSON = fs.readJSONSync(packageName) const keys = ['name', 'version', 'description', 'main', 'files', 'sideEffects', 'author', 'license', 'repository', 'dependencies', 'engines', 'browserslist'] -const allDist = 'allDist' -const toOneZip = process.env.tiny_mode === 'pc' const NPM_TAG = process.env.NPM_TAG // 命令行中指定的版本号 const VERSION_TAG = process.env.VERSION_TAG -const NPM_WAREHOUSE = process.env.NPM_WAREHOUSE for (let key in packageJSON) { if (Object.prototype.hasOwnProperty.call(packageJSON, key)) { @@ -33,7 +30,7 @@ if (VERSION_TAG) { // 根据modules.json生成所有组件列表信息 const genDependencies = () => { - const { getComponents } = require('./module-utils') + const { getComponents } = require('../build/module-utils') let dependencies = {} getComponents(false).forEach((component) => { @@ -61,6 +58,10 @@ const genDependencies = () => { return dependencies } +if (VERSION_TAG.startsWith('3')) { + packageJSON.types = 'index.d.ts' +} + // 根据组件列表信息重新package.json的dependencies信息 packageJSON.dependencies = Object.assign(packageJSON.dependencies || {}, genDependencies()) @@ -69,45 +70,15 @@ fs.copySync(packagePath, path.join(source, 'vue', packageName), { overwrite: true }) -if (toOneZip) { - const vuePackage = path.join(allDist, 'vue') +const entrys = ['pc.js', 'mobile.js', 'index.js'] - if (!fs.existsSync(allDist)) { - fs.mkdirSync(allDist) - } - - if (!fs.existsSync(vuePackage)) { - fs.mkdirSync(vuePackage) - } - - fs.copyFileSync(packageName, path.join(vuePackage, packageName)) - - fs.readdirSync(source).forEach((item) => { - const stat = fs.statSync(path.join(source, item)) - - if (!stat.isDirectory()) { - fs.copyFileSync(path.join(source, item), path.join(vuePackage, item)) - } +entrys.forEach((name) => { + fs.copySync(path.join(sourcePkg, name), path.join(source, 'vue', name), { + overwrite: true }) -} else { - const entrys = ['pc.js', 'mobile.js', 'index.js'] - - entrys.forEach((name) => { - fs.copyFileSync(path.join(sourcePkg, name), path.join(source, name)) - fs.copySync(path.join(sourcePkg, name), path.join(source, 'vue', name), { + if (VERSION_TAG.startsWith('3')) { + fs.copySync(path.join(typings, name.replace('.js', '.d.ts')), path.join(source, 'vue', name.replace('.js', '.d.ts')), { overwrite: true }) - }) - // 只有在发布npm测试仓库的时候才执行以下压缩包的逻辑 - if (NPM_WAREHOUSE === 'test') { - execSync('npm pack', { cwd: source }) - - fs.readdirSync(source).forEach((item) => { - if (item.endsWith('.tgz')) { - const tgzPath = path.join(source, item) - - fs.moveSync(tgzPath, path.join('tgzs', item), { overwrite: true }) - } - }) } -} +}) diff --git a/build/runtime-utils.js b/build/runtime-utils.js index 9737cb9d3..8b890680d 100644 --- a/build/runtime-utils.js +++ b/build/runtime-utils.js @@ -142,15 +142,7 @@ const runtimeComponents = { 'Chart', 'ChartBoxplot' ], - external: [ - 'CardTemplate', - 'CreditCard', - 'CreditCardForm', - 'SvgIcon', - 'AutonaviMap', - 'ChartWordcloud', - 'ChartLiquidfill' - ] + external: ['CardTemplate', 'CreditCard', 'CreditCardForm', 'SvgIcon', 'AutonaviMap', 'ChartWordcloud', 'ChartLiquidfill'] } const echartsVersion = getVersion('echarts') @@ -160,12 +152,10 @@ const dependencies = { vue: 'node_modules/vue/dist/vue.min.js', 'vue-i18n': 'node_modules/vue-i18n/dist/vue-i18n.min.js', axios: 'node_modules/axios/dist/axios.min.js', - 'axios-mock-adapter': - 'node_modules/axios-mock-adapter/dist/axios-mock-adapter.min.js', - '@vue/composition-api': - 'node_modules/@vue/composition-api/dist/vue-composition-api.prod.js', - '@aurora/core': 'node_modules/@aurora/core/dist/aurora.min.js', - '@aurora/service': 'node_modules/@aurora/service/dist/aurora.service.min.js', + 'axios-mock-adapter': 'node_modules/axios-mock-adapter/dist/axios-mock-adapter.min.js', + '@vue/composition-api': 'node_modules/@vue/composition-api/dist/vue-composition-api.prod.js', + '@huawei/core': 'node_modules/@huawei/core/dist/aurora.min.js', + '@huawei/service': 'node_modules/@huawei/service/dist/aurora.service.min.js', cropperjs: 'node_modules/cropperjs/dist/cropper.min.js', vue3: 'example/node_modules/vue/dist/vue.global.prod.js', 'vue3-i18n': 'example/node_modules/vue-i18n/dist/vue-i18n.global.js' @@ -176,17 +166,14 @@ const runtimeDeps = { vue: 'lib/vue.min.js' + getVersion('vue'), axios: 'lib/axios.min.js' + getVersion('axios'), 'vue-i18n': 'lib/vue-i18n.min.js' + getVersion('vue-i18n'), - 'axios-mock-adapter': - 'lib/axios-mock-adapter.min.js' + getVersion('axios-mock-adapter') + 'axios-mock-adapter': 'lib/axios-mock-adapter.min.js' + getVersion('axios-mock-adapter') }, aurora: { - '@aurora/core': 'lib/aurora.min.js' + getVersion('@aurora/core'), - '@aurora/service': - 'lib/aurora.service.min.js' + getVersion('@aurora/service') + '@huawei/core': 'lib/aurora.min.js' + getVersion('@huawei/core'), + '@huawei/service': 'lib/aurora.service.min.js' + getVersion('@huawei/service') }, - aui3Lib: { - '@vue/composition-api': - 'lib/vue-composition-api.prod.js' + getVersion('@vue/composition-api'), + tiny3Lib: { + '@vue/composition-api': 'lib/vue-composition-api.prod.js' + getVersion('@vue/composition-api'), echarts: echartsSource, 'echarts/lib/echarts': echartsSource, 'echarts/lib/chart/bar': echartsSource, @@ -217,13 +204,10 @@ const runtimeDeps = { 'echarts/lib/component/dataZoom': echartsSource, 'echarts/lib/component/visualMap': echartsSource, cropperjs: 'lib/cropper.min.js' + getVersion('cropperjs'), - '@opentiny/vue-renderless-common': - 'aui/common/renderless.js' + - getVersion('@opentiny/vue-renderless') + '@opentiny/vue-renderless-common': 'tiny/common/renderless.js' + getVersion('@opentiny/vue-renderless') }, - aui3Component: { - '@opentiny/vue-locale': - 'COMPONENT_DIR/locale.js' + auroraVueVersion, + tiny3Component: { + '@opentiny/vue-locale': 'COMPONENT_DIR/locale.js' + auroraVueVersion, '@opentiny/vue-icon': 'COMPONENT_DIR/icon.js' + auroraVueVersion, '@opentiny/vue-common': 'COMPONENT_DIR/common.js' + auroraVueVersion } @@ -241,9 +225,7 @@ const getPartDeps = (keys = []) => { return tempDeps } -const getAllDeps = () => { - return getPartDeps(Object.keys(runtimeDeps)) -} +const getAllDeps = () => getPartDeps(Object.keys(runtimeDeps)) const getAllComponents = () => { const componentMap = moduleUtils.getPcComponents(true) @@ -255,38 +237,26 @@ const getAllComponents = () => { let version = auroraVueVersion try { - version = - '?v=' + - require('../' + - libEntry.replace('index.js', 'package.json')).version.replace( - /[\^|~]/g, - '' - ) + version = '?v=' + require('../' + libEntry.replace('index.js', 'package.json')).version.replace(/[\^|~]/g, '') } catch (e) { logRed(e) } - systemMap[componentMap[i].importName] = - 'COMPONENT_DIR/' + libName + '.js' + version + systemMap[componentMap[i].importName] = 'COMPONENT_DIR/' + libName + '.js' + version } return systemMap } -const getFullRuntimeDeps = () => { - return { ...getAllDeps(), ...getAllComponents() } -} +const getFullRuntimeDeps = () => ({ ...getAllDeps(), ...getAllComponents() }) -const getComponentRuntimeDeps = () => { - return { - ...getPartDeps(['theme', 'aui3Lib', 'aui3Component']), - ...getAllComponents() - } -} +const getComponentRuntimeDeps = () => ({ + ...getPartDeps(['theme', 'tiny3Lib', 'tiny3Component']), + ...getAllComponents() +}) const getFullRuntime = (name) => { - const arr = - typeof name === 'string' ? [name] : name || Object.keys(runtimeComponents) + const arr = typeof name === 'string' ? [name] : name || Object.keys(runtimeComponents) return [].concat(...arr.map((key) => runtimeComponents[key])) } @@ -295,14 +265,7 @@ const getFullRuntime = (name) => { * 提取 @opentiny/vue-renderless 中的公共代码,打成独立包(避免组件运行不正常) */ const getRenderlessExports = () => { - const RENDERLESS_PATH = pathJoin( - '..', - 'node_modules', - '@aurora', - 'renderless', - 'common', - 'runtime.js' - ) + const RENDERLESS_PATH = pathJoin('..', 'node_modules', '@huawei', 'renderless', 'common', 'runtime.js') let EXTERNAL_RENDERLESS = [] diff --git a/example/build/build-icon.js b/example/build/build-icon.js index d1049ef2e..8dee19359 100644 --- a/example/build/build-icon.js +++ b/example/build/build-icon.js @@ -45,7 +45,7 @@ const build = (icons) => { } else if (itconComponent.path === 'lowercase.js') { inputs3.external = (deps) => !deps.includes('lowercase.js') } else { - inputs3.external = (deps) => !/@opentiny[\\/]vue-theme/.test(deps) && !deps.includes('index.js') + inputs3.external = (deps) => !/@huawei[\\/]tiny-vue-theme/.test(deps) && !deps.includes('index.js') } rollup diff --git a/example/build/build-ui.js b/example/build/build-ui.js index 0e2e46877..73ce312c0 100644 --- a/example/build/build-ui.js +++ b/example/build/build-ui.js @@ -25,7 +25,7 @@ const replaceConstant = { if (process.env.TINY_MODE === 'pc') { outputOptions.format = 'umd' - replaceConstant['process.env.TINY_MODE'] = JSON.stringify(process.env.tiny_mode) + replaceConstant['process.env.TINY_MODE'] = JSON.stringify(process.env.TINY_MODE) } const build = ({ comp, callbackFn }) => { diff --git a/example/build/config.js b/example/build/config.js index cf2d0d1f2..67da9a738 100644 --- a/example/build/config.js +++ b/example/build/config.js @@ -8,13 +8,27 @@ const { nodeResolve } = require('@rollup/plugin-node-resolve') const { pathJoin } = require('../../build/utils') const { getAllModules } = require('../../build/module-utils') -const external = ['vue', './pc', './mobile', '@opentiny/vue-common', '@opentiny/vue-locale', '@vue/composition-api', '@opentiny/vue-renderless'] +const external = [ + 'vue', + './pc', + './mobile', + '@opentiny/vue-common', + 'echarts', + 'echarts-amap', + '@opentiny/vue-locale', + 'quill', + '@vue/composition-api', + '@opentiny/vue-renderless' +] const globals = { vue: 'Vue', '@vue/composition-api': 'vueCompositionApi', '@opentiny/vue-locale': 'TinyVueLocale', '@opentiny/vue-common': 'TinyVueCommon', + 'echarts-amap': 'echarts.amap', + 'echarts-liquidfill': 'echarts-liquidfill', + 'echarts-wordcloud': 'echarts-wordcloud', '@opentiny/vue-renderless': 'TinyRenderLess' } @@ -30,14 +44,14 @@ components.forEach((itemComponent) => { const isComponent = itemComponent.type === 'component' - external.push(itemComponent.importName) - external.push(itemComponent.libName) + external.push(itemComponent.importName) // @opentiny/vue3-todo + external.push(itemComponent.libName) // @opentiny/vue3/todo globals[itemComponent.libName] = itemComponent.global // TinyTodo if (isComponent) { if (fs.existsSync(pathJoin('../../tiny-vue-theme'))) { - aliasList[`@opentiny/vue-theme/${itemComponent.LowerName}/index.css`] = pathJoin(`../../tiny-vue-theme/src/${itemComponent.LowerName}/index.css`) - aliasList[`@opentiny/vue-theme/${itemComponent.LowerName}/index.js`] = pathJoin(`../../tiny-vue-theme/src/${itemComponent.LowerName}/index.js`) + aliasList[`@opentiny/vue-theme/${itemComponent.LowerName}/index.css`] = pathJoin(`../../tiny-vue-theme/style/${itemComponent.LowerName}/index.css`) + aliasList[`@opentiny/vue-theme/${itemComponent.LowerName}/index.js`] = pathJoin(`../../tiny-vue-theme/style/${itemComponent.LowerName}/index.js`) } external.push(`${itemComponent.libName}/index.js`) } else { @@ -47,7 +61,8 @@ components.forEach((itemComponent) => { exports.aliasList = aliasList -exports.external = (deps) => external.includes(deps) || /^@opentiny[\\/](vue-common|vue-renderless|vue-theme|vue-icon|cropperjs)/.test(deps) +exports.external = (deps) => + external.includes(deps) || /^@huawei[\\/](tiny-vue-renderless|tiny-vue-theme|tiny-vue-common|tiny-vue-icon)|echarts|cropperjs|quill/.test(deps) exports.globalsMap = globals diff --git a/example/entry/icon.js b/example/entry/icon.js new file mode 100644 index 000000000..839248ed1 --- /dev/null +++ b/example/entry/icon.js @@ -0,0 +1 @@ +export * from '@opentiny/vue-icon' diff --git a/example/entry/pc.js b/example/entry/pc.js new file mode 100644 index 000000000..7a5b4c4b0 --- /dev/null +++ b/example/entry/pc.js @@ -0,0 +1,5 @@ +export * from '@opentiny/vue' +import locale from '@opentiny/vue-locale' + +// 这里需要在运行时导出国际化方法 +export { locale } diff --git a/example/package.json b/example/package.json index de7a49451..8c48dfb5f 100644 --- a/example/package.json +++ b/example/package.json @@ -4,22 +4,25 @@ "scripts": { "dev": "vite", "test": "vitest test", + "build:runtime-pc": "vite build --mode pc", + "build:runtime-icon": "vite build --mode icon", "build:icon3": "cross-env NODE_ENV=production node build/build-icon.js", "coverage": "vitest run --coverage" }, "devDependencies": { - "@vue/babel-plugin-jsx": "^1.1.0", - "rollup-plugin-postcss": "^2.0.3", - "rollup-plugin-vue": "^6.0.0", - "vue": "^3.2.11", - "@vue/test-utils": "^2.0.0", - "jsdom": "16.4.0", - "vue-i18n": "^9.1.7", - "vitest": "^0.22.1", - "vue-router": "^4.0.11", "@vitejs/plugin-vue": "^3.0.3", "@vitejs/plugin-vue-jsx": "^2.0.0", - "vite-plugin-markdown-vue": "^0.1.2" + "@vue/babel-plugin-jsx": "^1.1.0", + "@vue/test-utils": "^2.0.0", + "esbuild-register": "^3.3.3", + "jsdom": "16.4.0", + "rollup-plugin-postcss": "^2.0.3", + "rollup-plugin-vue": "^6.0.0", + "vite-plugin-markdown-vue": "^0.1.2", + "vitest": "^0.22.1", + "vue": "^3.2.25", + "vue-i18n": "^9.1.7", + "vue-router": "^4.0.11" }, "eslintConfig": { "root": true, diff --git a/example/public/favicon.ico b/example/public/favicon.ico index 719c584f7..586794445 100644 Binary files a/example/public/favicon.ico and b/example/public/favicon.ico differ diff --git a/example/public/index.html b/example/public/index.html index 22961e2e4..81cb3ee20 100644 --- a/example/public/index.html +++ b/example/public/index.html @@ -5,7 +5,9 @@ - TinyVue + + TinyUI for Vue ( <%= htmlWebpackPlugin.options.vueVersion %> ) +