knowns 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.3] - 2024-12-26
9
+
10
+ ### Fixed
11
+ - **Browser Command**: Fixed UI path detection when running from installed package
12
+ - Server now correctly finds pre-built UI files in `dist/ui`
13
+ - Works in both development mode (build on-the-fly) and production (serve pre-built)
14
+ - Fixed package root detection for bundled code
15
+ - **GitHub Actions**: Fixed release creation permissions error
16
+ - Updated permissions from `contents: read` to `contents: write`
17
+ - Switched from deprecated `actions/create-release@v1` to `softprops/action-gh-release@v1`
18
+ - Enhanced release notes with installation instructions
19
+
20
+ ### Added
21
+ - **Build Process**: UI files now built and included in npm package
22
+ - `dist/ui/index.html` - Main HTML file
23
+ - `dist/ui/main.js` - Minified React application (533KB)
24
+ - `dist/ui/main.css` - Compiled styles
25
+ - `dist/ui/index.css` - Additional styles
26
+ - Separate build scripts for CLI and UI (`build:cli`, `build:ui`, `build:copy-html`)
27
+ - Production vs development mode for browser server
28
+
29
+ ### Changed
30
+ - Browser command now serves pre-built UI instead of building on user's machine
31
+ - Improved error messages when UI files are not found
32
+ - Server logs now indicate whether using pre-built UI or development mode
33
+
8
34
  ## [0.1.2] - 2024-12-26
9
35
 
10
36
  ### Added
@@ -69,6 +95,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
69
95
  - CLAUDE.md with complete guidelines for AI agents
70
96
  - Example workflows and patterns
71
97
 
98
+ [0.1.3]: https://github.com/knowns-dev/knowns/compare/v0.1.2...v0.1.3
72
99
  [0.1.2]: https://github.com/knowns-dev/knowns/compare/v0.1.1...v0.1.2
73
100
  [0.1.1]: https://github.com/knowns-dev/knowns/compare/v0.1.0...v0.1.1
74
101
  [0.1.0]: https://github.com/knowns-dev/knowns/releases/tag/v0.1.0
package/dist/index.js CHANGED
@@ -8903,14 +8903,35 @@ async function startServer(options2) {
8903
8903
  client.send(msg);
8904
8904
  }
8905
8905
  };
