import { cp, mkdir, readFile, writeFile } from 'node:fs/promises'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; const rootDir = resolve(dirname(fileURLToPath(import.meta.url)), '..'); async function copyAsset(source, destination, banner) { await mkdir(dirname(destination), { recursive: true }); if (!banner) { await cp(source, destination); return; } const content = await readFile(source, 'utf8'); await writeFile(destination, `${banner}\n${content}`); } async function main() { await copyAsset( resolve(rootDir, 'node_modules/tabulator-tables/dist/js/tabulator.min.js'), resolve(rootDir, 'internal/web/assets/tabulator/tabulator.min.js'), '/* Generated from npm package tabulator-tables. Run npm run vendor:sync to refresh. */', ); await copyAsset( resolve(rootDir, 'node_modules/tabulator-tables/dist/css/tabulator_midnight.min.css'), resolve(rootDir, 'internal/web/assets/tabulator/tabulator_midnight.min.css'), '/* Generated from npm package tabulator-tables. Run npm run vendor:sync to refresh. */', ); await copyAsset( resolve(rootDir, 'node_modules/tabulator-tables/LICENSE'), resolve(rootDir, 'internal/web/assets/tabulator/LICENSE-tabulator'), 'Generated from npm package tabulator-tables.', ); await copyAsset( resolve(rootDir, 'node_modules/chart.js/dist/chart.umd.min.js'), resolve(rootDir, 'internal/web/assets/chartjs/chart.umd.min.js'), '/* Generated from npm package chart.js. Run npm run vendor:sync to refresh. */', ); await copyAsset( resolve(rootDir, 'node_modules/chart.js/LICENSE.md'), resolve(rootDir, 'internal/web/assets/chartjs/LICENSE-chartjs'), 'Generated from npm package chart.js.', ); } main().catch(error => { console.error(error); process.exitCode = 1; });