Skip to content

Commit 7f9ce79

Browse files
authored
refactor: complete Node.js to Deno migration (#147)
1 parent 9b59a9a commit 7f9ce79

11 files changed

Lines changed: 132 additions & 161 deletions

File tree

.github/workflows/gatsby.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Sample workflow for building and deploying a Gatsby site to GitHub Pages
1+
# Workflow for building and deploying the Gatsby website to GitHub Pages
2+
#
3+
# Note: The website (src/website/) is a Gatsby/React application that requires Node.js.
4+
# This is separate from the TypeScript projects which use Deno.
25
#
36
# To get started with Gatsby see: https://www.gatsbyjs.com/docs/quick-start/
47
#

.github/workflows/typescript.yml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# This workflow will build and test TypeScript/Deno projects
2-
name: Deno Build
1+
# This workflow will build and test TypeScript projects using Deno
2+
name: Deno TypeScript Build
33

44
on:
55
push:
@@ -94,28 +94,3 @@ jobs:
9494

9595
- name: Format check
9696
run: deno fmt --check src/
97-
98-
build-website:
99-
name: Build Website (Node.js)
100-
runs-on: ubuntu-latest
101-
defaults:
102-
run:
103-
working-directory: ./src/website
104-
105-
steps:
106-
- uses: actions/checkout@v4
107-
108-
- name: Setup Node.js
109-
uses: actions/setup-node@v4
110-
with:
111-
node-version: '22'
112-
cache: 'npm'
113-
cache-dependency-path: './src/website/package-lock.json'
114-
115-
- name: Install dependencies
116-
run: npm ci
117-
118-
- name: Build Gatsby site
119-
run: npm run build
120-
env:
121-
NODE_ENV: production

CLAUDE.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This repository is a comprehensive multi-language toolkit for ad-blocking, netwo
2828
- **Linear Import Tool** (`src/linear/`) - TypeScript tool with Deno support
2929

3030
### Website
31-
- **Gatsby Site** (`src/website/`) - Portfolio site deployed to GitHub Pages (Node.js)
31+
- **Gatsby Site** (`src/website/`) - Portfolio site deployed to GitHub Pages (requires Node.js)
3232

3333
### Configuration Support
3434
All compilers support JSON, YAML, and TOML configuration formats with full @adguard/hostlist-compiler compatibility.
@@ -41,7 +41,7 @@ A fully-featured Docker environment with all compilers and tools:
4141
# Dockerfile.warp
4242
FROM mcr.microsoft.com/dotnet/sdk:10.0-noble
4343
# Includes: .NET 10 SDK, Deno 2.x, Python 3.12, Rust stable, PowerShell 7
44-
# Pre-installed: hostlist-compiler, yq, pytest, ruff, clippy, Pester
44+
# Pre-installed: hostlist-compiler (via Deno), yq, pytest, ruff, clippy, Pester
4545
```
4646

4747
Build and run:
@@ -214,6 +214,7 @@ deno task check # Type check
214214

215215
### Gatsby Website (`src/website/`)
216216
```bash
217+
# Note: Website still uses Node.js/npm (Gatsby is a Node.js framework)
217218
cd src/website
218219
npm ci
219220
npm run develop # Dev server at localhost:8000
@@ -443,8 +444,8 @@ RemoveComments, Compress, RemoveModifiers, Validate, ValidateAllowIp, Deduplicat
443444

444445
GitHub Actions workflows validate:
445446
- `.github/workflows/dotnet.yml` - Builds/tests .NET projects (API client and rules compiler) with .NET 10
446-
- `.github/workflows/typescript.yml` - Deno 2.x for TypeScript projects, Node.js 22 for website
447-
- `.github/workflows/gatsby.yml` - Builds website and deploys to GitHub Pages
447+
- `.github/workflows/typescript.yml` - Deno 2.x for all TypeScript projects
448+
- `.github/workflows/gatsby.yml` - Builds website (Node.js) and deploys to GitHub Pages
448449
- `.github/workflows/security.yml` - Consolidated security scanning (CodeQL, DevSkim, PSScriptAnalyzer)
449450
- `.github/workflows/release.yml` - Builds and publishes release binaries (.NET, Rust, Python)
450451
- `.github/workflows/claude.yml` - Claude AI integration for @claude mentions
@@ -456,11 +457,11 @@ GitHub Actions workflows validate:
456457
|-------------|---------|--------------|
457458
| .NET SDK | 10.0+ | .NET compiler, API client |
458459
| Deno | 2.0+ | TypeScript projects (rules compiler, API client, linear) |
459-
| Node.js | 22.x LTS | Website (Gatsby) |
460+
| Node.js | 22.x LTS | Website only (Gatsby) |
460461
| PowerShell | 7+ | PowerShell scripts |
461462
| Python | 3.9+ | Python compiler |
462463
| Rust | 1.85+ | Rust compiler (install via rustup) |
463-
| hostlist-compiler | Latest | All compilers (`npm install -g @adguard/hostlist-compiler`) |
464+
| hostlist-compiler | Latest | All compilers (via Deno: `deno run npm:@adguard/hostlist-compiler`) |
464465
| Docker | 24.0+ | Container development (optional but recommended) |
465466

466467
## Key File Locations

Dockerfile.warp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# =============================================================================
22
# Docker Development Environment for ad-blocking toolkit
3-
# Includes: .NET 10, Node.js 22 LTS, Python 3.12, Rust, PowerShell 7
3+
# Includes: .NET 10, Deno 2.x, Python 3.12, Rust, PowerShell 7
44
# =============================================================================
55

66
FROM mcr.microsoft.com/dotnet/sdk:10.0-noble
77

88
# Build arguments for version control
9-
ARG NODE_VERSION=22
9+
ARG DENO_VERSION=2.x
1010
ARG PYTHON_VERSION=3.12
1111
ARG RUST_VERSION=stable
1212

@@ -15,12 +15,12 @@ ENV DEBIAN_FRONTEND=noninteractive \
1515
DOTNET_CLI_TELEMETRY_OPTOUT=1 \
1616
DOTNET_NOLOGO=1 \
1717
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 \
18-
NODE_ENV=development \
18+
DENO_DIR=/root/.deno \
1919
PYTHONDONTWRITEBYTECODE=1 \
2020
PYTHONUNBUFFERED=1 \
2121
CARGO_HOME=/root/.cargo \
2222
RUSTUP_HOME=/root/.rustup \
23-
PATH="/root/.cargo/bin:${PATH}"
23+
PATH="/root/.deno/bin:/root/.cargo/bin:${PATH}"
2424

2525
# =============================================================================
2626
# Base dependencies
@@ -43,15 +43,16 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4343
&& apt-get clean && rm -rf /var/lib/apt/lists/*
4444

4545
# =============================================================================
46-
# Node.js 22.x LTS via NodeSource
46+
# Deno 2.x
4747
# =============================================================================
48-
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \
49-
apt-get install -y --no-install-recommends nodejs && \
50-
npm install -g npm@latest && \
51-
apt-get clean && rm -rf /var/lib/apt/lists/*
48+
RUN curl -fsSL https://deno.land/install.sh | sh && \
49+
ln -s /root/.deno/bin/deno /usr/local/bin/deno
5250

53-
# Install global npm packages
54-
RUN npm install -g @adguard/hostlist-compiler typescript ts-node
51+
# Install hostlist-compiler via Deno's npm compatibility
52+
# Create a wrapper script for hostlist-compiler
53+
RUN echo '#!/bin/sh\ndeno run --allow-read --allow-write --allow-env --allow-net --allow-run npm:@adguard/hostlist-compiler "$@"' > /usr/local/bin/hostlist-compiler && \
54+
chmod +x /usr/local/bin/hostlist-compiler && \
55+
deno cache npm:@adguard/hostlist-compiler
5556

5657
# =============================================================================
5758
# Python 3.12
@@ -107,16 +108,15 @@ RUN curl -sL https://github.com/mikefarah/yq/releases/latest/download/yq_linux_a
107108
# =============================================================================
108109
RUN echo "=== Installed Versions ===" && \
109110
echo "dotnet: $(dotnet --version)" && \
110-
echo "node: $(node --version)" && \
111-
echo "npm: $(npm --version)" && \
111+
echo "deno: $(deno --version | head -1)" && \
112112
echo "python: $(python --version)" && \
113113
echo "pip: $(pip --version)" && \
114114
echo "rustc: $(rustc --version)" && \
115115
echo "cargo: $(cargo --version)" && \
116116
echo "pwsh: $(pwsh --version)" && \
117117
echo "git: $(git --version)" && \
118118
echo "yq: $(yq --version)" && \
119-
echo "hostlist-compiler: $(hostlist-compiler --version)" && \
119+
echo "hostlist-compiler: available via deno" && \
120120
echo "=========================="
121121

122122
# =============================================================================

docker-compose.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ services:
1111
context: .
1212
dockerfile: Dockerfile.warp
1313
args:
14-
NODE_VERSION: 22
14+
DENO_VERSION: 2.x
1515
RUST_VERSION: stable
1616
image: ad-blocking-dev:latest
1717
container_name: ad-blocking-dev
1818
volumes:
1919
- .:/workspace
2020
# Named volumes for dependency caching
21-
- node_modules_ts:/workspace/src/rules-compiler-typescript/node_modules
22-
- node_modules_web:/workspace/src/website/node_modules
21+
- deno_cache:/root/.deno
2322
- cargo_registry:/root/.cargo/registry
2423
- cargo_git:/root/.cargo/git
2524
- nuget_packages:/root/.nuget/packages
@@ -44,9 +43,9 @@ services:
4443
container_name: ad-blocking-typescript
4544
volumes:
4645
- .:/workspace
47-
- node_modules_ts:/workspace/src/rules-compiler-typescript/node_modules
46+
- deno_cache:/root/.deno
4847
working_dir: /workspace/src/rules-compiler-typescript
49-
command: npm run compile
48+
command: deno task compile
5049
depends_on:
5150
- dev
5251
profiles:
@@ -118,23 +117,18 @@ services:
118117
- ad-blocking-net
119118

120119
# ---------------------------------------------------------------------------
121-
# Gatsby Website development server
120+
# Gatsby Website development server (requires Node.js - uses separate image)
122121
# ---------------------------------------------------------------------------
123122
website:
124-
build:
125-
context: .
126-
dockerfile: Dockerfile.warp
127-
image: ad-blocking-dev:latest
123+
image: node:22-slim
128124
container_name: ad-blocking-website
129125
volumes:
130126
- .:/workspace
131127
- node_modules_web:/workspace/src/website/node_modules
132128
ports:
133129
- "8000:8000"
134130
working_dir: /workspace/src/website
135-
command: npm run develop -- --host 0.0.0.0
136-
depends_on:
137-
- dev
131+
command: sh -c "npm ci && npm run develop -- --host 0.0.0.0"
138132
profiles:
139133
- website
140134
networks:
@@ -151,15 +145,15 @@ services:
151145
container_name: ad-blocking-test
152146
volumes:
153147
- .:/workspace
154-
- node_modules_ts:/workspace/src/rules-compiler-typescript/node_modules
148+
- deno_cache:/root/.deno
155149
- nuget_packages:/root/.nuget/packages
156150
- cargo_registry:/root/.cargo/registry
157151
- cargo_git:/root/.cargo/git
158152
working_dir: /workspace
159153
command: >
160154
bash -c "
161155
echo '=== Running TypeScript Tests ===' &&
162-
cd /workspace/src/rules-compiler-typescript && npm test &&
156+
cd /workspace/src/rules-compiler-typescript && deno task test &&
163157
echo '=== Running .NET Tests ===' &&
164158
cd /workspace/src/rules-compiler-dotnet && dotnet test RulesCompiler.slnx &&
165159
echo '=== Running Python Tests ===' &&
@@ -206,8 +200,8 @@ services:
206200
# Named volumes for dependency caching
207201
# =============================================================================
208202
volumes:
209-
node_modules_ts:
210-
name: ad-blocking-node-ts
203+
deno_cache:
204+
name: ad-blocking-deno-cache
211205
node_modules_web:
212206
name: ad-blocking-node-web
213207
cargo_registry:

docs/LINEAR_DOCUMENTATION.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ A comprehensive, multi-component ad-blocking solution designed for network-level
6868
**Technology Stack:**
6969
- TypeScript 5.4.5
7070
- @adguard/hostlist-compiler v1.0.39
71-
- Jest 29.7.0 (testing)
72-
- Node.js 20
71+
- Deno test (testing)
72+
- Deno 2.0+
7373

7474
**Key Files:**
7575
| File | Description |
@@ -234,8 +234,8 @@ ad-blocking/
234234
|------------|---------|---------|
235235
| TypeScript | 5.4.5 | Strongly-typed JavaScript |
236236
| @adguard/hostlist-compiler | 1.0.39 | Core compilation engine |
237-
| Node.js | 20 | JavaScript runtime |
238-
| Jest | 29.7.0 | Testing framework |
237+
| Deno | 2.0+ | TypeScript/JavaScript runtime |
238+
| Deno test | built-in | Testing framework |
239239

240240
### Frontend
241241
| Technology | Version | Purpose |
@@ -285,16 +285,14 @@ Full API documentation available in `/docs/api/`.
285285
## Quick Start
286286

287287
### Prerequisites
288-
- Node.js 20+
288+
- Deno 2.0+
289289
- .NET 10 SDK
290290
- PowerShell 7+
291291

292292
### Filter Compiler
293293
```bash
294-
cd src/filter-compiler
295-
npm install
296-
npm run build
297-
npm run compile
294+
cd src/rules-compiler-typescript
295+
deno task compile
298296
```
299297

300298
### API Client
@@ -308,7 +306,7 @@ dotnet test
308306
### Website
309307
```bash
310308
cd src/website
311-
npm install
309+
npm install # Website still uses Node.js/Gatsby
312310
npm run develop
313311
```
314312

@@ -318,8 +316,8 @@ npm run develop
318316

319317
### TypeScript Tests
320318
```bash
321-
cd src/filter-compiler
322-
npm test
319+
cd src/rules-compiler-typescript
320+
deno task test
323321
```
324322

325323
### .NET Tests

0 commit comments

Comments
 (0)