Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
48cba2a
chore(deps): update Node.js version and package dependencies
devlegacy Dec 9, 2024
f3da608
refactor(commands): remove Notify imports and related log messages
devlegacy Dec 9, 2024
6341404
chore(deps): update Node.js and package dependencies to latest versions
devlegacy Dec 17, 2024
68adf70
chore(deps): update Node.js and package dependencies to latest versions
devlegacy Jan 14, 2025
95e04f0
chore(deps): update Node.js to v23.7.0 and update package dependencies
devlegacy Feb 1, 2025
9f18187
chore(deps): update @swc/core to v1.10.14 and pnpm to v10.2.0 with ov…
devlegacy Feb 4, 2025
65be6fc
chore(deps): update Node.js to v23.9.0 and update package dependencies
devlegacy Mar 1, 2025
cc0ec82
chore(deps): bump dependencies
devlegacy Apr 23, 2025
aa5e6e0
fix: remove redundant command installation before parsing
devlegacy Apr 24, 2025
0978122
chore(deps): update @swc/core to v1.11.22
devlegacy Apr 24, 2025
cc1903e
feat(commands): improve scaffold
devlegacy Jul 15, 2025
7b14833
feat(cli): implement yargs for command-line argument parsing
devlegacy Jul 15, 2025
ec49d4b
refactor(dvx): reorganize imports and streamline command installation
devlegacy Jul 15, 2025
8ede1f0
feat: add utility functions for array chunking, file handling, and co…
devlegacy Jul 15, 2025
5db972b
chore(deps): bump dependencies
devlegacy Oct 18, 2025
291155a
refactor: update pnpm-workspace.yaml to use allowBuilds instead of de…
devlegacy Apr 13, 2026
85b22ba
refactor: update import paths to remove deprecated syntax and improve…
devlegacy Apr 13, 2026
3032886
feat: add static method to format file size into human-readable string
devlegacy Apr 13, 2026
f0eb536
fix: update schema URL in .swcrc for correct validation
devlegacy Apr 13, 2026
721fc58
refactor: improve logging in imageMinifier function for better clarity
devlegacy Apr 13, 2026
d03ac0f
refactor: update description formatting and correct webP converter im…
devlegacy Apr 13, 2026
43ce8b2
refactor: correct import path comment formatting in image-resize command
devlegacy Apr 13, 2026
3d727dc
refactor: correct import path formatting in image-resizer job
devlegacy Apr 13, 2026
91bba7c
refactor: correct import path formatting in image-resizer file
devlegacy Apr 13, 2026
24abf96
refactor: correct import path formatting in image-webp-converter file
devlegacy Apr 13, 2026
39598e8
refactor: update import paths and enhance SVG optimization settings
devlegacy Apr 13, 2026
adf54e3
refactor: correct import path formatting in sharp-webp-converter job
devlegacy Apr 13, 2026
5f53879
refactor: update import path for sharp-webp-converter job and format …
devlegacy Apr 13, 2026
0d98995
refactor: remove Prettier configuration files and ignore settings
devlegacy Apr 13, 2026
257d748
chore: update pnpm workspace overrides and adjust TypeScript paths
devlegacy Apr 18, 2026
b75715e
chore(deps): bump dependencies
devlegacy Apr 18, 2026
1fc73bf
refactor: streamline logger configuration and remove commented code
devlegacy Apr 18, 2026
1e5c8b0
refactor: improve type safety and logging in runWorker function
devlegacy Apr 18, 2026
fc4752f
refactor: improve import organization and enhance error logging in Dv…
devlegacy Apr 18, 2026
90c3904
refactor: enhance runWorker to return detailed WorkerResult and impro…
devlegacy Apr 18, 2026
24d77b8
refactor: reorganize imports and enhance task handling in imageMinifi…
devlegacy Apr 18, 2026
59dcfc0
refactor: improve logging and streamline argument handling in image o…
devlegacy Apr 18, 2026
f809ae2
refactor: reorganize imports and streamline command execution in imag…
devlegacy Apr 18, 2026
ba4951c
refactor: reorganize imports and initialize tasks array in imageResiz…
devlegacy Apr 18, 2026
197a3bf
refactor: reorganize imports and enhance task management in webPConve…
devlegacy Apr 18, 2026
3eaca95
chore(deps): bump dependencies
devlegacy May 13, 2026
298c50f
chore(deps): bump dependencies
devlegacy Aug 3, 2026
7a0927c
refactor: reorganize imports and improve code formatting in imagemin-…
devlegacy Aug 3, 2026
fd8d0df
refactor: remove unused imageminGiflossy import and update gif plugin…
devlegacy Aug 3, 2026
e45a5aa
refactor: update TypeScript dependencies to use scoped packages
devlegacy Aug 3, 2026
40ffa90
chore(deps): bump dependencies
devlegacy Aug 3, 2026
db2f69c
refactor: simplify glob sync implementation and improve worker exit h…
devlegacy Aug 3, 2026
40f6e54
chore(deps): bump dependencies
devlegacy Aug 4, 2026
d30924f
refactor: remove dead DvxCLI class and its orphaned helpers
devlegacy Aug 4, 2026
bc49aa2
feat!: add --quality preset flag and size-savings reporting to image …
devlegacy Aug 4, 2026
e41d649
style: apply biome asNeeded semicolons and import sorting
devlegacy Aug 4, 2026
b6a72b0
chore(release): v4.0.0 — CI on Node 24, typecheck script, docs cleanup
devlegacy Aug 4, 2026
98cfaa4
chore(deps): bump dependencies
devlegacy Sep 8, 2026
7de3b63
Merge branch 'master' into feat/improve-codebase
devlegacy Sep 8, 2026
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
10 changes: 8 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ run-name: Node.js ⬢ CI

