Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions internals/automate/src/build-svg-to-js/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
export const svgsPath = '../../packages/theme/src/svgs'
export const iconsPath = '../../packages/vue-icon'

export const rewriteConfig = {
acceptance: 'activation'
}
export const rewriteConfig = {}
16 changes: 13 additions & 3 deletions internals/automate/src/build-svg-to-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ interface FileInfo {
const camelize = (str) => str.replace(/-(\w)/g, (_, c) => (c ? c.toUpperCase() : ''))
const isSaas = process.argv.includes('--icon-saas')
const { svgsPath, iconsPath, rewriteConfig } = isSaas ? configSaas : config
const themePackage = isSaas ? '@opentiny/vue-theme-saas' : '@opentiny/vue-theme'
const iconsSrcPath = `${iconsPath}/src`

// 生成前清理旧的图标产物,避免目录缺失导致写入失败
try {
fs.rmSync(iconsSrcPath, { recursive: true, force: true })
} catch (error) {
console.warn(`[build-svg-to-js] 清理目录失败: ${iconsSrcPath}`, error)
}
fs.mkdirSync(iconsSrcPath, { recursive: true })

// 1、统计svgs信息
const svgsMap: Record<string, FileInfo> = {}
Expand Down Expand Up @@ -87,8 +97,8 @@ Object.values(svgsMap).forEach((item) => {
fillList.push({ capName, svgName: item.svgName })
const tmplStr = `
import { svg } from '@opentiny/vue-common'
import ${capName} from '@opentiny/vue-theme/svgs/${item.svgName}.svg'
import ${capName}Filled from '@opentiny/vue-theme/svgs/${item.svgName + '-filled'}.svg'
import ${capName} from '${themePackage}/svgs/${item.svgName}.svg'
import ${capName}Filled from '${themePackage}/svgs/${item.svgName + '-filled'}.svg'

export default () => svg({ name: 'Icon${capName}', component: ${capName}, filledComponent: ${capName}Filled })()
`
Expand All @@ -100,7 +110,7 @@ export default () => svg({ name: 'Icon${capName}', component: ${capName}, filled
uncheckedList.push({ capName, svgName: item.svgName })
const tmplStr = `
import { svg } from '@opentiny/vue-common'
import ${capName} from '@opentiny/vue-theme/svgs/${item.svgName}.svg'
import ${capName} from '${themePackage}/svgs/${item.svgName}.svg'

export default () => svg({ name: 'Icon${capName}', component: ${capName}, filledComponent: ${capName} })()
`
Expand Down
2 changes: 2 additions & 0 deletions internals/cli/src/commands/build/build-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,8 @@ export async function buildUi(
tasks.push(...getAllIcons())
}

// return true

// 构建 @opentiny/vue
if (names.some((name) => ['@opentiny/vue', '@opentiny/vue', 'vue'].includes(name))) {
tasks.push(...getEntryTasks())
Expand Down
10 changes: 5 additions & 5 deletions internals/cli/src/shared/module-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,19 +461,19 @@ const createModuleMapping = (componentName, isMobile = false) => {
}

const getAllIcons = () => {
const entries = fg.sync('vue-icon*/src/*', { cwd: pathFromWorkspaceRoot('packages'), onlyDirectories: true })
const entries = fg.sync('vue-icon*/src/*.ts', { cwd: pathFromWorkspaceRoot('packages') })

return entries.map((item) => {
const name = path.basename(item)
const name = path.basename(item).replace('.ts', '')

return {
path: item + '/index.ts',
libPath: item.replace('/src/', '/lib/'),
path: item,
libPath: item.replace('/src/', '/lib/').replace('.ts', ''),
type: 'component',
componentType: 'icon',
name: kebabCase({ str: name }),
global: capitalizeKebabCase(name),
importName: '@opentiny/vue-' + item
importName: '@opentiny/vue-' + item.replace('.ts', '')
} as Module
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"// ---------- 打包运行时组件库 ----------": "",
"build:runtime": "pnpm create:icon-saas && pnpm -C internals/cli build:runtime",
"// ---------- 构建相关脚本 ----------": "",
"build:ui": "pnpm create:icon-saas && pnpm create:mapping && pnpm build:entry && pnpm -C internals/cli build:ui",
"build:ui": "pnpm build:svgs2iconSaas && pnpm create:mapping && pnpm build:entry && pnpm -C internals/cli build:ui",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

Verify consistency with the build:runtime script.

The change from create:icon-saas to build:svgs2iconSaas aligns with the cleanup logic added to prevent build failures. However, the build:runtime script on line 56 still uses create:icon-saas. If build:runtime encounters similar build issues, consider updating it consistently.

Run the following script to examine what these scripts actually execute:


🏁 Script executed:

#!/bin/bash
# Check what the create:icon-saas command does in internals/cli
# and compare with build-svgs-saas in internals/automate

echo "=== Checking internals/cli for create:icon-saas ==="
fd -t f "package.json" internals/cli --exec cat {} | jq -r '.scripts["create:icon-saas"]'

echo -e "\n=== Checking internals/automate for build-svgs-saas ==="
fd -t f "package.json" internals/automate --exec cat {} | jq -r '.scripts["build-svgs-saas"]'

echo -e "\n=== Checking if build:runtime might need the same fix ==="
cat package.json | jq -r '.scripts["build:runtime"]'

Length of output: 374


I need to examine the root package.json more carefully to understand the create:icon-saas script and its relationship to both build scripts.


---

🏁 Script executed:

```shell
#!/bin/bash
# Extract all scripts from root package.json
echo "=== Root package.json scripts ==="
cat package.json | jq '.scripts | keys_unsorted[]'

echo -e "\n=== Details of create:icon-saas script ==="
cat package.json | jq '.scripts["create:icon-saas"]'

echo -e "\n=== Details of build:ui script ==="
cat package.json | jq '.scripts["build:ui"]'

echo -e "\n=== Details of build:runtime script ==="
cat package.json | jq '.scripts["build:runtime"]'

echo -e "\n=== Details of build:svgs2iconSaas script ==="
cat package.json | jq '.scripts["build:svgs2iconSaas"]'

Length of output: 1791


Update build:runtime script to use build:svgs2iconSaas for consistency.

The build:ui script was changed to call build:svgs2iconSaas (which routes through internals/automate build-svgs-saas), but build:runtime still calls create:icon-saas (which attempts to invoke a non-existent script in internals/cli). Update line 56 from pnpm create:icon-saas && pnpm -C internals/cli build:runtime to pnpm build:svgs2iconSaas && pnpm -C internals/cli build:runtime to prevent build failures.

🤖 Prompt for AI Agents
In package.json around lines 56-58, the build:runtime script still invokes "pnpm
create:icon-saas" which calls a non-existent internals/cli script; replace that
segment with "pnpm build:svgs2iconSaas" so the build:runtime script becomes
consistent with build:ui and routes through internals/automate build-svgs-saas
before running "pnpm -C internals/cli build:runtime".

"build:chartTheme": "pnpm -C internals/cli build:chartTheme",
"build:renderless": "pnpm -C packages/renderless build:fast",
"build:theme": "pnpm -C packages/theme build:fast",
Expand Down
Loading
Loading