Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Add Windows start.bat launcher

Adarsh9fd8154cbaf2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 00000000..69b47b5a
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+*.bat text eol=crlf
diff --git a/README.md b/README.md
index ab41337d..1531d372 100644
--- a/README.md
+++ b/README.md
@@ -28,6 +28,8 @@ pnpm install
pnpm dev # http://localhost:3000
```
+On Windows, double-click `start.bat` instead: it installs pnpm and dependencies when they're missing, rebuilds when the source changed, starts the production server and opens the browser (`start.bat dev` runs the dev server; set `PORT` for another port; if it's taken, the next free one is used).
+
Open **Settings** and pick an **Engine mode**:
| Engine mode | What the install offers | Needs |
diff --git a/scripts/free-port.mjs b/scripts/free-port.mjs
new file mode 100644
index 00000000..0f17554b
--- /dev/null
+++ b/scripts/free-port.mjs
@@ -0,0 +1,13 @@
+// Used by start.bat: prints the first port from argv[2] (default 3000) that nothing is listening on.
+import net from "node:net";
+
+const free = (port) =>
+ new Promise((resolve) => {
+ const srv = net.createServer();
+ srv.once("error", () => resolve(false));
+ srv.listen(port, () => srv.close(() => resolve(true)));
+ });
+
+let port = Number(process.argv[2]) || 3000;
+while (!(await free(port))) port++;
+console.log(port);
diff --git a/scripts/needs-build.mjs b/scripts/needs-build.mjs
new file mode 100644
index 00000000..3c04fd55
--- /dev/null
+++ b/scripts/needs-build.mjs
@@ -0,0 +1,23 @@
+// Used by start.bat: exits 0 when the production build is missing or older than the source, 1 when it is current.
+import fs from "node:fs";
+import path from "node:path";
+
+let built;
+try {
+ built = fs.statSync(".next/BUILD_ID").mtimeMs;
+} catch {
+ process.exit(0);
+}
+
+const roots = ["src", "public", "skills", "package.json", "pnpm-lock.yaml", "next.config.ts", "tsconfig.json"];
+function newer(p) {
+ let st;
+ try {
+ st = fs.statSync(p);
+ } catch {
+ return false;
+ }
+ if (!st.isDirectory()) return st.mtimeMs > built;
+ return fs.readdirSync(p).some((f) => newer(path.join(p, f)));
+}
+process.exit(roots.some(newer) ? 0 : 1);
diff --git a/start.bat b/start.bat
new file mode 100644
index 00000000..5fa8f733
--- /dev/null
+++ b/start.bat
@@ -0,0 +1,56 @@
+@echo off
+rem Starts Fuobe. Double-click it, or run "start.bat dev" for the dev server (hot reload).
+rem Set PORT to use a port other than 3000.
+setlocal
+cd /d "%~dp0"
+title Fuobe
+if not defined PORT set PORT=3000
+
+where node >nul 2>nul
+if errorlevel 1 (
+ echo Node.js is not installed. Get it from https://nodejs.org and run this again.
+ pause
+ exit /b 1
+)
+
+where pnpm >nul 2>nul
+if errorlevel 1 (
+ echo Installing pnpm...
+ call npm install -g [email protected] || goto :fail
+)
+
+echo Checking dependencies...
+call pnpm install --frozen-lockfile --prefer-offline || goto :fail
+
+rem Another app may already be using the port; move to the next free one.
+set WANT=%PORT%
+for /f %%p in ('node scripts\free-port.mjs %PORT%') do set PORT=%%p
+if not "%PORT%"=="%WANT%" echo Port %WANT% is in use by another app, using %PORT% instead.
+
+if /i "%~1"=="dev" (
+ call :open
+ call pnpm dev -p %PORT%
+ goto :eof
+)
+
+node scripts\needs-build.mjs
+if not errorlevel 1 (
+ echo Building Fuobe, this takes a minute or two...
+ call pnpm build || goto :fail
+)
+
+call :open
+echo Fuobe is running at http://localhost:%PORT% - close this window or press Ctrl+C to stop.
+call pnpm start -p %PORT%
+goto :eof
+
+:open
+rem Opens the browser once the server answers.
+start "" /b powershell -NoProfile -WindowStyle Hidden -Command "for ($i = 0; $i -lt 180; $i++) { try { Invoke-WebRequest -UseBasicParsing -TimeoutSec 2 http://localhost:%PORT% | Out-Null; break } catch { if ($_.Exception.Response) { break }; Start-Sleep 1 } }; Start-Process http://localhost:%PORT%"
+exit /b 0
+
+:fail
+echo.
+echo Fuobe could not start. See the messages above.
+pause
+exit /b 1