Merge branch 'dev' of github.com:opentiny/tiny-vue into dev

This commit is contained in:
zzcr 2023-06-12 05:09:44 -07:00
commit 9a292394b4
No known key found for this signature in database
GPG Key ID: F6C4DFD2EF53A673
9 changed files with 47 additions and 16 deletions

View File

@ -1,6 +1,11 @@
import path from 'node:path' import path from 'node:path'
import { removeSync } from 'fs-extra' import { removeSync } from 'fs-extra'
import { walkFileTree, pathJoin, logGreen, logRed } from '../shared/utils' import {
walkFileTree,
logGreen,
logRed,
pathJoinFromCLI
} from '../shared/utils'
/** /**
* packages distruntimenode_modules * packages distruntimenode_modules
@ -22,7 +27,7 @@ const deleteDistFile = () => {
return flag return flag
}, },
dirPath: pathJoin('..', 'packages'), dirPath: pathJoinFromCLI('../../packages'),
callback() { callback() {
// empty // empty
} }

View File

@ -10,11 +10,12 @@ import fs from 'fs-extra'
import semver from 'semver' import semver from 'semver'
import { import {
getInputCmd, getInputCmd,
pathJoin,
walkFileTree, walkFileTree,
capitalizeKebabCase, capitalizeKebabCase,
logGreen, logGreen,
logYellow logYellow,
templatePath,
pathJoinFromCLI
} from '../../shared/utils' } from '../../shared/utils'
import { createModuleMapping } from '../../shared/module-utils' import { createModuleMapping } from '../../shared/module-utils'
import handlebarsRender from '../build/handlebars.render' import handlebarsRender from '../build/handlebars.render'
@ -24,9 +25,9 @@ const args = getInputCmd()
if (args.length > 0) { if (args.length > 0) {
const commands: string[] = [] const commands: string[] = []
const components: string[] = [] const components: string[] = []
const templateDir = pathJoin('../../public/template/component') const templateDir = path.join(templatePath, './component')
const componetDir = pathJoin('../../../../packages/vue/src') const componetDir = pathJoinFromCLI('../../packages/vue/src')
const { version } = fs.readJSONSync(pathJoin('../../../../packages/vue/package.json')) const { version } = fs.readJSONSync(pathJoinFromCLI('../../packages/vue/package.json'))
args.forEach((item) => { args.forEach((item) => {
if (item.indexOf('-') === 0) { if (item.indexOf('-') === 0) {

View File

@ -13,16 +13,16 @@ import {
capitalizeKebabCase, capitalizeKebabCase,
prettierFormat, prettierFormat,
logGreen, logGreen,
logRed logRed,
templatePath
} from '../../shared/utils' } from '../../shared/utils'
const svgRE = /\.svg$/ const svgRE = /\.svg$/
const svgDir = pathJoin('..', 'node_modules', '@opentiny', 'theme', 'svgs') const svgDir = pathJoin('..', 'node_modules', '@opentiny', 'theme', 'svgs')
const iconDir = pathJoin('..', 'packages', 'icon') const iconDir = pathJoin('..', 'packages', 'icon')
const packageJson = 'package.json' const packageJson = 'package.json'
const templatePath = pathJoin('..', 'template')
// 检查是否按照依赖包 // 检查是否安装依赖包
if (!fs.existsSync(svgDir)) { if (!fs.existsSync(svgDir)) {
logYellow('The @opentiny/vue-theme is not exist , please npm install @opentiny/vue-theme.') logYellow('The @opentiny/vue-theme is not exist , please npm install @opentiny/vue-theme.')
} }

View File

@ -11,7 +11,7 @@ import {
capitalizeKebabCase, capitalizeKebabCase,
kebabCase, kebabCase,
prettierFormat, prettierFormat,
pathJoin pathJoinFromCLI
} from './utils' } from './utils'
const require = createRequire(import.meta.url) const require = createRequire(import.meta.url)
@ -434,7 +434,7 @@ const createModuleMapping = (componentName, isMobile = false) => {
const moduleJson = quickSort({ sortData: moduleMap, returnType: 'object' }) const moduleJson = quickSort({ sortData: moduleMap, returnType: 'object' })
fs.writeJsonSync( fs.writeJsonSync(
pathJoin('..', 'modules.json'), pathJoinFromCLI('../../packages/modules.json'),
prettierFormat({ prettierFormat({
str: JSON.stringify(moduleJson), str: JSON.stringify(moduleJson),
options: { options: {

View File

@ -482,6 +482,23 @@ const filesFragmentReplace = (folderPath, regExpStr: Array<string | RegExp> | st
} }
} }
/** 是否已打包 */
const isCLIProduction = process.env.TINY_TSUP_ENV === 'production'
/** 相对 `CLI` 工程目录解析路径 */
const pathJoinFromCLI = (...args: string[]) => {
const cliDir = path.resolve(dirname, '../../', isCLIProduction ? '../' : '')
return path.join(cliDir, ...args)
}
/** 相对 `CLI` 入口文件解析目录 */
const pathJoinFromCLIEntry = (...args: string[]) => {
return path.join(dirname, '../', ...args)
}
/** 模板所在路径 */
const templatePath = isCLIProduction ? pathJoinFromCLIEntry('./template') : pathJoinFromCLI('./public/template')
export { export {
assetsPath, assetsPath,
capitalize, capitalize,
@ -517,4 +534,7 @@ export {
getBuildTag, getBuildTag,
getVueVersion, getVueVersion,
pathFromWorkspaceRoot, pathFromWorkspaceRoot,
pathJoinFromCLI,
pathJoinFromCLIEntry,
templatePath,
} }

View File

@ -9,7 +9,10 @@ const shared: Options = {
target: 'node14', target: 'node14',
platform: 'node', platform: 'node',
dts: false, dts: false,
publicDir: true publicDir: true,
env: {
TINY_TSUP_ENV: 'production'
}
} }
export default defineConfig([ export default defineConfig([

View File

@ -123,10 +123,12 @@
& &__close-icon { & &__close-icon {
position: absolute; position: absolute;
top: 0;
right: 0; right: 0;
padding: 0 8px; padding: 0 8px;
cursor: pointer; cursor: pointer;
display: inline-flex;
top: 50%;
transform: translateY(-50%);
} }
&-primary { &-primary {

View File

@ -64,7 +64,7 @@ export default defineComponent({
*/ */
isEnterSearch: { isEnterSearch: {
type: Boolean, type: Boolean,
default: false default: true
}, },
/** /**
* primary: gray: * primary: gray:

View File

@ -71,7 +71,7 @@ import { iconSearch, iconOperationfaild } from '@opentiny/vue-icon'
import '@opentiny/vue-theme-mobile/search/index.less' import '@opentiny/vue-theme-mobile/search/index.less'
export default defineComponent({ export default defineComponent({
props: [...props, 'transparent', 'searchTypes', 'placeholder', 'buttonText', 'modelValue', 'themeType'], props: [...props, 'transparent', 'searchTypes', 'placeholder', 'buttonText', 'modelValue', 'themeType', 'isEnterSearch'],
components: { components: {
IconSearch: iconSearch(), IconSearch: iconSearch(),
IconOperationfaild: iconOperationfaild() IconOperationfaild: iconOperationfaild()