Skip to content

Commit 731d278

Browse files
committed
feat(cicd)
1 parent 3768ea2 commit 731d278

File tree

6 files changed

+274
-54
lines changed

6 files changed

+274
-54
lines changed

.github/copilot-instructions.md

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,67 @@
11
# GitHub Copilot Instructions for moebius-web
22

3+
>[!NOTE]
4+
>this project, `moebius-web` is being rebranded as `teXt0wnz` or `text.0w.nz`
5+
36
## Project Overview
47

5-
Moebius-web is a web-based ANSI art editor that operates in two modes: server-side (collaborative) and client-side (standalone).
8+
teXt0wnz is a web-based ANSI art editor that operates in two modes: server-side (collaborative) and client-side (standalone).
69

710
This is a single-page application for creating ANSI/ASCII art with various drawing tools, color palettes, export capabilities, and real-time collaboration features.
811

9-
## Architecture & Key Files
10-
11-
### Client-Side Application (Primary Focus)
12+
### Client-Side Implementation (Drawing Editor)
1213

13-
**Entry Point & Core:**
14-
- `public/index.html` - Single HTML page, includes all necessary scripts
15-
- `public/js/document_onload.js` - **Main entry point**, initializes all tools and UI
16-
- `public/js/core.js` - **Core application logic**, canvas management, rendering
14+
Important Files:
1715

18-
**UI & Interaction:**
19-
- `public/js/ui.js` - UI components, overlays, toolbar management
20-
- `public/js/keyboard.js` - Keyboard event handlers and shortcuts
21-
- `public/js/elementhelper.js` - DOM utility functions
16+
#### Sources
17+
```
18+
public/
19+
├── css/
20+
│   └── style.css # tailwindcss style sheet
21+
├── fonts/ # folder of png format fonts
22+
├── img/ # static assets
23+
├── js/
24+
│   ├── canvas.js # textArtCanvas
25+
│   ├── file.js # File open/save
26+
│   ├── font.js # font management
27+
│   ├── freehand_tools.js # drawing tool logic
28+
│   ├── keyboard.js # keybind listeners/handlers
29+
│   ├── main.js # main interypoint
30+
│   ├── network.js # WebSocket handler
31+
│   ├── palette.js # color palette logic
32+
│   ├── state.js # global state machine
33+
│   ├── toolbar.js # ui toolbar
34+
│   ├── ui.js # ui helpers
35+
│   └── worker.js # webworker hanlder (not built)
36+
└── index.html # single page application
37+
```
2238

23-
**Drawing & Tools:**
24-
- `public/js/freehand_tools.js` - **Drawing tools implementation** (freehand, line, circle, square)
25-
- `public/js/file.js` - File operations (load/save ANSI, PNG, etc.)
26-
- `public/js/savers.js` - Export functionality for different formats
27-
- `public/js/loaders.js` - Import functionality for various file types
39+
#### built files
40+
```
41+
dist/
42+
├── ui/ # all static assets moved into this dir
43+
│   ├── fonts/ # same as public/fonts
44+
│   ├── editor-[has].js # minified js
45+
│   └── stylez-[hash].css # minified css
46+
└── index.html # single page app (vite updated)
47+
```
2848

29-
**Collaboration & Networking:**
30-
- `public/js/network.js` - **Core collaboration logic**, WebSocket/server communication, canvas settings synchronization
31-
- `public/js/worker.js` - **WebSocket worker**, handles real-time collaboration protocol and message passing
49+
**See the project `README.md` for more info about the frontend.**
3250

33-
**Unused in Client Mode:**
51+
---
3452

3553
### Server-Side Implementation (Collaboration Engine)
3654
- `server.js` - **Express server entry point**, WebSocket setup, SSL configuration, session management
3755
- `src/ansiedit.js` - **Core collaboration engine**, message handling, canvas state management, persistence
3856
- `src/binary_text.js` - **Binary format handler** for ANSI art storage and loading
3957

40-
### Reference Implementations
41-
- `tools/` - **Use as examples** when implementing new drawing tools or features
42-
4358
## Development Guidelines
4459

4560
### 1. Code Structure Patterns
4661

