chronocat/scripts/packllqqntengine.cts

75 lines
2.0 KiB
TypeScript
Raw Permalink Normal View History

2024-03-09 18:32:10 +00:00
import { cp, mkdir, writeFile } from 'node:fs/promises'
import { join, resolve } from 'node:path'
void Promise.all(
2024-09-07 06:05:45 +00:00
['engine-chronocat-api', 'engine-chronocat-event', 'engine-media'].map(
async (x) => {
2024-09-07 08:08:25 +00:00
const upper = x
.split('-')
.map((y) => y[0]!.toUpperCase() + y.slice(1))
.join('-')
2024-09-07 06:05:45 +00:00
const distName = `LiteLoaderQQNT-Plugin-Chronocat-${upper}`
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
const corePath = resolve(__dirname, `../packages/${x}/lib/index.js`)
const coreName = `${x.slice(7)}.engine.js`
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
const distPath = resolve(
__dirname,
`../build/dist/llqqnt-plugin-chronocat-${x}/${distName}`,
)
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
const srcPath = join(distPath, 'src')
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
await mkdir(srcPath, {
recursive: true,
})
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
await writeFile(
join(srcPath, 'main.js'),
`setTimeout(()=>{process.version='__chronocat__';process.version.load(require('./${coreName}'))},0)`,
)
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
await cp(corePath, join(srcPath, coreName))
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
const { version, description } =
// eslint-disable-next-line @typescript-eslint/no-var-requires
require(`../packages/${x}/package.json`) as {
version: string
description: string
}
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
const manifest = {
manifest_version: 4,
type: 'extension',
2024-09-07 08:08:25 +00:00
name: `Chronocat Engine: ${upper.slice(7)}`,
2024-09-07 06:05:45 +00:00
slug: `chronocat-${x}`,
description,
version,
thumbnail: './chronocat.png',
authors: [
{
name: 'Team Chrononeko',
link: 'https://github.com/chrononeko',
},
],
repository: {
repo: `chrononeko/${distName}`,
branch: 'master',
},
platform: ['win32', 'linux', 'darwin'],
dependencies: [],
injects: {
main: './src/main.js',
2024-03-09 18:32:10 +00:00
},
2024-09-07 06:05:45 +00:00
}
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
await writeFile(join(distPath, 'manifest.json'), JSON.stringify(manifest))
2024-03-09 18:32:10 +00:00
2024-09-07 06:05:45 +00:00
await cp(
resolve(__dirname, '../packages/docs/static/chronocat.png'),
join(distPath, 'chronocat.png'),
)
},
),
2024-03-09 18:32:10 +00:00
)