Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/browser-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"./package.json": "./package.json"
},
"scripts": {
"build": "rm -rf dist && mkdir -p dist && esbuild src/entry.js --bundle --format=iife --minify --outfile=dist/openui-bundle.min.js '--define:process.env.NODE_ENV=\"production\"' --target=es2020 && node scripts/concat-css.mjs",
"build": "node scripts/prepare-dist.mjs && esbuild src/entry.js --bundle --format=iife --minify --outfile=dist/openui-bundle.min.js '--define:process.env.NODE_ENV=\"production\"' --target=es2020 && node scripts/concat-css.mjs",
"typecheck": "echo \"(no types to check — IIFE bundle)\"",
"lint:check": "eslint ./src",
"lint:fix": "eslint ./src --fix",
Expand Down
9 changes: 9 additions & 0 deletions packages/browser-bundle/scripts/prepare-dist.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { mkdir, rm } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

const dirname = path.dirname(fileURLToPath(import.meta.url));
const distDir = path.resolve(dirname, "..", "dist");

await rm(distDir, { force: true, recursive: true });
await mkdir(distDir, { recursive: true });
2 changes: 1 addition & 1 deletion packages/openui-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"build:cli": "tsc -p .",
"build:templates": "rm -rf dist/templates/openui-chat && mkdir -p dist/templates && cp -R src/templates/openui-chat dist/templates/openui-chat",
"build:templates": "node scripts/build-templates.mjs",
"build": "pnpm run build:cli && pnpm run build:templates",
"build:exec": "node dist/index.js",
"lint:check": "eslint ./src --ignore-pattern 'src/templates/**'",
Expand Down
13 changes: 13 additions & 0 deletions packages/openui-cli/scripts/build-templates.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { cp, mkdir, rm } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

const dirname = path.dirname(fileURLToPath(import.meta.url));
const packageDir = path.resolve(dirname, "..");
const sourceDir = path.join(packageDir, "src", "templates", "openui-chat");
const templatesDir = path.join(packageDir, "dist", "templates");
const targetDir = path.join(templatesDir, "openui-chat");

await rm(targetDir, { force: true, recursive: true });
await mkdir(templatesDir, { recursive: true });
await cp(sourceDir, targetDir, { recursive: true });
3 changes: 2 additions & 1 deletion packages/react-ui/cp-css.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from "fs";
import { camelCase } from "lodash-es";
import path from "path";
import { fileURLToPath } from "url";

const dirname = path.dirname(new URL(import.meta.url).pathname);
const dirname = path.dirname(fileURLToPath(import.meta.url));

// Create directories if they don't exist
function ensureDirectoryExists(dirPath) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"copy-css": "node cp-css.js",
"generate-scss-index": "node src/scripts/scss-import.js",
"generate:css-utils": "tsx src/scripts/generate-css-utils.ts",
"build": "rm -rf dist && pnpm generate:css-utils && pnpm build:scss && pnpm build:tsc && pnpm build:cjs && pnpm run copy-css",
"build": "node scripts/clean-dist.mjs && pnpm generate:css-utils && pnpm build:scss && pnpm build:tsc && pnpm build:cjs && pnpm run copy-css",
"typecheck": "tsc --noEmit",
"build:tsc": "tsc -p . || true",
"build:cjs": "tsdown",
Expand Down
8 changes: 8 additions & 0 deletions packages/react-ui/scripts/clean-dist.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { rm } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";

const dirname = path.dirname(fileURLToPath(import.meta.url));
const distDir = path.resolve(dirname, "..", "dist");

await rm(distDir, { force: true, recursive: true });