style: linted files and added lint:fix

This commit is contained in:
Haoyu Xu
2025-10-05 20:50:22 +08:00
parent 33c7553506
commit 8bf964bef1
20 changed files with 270 additions and 151 deletions

View File

@@ -48,7 +48,9 @@ const download = async (
})
mapping.musicFiles.map((item) => {
if (!file.exists(path.join(item.source, item.filename))) {
const filename = item.filename.replace('.ogg', '').replace(/_(intro|loop)/, "")
const filename = item.filename
.replace('.ogg', '')
.replace(/_(intro|loop)/, '')
itemToDownload.add(filename)
}
})

View File

@@ -21,4 +21,4 @@
"lint:fix": "biome check --write .",
"build:cleanup": "rm -rf ./dist"
}
}
}

View File

@@ -20,4 +20,4 @@
"lint:fix": "biome check --write .",
"build:cleanup": "rm -rf ./dist"
}
}
}

View File

@@ -14,4 +14,4 @@
"lint": "biome lint --write .",
"lint:fix": "biome check --write ."
}
}
}

View File

@@ -21,4 +21,4 @@
"@types/yauzl-promise": "^4.0.1",
"@types/yazl": "^3.3.0"
}
}
}

View File

@@ -1,7 +1,7 @@
import path from 'node:path'
import { files as backgroundFiles } from '@aklive2d/background'
import config from '@aklive2d/config'
import { githubDownload } from '@aklive2d/downloader'
import {files as backgroundFiles} from "@aklive2d/background"
import { file } from '@aklive2d/libs'
import type {
AudioDataTable,
@@ -89,25 +89,36 @@ const generateMapping = () => {
for (const e of musicFiles) {
const musicPath = path.join(e.source, e.filename)
if (!file.exists(musicPath)) {
throw new Error(`Music file ${e.filename} is not found in music folder.`)
throw new Error(
`Music file ${e.filename} is not found in music folder.`
)
}
}
for (const e of Object.keys(musicFileMapping)) {
if (!backgroundFiles.includes(e)) {
throw new Error(`Background file ${e} is not found in background folder.`)
throw new Error(
`Background file ${e} is not found in background folder.`
)
}
}
for (const background of backgroundFiles) {
if (!musicFileMapping[background]) {
const alternativeMatch = background.replace(/_(form)(.*)(\.png)$/, "$3")
if (musicFileMapping[alternativeMatch]){
musicFileMapping[background] = structuredClone(musicFileMapping[alternativeMatch])
if (!musicFileMapping[background]) {
const alternativeMatch = background.replace(
/_(form)(.*)(\.png)$/,
'$3'
)
if (musicFileMapping[alternativeMatch]) {
musicFileMapping[background] = structuredClone(
musicFileMapping[alternativeMatch]
)
} else {
throw new Error(`Music mapping for background file ${background} is not found in music mapping.`)
throw new Error(
`Music mapping for background file ${background} is not found in music mapping.`
)
}
}
}
}
return {

View File

@@ -16,4 +16,4 @@
"lint": "biome lint --write .",
"lint:fix": "biome check --write ."
}
}
}

View File

@@ -158,9 +158,10 @@ const generateMapping = () => {
: operatorInfo.skinName['en-US']
const skinEntry = findSkinEntry(skinTable, name, type)
operator.filename = skinEntry.dynIllustId.replace(/_2$/, '')
operator.portrait_filename = type === 'skin'
? skinEntry.skinId.replace(/@/, '_')
: `${skinEntry.charId}_2`
operator.portrait_filename =
type === 'skin'
? skinEntry.skinId.replace(/@/, '_')
: `${skinEntry.charId}_2`
operator.fallback_name = `${operator.portrait_filename}${operator.isSP ? '_sp' : ''}`
const regions = Object.keys(

View File

@@ -73,7 +73,8 @@ const generateAssets = async (name: string) => {
) as string
if (!portraitHubContent) throw new Error('portrait_hub.json not found')
const portraitHub: PortraitHub = JSON.parse(portraitHubContent)
const portrait_filename_lowerCase = operators[name].portrait_filename.toLowerCase()
const portrait_filename_lowerCase =
operators[name].portrait_filename.toLowerCase()
const portraitItem = portraitHub._sprites.find(
(item) => item.name.toLowerCase() === portrait_filename_lowerCase
)

View File

@@ -25,4 +25,4 @@
"devDependencies": {
"@types/unidecode": "^1.1.0"
}
}
}

View File

@@ -20,4 +20,4 @@
"lint": "biome lint --write .",
"lint:fix": "biome check --write ."
}
}
}

View File

@@ -21,4 +21,4 @@
"lint": "biome lint --write .",
"lint:fix": "biome check --write ."
}
}
}