feat(showcase): add music
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
/* eslint-disable no-undef */
|
||||
import path from 'path'
|
||||
import { appendSync, readSync } from './file.js'
|
||||
|
||||
export function appendReadme(operatorName) {
|
||||
const operatorConfig = __config.operators[operatorName]
|
||||
const projectJson = JSON.parse(readSync(path.join(__projetRoot, __config.folder.operator, operatorName, 'project.json')))
|
||||
const projectJson = JSON.parse(readSync(path.join(__projectRoot, __config.folder.operator, operatorName, 'project.json')))
|
||||
appendSync(
|
||||
`\n| ${operatorConfig.codename["en-US"]} | [Link](https://arknights.halyul.dev/${operatorConfig.link}/?settings) | [Link](https://steamcommunity.com/sharedfiles/filedetails/?id=${projectJson.workshopid}) |`,
|
||||
path.join(__projetRoot, 'README.md')
|
||||
path.join(__projectRoot, 'README.md')
|
||||
)
|
||||
}
|
||||
|
||||
export function appendMainConfig(operatorName) {
|
||||
appendSync(
|
||||
`\n ${operatorName}: !include config/${operatorName}.yaml`,
|
||||
path.join(__projetRoot, 'config.yaml')
|
||||
path.join(__projectRoot, 'config.yaml')
|
||||
)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-undef */
|
||||
import path from 'path'
|
||||
import { read, write, readSync } from './file.js'
|
||||
import AlphaComposite from './alpha_composite.js'
|
||||
@@ -9,7 +10,7 @@ export default class AssetsProcessor {
|
||||
#shareFolder
|
||||
|
||||
constructor(operatorName, shareFolder) {
|
||||
this.#operatorSourceFolder = path.join(__projetRoot, __config.folder.operator)
|
||||
this.#operatorSourceFolder = path.join(__projectRoot, __config.folder.operator)
|
||||
this.#alphaCompositer = new AlphaComposite()
|
||||
this.#operatorName = operatorName
|
||||
this.#shareFolder = shareFolder
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-undef */
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import sharp from "sharp";
|
||||
@@ -8,7 +9,7 @@ export default class Background {
|
||||
#files
|
||||
|
||||
constructor() {
|
||||
this.#backgroundFolder = path.join(__projetRoot, __config.folder.operator, __config.folder.share, __config.folder.background);
|
||||
this.#backgroundFolder = path.join(__projectRoot, __config.folder.operator, __config.folder.share, __config.folder.background);
|
||||
this.#extractFolder = path.join(this.#backgroundFolder, 'extracted');
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export function getOperatorId(operatorConfig) {
|
||||
|
||||
export default class CharwordTable {
|
||||
#operatorIDs = Object.values(__config.operators).map(operator => { return getOperatorId(operator) })
|
||||
#charwordTablePath = path.join(__projetRoot, __config.folder.operator, __config.folder.share)
|
||||
#charwordTablePath = path.join(__projectRoot, __config.folder.operator, __config.folder.share)
|
||||
#charwordTableFile = path.join(this.#charwordTablePath, 'charword_table.json')
|
||||
#charwordTable = JSON.parse(readSync(this.#charwordTableFile)) || {
|
||||
config: {
|
||||
@@ -135,10 +135,10 @@ export default class CharwordTable {
|
||||
console.log(`charword_table_${region}.json is updated.`)
|
||||
|
||||
// remove old file
|
||||
const files = readdirSync(path.join(__projetRoot, __config.folder.operator, __config.folder.share))
|
||||
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
|
||||
for (const file of files) {
|
||||
if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) {
|
||||
rm(path.join(__projetRoot, __config.folder.operator, __config.folder.share, file))
|
||||
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
|
||||
}
|
||||
}
|
||||
return data
|
||||
@@ -215,10 +215,10 @@ export default class CharwordTable {
|
||||
console.log(`charword_table_${region}.json is updated.`)
|
||||
|
||||
// remove old file
|
||||
const files = readdirSync(path.join(__projetRoot, __config.folder.operator, __config.folder.share))
|
||||
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
|
||||
for (const file of files) {
|
||||
if (file.startsWith(`charword_table_${region}`) && file !== path.basename(filepath)) {
|
||||
rm(path.join(__projetRoot, __config.folder.operator, __config.folder.share, file))
|
||||
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
|
||||
}
|
||||
}
|
||||
output.data = data
|
||||
@@ -233,10 +233,10 @@ export default class CharwordTable {
|
||||
console.log(`handbook_info_table_${region}.json is updated.`)
|
||||
|
||||
// remove old file
|
||||
const files = readdirSync(path.join(__projetRoot, __config.folder.operator, __config.folder.share))
|
||||
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
|
||||
for (const file of files) {
|
||||
if (file.startsWith(`handbook_info_table_${region}`) && file !== path.basename(handbookFilepath)) {
|
||||
rm(path.join(__projetRoot, __config.folder.operator, __config.folder.share, file))
|
||||
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
|
||||
}
|
||||
}
|
||||
output.handbook = data
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/* eslint-disable no-undef */
|
||||
import path from 'path'
|
||||
import { read } from './yaml.js'
|
||||
import { read as readVersion } from './version.js'
|
||||
import { getOperatorId } from './charword_table.js'
|
||||
|
||||
export default function () {
|
||||
return process(read(path.join(__projetRoot, 'config.yaml')))
|
||||
return process(read(path.join(__projectRoot, 'config.yaml')))
|
||||
}
|
||||
|
||||
function process(config) {
|
||||
@@ -23,8 +24,8 @@ function process(config) {
|
||||
|
||||
// version
|
||||
config.version = {
|
||||
showcase: readVersion(path.join(__projetRoot)),
|
||||
directory: readVersion(path.join(__projetRoot, 'directory')),
|
||||
showcase: readVersion(path.join(__projectRoot)),
|
||||
directory: readVersion(path.join(__projectRoot, 'directory')),
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-undef */
|
||||
export default class Matcher {
|
||||
#start
|
||||
#end
|
||||
|
||||
@@ -3,11 +3,12 @@ import path from 'path'
|
||||
import { writeSync, copy, readSync as readFile } from './file.js'
|
||||
import { read } from './yaml.js';
|
||||
import AssetsProcessor from './assets_processor.js'
|
||||
import EnvGenerator from './env_generator.js'
|
||||
|
||||
export default function ({ backgrounds, charwordTable }) {
|
||||
const extractedFolder = path.join(__projetRoot, __config.folder.operator, '_directory')
|
||||
const targetFolder = path.join(__projetRoot, __config.folder.release, __config.folder.directory);
|
||||
const sourceFolder = path.join(__projetRoot, __config.folder.operator);
|
||||
export default function ({ backgrounds }) {
|
||||
const extractedFolder = path.join(__projectRoot, __config.folder.operator, '_directory')
|
||||
const targetFolder = path.join(__projectRoot, __config.folder.release, __config.folder.directory);
|
||||
const sourceFolder = path.join(__projectRoot, __config.folder.operator);
|
||||
const filesToCopy = Object.keys(__config.operators)
|
||||
const directoryJson = {
|
||||
operators: Object.values(
|
||||
@@ -22,7 +23,7 @@ export default function ({ backgrounds, charwordTable }) {
|
||||
|
||||
cur.workshopId = null
|
||||
try {
|
||||
cur.workshopId = JSON.parse(readFile(path.join(__projetRoot, __config.folder.operator, cur.link, 'project.json'))).workshopid
|
||||
cur.workshopId = JSON.parse(readFile(path.join(__projectRoot, __config.folder.operator, cur.link, 'project.json'))).workshopid
|
||||
} catch (e) {
|
||||
console.log(`No workshop id for ${cur.link}!`, e)
|
||||
}
|
||||
@@ -33,7 +34,7 @@ export default function ({ backgrounds, charwordTable }) {
|
||||
}
|
||||
const versionJson = __config.version
|
||||
|
||||
const changelogs = read(path.join(__projetRoot, 'changelogs.yaml'))
|
||||
const changelogs = read(path.join(__projectRoot, 'changelogs.yaml'))
|
||||
const changelogsArray = Object.keys(changelogs).reduce((acc, cur) => {
|
||||
const array = []
|
||||
Object.keys(changelogs[cur]).map((item) => {
|
||||
@@ -78,7 +79,7 @@ export default function ({ backgrounds, charwordTable }) {
|
||||
key: "error_files",
|
||||
value: JSON.stringify(__config.directory.error).replace('#', '%23')
|
||||
}
|
||||
]), path.join(__projetRoot, 'directory', '.env'))
|
||||
]), path.join(__projectRoot, 'directory', '.env'))
|
||||
|
||||
writeSync(JSON.stringify(directoryJson, null), path.join(targetFolder, "directory.json"))
|
||||
writeSync(JSON.stringify(versionJson, null), path.join(targetFolder, "version.json"))
|
||||
|
||||
@@ -4,5 +4,4 @@ export default class EnvGenerator {
|
||||
return `VITE_${value.key.toUpperCase()}=${value.value}`
|
||||
}).join('\n')
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-undef */
|
||||
import path from 'path'
|
||||
import { stringify } from 'yaml'
|
||||
import { read as readYAML } from './yaml.js'
|
||||
@@ -9,9 +10,9 @@ export default function init(operatorName, extractedDir) {
|
||||
mkdir(dir)
|
||||
})
|
||||
const date = new Date()
|
||||
const template = readYAML(path.join(__projetRoot, 'config', '_template.yaml'))
|
||||
const template = readYAML(path.join(__projectRoot, 'config', '_template.yaml'))
|
||||
template.link = operatorName
|
||||
template.date = `${date.getFullYear()}/${(date.getMonth() + 1).toString().padStart(2, '0') }`
|
||||
writeSync(stringify(template), path.join(__projetRoot, 'config', `${operatorName}.yaml`))
|
||||
writeSync(stringify(template), path.join(__projectRoot, 'config', `${operatorName}.yaml`))
|
||||
appendMainConfig(operatorName)
|
||||
}
|
||||
19
libs/music.js
Normal file
19
libs/music.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/* eslint-disable no-undef */
|
||||
import path from 'path';
|
||||
import { read } from './yaml.js';
|
||||
|
||||
export default function () {
|
||||
const musicFolder = path.join(__projectRoot, __config.folder.operator, __config.folder.share, __config.folder.music);
|
||||
const musicMapping = read(path.join(musicFolder, 'mapping.yaml'));
|
||||
const musicToCopy = Object.values(musicMapping).map(entry => Object.values(entry)).flat(1).filter(entry => entry !== null).map(entry => {
|
||||
return {
|
||||
filename: entry,
|
||||
source: musicFolder,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
musicToCopy,
|
||||
musicMapping,
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable no-undef */
|
||||
import path from 'path'
|
||||
import Matcher from './content_processor.js'
|
||||
import { read as readFile, exists } from './file.js'
|
||||
@@ -13,7 +14,7 @@ export default class ProjectJson {
|
||||
|
||||
constructor(operatorName, operatorShareFolder, assets) {
|
||||
this.#operatorName = operatorName
|
||||
this.#operatorSourceFolder = path.join(__projetRoot, __config.folder.operator)
|
||||
this.#operatorSourceFolder = path.join(__projectRoot, __config.folder.operator)
|
||||
this.#operatorShareFolder = operatorShareFolder
|
||||
this.#assets = assets
|
||||
}
|
||||
@@ -44,7 +45,7 @@ export default class ProjectJson {
|
||||
return matcher.result
|
||||
}
|
||||
}
|
||||
this.#template = readYAML(path.join(__projetRoot, 'config', '_project_json.yaml'), [match])
|
||||
this.#template = readYAML(path.join(__projectRoot, 'config', '_project_json.yaml'), [match])
|
||||
this.#process()
|
||||
return this.#json
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user