4762
**Tool Implementation Pattern** (see `public/js/freehand_tools.js`):
4863
```javascript
49-
function createToolController() {
64+
const createToolController = () => {
5065
"use strict";
5166

5267
function enable() {
@@ -90,15 +105,11 @@ function $(divName) {
90105

91106
### 2. Adding New Features
92107

93-
1. **For new drawing tools**: Use `tools/` directory examples as reference
94-
2. **Follow the factory pattern**: Create functions that return objects with enable/disable methods
95108
3. **Canvas interaction**: Use the established event system (`onTextCanvasDown`, etc.)
96109
4. **UI integration**: Register with `Toolbar.add()` and create corresponding HTML elements
97110

98111
### 3. Code Style
99112

100-
- Use `"use strict";` in all functions
101-
- Prefer factory functions over classes
102113
- Use meaningful variable names (`textArtCanvas`, `characterBrush`, etc.)
103114
- Follow existing indentation (tabs)
104115
- Use explicit returns with named properties: `return { "enable": enable, "disable": disable };`
@@ -108,7 +119,7 @@ function $(divName) {
108119
**Canvas System:**
109120
- `textArtCanvas` - Main drawing surface
110121
- Uses character-based coordinates (not pixel-based)
111-
- Supports undo/redo operations via `textArtCanvas.startUndo()`
122+
- Supports undo/redo operations via `State.textArtCanvas.startUndo()`
112123

113124
**Color Management:**
114125
- `palette` - Color palette management
@@ -225,13 +236,13 @@ case "newFeature":
225236
**Client-Side Integration Pattern:**
226237
```javascript
227238
// In public/js/network.js
228-
function sendNewFeature(value) {
239+
const sendNewFeature = value => {
229240
if (collaborationMode && connected && !applyReceivedSettings && !initializing) {
230241
worker.postMessage({ "cmd": "newFeature", "someProperty": value });
231242
}
232243
}
233244

234-
function onNewFeature(value) {
245+
const onNewFeature = value => {
235246
if (applyReceivedSettings) return; // Prevent loops
236247
applyReceivedSettings = true;
237248
// Apply the change to UI/canvas
@@ -271,38 +282,35 @@ function onNewFeature(value) {
271282

272283
## How to Run
273284

274-
This project **does not use Node.js or package.json**.
275-
**There is nothing to build.**
276-
All you need is a static web server pointed at the `public/` directory.
285+
### build and install
286+
287+
```
288+
bun i
289+
bun bake
290+
```
291+
292+
- these commands will setup the node_modules and build the application to the `dist` folder
293+
- Now you need is a static web server pointed at the `dist/` directory.
277294

278295
### Fastest way to run (from the project root):
279296

280297
```sh
281-
cd public
298+
cd dist
282299
python3 -m http.server 8080
283300
```
284301

285302
Then open [http://localhost:8080/](http://localhost:8080/) in your browser.
286303

287304
- **Any static web server will work** (e.g. Python, PHP, Ruby, `npx serve`, etc).
288-
- Just make sure your web server's root is the `public/` directory.
305+
- Just make sure your web server's root is the `dist/` directory.
289306

290307
## Summary
291308

292-
- **No build step**
293-
- **No package.json**
294-
- **Just serve the `public/` folder as static files.**
295-
296-
## For Copilot and Automation Agents
297-
298-
- Do **not** look for `npm start`, `yarn`, or `package.json`.
299-
- The only requirement is to start a static server in the `public/` directory.
300-
- Example: `cd public && python3 -m http.server 8080`
301-
- For CI, simply check that all files are present in `public/`.
309+
- **Just build and serve the `dist/` folder as static files.**
302310

303311
### Local Development Setup
304312
1. **Client-only**: Start local server: `python3 -m http.server 8080` from `public/` directory
305-
2. **With collaboration**: Run `node server.js` then access at `http://localhost:1337`
313+
2. **With collaboration**: Run `bun server 1337` then access at `http://localhost:1337`
306314
3. Use browser dev tools for debugging
307315
4. Test collaboration with multiple browser tabs/windows
308316

@@ -326,9 +334,8 @@ await page.goto('http://localhost:8080'); // or 1337 for collaboration
326334
## Common Tasks
327335

328336
### Adding a New Drawing Tool
329-
1. Study examples in `tools/` directory (e.g., `tools/freehand.js`)
330337
2. Implement in `public/js/freehand_tools.js` or create new file
331-
3. Register with toolbar in `public/js/document_onload.js`
338+
3. Register with toolbar in `public/js/main.js`
332339
4. Add HTML elements to `public/index.html` if needed
333340
5. Add keyboard shortcut to paint shortcuts configuration
334341

@@ -358,17 +365,15 @@ await page.goto('http://localhost:8080'); // or 1337 for collaboration
358365
## Important Notes
359366

360367
- **Always test changes locally** before committing
368+
- **Always run `bun lint:fix`** before committing
361369
- **Preserve existing functionality** - this is a working art editor used by artists
362370
- **Test both local and collaboration modes** when making changes that affect canvas or UI
363-
- **Use the tools/ directory** as reference for complex feature implementations
364371
- **Maintain the established patterns** for consistency and reliability
365372
- **Validate server message protocol changes** with multiple connected clients
366-
- **Consider backwards compatibility** when modifying server message formats
367373

368374
## Dependencies & Browser Support
369375

370-
- Pure JavaScript (ES5 compatible) for client-side
376+
- Pure JavaScript for client-side
371377
- Node.js with Express framework for server-side collaboration
372-
- No external client libraries or frameworks
373378
- Works in modern browsers with Canvas, File API, and WebSocket support
374379
- Uses Web Workers for real-time collaboration communication

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build Test
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build-test:
12+
runs-on: ubuntu-latest
13+
name: Build Test
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
20+
with:
21+
node-version: "22.8"
22+
cache: "npm"
23+
24+
- name: Install Bun
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y unzip
28+
curl -fsSL https://bun.sh/install | bash
29+
echo "$HOME/.bun/bin" >> $GITHUB_PATH
30+
31+
- name: Install dependencies
32+
run: bun i
33+
34+
- name: Build application
35+
run: bun bake
36+
37+
- name: Check build artifacts
38+
run: |
39+
test -f dist/index.html
40+
test -d dist/ui
41+
test -f dist/ui/editor-*.js
42+
test -f dist/ui/stylez-*.css
43+
echo "Build successful"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Copilot Environment Setup"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
pull_request:
9+
paths:
10+
- .github/workflows/copilot-setup-steps.yml
11+
12+
jobs:
13+
copilot-setup-steps:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
24+
with:
25+
node-version: "22.8"
26+
cache: "npm"
27+
28+
- name: Install Bun
29+
run: |
30+
curl -fsSL https://bun.sh/install | bash
31+
echo "$HOME/.bun/bin" >> $GITHUB_PATH
32+
echo "$HOME/.bun/bin" >> $HOME/.profile
33+
export PATH="$HOME/.bun/bin:$PATH"
34+
35+
- name: Install project dependencies (npm)
36+
run: npm install
37+
38+
- name: Install project dependencies (bun)
39+
run: bun i
40+
41+
# - name: Install project dependencies (bun)
42+
# run: bun playwright:install && bun i -g playwright
43+
#
44+
- name: Install Dev Tools
45+
run: |
46+
bun i -g eslint prettier

.github/workflows/deploy-pages.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
pages: write
9+
id-token: write
10+
11+
concurrency:
12+
group: 'pages'
13+
cancel-in-progress: false
14+
15+
jobs:
16+
build:
17+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
18+
runs-on: ubuntu-latest
19+
name: Build Application
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
26+
with:
27+
node-version: "22.8"
28+
cache: 'npm'
29+
30+
- name: Install Bun
31+
run: |
32+
sudo apt-get update
33+
sudo apt-get install -y unzip
34+
curl -fsSL https://bun.sh/install | bash
35+
echo "$HOME/.bun/bin" >> $GITHUB_PATH
36+
37+
- name: Install dependencies
38+
run: bun i
39+
40+
- name: Build application for production
41+
run: bun bake
42+
43+
- name: Setup Pages
44+
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
45+
46+
- name: Upload artifact
47+
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3
48+
with:
49+
path: dist/
50+
51+
deploy:
52+
environment:
53+
name: github-pages
54+
url: ${{ steps.deployment.outputs.page_url }}
55+
runs-on: ubuntu-latest
56+
needs: build
57+
name: Deploy to GitHub Pages
58+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
59+
steps:
60+
- name: Deploy to GitHub Pages
61+
id: deployment
62+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4

0 commit comments

Comments
 (0)