Refactor 7s novel compile scripts
This commit is contained in:
+4
-1
@@ -57,7 +57,10 @@
|
||||
"tsc": "tsc --watch",
|
||||
"node": "ts-node -T -P ./tsconfig-node.json",
|
||||
"assets-sync": "sh ./secrets/scripts/sync-public-assets.sh",
|
||||
"compile:novels": "npm run node src/scripts/compile7sChapters.ts",
|
||||
"compile:novels": "npm run compile:novel-7s-chapters-en && npm run compile:novel-7s-chapters-kr && npm run compile:novel-7s-archives-kr",
|
||||
"compile:novel-7s-chapters-en": "npm run node src/scripts/compile7sChaptersEn.ts",
|
||||
"compile:novel-7s-chapters-kr": "npm run node src/scripts/compile7sChaptersKr.ts",
|
||||
"compile:novel-7s-archives-kr": "npm run node src/scripts/compile7sArchivesKr.ts",
|
||||
"copy-dump": "sh ./src/scripts/copyRawAssets.sh",
|
||||
"compile:raw-data": "npm run node src/scripts/compileRawData.ts",
|
||||
"test": "jest"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
function compileArchives() {
|
||||
const fileNames = fs
|
||||
.readdirSync(path.join(__dirname, '../../public/novels/7s/ko-KR/archives'))
|
||||
.filter((fileName) => fileName.endsWith('.txt'))
|
||||
const archiveMap: { [key: string]: string } = {}
|
||||
for (const fileName of fileNames) {
|
||||
const filePath = path.join(
|
||||
__dirname,
|
||||
'../../public/novels/7s/ko-KR/archives',
|
||||
fileName
|
||||
)
|
||||
|
||||
const description = fs.readFileSync(filePath).toString()
|
||||
const [id] = fileName.split('.')
|
||||
archiveMap[id] = description
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '../../public/novels/7s/ko-KR/archives.js'),
|
||||
`const archiveMap = ${JSON.stringify(archiveMap)}`
|
||||
)
|
||||
}
|
||||
|
||||
compileArchives()
|
||||
@@ -0,0 +1,3 @@
|
||||
import { compileNovel } from './lib/7slib'
|
||||
|
||||
compileNovel('en-US')
|
||||
@@ -0,0 +1,4 @@
|
||||
import { compileNovel } from './lib/7slib'
|
||||
|
||||
compileNovel('en-US')
|
||||
compileNovel('ko-KR')
|
||||
@@ -1,13 +1,12 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const locales = ['ko-KR', 'en-US']
|
||||
const chapters = [4, 6, 7, 11]
|
||||
|
||||
function compileNovel(locale: string) {
|
||||
export function compileNovel(locale: string) {
|
||||
const xmlDirPath = path.join(
|
||||
__dirname,
|
||||
`../../public/novels/7s/${locale}/xml`
|
||||
`../../../public/novels/7s/${locale}/xml`
|
||||
)
|
||||
|
||||
const list = fs.readdirSync(xmlDirPath)
|
||||
@@ -40,30 +39,3 @@ function compileNovel(locale: string) {
|
||||
|
||||
chapters.forEach(concatScenes)
|
||||
}
|
||||
|
||||
function compileArchives() {
|
||||
const fileNames = fs
|
||||
.readdirSync(path.join(__dirname, '../../public/novels/7s/ko-KR/archives'))
|
||||
.filter((fileName) => fileName.endsWith('.txt'))
|
||||
const archiveMap: { [key: string]: string } = {}
|
||||
for (const fileName of fileNames) {
|
||||
const filePath = path.join(
|
||||
__dirname,
|
||||
'../../public/novels/7s/ko-KR/archives',
|
||||
fileName
|
||||
)
|
||||
|
||||
const description = fs.readFileSync(filePath).toString()
|
||||
const [id] = fileName.split('.')
|
||||
archiveMap[id] = description
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
path.join(__dirname, '../../public/novels/7s/ko-KR/archives.js'),
|
||||
`const archiveMap = ${JSON.stringify(archiveMap)}`
|
||||
)
|
||||
}
|
||||
|
||||
locales.forEach(compileNovel)
|
||||
|
||||
compileArchives()
|
||||
Reference in New Issue
Block a user