chore(media): add build scripts

This commit is contained in:
Il Harper 2024-09-07 14:05:45 +08:00
parent 3f2c972001
commit c56844a5b4
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
4 changed files with 79 additions and 72 deletions

View File

@ -14,7 +14,7 @@
], ],
"scripts": { "scripts": {
"clean": "node -r esbuild-register scripts/clean.cts", "clean": "node -r esbuild-register scripts/clean.cts",
"build": "concurrently -n red \"yarn workspace @chronocat/red build\" && concurrently -n shell \"yarn workspace @chronocat/shell build\" && concurrently -n api,event \"yarn workspace @chronocat/engine-chronocat-api build\" \"yarn workspace @chronocat/engine-chronocat-event build\" && concurrently -n llqqnt,iife \"yarn workspace @chronocat/plugin-llqqnt build\" \"yarn workspace @chronocat/plugin-iife build\" && concurrently -n packengine,packllqqntengine yarn:packengine yarn:packllqqntengine", "build": "concurrently -n red \"yarn workspace @chronocat/red build\" && concurrently -n shell \"yarn workspace @chronocat/shell build\" && concurrently -n api,event,media \"yarn workspace @chronocat/engine-chronocat-api build\" \"yarn workspace @chronocat/engine-chronocat-event build\" \"yarn workspace @chronocat/engine-media build\" && concurrently -n llqqnt,iife \"yarn workspace @chronocat/plugin-llqqnt build\" \"yarn workspace @chronocat/plugin-iife build\" && concurrently -n packengine,packllqqntengine yarn:packengine yarn:packllqqntengine",
"packengine": "node -r esbuild-register scripts/packengine.cts", "packengine": "node -r esbuild-register scripts/packengine.cts",
"packllqqntengine": "node -r esbuild-register scripts/packllqqntengine.cts", "packllqqntengine": "node -r esbuild-register scripts/packllqqntengine.cts",
"lint": "eslint --ignore-path .gitignore --ignore-pattern '**/*.d.ts' .", "lint": "eslint --ignore-path .gitignore --ignore-pattern '**/*.d.ts' .",

View File

@ -17,6 +17,9 @@ void Promise.all(
'../packages/engine-chronocat-event/src/.runOnChanged.hashes.json', '../packages/engine-chronocat-event/src/.runOnChanged.hashes.json',
'../packages/engine-chronocat-event/lib', '../packages/engine-chronocat-event/lib',
'../packages/engine-chronocat-event/tsconfig.tsbuildinfo', '../packages/engine-chronocat-event/tsconfig.tsbuildinfo',
'../packages/engine-media/src/.runOnChanged.hashes.json',
'../packages/engine-media/lib',
'../packages/engine-media/tsconfig.tsbuildinfo',
'../packages/iife/lib', '../packages/iife/lib',
'../packages/llqqnt/lib', '../packages/llqqnt/lib',
'../packages/docs/static/config-v0.schema.json', '../packages/docs/static/config-v0.schema.json',

View File

@ -2,27 +2,29 @@ import { cp, mkdir } from 'node:fs/promises'
import { join, resolve } from 'node:path' import { join, resolve } from 'node:path'
void Promise.all( void Promise.all(
['engine-chronocat-api', 'engine-chronocat-event'].map(async (x) => { ['engine-chronocat-api', 'engine-chronocat-event', 'engine-media'].map(
const srcPath = resolve(__dirname, `../packages/${x}/lib/index.js`) async (x) => {
const srcPath = resolve(__dirname, `../packages/${x}/lib/index.js`)
const distDir = resolve(__dirname, `../build/dist/${x}`) const distDir = resolve(__dirname, `../build/dist/${x}`)
await mkdir(distDir, { await mkdir(distDir, {
recursive: true, recursive: true,
}) })
const filename = `${x.slice(7)}.engine.js` const filename = `${x.slice(7)}.engine.js`
const distPath = join(distDir, filename) const distPath = join(distDir, filename)
await cp(srcPath, distPath) await cp(srcPath, distPath)
// await cp( // await cp(
// distPath, // distPath,
// resolve( // resolve(
// __dirname, // __dirname,
// `../build/dist/llqqnt/LiteLoaderQQNT-Plugin-Chronocat/src/${filename}`, // `../build/dist/llqqnt/LiteLoaderQQNT-Plugin-Chronocat/src/${filename}`,
// ), // ),
// ) // )
}), },
),
) )

View File

@ -2,68 +2,70 @@ import { cp, mkdir, writeFile } from 'node:fs/promises'
import { join, resolve } from 'node:path' import { join, resolve } from 'node:path'
void Promise.all( void Promise.all(
['engine-chronocat-api', 'engine-chronocat-event'].map(async (x) => { ['engine-chronocat-api', 'engine-chronocat-event', 'engine-media'].map(
const upper = `${x[0]!.toUpperCase()}${x.slice(1, 7)}${x[7]!.toUpperCase()}${x.slice(8, 17)}${x[17]!.toUpperCase()}${x.slice(18)}` async (x) => {
const distName = `LiteLoaderQQNT-Plugin-Chronocat-${upper}` const upper = `${x[0]!.toUpperCase()}${x.slice(1, 7)}${x[7]!.toUpperCase()}${x.slice(8, 17)}${x[17]!.toUpperCase()}${x.slice(18)}`
const distName = `LiteLoaderQQNT-Plugin-Chronocat-${upper}`
const corePath = resolve(__dirname, `../packages/${x}/lib/index.js`) const corePath = resolve(__dirname, `../packages/${x}/lib/index.js`)
const coreName = `${x.slice(7)}.engine.js` const coreName = `${x.slice(7)}.engine.js`
const distPath = resolve( const distPath = resolve(
__dirname, __dirname,
`../build/dist/llqqnt-plugin-chronocat-${x}/${distName}`, `../build/dist/llqqnt-plugin-chronocat-${x}/${distName}`,
) )
const srcPath = join(distPath, 'src') const srcPath = join(distPath, 'src')
await mkdir(srcPath, { await mkdir(srcPath, {
recursive: true, recursive: true,
}) })
await writeFile( await writeFile(
join(srcPath, 'main.js'), join(srcPath, 'main.js'),
`setTimeout(()=>{process.version='__chronocat__';process.version.load(require('./${coreName}'))},0)`, `setTimeout(()=>{process.version='__chronocat__';process.version.load(require('./${coreName}'))},0)`,
) )
await cp(corePath, join(srcPath, coreName)) await cp(corePath, join(srcPath, coreName))
const { version, description } = const { version, description } =
// eslint-disable-next-line @typescript-eslint/no-var-requires // eslint-disable-next-line @typescript-eslint/no-var-requires
require(`../packages/${x}/package.json`) as { require(`../packages/${x}/package.json`) as {
version: string version: string
description: string description: string
}
const manifest = {
manifest_version: 4,
type: 'extension',
name: `Chronocat Engine: ${x[7]!.toUpperCase()}${x.slice(8, 17)}${x[17]!.toUpperCase()}${x.slice(18)}`,
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',
},
} }
const manifest = { await writeFile(join(distPath, 'manifest.json'), JSON.stringify(manifest))
manifest_version: 4,
type: 'extension',
name: `Chronocat Engine: ${x[7]!.toUpperCase()}${x.slice(8, 17)}${x[17]!.toUpperCase()}${x.slice(18)}`,
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',
},
}
await writeFile(join(distPath, 'manifest.json'), JSON.stringify(manifest)) await cp(
resolve(__dirname, '../packages/docs/static/chronocat.png'),
await cp( join(distPath, 'chronocat.png'),
resolve(__dirname, '../packages/docs/static/chronocat.png'), )
join(distPath, 'chronocat.png'), },
) ),
}),
) )