diff --git a/scripts/build-assets.mjs b/scripts/build-assets.mjs index d2dabe8532..8a8a50d9ba 100644 --- a/scripts/build-assets.mjs +++ b/scripts/build-assets.mjs @@ -12,6 +12,7 @@ import * as terser from 'terser'; import { build as buildLocales } from '../locales/index.js'; import generateDTS from '../locales/generateDTS.js'; import meta from '../package.json' assert { type: "json" }; +import buildTarball from './tarball.mjs'; let locales = buildLocales(); @@ -77,12 +78,13 @@ async function build() { copyBackendViews(), buildBackendScript(), buildBackendStyle(), + buildTarball(), ]); } await build(); -if (process.argv.includes("--watch")) { +if (process.argv.includes('--watch')) { const watcher = fs.watch('./locales'); for await (const event of watcher) { const filename = event.filename?.replaceAll('\\', '/'); diff --git a/scripts/tarball.mjs b/scripts/tarball.mjs index 2652a182f5..9de9c03e1d 100644 --- a/scripts/tarball.mjs +++ b/scripts/tarball.mjs @@ -6,8 +6,6 @@ import glob from 'fast-glob'; import Pack from 'tar/lib/pack.js'; import meta from '../package.json' assert { type: "json" }; -const cwd = fileURLToPath(new URL('..', import.meta.url)); -const mkdirPromise = mkdir(resolve(cwd, 'built', 'tarball'), { recursive: true }); const patterns = [ '{assets,fluent-emojis,locales,misskey-assets}/**/*', 'packages/.config/example.yml', @@ -29,14 +27,19 @@ const patterns = [ 'pnpm-lock.yaml', 'pnpm-workspace.yaml', ]; -const pack = new Pack({ cwd, gzip: true }); -for await (const entry of glob.stream(patterns)) { - pack.add(entry); +export default async function build() { + const cwd = fileURLToPath(new URL('..', import.meta.url)); + const mkdirPromise = mkdir(resolve(cwd, 'built', 'tarball'), { recursive: true }); + const pack = new Pack({ cwd, gzip: true }); + + for await (const entry of glob.stream(patterns)) { + pack.add(entry); + } + + pack.end(); + + await mkdirPromise; + + pack.pipe(createWriteStream(resolve(cwd, 'built', 'tarball', `misskey-${meta.version}.tar.gz`))); } - -pack.end(); - -await mkdirPromise; - -pack.pipe(createWriteStream(resolve(cwd, 'built', 'tarball', `misskey-${meta.version}.tar.gz`)));