Skip to content

Commit

Permalink
build: pack on build-assets
Browse files Browse the repository at this point in the history
  • Loading branch information
acid-chicken committed Feb 11, 2024
1 parent c27eba4 commit 30224a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 3 additions & 1 deletion scripts/build-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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('\\', '/');
Expand Down
21 changes: 12 additions & 9 deletions scripts/tarball.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
pack.end();

await mkdirPromise;
await mkdirPromise;

pack.pipe(createWriteStream(resolve(cwd, 'built', 'tarball', `misskey-${meta.version}.tar.gz`)));
pack.pipe(createWriteStream(resolve(cwd, 'built', 'tarball', `misskey-${meta.version}.tar.gz`)));
}

0 comments on commit 30224a8

Please sign in to comment.