2024-01-10 11:35:21 +03:00
|
|
|
import { writeFile } from 'node:fs/promises';
|
|
|
|
import { join } from 'node:path';
|
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
2024-02-19 17:03:26 +03:00
|
|
|
import { CanvasTextFonts } from '@blocksuite/blocks/dist/surface-block/consts.js';
|
2024-01-10 11:35:21 +03:00
|
|
|
|
|
|
|
const fontPath = join(
|
|
|
|
fileURLToPath(import.meta.url),
|
|
|
|
'..',
|
|
|
|
'..',
|
|
|
|
'packages',
|
|
|
|
'frontend',
|
2024-03-19 10:48:56 +03:00
|
|
|
'web',
|
2024-01-10 11:35:21 +03:00
|
|
|
'dist',
|
|
|
|
'assets'
|
|
|
|
);
|
|
|
|
|
|
|
|
await Promise.all(
|
2024-02-19 17:03:26 +03:00
|
|
|
CanvasTextFonts.map(async ({ url }) => {
|
2024-01-10 11:35:21 +03:00
|
|
|
const buffer = await fetch(url).then(res =>
|
|
|
|
res.arrayBuffer().then(res => Buffer.from(res))
|
|
|
|
);
|
|
|
|
const filename = url.split('/').pop();
|
|
|
|
const distPath = join(fontPath, filename);
|
|
|
|
await writeFile(distPath, buffer);
|
|
|
|
console.info(`Downloaded ${distPath} successfully`);
|
|
|
|
})
|
|
|
|
);
|