Mercurial
changeset 15:2b9e75756825
[GuiZe] Updated to handle bundling and created a shee
l script for pushing.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Fri, 03 Oct 2025 06:50:33 -0700 |
| parents | 0570ada19343 |
| children | fb2cff495a60 |
| files | .hgignore bundle_push_to_git.sh gui_ze/gui_ze.bzl mrjunejune/BUILD mrjunejune/pages/react/index.html playground/BUILD playground/june.tsx playground/main.ts |
| diffstat | 8 files changed, 83 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Thu Oct 02 14:41:06 2025 -0700 +++ b/.hgignore Fri Oct 03 06:50:33 2025 -0700 @@ -2,19 +2,10 @@ # 1) Bazel’s output base directories (e.g. bazel-<workspace-hash>/) bazel-*/ - -# 2) Runfiles trees (created beside binaries) *.runfiles/ - -# 3) Runfile manifest files *.runfiles_manifest - -# 4) Test log directories bazel-*/testlogs/ - -# 5) External-dependency symlinks bazel-*/external/ - -# 6) Local Bazel cache (if you ever put it under the repo) .bazelcache/ +projects/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bundle_push_to_git.sh Fri Oct 03 06:50:33 2025 -0700 @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Usage: ./deploy.sh <project_name> <bundle_path> +if [ $# -ne 2 ]; then + echo "Usage: $0 <project_name> <bundle_path>" + exit 1 +fi + +PROJECT_NAME="$1" +BUNDLE_PATH="$2" + +SRC=$BUNDLE_PATH +DEST="projects/$PROJECT_NAME" + +echo $BUNDLE_PATH $DEST + +mkdir -p "$DEST" +# Force write copy as I write this. +rsync -a --delete \ + --exclude='.git/' \ + --exclude='.gitignore' \ + --chmod=Du+rwx,Fu+rw \ + "$SRC"/ "$DEST"/ + +pushd "$DEST" > /dev/null +if [ ! -d .git ]; then + git init + [ -f .gitignore ] || touch .gitignore + git add . + git commit -m "Initial import of mrjunejune_server_bundle" +else + git add -A + git commit -m "Update bundle @ $(date -u +"%Y-%m-%dT%H:%M:%SZ")" +fi + +popd > /dev/null + +echo "✅ Deployed to $DEST (git repo initialized: $( [ -d "$DEST/.git" ] && echo yes || echo no ))"
--- a/gui_ze/gui_ze.bzl Thu Oct 02 14:41:06 2025 -0700 +++ b/gui_ze/gui_ze.bzl Fri Oct 03 06:50:33 2025 -0700 @@ -28,8 +28,16 @@ for f in runfiles_files: if f.path == binary.path: continue + + start = 0 + for directory in f.path.split("/"): + if directory == binary.short_path.split("/")[0]: + break + print("\n\n equals: ", directory, binary.short_path.split("/")[0]); + start += 1 + # Remove the first folder (output) and last file (actaul files that needed to be copied) - paths = "/".join(f.path.split("/")[:-1]) + paths = "/".join(f.path.split("/")[start:-1]) full_path = "{}/{}".format(out_dir.path, paths) copy_cmd.append("mkdir -p {}".format(full_path)) copy_cmd.append("cp {} {}".format(f.path, full_path)) @@ -89,6 +97,15 @@ ) def _bun_build_impl(ctx): + """ + Run bun build on the folder + + This sucks because you need to either copy node module into the root folder where main.ts file + exists or copy everything outwards. I chose to do it in this way. + + TODO: If possible, maybe create a node_module inside of the main target path and create a symlink, + but I couldn't get it to work lol. + """ out = ctx.actions.declare_file(ctx.label.name + ".js") inputs = [ctx.file.src] + ctx.files.data
--- a/mrjunejune/BUILD Thu Oct 02 14:41:06 2025 -0700 +++ b/mrjunejune/BUILD Fri Oct 03 06:50:33 2025 -0700 @@ -1,11 +1,11 @@ load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") -load("//gui_ze:gui_ze.bzl", "move_files_into_dir_precompile") +load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle") move_files_into_dir( name = "compiled_ts", - src = [ - "//playground:playground_tsx", + srcs = [ + "//playground:hello", ], dest = "pages", ) @@ -21,3 +21,8 @@ deps = ["//seobeo:seobeo"], data = [":pages_files"], ) + +bundle( + name = "mrjunejune_server_bundle", + binary = ":mrjunejune_server", +)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mrjunejune/pages/react/index.html Fri Oct 03 06:50:33 2025 -0700 @@ -0,0 +1,9 @@ +<html lang="en"> + <head> + <BaseHead title="Resume" description="June's resume" /> + </head> + <body> + <div id="root"></div> + </body> + <script src="/hello.js"></script> +</html>
--- a/playground/BUILD Thu Oct 02 14:41:06 2025 -0700 +++ b/playground/BUILD Fri Oct 03 06:50:33 2025 -0700 @@ -1,5 +1,5 @@ load("@rules_cc//cc:cc_binary.bzl", "cc_binary") -load("//gui_ze:gui_ze.bzl", "bun_build", "move_to_directory") +load("//gui_ze:gui_ze.bzl", "bun_build") alias( name = "playground", @@ -13,13 +13,6 @@ srcs = ["main.c"], ) -# TODO: Testing out if I can create a symlink for this. -move_to_directory( - name = "node_modules", - data = ["//third_party/bun:node_modules"], - dest = "", -) - filegroup( name = "all_ts_files", srcs = glob([ @@ -31,7 +24,7 @@ ) bun_build( - name = "playground_tsx", + name = "hello", src = "main.ts", data = ["//third_party/bun:node_modules", ":all_ts_files"], visibility = ["//visibility:public"],
--- a/playground/june.tsx Thu Oct 02 14:41:06 2025 -0700 +++ b/playground/june.tsx Fri Oct 03 06:50:33 2025 -0700 @@ -1,11 +1,11 @@ import react from "React" -const foo = () => { +const Foo = () => { return ( - <> June </> + <> Test </> ); } export { - foo, + Foo, }
--- a/playground/main.ts Thu Oct 02 14:41:06 2025 -0700 +++ b/playground/main.ts Fri Oct 03 06:50:33 2025 -0700 @@ -1,10 +1,5 @@ -import { JUNE } from "./hello"; -import { foo } from "./june"; -import { foo as xd } from "./foo/foo.ts"; - +import { Foo } from "./june"; +import ReactDOM from 'react-dom/client'; -const main = (name: string) => console.log(name); +ReactDOM.createRoot(document.getElementById('root')!).render(Foo()); -main(JUNE); -foo(); -xd();