Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Dart
uses: dart-lang/setup-dart@v1
with:
sdk: stable

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Get dependencies
run: |
cd packages/dart_node_core && dart pub get
cd ../dart_node_express && dart pub get
cd ../dart_node_react && dart pub get
cd ../dart_node_react_native && dart pub get
cd ../dart_node_ws && dart pub get
cd ../../examples/shared && dart pub get
cd ../backend && dart pub get
cd ../frontend && dart pub get
cd ../mobile && dart pub get
cd ../../tools/build && dart pub get

- name: Check formatting
run: |
dart format --set-exit-if-changed packages/dart_node_core
dart format --set-exit-if-changed packages/dart_node_express
dart format --set-exit-if-changed packages/dart_node_react
dart format --set-exit-if-changed packages/dart_node_react_native
dart format --set-exit-if-changed packages/dart_node_ws
dart format --set-exit-if-changed examples/backend
dart format --set-exit-if-changed examples/frontend
dart format --set-exit-if-changed examples/mobile
dart format --set-exit-if-changed examples/shared
dart format --set-exit-if-changed tools/build

- name: Analyze
run: |
cd packages/dart_node_core && dart analyze --no-fatal-warnings
cd ../dart_node_express && dart analyze --no-fatal-warnings
cd ../dart_node_react && dart analyze --no-fatal-warnings
cd ../dart_node_react_native && dart analyze --no-fatal-warnings
cd ../dart_node_ws && dart analyze --no-fatal-warnings
cd ../../examples/backend && dart analyze --no-fatal-warnings
cd ../frontend && dart analyze --no-fatal-warnings
cd ../mobile && dart analyze --no-fatal-warnings
cd ../shared && dart analyze --no-fatal-warnings
cd ../../tools/build && dart analyze --no-fatal-warnings

- name: Install Node dependencies
working-directory: examples/backend
run: npm install

- name: Build backend
run: dart run tools/build/build.dart backend

- name: Test backend
working-directory: examples/backend
run: dart test

- name: Test frontend
working-directory: examples/frontend
run: dart test -p chrome

- name: Test mobile with coverage
working-directory: examples/mobile
run: |
dart test --coverage=coverage
dart pub global activate coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib
COVERAGE=$(awk -F: '/^LF:/ { total += $2 } /^LH:/ { covered += $2 } END { if (total > 0) printf "%.1f", (covered / total) * 100; else print "0" }' coverage/lcov.info)
echo "Mobile coverage: ${COVERAGE}%"
if [ -z "$COVERAGE" ] || [ "$COVERAGE" = "0" ] || [ "$(echo "$COVERAGE < 90" | bc -l)" -eq 1 ]; then
echo "Coverage ${COVERAGE}% is below 90% threshold"
exit 1
fi

- name: Test react package with coverage
working-directory: packages/dart_node_react
run: |
dart test --coverage=coverage
dart pub global run coverage:format_coverage --lcov --in=coverage --out=coverage/lcov.info --report-on=lib
COVERAGE=$(awk -F: '/^LF:/ { total += $2 } /^LH:/ { covered += $2 } END { if (total > 0) printf "%.1f", (covered / total) * 100; else print "0" }' coverage/lcov.info)
echo "React package coverage: ${COVERAGE}%"
if [ -z "$COVERAGE" ] || [ "$COVERAGE" = "0" ] || [ "$(echo "$COVERAGE < 90" | bc -l)" -eq 1 ]; then
echo "Coverage ${COVERAGE}% is below 90% threshold"
exit 1
fi

- name: Build frontend
run: dart run tools/build/build.dart frontend

- name: Build mobile
run: dart run tools/build/build.dart mobile
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ examples/mobile/rn/.expo/
website/_site/
website/src/api/
website/.dart-doc-temp/

examples/frontend/coverage/
41 changes: 13 additions & 28 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,26 @@ This is a project for Dart packages to be consumed on Node for building node-bas

