chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import { readFile, writeFile } from 'node:fs/promises'
|
||||
import { pinyin } from 'pinyin-pro'
|
||||
import { format } from 'vite-plus/fmt'
|
||||
|
||||
const output = new URL(
|
||||
'../app/components/workflow/block-selector/provider-initials.generated.ts',
|
||||
import.meta.url,
|
||||
)
|
||||
const metadata = await readFile(
|
||||
new URL('../node_modules/pinyin-pro/package.json', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const { version } = JSON.parse(metadata) as { version: string }
|
||||
const license = await readFile(
|
||||
new URL('../node_modules/pinyin-pro/LICENSE', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
|
||||
// Preserve the existing single-character grouping range and default readings.
|
||||
let initials = ''
|
||||
for (let code = 0x4e00; code <= 0x9fa5; code++) {
|
||||
const character = String.fromCharCode(code)
|
||||
const initial = (
|
||||
pinyin(character, { pattern: 'first', toneType: 'none' })[0] || character
|
||||
).toUpperCase()
|
||||
initials += /^[A-Z]$/.test(initial) ? initial : '#'
|
||||
}
|
||||
|
||||
const source = `// Generated by pnpm --dir web gen-provider-initials. Do not edit.
|
||||
// Single-character initials derived from pinyin-pro ${version} (https://github.com/zh-lx/pinyin-pro).
|
||||
/*
|
||||
${license.trim()}
|
||||
*/
|
||||
|
||||
// Indexed by UTF-16 code unit minus U+4E00, through U+9FA5 inclusive.
|
||||
export const providerInitials = ${JSON.stringify(initials)}
|
||||
`
|
||||
const result = await format(output.pathname, source, { singleQuote: true, semi: false })
|
||||
if (result.errors.length) throw new Error('Could not format provider initials')
|
||||
if (process.argv.includes('--check')) {
|
||||
if ((await readFile(output, 'utf8')) !== result.code)
|
||||
throw new Error('Provider initials are stale. Run pnpm --dir web gen-provider-initials.')
|
||||
} else {
|
||||
await writeFile(output, result.code)
|
||||
}
|
||||
Reference in new issue
Block a user