chore: lint generated files

This commit is contained in:
zernonia 2024-11-21 15:56:39 +08:00
parent aec80c9342
commit ec54afa796
13 changed files with 41 additions and 40 deletions

View File

@ -21505,3 +21505,4 @@ export const Index: Record<string, any> = {
}, },
}, },
} }

View File

@ -232,7 +232,7 @@ export const Index: Record<string, any> = {
// // // Write component file. // // // Write component file.
// // rimraf.sync(targetFilePath) // // rimraf.sync(targetFilePath)
// // await fs.writeFile(targetFilePath, code, 'utf8') // // await writeFile(targetFilePath, code, 'utf8')
// // return { // // return {
// // name: chunkName, // // name: chunkName,
@ -266,8 +266,8 @@ export const Index: Record<string, any> = {
// } // }
// rimraf.sync(sourcePath) // rimraf.sync(sourcePath)
// // await fs.writeFile(sourcePath, sourceFile.getText()) // // await writeFile(sourcePath, sourceFile.getText())
// await fs.writeFile(sourcePath, raw) // await writeFile(sourcePath, raw)
// } // }
let componentPath = `@/registry/${style.name}/${type}/${item.name}` let componentPath = `@/registry/${style.name}/${type}/${item.name}`
@ -346,15 +346,14 @@ export const Index: Record<string, any> = {
}) })
const registryJson = JSON.stringify(items, null, 2) const registryJson = JSON.stringify(items, null, 2)
rimraf.sync(path.join(REGISTRY_PATH, 'index.json')) rimraf.sync(path.join(REGISTRY_PATH, 'index.json'))
await fs.writeFile( await writeFile(
path.join(REGISTRY_PATH, 'index.json'), path.join(REGISTRY_PATH, 'index.json'),
registryJson, registryJson,
'utf8',
) )
// Write style index. // Write style index.
rimraf.sync(path.join(process.cwd(), '__registry__/index.ts')) rimraf.sync(path.join(process.cwd(), '__registry__/index.ts'))
await fs.writeFile(path.join(process.cwd(), '__registry__/index.ts'), index) await writeFile(path.join(process.cwd(), '__registry__/index.ts'), index)
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -458,10 +457,9 @@ async function buildStyles(registry: Registry) {
}) })
if (payload.success) { if (payload.success) {
await fs.writeFile( await writeFile(
path.join(targetPath, `${item.name}.json`), path.join(targetPath, `${item.name}.json`),
`${JSON.stringify(payload.data, null, 2)}\r\n`, JSON.stringify(payload.data, null, 2),
'utf8',
) )
} }
} }
@ -471,10 +469,10 @@ async function buildStyles(registry: Registry) {
// Build registry/styles/index.json. // Build registry/styles/index.json.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
const stylesJson = JSON.stringify(styles, null, 2) const stylesJson = JSON.stringify(styles, null, 2)
await fs.writeFile( await writeFile(
path.join(REGISTRY_PATH, 'styles/index.json'), path.join(REGISTRY_PATH, 'styles/index.json'),
stylesJson, stylesJson,
'utf8',
) )
} }
@ -510,10 +508,10 @@ async function buildStylesIndex() {
files: [], files: [],
} }
await fs.writeFile( await writeFile(
path.join(targetPath, 'index.json'), path.join(targetPath, 'index.json'),
JSON.stringify(payload, null, 2), JSON.stringify(payload, null, 2),
'utf8',
) )
} }
} }
@ -560,10 +558,10 @@ async function buildThemes() {
} }
} }
await fs.writeFile( await writeFile(
path.join(colorsTargetPath, 'index.json'), path.join(colorsTargetPath, 'index.json'),
`${JSON.stringify(colorsData, null, 2)}\r\n`, JSON.stringify(colorsData, null, 2),
'utf8',
) )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -682,10 +680,9 @@ async function buildThemes() {
colors: base.cssVars, colors: base.cssVars,
}) })
await fs.writeFile( await writeFile(
path.join(REGISTRY_PATH, `colors/${baseColor}.json`), path.join(REGISTRY_PATH, `colors/${baseColor}.json`),
`${JSON.stringify(base, null, 2)}\r\n`, JSON.stringify(base, null, 2),
'utf8',
) )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -766,10 +763,9 @@ async function buildThemes() {
) )
} }
await fs.writeFile( await writeFile(
path.join(REGISTRY_PATH, `themes.css`), path.join(REGISTRY_PATH, `themes.css`),
themeCSS.join('\n'), themeCSS.join('\n'),
'utf8',
) )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -809,10 +805,9 @@ async function buildThemes() {
await fs.mkdir(targetPath, { recursive: true }) await fs.mkdir(targetPath, { recursive: true })
} }
await fs.writeFile( await writeFile(
path.join(targetPath, `${payload.name}.json`), path.join(targetPath, `${payload.name}.json`),
JSON.stringify(payload, null, 2), JSON.stringify(payload, null, 2),
'utf8',
) )
} }
} }
@ -830,10 +825,9 @@ async function buildIcons() {
const iconsData = icons const iconsData = icons
await fs.writeFile( await writeFile(
path.join(iconsTargetPath, 'index.json'), path.join(iconsTargetPath, 'index.json'),
JSON.stringify(iconsData, null, 2), JSON.stringify(iconsData, null, 2),
'utf8',
) )
} }
@ -870,10 +864,9 @@ export const Icons = {
// Write style index. // Write style index.
rimraf.sync(path.join(process.cwd(), '__registry__/icons.ts')) rimraf.sync(path.join(process.cwd(), '__registry__/icons.ts'))
await fs.writeFile( await writeFile(
path.join(process.cwd(), '__registry__/icons.ts'), path.join(process.cwd(), '__registry__/icons.ts'),
index, index,
'utf8',
) )
} }
@ -881,10 +874,9 @@ try {
const content = await crawlContent() const content = await crawlContent()
const result = registrySchema.safeParse([...registry, ...content]) const result = registrySchema.safeParse([...registry, ...content])
await fs.writeFile( await writeFile(
path.join(REGISTRY_PATH, 'temp.json'), path.join(REGISTRY_PATH, 'temp.json'),
JSON.stringify(result.data ?? '', null, 2), JSON.stringify(result.data ?? '', null, 2),
'utf8',
) )
if (!result.success) { if (!result.success) {
@ -907,3 +899,11 @@ catch (error) {
console.error(error) console.error(error)
process.exit(1) process.exit(1)
} }
async function writeFile(path: string, payload: any) {
return fs.writeFile(
path,
`${payload}\r\n`,
'utf8',
)
}