init
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import dirTree from 'directory-tree'
|
||||
import treeify from 'treeify'
|
||||
|
||||
// eslint-disable-next-line node/prefer-global/process
|
||||
const filteredTree = dirTree(process.cwd(), {
|
||||
exclude: [/node_modules/, /\.git/, /\.vscode/, /\.idea/],
|
||||
})
|
||||
|
||||
const children = filteredTree.children ?? []
|
||||
|
||||
function genObj(children: any[]) {
|
||||
const obj: Record<string, any> = {}
|
||||
for (const child of children)
|
||||
obj[child.name] = (child?.children && child.children.length > 0) ? genObj(child.children) : null
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
const obj = genObj(children)
|
||||
|
||||
const md = treeify.asTree(obj, true, null)
|
||||
|
||||
console.log(md)
|
||||
@@ -0,0 +1,35 @@
|
||||
import path from 'node:path'
|
||||
import { theme } from 'ant-design-vue'
|
||||
import fsExtra from 'fs-extra'
|
||||
import lodash from 'lodash'
|
||||
|
||||
const { defaultAlgorithm, defaultSeed } = theme
|
||||
|
||||
const mapToken = defaultAlgorithm(defaultSeed)
|
||||
|
||||
function formatKey(key: string, prefixCls: string) {
|
||||
return `${prefixCls}${lodash.kebabCase(key)}`
|
||||
}
|
||||
const prefixCls = '--pro-ant-'
|
||||
|
||||
const variables: {
|
||||
colors: Record<string, any>
|
||||
} = {
|
||||
colors: {},
|
||||
}
|
||||
let colorTheme = ''
|
||||
for (const key in mapToken) {
|
||||
if (key.startsWith('color')) {
|
||||
const cssVar = formatKey(key, prefixCls)
|
||||
const colors = variables.colors
|
||||
const themeKey = lodash.camelCase(key.slice(5))
|
||||
colors[themeKey] = `var(${cssVar})`
|
||||
colorTheme += `${themeKey}\n`
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line node/prefer-global/process
|
||||
fsExtra.outputFile(path.resolve(process.cwd(), './themes/antd-uno-theme.json'), JSON.stringify(variables, null, 2))
|
||||
|
||||
// eslint-disable-next-line node/prefer-global/process
|
||||
fsExtra.outputFile(path.resolve(process.cwd(), './themes/color-theme-var.md'), colorTheme)
|
||||
@@ -0,0 +1,17 @@
|
||||
import { resolve } from 'node:path'
|
||||
import * as process from 'node:process'
|
||||
import { transformSync } from 'esbuild'
|
||||
import fsExtra from 'fs-extra'
|
||||
|
||||
const themeConfig = resolve(process.cwd(), './src/config/default-setting.ts')
|
||||
const code = fsExtra.readFileSync(themeConfig, 'utf-8')
|
||||
|
||||
function toJs(code: string) {
|
||||
const res = transformSync(code, {
|
||||
target: 'esnext',
|
||||
loader: 'ts',
|
||||
})
|
||||
console.log(res.code)
|
||||
}
|
||||
|
||||
toJs(code)
|
||||
Reference in New Issue
Block a user