2023-07-27 08:31:52 +03:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-07-08 07:03:31 +03:00
|
|
|
import fs from 'node:fs';
|
|
|
|
import { dirname } from 'node:path';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
import { execa } from 'execa';
|
|
|
|
|
|
|
|
const _filename = fileURLToPath(import.meta.url);
|
|
|
|
const _dirname = dirname(_filename);
|
|
|
|
|
2023-11-03 06:34:57 +02:00
|
|
|
const vitePort = process.env.VITE_PORT ? ["--strictPort", "--port", process.env.VITE_PORT] : ["--strictPort"];
|
|
|
|
|
2023-07-08 07:03:31 +03:00
|
|
|
await execa('pnpm', ['clean'], {
|
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
|
|
|
await execa('pnpm', ['build-pre'], {
|
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
2023-09-07 10:56:17 +03:00
|
|
|
await execa('pnpm', ['build-assets'], {
|
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
|
|
|
execa('pnpm', ['build-assets', '--watch'], {
|
2023-07-08 07:03:31 +03:00
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
|
|
|
execa('pnpm', ['--filter', 'backend', 'watch'], {
|
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
2023-11-03 06:34:57 +02:00
|
|
|
execa('pnpm', ['--filter', 'frontend', 'watch', ...vitePort], {
|
2023-07-08 07:03:31 +03:00
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
|
|
|
execa('pnpm', ['--filter', 'sw', 'watch'], {
|
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
|
|
|
const start = async () => {
|
|
|
|
try {
|
2023-09-15 08:28:29 +03:00
|
|
|
const stat = fs.statSync(_dirname + '/../packages/backend/built/boot/entry.js');
|
2023-07-08 07:03:31 +03:00
|
|
|
if (!stat) throw new Error('not exist yet');
|
|
|
|
if (stat.size === 0) throw new Error('not built yet');
|
|
|
|
|
|
|
|
const subprocess = await execa('pnpm', ['start'], {
|
|
|
|
cwd: _dirname + '/../',
|
|
|
|
stdout: process.stdout,
|
|
|
|
stderr: process.stderr,
|
|
|
|
});
|
|
|
|
|
|
|
|
// なぜかworkerだけが終了してmasterが残るのでその対策
|
|
|
|
process.on('SIGINT', () => {
|
|
|
|
subprocess.kill('SIGINT');
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
start();
|