Skip to content

Commit 9b59a9a

Browse files
authored
refactor(typescript): migrate all TypeScript projects from Node.js to Deno (#146)
1 parent f891915 commit 9b59a9a

78 files changed

Lines changed: 1322 additions & 17100 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/typescript.yml

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

44
on:
55
push:
@@ -8,8 +8,8 @@ on:
88
branches: [ "main" ]
99

1010
jobs:
11-
build-compiler:
12-
name: Build and Test Rules Compiler
11+
build-rules-compiler:
12+
name: Build and Test Rules Compiler (Deno)
1313
runs-on: ubuntu-latest
1414
defaults:
1515
run:
@@ -18,30 +18,85 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020

21-
- name: Setup Node.js
22-
uses: actions/setup-node@v4
21+
- name: Setup Deno
22+
uses: denoland/setup-deno@v2
2323
with:
24-
node-version: '20'
25-
cache: 'npm'
26-
cache-dependency-path: './src/rules-compiler-typescript/package-lock.json'
24+
deno-version: v2.x
2725

28-
- name: Install dependencies
29-
run: npm ci
26+
- name: Verify Deno installation
27+
run: deno --version
3028

3129
- name: Type check
32-
run: npx tsc --noEmit
30+
run: deno task check
3331

3432
- name: Lint
35-
run: npx eslint src/
33+
run: deno task lint
3634

37-
- name: Build
38-
run: npm run build
35+
- name: Format check
36+
run: deno fmt --check src/
37+
38+
- name: Test
39+
run: deno task test
40+
41+
build-adguard-api:
42+
name: Build and Test AdGuard API Client (Deno)
43+
runs-on: ubuntu-latest
44+
defaults:
45+
run:
46+
working-directory: ./src/adguard-api-typescript
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Setup Deno
52+
uses: denoland/setup-deno@v2
53+
with:
54+
deno-version: v2.x
55+
56+
- name: Verify Deno installation
57+
run: deno --version
58+
59+
- name: Type check
60+
run: deno task check
61+
62+
- name: Lint
63+
run: deno task lint
64+
65+
- name: Format check
66+
run: deno fmt --check src/
3967

4068
- name: Test
41-
run: npm test
69+
run: deno task test
70+
71+
build-linear:
72+
name: Build Linear Import Tool (Deno)
73+
runs-on: ubuntu-latest
74+
defaults:
75+
run:
76+
working-directory: ./src/linear
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Setup Deno
82+
uses: denoland/setup-deno@v2
83+
with:
84+
deno-version: v2.x
85+
86+
- name: Verify Deno installation
87+
run: deno --version
88+
89+
- name: Type check
90+
run: deno task check
91+
92+
- name: Lint
93+
run: deno task lint
94+
95+
- name: Format check
96+
run: deno fmt --check src/
4297

4398
build-website:
44-
name: Build Website
99+
name: Build Website (Node.js)
45100
runs-on: ubuntu-latest
46101
defaults:
47102
run:
@@ -53,7 +108,7 @@ jobs:
53108
- name: Setup Node.js
54109
uses: actions/setup-node@v4
55110
with:
56-
node-version: '20'
111+
node-version: '22'
57112
cache: 'npm'
58113
cache-dependency-path: './src/website/package-lock.json'
59114

CLAUDE.md

Lines changed: 74 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
77
This repository is a comprehensive multi-language toolkit for ad-blocking, network protection, and AdGuard DNS management:
88

99
### Rules Compilers (4 languages)
10-
- **TypeScript** (`src/rules-compiler-typescript/`) - Node.js 18+ with Deno and Bun support, optional Rust frontend
10+
- **TypeScript** (`src/rules-compiler-typescript/`) - Deno 2.0+ with npm compatibility
1111
- **C#/.NET 10** (`src/rules-compiler-dotnet/`) - Library and Spectre.Console CLI with DI support
1212
- **Python 3.9+** (`src/rules-compiler-python/`) - pip-installable package with CLI and API
1313
- **Rust** (`src/rules-compiler-rust/`) - High-performance single binary with zero runtime deps
@@ -23,12 +23,12 @@ This repository is a comprehensive multi-language toolkit for ad-blocking, netwo
2323

2424
### API Client & Tools
2525
- **AdGuard API Client - .NET** (`src/adguard-api-dotnet/`) - C# SDK for AdGuard DNS API v1.11
26-
- **AdGuard API Client - TypeScript** (`src/adguard-api-typescript/`) - TypeScript SDK with Node.js, Deno, and Bun support
26+
- **AdGuard API Client - TypeScript** (`src/adguard-api-typescript/`) - TypeScript SDK with Deno support
2727
- **Console UI** (`src/adguard-api-dotnet/src/AdGuard.ConsoleUI/`) - Spectre.Console interactive interface
28-
- **Linear Import Tool** (`src/linear/`) - TypeScript tool with Node.js, Deno, and Bun support
28+
- **Linear Import Tool** (`src/linear/`) - TypeScript tool with Deno support
2929

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

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

@@ -65,29 +65,23 @@ Warp Environment: `jaysonknight/warp-env:ad-blocking` (ID: `Egji4sZU4TNIOwNasFU7
6565
### TypeScript Rules Compiler (`src/rules-compiler-typescript/`)
6666
```bash
6767
cd src/rules-compiler-typescript
68-
npm ci # Install dependencies
69-
npm run build # Build TypeScript
70-
npm test # Run Jest tests
71-
npm run test:coverage # Run tests with coverage
72-
npm run lint # ESLint
73-
npm run compile # Compile filter rules
74-
npm run compile:yaml # Compile using YAML config
75-
npm run compile:toml # Compile using TOML config
76-
npm run dev # Run with ts-node
68+
69+
# Deno tasks
70+
deno task compile # Compile filter rules
71+
deno task compile:yaml # Compile using YAML config
72+
deno task compile:toml # Compile using TOML config
73+
deno task dev # Run with watch mode
74+
deno task test # Run Deno tests
75+
deno task test:coverage # Run tests with coverage
76+
deno task lint # Lint source files
77+
deno task fmt # Format source files
78+
deno task check # Type check
79+
deno task version # Show version
7780

7881
# CLI with options
79-
npm run compile -- -c config.yaml -r -d
80-
npm run compile -- --help
81-
npm run compile -- --version
82-
83-
# Bun commands (alternative runtime)
84-
bun install # Install dependencies
85-
bun run bun:build # Build with Bun
86-
bun run bun:dev # Run with Bun
87-
bun run bun:compile # Compile filter rules
88-
bun run bun:compile:yaml # Compile using YAML config
89-
bun run bun:compile:toml # Compile using TOML config
90-
bun run bun:test # Run tests with Bun
82+
deno task compile -- -c config.yaml -r -d
83+
deno run --allow-read --allow-write --allow-env --allow-run src/mod.ts --help
84+
deno run --allow-read --allow-write --allow-env --allow-run src/mod.ts --version
9185
```
9286

9387
### Shell Scripts (`src/rules-compiler-shell/`)
@@ -188,19 +182,43 @@ dotnet run --project src/AdGuard.ConsoleUI/AdGuard.ConsoleUI.csproj
188182
dotnet run --project src/AdGuard.ApiClient.Benchmarks -c Release
189183
```
190184

185+
### TypeScript API Client (`src/adguard-api-typescript/`)
186+
```bash
187+
cd src/adguard-api-typescript
188+
189+
# Deno tasks
190+
deno task start # Start CLI
191+
deno task sync # Sync rules
192+
deno task cli # Run CLI directly
193+
deno task test # Run tests
194+
deno task test:coverage # Run tests with coverage
195+
deno task lint # Lint source files
196+
deno task fmt # Format source files
197+
deno task check # Type check
198+
```
199+
200+
### Linear Import Tool (`src/linear/`)
201+
```bash
202+
cd src/linear
203+
204+
# Deno tasks
205+
deno task import # Run import tool
206+
deno task import:docs # Import documentation
207+
deno task import:dry-run # Preview import
208+
deno task cli # Run CLI directly
209+
deno task test # Run tests
210+
deno task lint # Lint source files
211+
deno task fmt # Format source files
212+
deno task check # Type check
213+
```
214+
191215
### Gatsby Website (`src/website/`)
192216
```bash
193217
cd src/website
194218
npm ci
195219
npm run develop # Dev server at localhost:8000
196220
npm run build # Production build
197221
npm run serve # Serve local build
198-
199-
# Bun commands (experimental Gatsby support)
200-
bun install # Install dependencies (faster)
201-
bun run bun:develop # Dev server with Bun
202-
bun run bun:build # Production build with Bun
203-
bun run bun:serve # Serve local build with Bun
204222
```
205223

206224
### PowerShell RulesCompiler Module (`src/adguard-api-powershell/`)
@@ -229,12 +247,12 @@ Invoke-ScriptAnalyzer -Path src/adguard-api-powershell -Recurse
229247

230248
## Running Individual Tests
231249

232-
### TypeScript (Jest)
250+
### TypeScript (Deno)
233251
```bash
234252
cd src/rules-compiler-typescript
235-
npx jest cli.test.ts # By file
236-
npx jest -t "should compile rules" # By test name
237-
npm run test:coverage # With coverage
253+
deno test src/cli.test.ts # By file
254+
deno test --filter "parseArgs" # By test name
255+
deno task test:coverage # With coverage
238256
```
239257

240258
### .NET (xUnit)
@@ -286,15 +304,15 @@ cargo test config:: # Tests in module
286304

287305
### Rules Compiler - TypeScript (`src/rules-compiler-typescript/`)
288306
- TypeScript wrapper around @adguard/hostlist-compiler
307+
- Deno 2.0+ runtime with npm compatibility
289308
- Supports JSON, YAML, and TOML configuration formats
290309
- `src/cli.ts` - Command-line interface with argument parsing
291310
- `src/config-reader.ts` - Multi-format configuration reader
292311
- `src/compiler.ts` - Core compilation logic
293312
- `src/mod.ts` - Deno entry point
294313
- `frontend-rust/` - Optional Rust CLI frontend
295-
- Deno support via `deno.json`
296-
- Bun support via `bunfig.toml` and `bun:*` npm scripts
297-
- ESLint and Jest for testing
314+
- `deno.json` - Deno configuration and tasks
315+
- Uses Deno's built-in testing framework
298316

299317
### Shell Scripts (`src/rules-compiler-shell/`)
300318
- Cross-platform shell scripts for filter compilation
@@ -330,7 +348,7 @@ cargo test config:: # Tests in module
330348
- `src/compiler.rs` - `RulesCompiler` struct and `compile_rules()` function
331349
- `src/main.rs` - clap-based CLI with argument parsing
332350
- `src/error.rs` - `CompilerError` enum with thiserror
333-
- Single binary distribution with zero runtime dependencies (except Node.js for hostlist-compiler)
351+
- Single binary distribution with zero runtime dependencies (except hostlist-compiler)
334352
- Key structs: `RulesCompiler`, `CompilerConfiguration`, `CompilerResult`, `VersionInfo`
335353
- LTO optimization enabled for small binary size
336354

@@ -343,26 +361,24 @@ cargo test config:: # Tests in module
343361

344362
### API Client - TypeScript (`src/adguard-api-typescript/`)
345363
- TypeScript SDK for AdGuard DNS API v1.11 with feature parity to .NET version
346-
- Node.js 18+, Deno 2.0+, and Bun 1.0+ support
364+
- Deno 2.0+ runtime with npm compatibility
347365
- `src/client.ts` - Main `AdGuardDnsClient` class with fluent API
348366
- `src/api/` - API endpoint implementations (account, devices, DNS servers, statistics, etc.)
349367
- `src/repositories/` - Higher-level repository pattern abstractions
350368
- `src/cli/` - Interactive CLI with menu-driven interface
351369
- `src/mod.ts` - Deno entry point
352-
- Bun support via `bunfig.toml` and `bun:*` npm scripts
353370
- Key classes: `AdGuardDnsClient`, `DeviceRepository`, `DnsServerRepository`, `UserRulesRepository`
354-
- Dependencies: axios, commander, inquirer, chalk
371+
- Dependencies (via npm:): axios, commander, inquirer, chalk
355372

356373
### Linear Import Tool (`src/linear/`)
357374
- TypeScript tool for importing documentation into Linear project management
358-
- Node.js 18+, Deno 2.0+, and Bun 1.0+ support
359-
- `src/linear-import.ts` - Main CLI entry point (Node.js)
375+
- Deno 2.0+ runtime with npm compatibility
376+
- `src/linear-import.ts` - Main CLI entry point
360377
- `src/mod.ts` - Deno entry point
361-
- Bun support via `bunfig.toml` and `bun:*` npm scripts
362378
- `src/parser.ts` - Markdown documentation parser
363379
- `src/linear-client.ts` - Linear API client wrapper
364380
- `src/types.ts` - TypeScript type definitions
365-
- Dependencies: @linear/sdk, commander, marked, dotenv
381+
- Dependencies (via npm:): @linear/sdk, commander, marked, dotenv
366382

367383
### Console UI (`src/adguard-api-dotnet/src/AdGuard.ConsoleUI/`)
368384
- Spectre.Console menu-driven interface
@@ -412,16 +428,22 @@ RemoveComments, Compress, RemoveModifiers, Validate, ValidateAllowIp, Deduplicat
412428
| Variable | Description |
413429
|----------|-------------|
414430
| `AdGuard:ApiKey` | API credential for console UI (can also prompt interactively) |
431+
| `ADGUARD_API_KEY` | API credential for TypeScript client |
432+
| `ADGUARD_AdGuard__ApiKey` | .NET-compatible API credential format |
415433
| `LINEAR_API_KEY` | For Linear import scripts (`src/linear/`) |
416-
| `DEBUG` | Set to any value to enable debug logging in PowerShell modules |
434+
| `LINEAR_TEAM_ID` | Optional Linear team ID |
435+
| `LINEAR_PROJECT_NAME` | Optional Linear project name |
436+
| `DEBUG` | Set to any value to enable debug logging |
437+
| `LOG_LEVEL` | Log level (DEBUG, INFO, WARN, ERROR, SILENT) |
438+
| `LOG_FORMAT` | Set to `json` for structured logging |
417439
| `RULESCOMPILER_config` | Default configuration file path (.NET compiler) |
418440
| `RULESCOMPILER_Logging__LogLevel__Default` | Log level for .NET compiler |
419441

420442
## CI/CD Alignment
421443

422444
GitHub Actions workflows validate:
423445
- `.github/workflows/dotnet.yml` - Builds/tests .NET projects (API client and rules compiler) with .NET 10
424-
- `.github/workflows/typescript.yml` - Node 20, tsc --noEmit, eslint for rules-compiler-typescript and website
446+
- `.github/workflows/typescript.yml` - Deno 2.x for TypeScript projects, Node.js 22 for website
425447
- `.github/workflows/gatsby.yml` - Builds website and deploys to GitHub Pages
426448
- `.github/workflows/security.yml` - Consolidated security scanning (CodeQL, DevSkim, PSScriptAnalyzer)
427449
- `.github/workflows/release.yml` - Builds and publishes release binaries (.NET, Rust, Python)
@@ -433,8 +455,8 @@ GitHub Actions workflows validate:
433455
| Requirement | Version | Required For |
434456
|-------------|---------|--------------|
435457
| .NET SDK | 10.0+ | .NET compiler, API client |
436-
| Node.js | 22.x LTS | All compilers, Website |
437-
| Bun | 1.0+ | TypeScript projects (optional alternative to Node.js) |
458+
| Deno | 2.0+ | TypeScript projects (rules compiler, API client, linear) |
459+
| Node.js | 22.x LTS | Website (Gatsby) |
438460
| PowerShell | 7+ | PowerShell scripts |
439461
| Python | 3.9+ | Python compiler |
440462
| Rust | 1.85+ | Rust compiler (install via rustup) |
@@ -445,6 +467,7 @@ GitHub Actions workflows validate:
445467

446468
- **Main filter list**: `rules/adguard_user_filter.txt`
447469
- **Compiler configs**: `src/rules-compiler-*/`
470+
- **Deno configs**: `src/*/deno.json`
448471
- **OpenAPI spec**: `api/openapi.yaml`
449472
- **Docker config**: `Dockerfile.warp`, `docker-compose.yml`, `.dockerignore`
450473
- **Documentation**: `docs/`

src/adguard-api-typescript/bunfig.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)