mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-30 19:31:11 +00:00
feat(media): add prepare script
This commit is contained in:
parent
ddc7473197
commit
3f2c972001
@ -14,12 +14,15 @@
|
|||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node -r esbuild-register ../../scripts/runOnChanged.cts ./src concurrently -n cjs,dts yarn:build:cjs yarn:build:dts",
|
"prepare": "node -r esbuild-register scripts/prepare.cts",
|
||||||
|
"build": "yarn prepare && node -r esbuild-register ../../scripts/runOnChanged.cts ./src concurrently -n cjs,dts yarn:build:cjs yarn:build:dts",
|
||||||
"build:cjs": "node -r esbuild-register ../../scripts/build.cts",
|
"build:cjs": "node -r esbuild-register ../../scripts/build.cts",
|
||||||
"build:dts": "tsc -p tsconfig.json"
|
"build:dts": "tsc -p tsconfig.json"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@chronocat/shell": "workspace:packages/shell",
|
"@chronocat/shell": "workspace:packages/shell",
|
||||||
|
"@types/adm-zip": "^0.5.0",
|
||||||
|
"adm-zip": "^0.5.10",
|
||||||
"concurrently": "^8.2.1",
|
"concurrently": "^8.2.1",
|
||||||
"esbuild-register": "^3.5.0",
|
"esbuild-register": "^3.5.0",
|
||||||
"ts-toolbelt": "^9.6.0",
|
"ts-toolbelt": "^9.6.0",
|
||||||
|
40
packages/engine-media/scripts/prepare.cts
Normal file
40
packages/engine-media/scripts/prepare.cts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import AdmZip from 'adm-zip'
|
||||||
|
import { access, mkdir } from 'node:fs/promises'
|
||||||
|
import { join, resolve } from 'node:path'
|
||||||
|
|
||||||
|
const filenames = ['ntsilk-win32-x64.exe', 'ntsilk-linux-x64']
|
||||||
|
const dstDir = resolve(__dirname, '../../../build/caches')
|
||||||
|
const dstPath = join(dstDir, 'ntsilk.zip')
|
||||||
|
|
||||||
|
export async function exists(path: string): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await access(path)
|
||||||
|
} catch (_) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
await mkdir(dstDir, {
|
||||||
|
recursive: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (await exists(dstPath)) return
|
||||||
|
|
||||||
|
const zip = new AdmZip()
|
||||||
|
|
||||||
|
await Promise.all(
|
||||||
|
filenames.map((name) =>
|
||||||
|
fetch(
|
||||||
|
`https://raw.githubusercontent.com/ntsilk-userland/binaries/master/${name}`,
|
||||||
|
)
|
||||||
|
.then((response) => response.arrayBuffer())
|
||||||
|
.then((data) => {
|
||||||
|
zip.addFile(name, Buffer.from(data))
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
await zip.writeZipPromise(dstPath)
|
||||||
|
})()
|
Loading…
Reference in New Issue
Block a user