feat: migrate to turbo (#22)
* feat: migrate top turbo * ci: ci test * fix: fix codeql issues * feat: ci test * chore: lint * chore: misc changes * feat: rename vite helpers * feat: use fetch to handle assets * feat: update directory * feat: fetch charword table * feat: migrate download game data and detect missing voice files * feat: symlink relative path * feat: finish wrangler upload * feat: migrate wrangler download * feat: finish * chore: auto update * ci: update ci * ci: update ci --------- Co-authored-by: Halyul <Halyul@users.noreply.github.com>
This commit is contained in:
49
packages/assets/libs/build.js
Normal file
49
packages/assets/libs/build.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import path from 'node:path'
|
||||
import { file } from '@aklive2d/libs'
|
||||
import config from '@aklive2d/config'
|
||||
import { DIST_DIR } from '../index.js'
|
||||
|
||||
export default async (packageDir) => {
|
||||
const copyQueue = [
|
||||
{
|
||||
fn: file.symlink,
|
||||
source: path.resolve(
|
||||
packageDir,
|
||||
'background',
|
||||
config.dir_name.dist
|
||||
),
|
||||
target: path.resolve(DIST_DIR, config.dir_name.background),
|
||||
},
|
||||
{
|
||||
fn: file.symlink,
|
||||
source: path.resolve(
|
||||
packageDir,
|
||||
'charword-table',
|
||||
config.dir_name.dist
|
||||
),
|
||||
target: path.resolve(DIST_DIR, config.dir_name.charword_table),
|
||||
},
|
||||
{
|
||||
fn: file.symlink,
|
||||
source: path.resolve(packageDir, 'music', config.dir_name.data),
|
||||
target: path.resolve(DIST_DIR, config.dir_name.music),
|
||||
},
|
||||
{
|
||||
fn: file.symlinkAll,
|
||||
source: path.resolve(packageDir, 'operator', config.dir_name.dist),
|
||||
target: path.resolve(DIST_DIR),
|
||||
},
|
||||
{
|
||||
fn: file.symlink,
|
||||
source: path.resolve(
|
||||
packageDir,
|
||||
'project-json',
|
||||
config.dir_name.dist
|
||||
),
|
||||
target: path.resolve(DIST_DIR, config.dir_name.project_json),
|
||||
},
|
||||
]
|
||||
copyQueue.map(({ fn, source, target }) => {
|
||||
fn(source, target)
|
||||
})
|
||||
}
|
||||
57
packages/assets/libs/download.js
Normal file
57
packages/assets/libs/download.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import path from 'node:path'
|
||||
import { file } from '@aklive2d/libs'
|
||||
import { unzipDownload } from '@aklive2d/downloader'
|
||||
import { getOperatorId, getOperatorAlternativeId } from '@aklive2d/operator'
|
||||
import { mapping } from '@aklive2d/music'
|
||||
import config from '../index.js'
|
||||
|
||||
export default async (dataDir) => {
|
||||
const pidSet = new Set()
|
||||
const versionRes = await fetch(
|
||||
'https://ak-conf.hypergryph.com/config/prod/official/Android/version'
|
||||
)
|
||||
const version = (await versionRes.json()).resVersion
|
||||
const lpacksRes = await fetch(
|
||||
`https://ak.hycdn.cn/assetbundle/official/Android/assets/${version}/hot_update_list.json`
|
||||
)
|
||||
const updateList = await lpacksRes.json()
|
||||
const itemToDownload = new Set(config.item_to_download)
|
||||
updateList.abInfos.map((item) => {
|
||||
if (item.name.includes(config.dynchars)) {
|
||||
const id = getOperatorId(item.name).replace('.ab', '')
|
||||
itemToDownload.add(id)
|
||||
itemToDownload.add(getOperatorAlternativeId(id))
|
||||
}
|
||||
})
|
||||
mapping.musicFiles.map((item) => {
|
||||
if (!file.exists(path.join(item.source, item.filename))) {
|
||||
const filename = item.filename.replace('.ogg', '')
|
||||
itemToDownload.add(filename)
|
||||
}
|
||||
})
|
||||
const itemToDownloadRegExp = new RegExp(
|
||||
`(.*)(${Array.from(itemToDownload).join('|')})(.*)`
|
||||
)
|
||||
updateList.abInfos.map((item) => {
|
||||
if (itemToDownloadRegExp.test(item.name)) {
|
||||
item.pid && pidSet.add(item.pid)
|
||||
}
|
||||
})
|
||||
const lpacksToDownload = []
|
||||
pidSet.forEach((item) => {
|
||||
lpacksToDownload.push({
|
||||
name: item,
|
||||
url: `https://ak.hycdn.cn/assetbundle/official/Android/assets/${version}/${item}.dat`,
|
||||
})
|
||||
})
|
||||
const regexs = []
|
||||
if (config.additional_regex.length > 0) {
|
||||
for (const item of config.additional_regex) {
|
||||
regexs.push(new RegExp(item))
|
||||
}
|
||||
}
|
||||
await unzipDownload(lpacksToDownload, dataDir, {
|
||||
matchRegExps: regexs,
|
||||
defaultRegex: itemToDownloadRegExp,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user