From dea5d0b0ace052d85034ebd73a98bb17fdecfb70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Mon, 27 Nov 2023 14:30:08 +0800 Subject: [PATCH] fix: dts --- package.json | 12 +- packages/svg/package.json | 2 +- packages/vue/build/generate.ts | 47 +- packages/vue/package.json | 28 +- playground/package.json | 8 +- pnpm-lock.yaml | 2317 ++++++++++++++++++-------------- 6 files changed, 1374 insertions(+), 1040 deletions(-) diff --git a/package.json b/package.json index ebcea3e..d7052a5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@element-plus/icons-monorepo", "version": "2.2.0", "private": true, - "packageManager": "pnpm@8.6.2", + "packageManager": "pnpm@8.11.0", "type": "module", "license": "MIT", "scripts": { @@ -14,10 +14,10 @@ "release": "bumpp -r" }, "devDependencies": { - "@sxzz/eslint-config": "^3.0.0", - "bumpp": "^9.1.1", - "eslint": "^8.43.0", - "prettier": "^2.8.8", - "typescript": "^5.1.3" + "@sxzz/eslint-config": "^3.7.5", + "bumpp": "^9.2.0", + "eslint": "^8.54.0", + "prettier": "^3.1.0", + "typescript": "^5.3.2" } } diff --git a/packages/svg/package.json b/packages/svg/package.json index 7c41d83..31ee73b 100644 --- a/packages/svg/package.json +++ b/packages/svg/package.json @@ -24,6 +24,6 @@ "optimize": "svgo -f . -o ." }, "devDependencies": { - "svgo": "^3.0.2" + "svgo": "^3.0.4" } } diff --git a/packages/vue/build/generate.ts b/packages/vue/build/generate.ts index 0001210..e952f44 100644 --- a/packages/vue/build/generate.ts +++ b/packages/vue/build/generate.ts @@ -10,17 +10,28 @@ import { findWorkspaceDir } from '@pnpm/find-workspace-dir' import { findWorkspacePackages } from '@pnpm/find-workspace-packages' import { pathComponents } from './paths' -const getSvgFiles = async () => { +consola.info(chalk.blue('generating vue components')) +await ensureDir(pathComponents) +await emptyDir(pathComponents) +const files = await getSvgFiles() + +consola.info(chalk.blue('generating vue files')) +await Promise.all(files.map((file) => transformToVueComponent(file))) + +consola.info(chalk.blue('generating entry file')) +await generateEntry(files) + +async function getSvgFiles() { const pkgs = await findWorkspacePackages( - (await findWorkspaceDir(process.cwd()))! + (await findWorkspaceDir(process.cwd()))!, ) const pkg = pkgs.find( - (pkg) => pkg.manifest.name === '@element-plus/icons-svg' + (pkg) => pkg.manifest.name === '@element-plus/icons-svg', )! return glob('*.svg', { cwd: pkg.dir, absolute: true }) } -const getName = (file: string) => { +function getName(file: string) { const filename = path.basename(file).replace('.svg', '') const componentName = camelcase(filename, { pascalCase: true }) return { @@ -29,17 +40,18 @@ const getName = (file: string) => { } } -const formatCode = (code: string, parser: BuiltInParserName = 'typescript') => - format(code, { +function formatCode(code: string, parser: BuiltInParserName = 'typescript') { + return format(code, { parser, semi: false, singleQuote: true, }) +} -const transformToVueComponent = async (file: string) => { +async function transformToVueComponent(file: string) { const content = await readFile(file, 'utf-8') const { filename, componentName } = getName(file) - const vue = formatCode( + const vue = await formatCode( `