2023-04-25 09:41:29 +08:00
|
|
|
import { copy } from 'fs-extra';
|
|
|
|
import { join } from 'path';
|
2023-04-25 00:17:36 +08:00
|
|
|
import { loadBench } from './bench';
|
|
|
|
import type { SaveBenchOptions } from './bench';
|
2023-04-25 09:41:29 +08:00
|
|
|
import { SANDBOX_DIRECTORY, CODE_DIRECTORY } from './utils/constants';
|
|
|
|
|
|
|
|
const templateKey = process.argv[2];
|
|
|
|
|
|
|
|
const sandboxDir = process.env.SANDBOX_ROOT || SANDBOX_DIRECTORY;
|
|
|
|
const templateSandboxDir = templateKey && join(sandboxDir, templateKey.replace('/', '-'));
|
2023-04-25 00:17:36 +08:00
|
|
|
|
|
|
|
const uploadBench = async () => {
|
|
|
|
const keys = ['build', 'dev', 'bench-build', 'bench-dev'] as SaveBenchOptions['key'][];
|
|
|
|
// const data = {} as Record<string, any>;
|
|
|
|
await Promise.all(
|
|
|
|
keys.map(async (key) => {
|
2023-04-25 09:41:29 +08:00
|
|
|
const val = await loadBench({ key, rootDir: templateSandboxDir });
|
2023-04-25 00:17:36 +08:00
|
|
|
console.log({ key, val });
|
|
|
|
})
|
|
|
|
);
|
2023-04-25 09:41:29 +08:00
|
|
|
|
|
|
|
await copy(`${templateSandboxDir}/bench-results`, `${CODE_DIRECTORY}/bench-results`);
|
2023-04-25 00:17:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
uploadBench().then(() => {
|
|
|
|
console.log('done');
|
|
|
|
});
|