on:
push:
branches: [develop]
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.x]
node-version: [24.x]

name: Node.js ${{ matrix.node-version }} 🚀
steps:
Expand Down Expand Up @@ -45,6 +47,10 @@ jobs:
run: |
pnpm install --frozen-lockfile

- name: Typecheck 🔎
run: |
pnpm run typecheck

- name: Run tests 🧪
run: |
make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.vscode
bin
node_modules
*.tsbuildinfo
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
save-exact=true
legacy-peer-deps=true
ignore-scripts=true #giflossy, zopflipng
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v22.5.1
v26.8.1
12 changes: 0 additions & 12 deletions .prettierignore

This file was deleted.

15 changes: 0 additions & 15 deletions .prettierrc

This file was deleted.

2 changes: 1 addition & 1 deletion .swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"$schema": "https://swc.rs/schema.json",
"jsc": {
"target": "esnext",
"parser": {
Expand Down
130 changes: 130 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

DVX CLI is a TypeScript-based command-line tool for image processing and asset optimization in frontend development. It provides utilities for image minification, format conversion, resizing, HTML validation, and CSS source map cleaning.

## Build & Development Commands

### Building the project

```bash
pnpm run build
```

This compiles TypeScript to JavaScript using SWC, outputs to `bin/` directory, and replaces import paths.

### Clean build artifacts

```bash
pnpm run build:clean
```

### Typechecking

```bash
pnpm run typecheck
```

SWC does not typecheck during build — run this before committing. CI runs it too.

### Running tests

```bash
pnpm run test # Run all tests (unit + features)
pnpm run test:unit # Run only unit tests
make test # Alternative using Makefile
```

### Running a single test file

```bash
node --import @swc-node/register/esm-register --test tests/lib/file.test.ts
```

### Code formatting

```bash
# Project uses Biome for formatting and linting
# Configuration in biome.json
```

### Rebuilding native dependencies

```bash
pnpm run rebuild # Rebuild native image processing binaries
```

### Dependency management

```bash
pnpm run package:update # Update dependencies
make deps/update # Comprehensive dependency update with deduplication
```

## Code Architecture

### Entry Point

- `src/index.ts` - CLI entry: configures yargs and auto-registers commands via `.commandDir()`
- `bin/index.js` - Built entry point for the CLI binary

### Command Structure

Commands are auto-discovered from `src/commands/` (recursively) using the pattern `*.command.ts`. Each command is a module-style yargs command exporting `command`, `description`, `builder`, and `handler`. Handlers must return/await their promise so yargs waits for completion.

Available command categories:

- **Images**: `img:minify`, `img:towebp`, `img:resize`, `img:optimize` (all support `--quality high|medium|low`)
- **HTML**: `html:validate` (using HTMLHint)
- **Files**: `files:clean-sourcemaps`

### Key Directories

- `src/commands/` - Command implementations organized by category
- `src/shared/domain/` - Pure utilities (file ops, worker runner, quality presets, formatting)
- `src/shared/infrastructure/` - Side-effectful services (logger, notifications, config)
- `tests/` - Test files using Node.js native test runner
- `bin/` - Compiled output directory

### Architecture Patterns

- Module-style yargs commands loaded with `.commandDir()`
- Worker-based processing for image operations: helper (`image-minifier.ts`) chunks files per CPU and spawns a `*.job.ts` worker per chunk via `runWorker`; workers post `WorkerResult` (`processed`, `endTime`, optional `bytesIn`/`bytesOut`)
- Quality presets shared across jobs in `src/shared/domain/quality-presets.ts`

### Testing Structure

- Uses Node.js native test runner (`node:test`)
- Test files follow `*.test.ts` pattern
- Tests use `node:assert/strict` for assertions
- Test stubs in `tests/stubs/` directory

## Key Dependencies

### Runtime

- `yargs` - CLI argument parsing
- `imagemin` ecosystem - Image optimization
- `sharp` - Image processing fallback
- `htmlhint` - HTML validation

### Build

- `@swc/core` - TypeScript compilation
- `@swc/cli` - SWC command-line interface
- `@swc-node/register` - SWC Node.js loader for tests
- `replace-in-file` - Post-build path replacement

## Development Notes

- Uses ES modules (`"type": "module"` in package.json)
- Import paths use `#/` prefix that gets replaced during build
- Node.js >=24 required (`engineStrict: true`)
- Package manager: pnpm >=11
- Build target: ESNext with SWC compiler
- Code formatting with Biome (configuration in biome.json)
- Native dependencies require periodic rebuilding (`pnpm run rebuild`)
- Make targets available for common tasks (test, dependency updates)
31 changes: 26 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL:=$(shell which bash)
MAKEFLAGS += -s

current_work_directory := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
Expand All @@ -23,11 +24,31 @@ help: ## 📋 Display help message with descriptions of all available commands.
.PHONY: deps/update
.SILENT: deps/update
deps/update: ## ⬆️ Update all project dependencies to their latest versions.
$(print_message) "updating dependencies"
ncu -u && ncu --target minor -u && ncu --target patch -u
corepack up
NODE_ENV= pnpm install
NODE_ENV= pnpm audit --fix
set -eo pipefail
$(print_message) "bump dependencies"
PNPM_QUIET_FLAGS="--config.loglevel=error"
NODE_ENV= pnpm audit || true
find . -type d -name node_modules -not -path '*/.git/*' -prune -exec rm -rf '{}' +
rm -f pnpm-lock.yaml
CI=true corepack use pnpm@latest-11
if command -v ncu &>/dev/null; then
NCU_CMD=ncu
elif [ -f ./node_modules/.bin/ncu ]; then
NCU_CMD=./node_modules/.bin/ncu
else
echo "ncu (npm-check-updates) not found. Install with one of:"
echo " npm i -g npm-check-updates"
echo " pnpm add -g npm-check-updates"
echo " pnpm add -O npm-check-updates # optional/local"
exit 1
fi
$$NCU_CMD --target patch -u && $$NCU_CMD --target minor -u && $$NCU_CMD -u
NODE_ENV= pnpm install --no-frozen-lockfile $$PNPM_QUIET_FLAGS
NODE_ENV= pnpm up --recursive $$PNPM_QUIET_FLAGS
NODE_ENV= pnpm audit --fix=update $$PNPM_QUIET_FLAGS
NODE_ENV= pnpm dedupe $$PNPM_QUIET_FLAGS
NODE_ENV= pnpm rebuild @swc-node/register @swc/cli @swc/core sharp
NODE_ENV= pnpm audit --ignore-unfixable

.PHONY: test
.SILENT: test
Expand Down
12 changes: 12 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,15 @@ https://nodejs.org/api/process.html#processargv0
node ~/src/github.com/devlegacy/dvx-cli html:validate
@squoosh/lib
imagemin-svgo

bun pm untrusted
bun pm trust

pnpm approve-builds

img:minify open TODOs:

- Skip unchanged files — no mtime/hash check; reruns on already-optimized images
- Progress indicator — large batches (24+ files) have no ETA or count
- Results table — before/after per-file KB would help identify worst offenders
- exclude only filters the resizer — minifier still processes excluded patterns (inconsistent with docs)
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

<h2 align="center">📦 Install</h2>

### macOS prerequisites

Some optimizers build native binaries from source and need these libraries:

```sh
brew install libpng libimagequant
brew link libpng
```

### Global installation

To install the CLI tool globally, run the following command:
Expand Down
40 changes: 40 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://biomejs.dev/schemas/latest/schema.json",
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineEnding": "lf",
"indentWidth": 2,
"lineWidth": 120
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
},
"files": {
"ignoreUnknown": false
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded",
"trailingCommas": "all",
"expand": "always"
}
}
}
Loading
Loading