feat(aklive2d): use offical_update to fetch info

This commit is contained in:
Haoyu Xu
2023-11-01 18:06:21 -04:00
parent b05590764f
commit 013783366b
44 changed files with 176 additions and 209 deletions

View File

@@ -5,13 +5,19 @@ import { read as readYAML } from './yaml.js'
import { mkdir, writeSync } from './file.js'
import { appendMainConfig } from './append.js'
export default function init(operatorName, extractedDir) {
export default function init(operatorName, extractedDir, officalInfo) {
const officalId = process.argv[4]
const template = readYAML(path.join(__projectRoot, 'config', '_template.yaml'))
extractedDir.forEach((dir) => {
mkdir(dir)
})
const date = new Date()
const template = readYAML(path.join(__projectRoot, 'config', '_template.yaml'))
template.date = `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0') }`
const currentOpertor = officalInfo.find(officalId);
if (currentOpertor === undefined) {
throw new Error('Invalid operator id')
}
template.offical_id = currentOpertor.id
template.codename = currentOpertor.codename
writeSync(stringify(template), path.join(__projectRoot, 'config', `${operatorName}.yaml`))
appendMainConfig(operatorName)
}