From c56844a5b467d7c82817a72996032e6e62d160d7 Mon Sep 17 00:00:00 2001 From: Il Harper Date: Sat, 7 Sep 2024 14:05:45 +0800 Subject: [PATCH] chore(media): add build scripts --- package.json | 2 +- scripts/clean.cts | 3 + scripts/packengine.cts | 36 ++++++------ scripts/packllqqntengine.cts | 110 ++++++++++++++++++----------------- 4 files changed, 79 insertions(+), 72 deletions(-) diff --git a/package.json b/package.json index 546f0b7..36d0b43 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ ], "scripts": { "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", "packllqqntengine": "node -r esbuild-register scripts/packllqqntengine.cts", "lint": "eslint --ignore-path .gitignore --ignore-pattern '**/*.d.ts' .", diff --git a/scripts/clean.cts b/scripts/clean.cts index 0afdcef..07e90ad 100644 --- a/scripts/clean.cts +++ b/scripts/clean.cts @@ -17,6 +17,9 @@ void Promise.all( '../packages/engine-chronocat-event/src/.runOnChanged.hashes.json', '../packages/engine-chronocat-event/lib', '../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/llqqnt/lib', '../packages/docs/static/config-v0.schema.json', diff --git a/scripts/packengine.cts b/scripts/packengine.cts index 0beab2e..7c277d2 100644 --- a/scripts/packengine.cts +++ b/scripts/packengine.cts @@ -2,27 +2,29 @@ import { cp, mkdir } from 'node:fs/promises' import { join, resolve } from 'node:path' void Promise.all( - ['engine-chronocat-api', 'engine-chronocat-event'].map(async (x) => { - const srcPath = resolve(__dirname, `../packages/${x}/lib/index.js`) + ['engine-chronocat-api', 'engine-chronocat-event', 'engine-media'].map( + 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, { - recursive: true, - }) + await mkdir(distDir, { + 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( - // distPath, - // resolve( - // __dirname, - // `../build/dist/llqqnt/LiteLoaderQQNT-Plugin-Chronocat/src/${filename}`, - // ), - // ) - }), + // await cp( + // distPath, + // resolve( + // __dirname, + // `../build/dist/llqqnt/LiteLoaderQQNT-Plugin-Chronocat/src/${filename}`, + // ), + // ) + }, + ), ) diff --git a/scripts/packllqqntengine.cts b/scripts/packllqqntengine.cts index b843ba5..1c01612 100644 --- a/scripts/packllqqntengine.cts +++ b/scripts/packllqqntengine.cts @@ -2,68 +2,70 @@ import { cp, mkdir, writeFile } from 'node:fs/promises' import { join, resolve } from 'node:path' void Promise.all( - ['engine-chronocat-api', 'engine-chronocat-event'].map(async (x) => { - 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}` + ['engine-chronocat-api', 'engine-chronocat-event', 'engine-media'].map( + async (x) => { + 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 coreName = `${x.slice(7)}.engine.js` + const corePath = resolve(__dirname, `../packages/${x}/lib/index.js`) + const coreName = `${x.slice(7)}.engine.js` - const distPath = resolve( - __dirname, - `../build/dist/llqqnt-plugin-chronocat-${x}/${distName}`, - ) + const distPath = resolve( + __dirname, + `../build/dist/llqqnt-plugin-chronocat-${x}/${distName}`, + ) - const srcPath = join(distPath, 'src') + const srcPath = join(distPath, 'src') - await mkdir(srcPath, { - recursive: true, - }) + await mkdir(srcPath, { + recursive: true, + }) - await writeFile( - join(srcPath, 'main.js'), - `setTimeout(()=>{process.version='__chronocat__';process.version.load(require('./${coreName}'))},0)`, - ) + await writeFile( + join(srcPath, 'main.js'), + `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 } = - // eslint-disable-next-line @typescript-eslint/no-var-requires - require(`../packages/${x}/package.json`) as { - version: string - description: string + const { version, description } = + // eslint-disable-next-line @typescript-eslint/no-var-requires + require(`../packages/${x}/package.json`) as { + version: 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 = { - 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 writeFile(join(distPath, 'manifest.json'), JSON.stringify(manifest)) - - await cp( - resolve(__dirname, '../packages/docs/static/chronocat.png'), - join(distPath, 'chronocat.png'), - ) - }), + await cp( + resolve(__dirname, '../packages/docs/static/chronocat.png'), + join(distPath, 'chronocat.png'), + ) + }, + ), )