From 00e6916ad18ec950505dc0ad92ab67d57a0cec4f Mon Sep 17 00:00:00 2001 From: Haoyu Xu Date: Mon, 27 Feb 2023 16:33:42 -0500 Subject: [PATCH] feat(aklive2d): add ability to read and increase version number --- config/chen.yaml | 3 ++- config/chongyue.yaml | 3 ++- config/dusk.yaml | 3 ++- config/gavial.yaml | 3 ++- config/ling.yaml | 3 ++- config/mizuki_summer_feast.yaml | 3 ++- config/nearl.yaml | 3 ++- config/nian.yaml | 3 ++- config/phatom_focus.yaml | 3 ++- config/rosmontis.yaml | 3 ++- config/skadi.yaml | 3 ++- config/specter.yaml | 3 ++- config/texas_the_omertosa.yaml | 3 ++- config/w.yaml | 3 ++- libs/config.js | 7 +++++++ libs/content_processor.js | 2 +- libs/directory.js | 19 ++++++++++++++----- libs/version.js | 13 +++++++++++++ src/components/voice.js | 2 +- 19 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 libs/version.js diff --git a/config/chen.yaml b/config/chen.yaml index bf145b7..1d13bc1 100644 --- a/config/chen.yaml +++ b/config/chen.yaml @@ -10,4 +10,5 @@ invert_filter: false color: rgba(14, 126, 239, 0.85) codename: zh-CN: 假日威龙陈 - en-US: Ch'en/Chen the Holungday \ No newline at end of file + en-US: Ch'en/Chen the Holungday +portrait: null \ No newline at end of file diff --git a/config/chongyue.yaml b/config/chongyue.yaml index fedd4ab..3be46a1 100644 --- a/config/chongyue.yaml +++ b/config/chongyue.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(255, 133, 34) codename: zh-CN: 重岳 - en-US: Chongyue \ No newline at end of file + en-US: Chongyue +portrait: null \ No newline at end of file diff --git a/config/dusk.yaml b/config/dusk.yaml index e3b25f3..1641ae3 100644 --- a/config/dusk.yaml +++ b/config/dusk.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(9, 212, 208) codename: zh-CN: 夕 - en-US: Dusk \ No newline at end of file + en-US: Dusk +portrait: null \ No newline at end of file diff --git a/config/gavial.yaml b/config/gavial.yaml index ee6a766..7bac9b9 100644 --- a/config/gavial.yaml +++ b/config/gavial.yaml @@ -10,4 +10,5 @@ invert_filter: false color: rgb(29, 185, 53) codename: zh-CN: 百练嘉维尔 - en-US: Gavial the Invincible \ No newline at end of file + en-US: Gavial the Invincible +portrait: null \ No newline at end of file diff --git a/config/ling.yaml b/config/ling.yaml index 143565e..76ba06d 100644 --- a/config/ling.yaml +++ b/config/ling.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(15, 206, 216) codename: zh-CN: 令 - en-US: Ling \ No newline at end of file + en-US: Ling +portrait: null \ No newline at end of file diff --git a/config/mizuki_summer_feast.yaml b/config/mizuki_summer_feast.yaml index 529b2a6..d59a2e8 100644 --- a/config/mizuki_summer_feast.yaml +++ b/config/mizuki_summer_feast.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(156, 210, 246) codename: zh-CN: 夏日餮宴 · 水月 - en-US: Summer Feast / Mizuki \ No newline at end of file + en-US: Summer Feast / Mizuki +portrait: null \ No newline at end of file diff --git a/config/nearl.yaml b/config/nearl.yaml index efc8a5f..881e72b 100644 --- a/config/nearl.yaml +++ b/config/nearl.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgba(253, 236, 189, 0.95) codename: zh-CN: 耀骑士临光 - en-US: Nearl the Radiant Knight \ No newline at end of file + en-US: Nearl the Radiant Knight +portrait: null \ No newline at end of file diff --git a/config/nian.yaml b/config/nian.yaml index 7ce2dfd..766bdbf 100644 --- a/config/nian.yaml +++ b/config/nian.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(255, 48, 0) codename: zh-CN: 年 - en-US: Nian \ No newline at end of file + en-US: Nian +portrait: null \ No newline at end of file diff --git a/config/phatom_focus.yaml b/config/phatom_focus.yaml index 0653420..75044f3 100644 --- a/config/phatom_focus.yaml +++ b/config/phatom_focus.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(158, 2, 2) codename: zh-CN: 焦点 · 傀影 - en-US: Focus / Phatom \ No newline at end of file + en-US: Focus / Phatom +portrait: null \ No newline at end of file diff --git a/config/rosmontis.yaml b/config/rosmontis.yaml index bb5450d..856582a 100644 --- a/config/rosmontis.yaml +++ b/config/rosmontis.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(23, 210, 236) codename: zh-CN: 迷迭香 - en-US: Rosmontis \ No newline at end of file + en-US: Rosmontis +portrait: null \ No newline at end of file diff --git a/config/skadi.yaml b/config/skadi.yaml index aec5627..971871d 100644 --- a/config/skadi.yaml +++ b/config/skadi.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(226, 96, 96) codename: zh-CN: 浊心斯卡蒂 - en-US: Skadi the Corrupting Heart \ No newline at end of file + en-US: Skadi the Corrupting Heart +portrait: null \ No newline at end of file diff --git a/config/specter.yaml b/config/specter.yaml index 9b67de6..d9c1e50 100644 --- a/config/specter.yaml +++ b/config/specter.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgba(14, 124, 203, 0.86) codename: zh-CN: 归溟幽灵鲨 - en-US: Specter the Unchained \ No newline at end of file + en-US: Specter the Unchained +portrait: null \ No newline at end of file diff --git a/config/texas_the_omertosa.yaml b/config/texas_the_omertosa.yaml index e29b708..3928803 100644 --- a/config/texas_the_omertosa.yaml +++ b/config/texas_the_omertosa.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgba(34, 37, 255, 0.9) codename: zh-CN: 缄默德克萨斯 - en-US: Texas the Omertosa \ No newline at end of file + en-US: Texas the Omertosa +portrait: null \ No newline at end of file diff --git a/config/w.yaml b/config/w.yaml index bc86100..0383fb4 100644 --- a/config/w.yaml +++ b/config/w.yaml @@ -10,4 +10,5 @@ invert_filter: true color: rgb(228, 54, 56) codename: zh-CN: W - en-US: W \ No newline at end of file + en-US: W +portrait: null \ No newline at end of file diff --git a/libs/config.js b/libs/config.js index ced88a4..c5ad089 100644 --- a/libs/config.js +++ b/libs/config.js @@ -1,5 +1,6 @@ import path from 'path' import { read } from './yaml.js' +import { read as readVersion } from './version.js' export default function () { return process(read(path.join(__projetRoot, 'config.yaml'))) @@ -16,5 +17,11 @@ function process(config) { operator.link = operatorName } + // version + config.version = { + showcase: readVersion(path.join(__projetRoot)), + directory: readVersion(path.join(__projetRoot, 'directory')), + } + return config } \ No newline at end of file diff --git a/libs/content_processor.js b/libs/content_processor.js index 33ba752..0af15e0 100644 --- a/libs/content_processor.js +++ b/libs/content_processor.js @@ -49,7 +49,7 @@ class Evalable { } version(prefix, suffix) { - return `${prefix}${__config.version}${suffix}` + return `${prefix}${__config.version.showcase}${suffix}` } #step(location, varName) { diff --git a/libs/directory.js b/libs/directory.js index 2a0afd3..bb2c6db 100644 --- a/libs/directory.js +++ b/libs/directory.js @@ -10,11 +10,20 @@ export default function () { const targetFolder = path.join(__projetRoot, __config.folder.release, __config.folder.directory); const sourceFolder = path.join(__projetRoot, __config.folder.operator); rmdir(targetFolder); - const filesToCopy = []; - const directoryJson = [] - for (const [key, value] of Object.entries(__config.operators)) { - filesToCopy.push(key); - directoryJson.push(value); + const filesToCopy = Object.keys(__config.operators) + const directoryJson = { + operators: Object.values( + Object.values(__config.operators) + .reduce((acc, cur) => { + const date = cur.date + if (acc[date]) { + acc[date].push(cur) + } else { + acc[date] = [cur] + } + return acc + }, {})) + .sort((a, b) => Date.parse(b[0].date) - Date.parse(a[0].date)), } writeSync(JSON.stringify(directoryJson, null), path.join(targetFolder, "directory.json")) filesToCopy.forEach((key) => { diff --git a/libs/version.js b/libs/version.js new file mode 100644 index 0000000..5d4808e --- /dev/null +++ b/libs/version.js @@ -0,0 +1,13 @@ +import path from 'path' +import { readSync, writeSync } from './file.js' + +export function read (dir) { + return readSync(path.join(dir, 'Version')) +} + +export function increase(dir) { + // release version will be lagged by 0.0.1 + const version = read(dir) + const [major, minor, patch] = version.split('.') + writeSync(`${major}.${minor}.${+patch + 1}`, path.join(dir, 'Version')) +} \ No newline at end of file diff --git a/src/components/voice.js b/src/components/voice.js index d93953a..6049fa0 100644 --- a/src/components/voice.js +++ b/src/components/voice.js @@ -364,7 +364,7 @@ export default class Voice { #insertHTML() { this.#el.innerHTML = `