8906
- const uiPath = join9(projectRoot, "src", "ui");
8907
- const entrypoint = join9(uiPath, "index.html");
8908
- const buildDir = join9(projectRoot, ".knowns", "ui-build");
8909
- const entryFile = Bun.file(entrypoint);
8910
- if (!await entryFile.exists()) {
8911
- throw new Error(`UI entry point not found: ${entrypoint}`);
8906
+ const currentDir = import.meta.dir;
8907
+ let packageRoot = currentDir;
8908
+ if (currentDir.endsWith("/dist")) {
8909
+ packageRoot = join9(currentDir, "..");
8910
+ } else if (currentDir.includes("/src/server")) {
8911
+ packageRoot = join9(currentDir, "..", "..");
8912
+ }
8913
+ const uiSourcePath = join9(packageRoot, "src", "ui");
8914
+ const uiDistPath = join9(packageRoot, "dist", "ui");
8915
+ let uiPath;
8916
+ let shouldBuild = false;
8917
+ if (existsSync6(join9(uiDistPath, "main.js"))) {
8918
+ uiPath = uiDistPath;
8919
+ shouldBuild = false;
8920
+ } else if (existsSync6(join9(uiSourcePath, "index.html"))) {
8921
+ uiPath = uiSourcePath;
8922
+ shouldBuild = true;
8923
+ } else {
8924
+ throw new Error(`UI files not found. Tried:
8925
+ - ${uiDistPath} (${existsSync6(uiDistPath) ? "exists but no main.js" : "not found"})
8926
+ - ${uiSourcePath} (${existsSync6(uiSourcePath) ? "exists but no index.html" : "not found"})
8927
+ Package root: ${packageRoot}
8928
+ Current dir: ${currentDir}`);
8912
8929
  }
8930
+ const buildDir = join9(projectRoot, ".knowns", "ui-build");
8913
8931
  const buildUI = async () => {
8932
+ if (!shouldBuild) {
8933
+ return true;
8934
+ }
8914
8935
  console.log("Building UI...");
8915
8936
  const startTime = Date.now();
8916
8937
  const buildResult = await Bun.build({
@@ -8940,31 +8961,36 @@ async function startServer(options2) {
8940
8961
  console.log(`UI built in ${Date.now() - startTime}ms`);
8941
8962
  return true;
8942
8963
  };
8943
- if (!await buildUI()) {
8944
- throw new Error("Failed to build UI");
8945
- }
8946
- let rebuildTimeout = null;
8947
- const watcher = watch(uiPath, { recursive: true }, async (_event, filename) => {
8948
- if (!filename)
8949
- return;
8950
- if (!filename.endsWith(".tsx") && !filename.endsWith(".ts") && !filename.endsWith(".css")) {
8951
- return;
8952
- }
8953
- if (rebuildTimeout) {
8954
- clearTimeout(rebuildTimeout);
8964
+ if (shouldBuild) {
8965
+ if (!await buildUI()) {
8966
+ throw new Error("Failed to build UI");
8955
8967
  }
8956
- rebuildTimeout = setTimeout(async () => {
8957
- console.log(`File changed: ${filename}`);
8958
- const success = await buildUI();
8959
- if (success) {
8960
- broadcast({ type: "reload" });
8968
+ }
8969
+ let watcher = null;
8970
+ if (shouldBuild) {
8971
+ let rebuildTimeout = null;
8972
+ watcher = watch(uiPath, { recursive: true }, async (_event, filename) => {
8973
+ if (!filename)
8974
+ return;
8975
+ if (!filename.endsWith(".tsx") && !filename.endsWith(".ts") && !filename.endsWith(".css")) {
8976
+ return;
8961
8977
  }
8962
- }, 100);
8963
- });
8964
- process.on("SIGINT", () => {
8965
- watcher.close();
8966
- process.exit(0);
8967
- });
8978
+ if (rebuildTimeout) {
8979
+ clearTimeout(rebuildTimeout);
8980
+ }
8981
+ rebuildTimeout = setTimeout(async () => {
8982
+ console.log(`File changed: ${filename}`);
8983
+ const success = await buildUI();
8984
+ if (success) {
8985
+ broadcast({ type: "reload" });
8986
+ }
8987
+ }, 100);
8988
+ });
8989
+ process.on("SIGINT", () => {
8990
+ watcher?.close();
8991
+ process.exit(0);
8992
+ });
8993
+ }
8968
8994
  const server = Bun.serve({
8969
8995
  port,
8970
8996
  async fetch(req, server2) {
@@ -8982,7 +9008,10 @@ async function startServer(options2) {
8982
9008
  return handleAPI(req, url, store, broadcast);
8983
9009
  }
8984
9010
  if (url.pathname === "/main.js" || url.pathname.startsWith("/main.js?")) {
8985
- const file = Bun.file(join9(buildDir, "main.js"));
9011
+ let file = Bun.file(join9(buildDir, "main.js"));
9012
+ if (!await file.exists()) {
9013
+ file = Bun.file(join9(uiPath, "main.js"));
9014
+ }
8986
9015
  if (await file.exists()) {
8987
9016
  return new Response(file, {
8988
9017
  headers: {
@@ -8993,7 +9022,10 @@ async function startServer(options2) {
8993
9022
  }
8994
9023
  }
8995
9024
  if (url.pathname === "/index.css" || url.pathname.startsWith("/index.css?")) {
8996
- const file = Bun.file(join9(buildDir, "index.css"));
9025
+ let file = Bun.file(join9(buildDir, "index.css"));
9026
+ if (!await file.exists()) {
9027
+ file = Bun.file(join9(uiPath, "main.css"));
9028
+ }
8997
9029
  if (await file.exists()) {
8998
9030
  return new Response(file, {
8999
9031
  headers: {
@@ -9081,7 +9113,11 @@ async function startServer(options2) {
9081
9113
  });
9082
9114
  console.log(`Server running at http://localhost:${port}`);
9083
9115
  console.log(`Open in browser: http://localhost:${port}`);
9084
- console.log(`Live reload enabled - watching ${uiPath}`);
9116
+ if (shouldBuild) {
9117
+ console.log(`Live reload enabled - watching ${uiPath}`);
9118
+ } else {
9119
+ console.log(`Serving pre-built UI from ${uiPath}`);
9120
+ }
9085
9121
  if (open) {
9086
9122
  const openCommand = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
9087
9123
  try {
@@ -0,0 +1 @@
1
+ @tailwind base;@tailwind components;@tailwind utilities;:root{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,Arial,sans-serif;font-weight:400;line-height:1.5}body{min-height:100vh;margin:0}*{box-sizing:border-box}
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Knowns.dev</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="./main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1 @@
1
+ @tailwind base;@tailwind components;@tailwind utilities;:root{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,Arial,sans-serif;font-weight:400;line-height:1.5}body{min-height:100vh;margin:0}*{box-sizing:border-box}