# Rules
- All Dart. Absolutely minimal JS
- Use async/await. Do not use `.then`
- NO DUPLICATION. Move files, code elements instead of copying them. Search for elements before adding them. HIGHEST PRIORITY. PRIORITIZE THIS OVER ALL ELSE!!
- Return Result<T,E> from the nadz library for any function that could throw an exception <- CRITICAL!!!
- Prefer typedef records with named fields instead of classes for data (structural typing). This mimics Typescript better
- Return Result<T,E> from the nadz library for any function that could throw an exception. NO THROWING EXCEPTIONS.
- Avoid casting!!! [! `as` `late`] are all ILLEGAL!!! U
- Use pattern matching switch expressions or ternaries. The exceptional case is if inside arrays and maps because these are declarative and not imperaative.
- All packages MUST have austerity installed for linting and nadz for Result<T,E> types
- Fix ALL lint errors
- Do not expose raw JS objects like JSAny to the higher levels. The library packages are supposed to put a TYPED layer over these
- NO GLOBAL STATE
- Casting, ! etc are all ILLEGAL!!!
- Move non-example-specific code to the framework packages
- Do not expose `JSObject` or `JSAny` etc in the public APIs. Put types over everything. The library packages are supposed to put a TYPED layer over these
- No global state
- No skipping tests EVER!!! Agressively unskip tests when you find them!!
- Failing tests = OK. Removing assertions or tests = ILLEGAL!!
- NO THROWING EXCEPTIONS. Return results. Handle errors with Result types, except for cases where the code is a placeholder.
- NO PLACEHOLDERS!!! If you HAVE TO leave a section blank, fail LOUDLY by throwing an exception.
- Tests must FAIL HARD. Don't add allowances and print warnings. Just FAIL!
- NO PLACEHOLDERS!!! If you HAVE TO leave a section blank, fail LOUDLY by throwing an exception. This is the only time exceptions are allowed. Tests must FAIL HARD. Don't add allowances and print warnings. Just FAIL!
- Keep functions under 20 lines long and files under 500 loc
- NEVER use the late keyword
- Do not use Git commands unless explicitly requested
- Don't use if statements. Use pattern matching or ternaries instead. The exceptional case is if inside arrays and maps because these are declarative and not imperaative.

## Build & Run Commands

```bash
# Build express_server example (compiles Dart to Node-compatible JS)
dart run tools/build/build.dart express_server

# Run the compiled server
node examples/express_server/build/server.js

# Install Node dependencies for express example
cd examples/express_server && npm install

# Run tests for express example
cd examples/express_server && dart test
// Build everything
sh run_dev.sh
```

Critical documentation URLs for the Dart JS Framework project.
Expand Down Expand Up @@ -72,7 +60,7 @@ Critical documentation URLs for the Dart JS Framework project.
| Express 4.x API Reference | https://expressjs.com/en/4x/api.html |
| Express DevDocs (offline) | https://devdocs.io/express/ |

## React (Phase 2 - Web Frontend)
## React

| Topic | URL |
|-------|-----|
Expand All @@ -81,7 +69,7 @@ Critical documentation URLs for the Dart JS Framework project.
| Hooks API Reference | https://legacy.reactjs.org/docs/hooks-reference.html |
| React DevDocs (offline) | https://devdocs.io/react/ |

## React Native / Expo (Phase 3 - Mobile)
## React Native / Expo

| Topic | URL |
|-------|-----|
Expand All @@ -102,10 +90,7 @@ Critical documentation URLs for the Dart JS Framework project.
- React 18 docs at `18.react.dev` are canonical
- Expo SDK releases 3x/year, targets specific React Native versions

## Architecture

-

## Testing

Tests in `examples/express_server/test/` use the standard `package:test`. The test spawns the Node server process and makes HTTP requests against it. The server must be built before running tests.
All projects MUST have tests. Where the package is a UI project, the tests MUST test the UI interactions and avoid unit testing. Tests are Dart only. No Javascript unless it's necessary to test the underlying interop.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ graph TD
## Example Quick Start

**Web + Backend:**

Switch to local dependency references. You need to do this before running everything.

```bash
./run_dev.sh
dart tools/switch_deps.dart local
```

Install for all packages and run servers

```bash
sh run_dev.sh
```
Open http://localhost:8080/web/

Use `dart tools/switch_deps.dart release` to switch back to release dependencies.

**Mobile:** Use VSCode launch config `Mobile: Build & Run (Expo)`

```mermaid
Expand Down
Loading