diff --git a/web/package.json b/web/package.json index e1df1e132056..5ebb8980019d 100644 --- a/web/package.json +++ b/web/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "sync-assets": "rm -rf public/fonts public/ds-assets && cp -r node_modules/@nous-research/ui/dist/fonts public/fonts && cp -r node_modules/@nous-research/ui/dist/assets public/ds-assets", + "sync-assets": "node scripts/sync-assets.js", "predev": "npm run sync-assets", "prebuild": "npm run sync-assets", "dev": "vite", diff --git a/web/scripts/sync-assets.js b/web/scripts/sync-assets.js new file mode 100644 index 000000000000..e63b268d9085 --- /dev/null +++ b/web/scripts/sync-assets.js @@ -0,0 +1,34 @@ +#!/usr/bin/env node +// Cross-platform sync-assets: replaces `rm -rf public/fonts public/ds-assets && cp -r ...` +// Works on Windows (CMD/PowerShell), macOS, and Linux without Unix utilities. +import fs from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const webRoot = path.resolve(__dirname, ".."); + +const targets = ["fonts", "ds-assets"]; +const destDir = path.join(webRoot, "public"); + +for (const target of targets) { + const dest = path.join(destDir, target); + // Remove existing directory (recursive, works cross-platform) + if (fs.existsSync(dest)) { + fs.rmSync(dest, { recursive: true, force: true }); + } +} + +// Copy from node_modules +const srcPkg = "@nous-research/ui"; +const srcFonts = path.join(webRoot, "node_modules", srcPkg, "dist", "fonts"); +const srcAssets = path.join(webRoot, "node_modules", srcPkg, "dist", "assets"); +const destFonts = path.join(destDir, "fonts"); +const destAssets = path.join(destDir, "ds-assets"); + +if (fs.existsSync(srcFonts)) { + fs.cpSync(srcFonts, destFonts, { recursive: true }); +} +if (fs.existsSync(srcAssets)) { + fs.cpSync(srcAssets, destAssets, { recursive: true }); +}