feat(aklive2d): updated downloader
This commit is contained in:
@@ -39,8 +39,8 @@ do
|
|||||||
done
|
done
|
||||||
|
|
||||||
ASSET_FOLDER="assets"
|
ASSET_FOLDER="assets"
|
||||||
FILES_TO_KEEP=("spritepack/ui_camp_logo_h2_0.ab" "spritepack/ui_camp_logo_h2_linkage_0.ab" "arts/dynchars" "chararts" "skinpack" "arts/ui/homebackground/wrapper" "arts/charportraits" "audio/sound_beta_2/music" "audio/sound_beta_2/voice*")
|
FILES_TO_KEEP=("spritepack/ui_camp_logo_0.ab" "arts/dynchars" "chararts" "skinpack" "arts/ui/homebackground/wrapper" "arts/charportraits" "audio/sound_beta_2/music" "audio/sound_beta_2/voice*")
|
||||||
FILES_DESTS=("ui_camp_logo_h2_0.ab" "ui_camp_logo_h2_linkage_0.ab" "dynchars" "chararts" "skinpack" "homebackground" "charportraits" "music" ".")
|
FILES_DESTS=("ui_camp_logo_0.ab" "dynchars" "chararts" "skinpack" "homebackground" "charportraits" "music" ".")
|
||||||
mkdir -p ./$ASSET_FOLDER
|
mkdir -p ./$ASSET_FOLDER
|
||||||
|
|
||||||
for i in "${!FILES_TO_KEEP[@]}"; do
|
for i in "${!FILES_TO_KEEP[@]}"; do
|
||||||
|
|||||||
@@ -124,7 +124,11 @@ export default class CharwordTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async #download(region) {
|
async #download(region) {
|
||||||
return await (new Downloader()).github(`https://api.github.com/repos/${REGION_URLS[region]}/commits?path=${region}/gamedata/excel/charword_table.json`, `https://raw.githubusercontent.com/${REGION_URLS[region]}/master/${region}/gamedata/excel/charword_table.json`, path.join(this.#charwordTablePath, `charword_table_${region}.json`))
|
return await (new Downloader()).github(
|
||||||
|
`https://api.github.com/repos/${REGION_URLS[region]}/commits?path=${region}/gamedata/excel/charword_table.json`,
|
||||||
|
`https://raw.githubusercontent.com/${REGION_URLS[region]}/master/${region}/gamedata/excel/charword_table.json`,
|
||||||
|
path.join(this.#charwordTablePath, `charword_table_${region}.json`)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,11 @@ export default class Downloader {
|
|||||||
const historyData = await historyResponse.json()
|
const historyData = await historyResponse.json()
|
||||||
const lastCommit = historyData[0]
|
const lastCommit = historyData[0]
|
||||||
const lastCommitDate = new Date(lastCommit.commit.committer.date)
|
const lastCommitDate = new Date(lastCommit.commit.committer.date)
|
||||||
console.log(`Last commit date: ${lastCommitDate.getTime()}`)
|
|
||||||
const ext = path.extname(filepath)
|
const ext = path.extname(filepath)
|
||||||
const basename = path.basename(filepath).replace(ext, '')
|
const basename = path.basename(filepath).replace(ext, '')
|
||||||
filepath = path.join(filepath, "..", `${basename}_${lastCommitDate.getTime()}${ext}`)
|
filepath = path.join(filepath, "..", `${basename}_${lastCommitDate.getTime()}${ext}`)
|
||||||
|
const dirpath = path.join(filepath, "..")
|
||||||
|
console.log(`Last ${basename} commit date: ${lastCommitDate.getTime()}`)
|
||||||
|
|
||||||
if (exists(filepath)) {
|
if (exists(filepath)) {
|
||||||
console.log(`${basename} is the latest version.`)
|
console.log(`${basename} is the latest version.`)
|
||||||
@@ -25,10 +26,10 @@ export default class Downloader {
|
|||||||
console.log(`${basename} is updated.`)
|
console.log(`${basename} is updated.`)
|
||||||
|
|
||||||
// remove old file
|
// remove old file
|
||||||
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
|
const files = readdirSync(path.join(dirpath))
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
if (file.startsWith(basename) && file !== path.basename(filepath)) {
|
if (file.startsWith(basename) && file !== path.basename(filepath)) {
|
||||||
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
|
rm(path.join(dirpath, file))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user