Skip to content

Commit b266150

Browse files
committed
feat: enhance build process with folder support and improve directory handling
1 parent c546e38 commit b266150

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

_build_scripts/build-component.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ await init();
66
const encoder = new TextEncoder();
77
const decoder = new TextDecoder();
88

9-
export async function buildComponent(componentName: string, copyFolders: string[] = []) {
9+
export async function buildComponent(componentName: string, folder: string = "", copyFolders: string[] = []) {
1010
console.log(`Building ${componentName}`);
11-
await build_src(componentName);
12-
await copy_files(componentName);
11+
12+
if (folder.length > 0) {
13+
folder = `${folder}/`;
14+
}
15+
16+
await build_src(componentName, folder);
17+
await copy_files(componentName, folder);
1318

1419
if (copyFolders.length > 0) {
15-
for (const folder of copyFolders) {
16-
await copyFilesToFolder(`components/${componentName}/${folder}`, `dist/components/${componentName}/${folder}`);
20+
for (const subFolder of copyFolders) {
21+
await copyFilesToFolder(`components/${componentName}/${folder}${subFolder}`, `dist/components/${componentName}/${folder}`);
1722
}
1823
}
1924
}
2025

21-
async function build_src(componentName: string) {
26+
async function build_src(componentName: string, folder: string = "") {
2227
const result = await esbuild.build({
23-
entryPoints: [`components/${componentName}/${componentName}.js`],
24-
outfile: `dist/components/${componentName}/${componentName}.js`,
28+
entryPoints: [`components/${folder}${componentName}/${componentName}.js`],
29+
outfile: `dist/components/${folder}${componentName}/${componentName}.js`,
2530
bundle: true,
2631
minify: true,
2732
sourcemap: true,
@@ -39,9 +44,9 @@ async function build_src(componentName: string) {
3944

4045
// Copy all files and folders.
4146
// Ignore js files.
42-
async function copy_files(componentName: string) {
43-
const srcFolder = `components/${componentName}`;
44-
const distFolder = `dist/components/${componentName}`;
47+
async function copy_files(componentName: string, folder: string = "") {
48+
const srcFolder = `components/${folder}${componentName}`;
49+
const distFolder = `dist/components/${folder}${componentName}`;
4550

4651
for await (const entry of Deno.readDir(srcFolder)) {
4752
if (entry.isFile && entry.name.endsWith(".js")) {

_build_scripts/build.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,40 @@ import { buildSrcFile } from "./build-src.ts";
22
import { buildComponent } from "./build-component.ts";
33

44
async function cleaerDistFolder() {
5-
await Deno.remove("dist", { recursive: true });
5+
const hasDistFolder = await Deno.stat("dist").catch(() => null);
6+
7+
if (hasDistFolder) {
8+
await Deno.remove("dist", { recursive: true });
9+
}
10+
611
await Deno.mkdir("dist");
712
await Deno.mkdir("dist/src");
813
}
914

1015
await cleaerDistFolder();
1116

1217
// Components
13-
// await buildComponent("activity-state");
14-
// await buildComponent("app-header");
15-
// await buildComponent("dynamic-rows");
16-
// await buildComponent("dynamic-columns");
17-
await buildComponent("material-icon", ["icons"]);
18-
// await buildComponent("menu");
18+
await buildComponent("activity-state");
19+
await buildComponent("app-header");
20+
await buildComponent("dynamic-rows");
21+
await buildComponent("dynamic-columns");
22+
await buildComponent("material-icon", "", ["icons"]);
23+
await buildComponent("divider-item", "menu");
24+
await buildComponent("menu-container", "menu");
25+
await buildComponent("menu-group", "menu");
26+
await buildComponent("menu-item", "menu");
27+
await buildComponent("menu-label", "menu");
28+
await buildComponent("toast-notification");
29+
await buildComponent("tool-bar");
30+
await buildComponent("tree-view");
1931
// await buildComponent("ollama-ui");
20-
// await buildComponent("toast-notification");
21-
// await buildComponent("toolbar");
22-
// await buildComponent("tree-view");
2332

2433
// System Files
25-
// await buildSrcFile("system/assert.js");
26-
// await buildSrcFile("system/events-manager.js");
27-
// await buildSrcFile("system/logger.js");
34+
await buildSrcFile("system/assert.js");
35+
await buildSrcFile("system/events-manager.js");
36+
await buildSrcFile("system/logger.js");
2837

2938
// Validation Files
30-
// await buildSrcFile("validate/conditions.js");
39+
await buildSrcFile("validate/conditions.js");
3140

32-
41+
Deno.kill(Deno.pid); // Exit the process

0 commit comments

Comments
 (0)