Skip to content

Commit fd6856d

Browse files
committed
release: 1.11.0
1 parent b7e5a4e commit fd6856d

File tree

10 files changed

+494
-94
lines changed

10 files changed

+494
-94
lines changed

CHANGELOG.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.11.0] - 2025-12-03
11+
1012
### Added
1113

14+
- **File Exclusion Feature**: New `--exclude` flag for filtering files using glob patterns
15+
- Support for simple wildcards (`*.map`, `*.txt`) and directory patterns (`test/**/*.js`)
16+
- Multiple pattern formats: repeated flags (`--exclude *.map --exclude *.md`) and comma-separated (`--exclude="*.map,*.md"`)
17+
- Default exclusions for common system and development files (`.DS_Store`, `Thumbs.db`, `.git`, `.svn`, `*.swp`, `*~`, `.gitignore`, `.gitattributes`)
18+
- Cyan-colored console output showing excluded file count and list
19+
- Cross-platform path normalization for Windows compatibility
20+
- Uses `picomatch` library (transitive dependency via `tinyglobby`) for pattern matching
1221
- Unit testing infrastructure using Vitest
13-
- Comprehensive test coverage (~68%) for core modules:
14-
- `commandLine.ts` (84.56%): CLI argument parsing and validation
15-
- `file.ts` (100%): File operations and duplicate detection
22+
- Comprehensive test coverage (~72%) for core modules:
23+
- `commandLine.ts` (~90%): CLI argument parsing and validation including exclude patterns
24+
- `file.ts` (100%): File operations, duplicate detection, and exclusion filtering
1625
- `cppCode.ts` (96.62%): C++ code generation and templates
17-
- `consoleColor.ts` (100%): Console utilities
26+
- `consoleColor.ts` (100%): Console utilities including new `cyanLog` function
27+
- 15 new unit tests for file exclusion feature (8 for CLI parsing, 7 for exclusion logic)
1828
- Test fixtures for validating file processing
1929
- Coverage reports with HTML output
20-
- Development documentation for testing in README.md and CLAUDE.md
30+
- `cyanLog()` color function for exclusion output messages
2131

2232
### Changed
2333

34+
- Updated file collection pipeline to filter excluded files after pre-compressed detection
35+
- Enhanced `commandLine.ts` with exclude pattern parsing for three argument formats
36+
- Enhanced `file.ts` with `isExcluded()` function and exclusion reporting
2437
- Updated `.gitignore` to exclude `coverage/` directory
25-
- Enhanced documentation with testing sections
38+
- Enhanced documentation with testing sections and comprehensive file exclusion guide
39+
- Updated README.md with file exclusion section including usage examples, pattern syntax, and default exclusions
40+
- Updated CLAUDE.md with technical file exclusion implementation details and example output
2641

2742
## [1.10.0] - 2025-11-20
2843

@@ -251,6 +266,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
251266
- CLI interface with `-s`, `-e`, `-o` options
252267
- `index.html` automatic default route handling
253268

269+
[1.11.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.10.0...v1.11.0
254270
[1.10.0]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.9.4...v1.10.0
255271
[1.9.4]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.9.3...v1.9.4
256272
[1.9.3]: https://github.com/BCsabaEngine/svelteesp32/compare/v1.9.2...v1.9.3

CLAUDE.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ npx svelteesp32 -e espidf -s ./dist -o ./output.h --etag=true --gzip=true
7575

7676
# Test the CLI directly using tsx (for development)
7777
npx tsx src/index.ts -e psychic -s ./demo/svelte/dist -o ./output.h --etag=true --gzip=true
78+
79+
# Generate header with file exclusions
80+
npx svelteesp32 -e psychic -s ./dist -o ./output.h --exclude="*.map" --exclude="*.md"
7881
```
7982

8083
## Architecture
@@ -90,7 +93,7 @@ npx tsx src/index.ts -e psychic -s ./demo/svelte/dist -o ./output.h --etag=true
9093

9194
### Processing Pipeline
9295

93-
1. **File Collection** (`src/file.ts`): Scans source directory recursively using glob, skips pre-compressed files (.gz, .br) if originals exist, detects duplicate files via SHA256 hashing
96+
1. **File Collection** (`src/file.ts`): Scans source directory recursively using glob, skips pre-compressed files (.gz, .br) if originals exist, filters files matching exclude patterns, detects duplicate files via SHA256 hashing
9497
2. **Content Analysis** (`src/index.ts`): Determines MIME types using `mime-types` library, calculates MD5 hashes for ETag generation, groups files by extension for statistics
9598
3. **Compression** (`src/index.ts`): Applies gzip level 9 compression, uses compressed version only when size reduction >15% and original >1024 bytes
9699
4. **Code Generation** (`src/cppCode.ts`, `src/cppCodeEspIdf.ts`): Uses Handlebars templates with custom helpers (switch/case), generates optimized engine-specific C++ code with:
@@ -112,11 +115,58 @@ npx tsx src/index.ts -e psychic -s ./demo/svelte/dist -o ./output.h --etag=true
112115
- **Automatic Gzip Compression**: Compresses assets when size reduction >15% and >1024 bytes
113116
- **ETag Support**: HTTP cache validation for reduced network traffic with 304 Not Modified responses across all engines (psychic, psychic2, async, espidf)
114117
- **Cache Control**: Configurable browser caching with `--cachetime`
118+
- **File Exclusion**: Exclude unwanted files using glob patterns with `--exclude` option
115119
- **Multi-Engine Support**: Generate code for different ESP web server libraries
116120
- **File Type Analysis**: Groups files by extension with count statistics
117121
- **Memory Optimization**: Binary data stored as const arrays in program memory
118122
- **Optimized C++ Code**: Generated code uses modern C++ best practices with minimal overhead
119123

124+
### File Exclusion
125+
126+
The tool supports flexible file exclusion using glob patterns to filter out unwanted files from being embedded in the ESP32 firmware.
127+
128+
**Pattern Support:**
129+
130+
- Simple wildcards: `*.map`, `*.txt`
131+
- Directory patterns: `test/**/*.js`, `docs/**/*`
132+
- Specific files: `.DS_Store`, `README.md`
133+
134+
**Multiple Patterns:**
135+
136+
- Repeated flag: `--exclude *.map --exclude *.md`
137+
- Comma-separated: `--exclude="*.map,*.md,*.txt"`
138+
- Combined: Both formats can be mixed
139+
140+
**Default Exclusions:**
141+
System and development files are excluded by default:
142+
143+
- `.DS_Store`, `Thumbs.db` (system files)
144+
- `.git`, `.svn` (version control)
145+
- `*.swp`, `*~` (editor files)
146+
- `.gitignore`, `.gitattributes` (git config)
147+
148+
**Implementation:**
149+
150+
- Uses `picomatch` library (transitive dependency via `tinyglobby`)
151+
- Filtering occurs after pre-compressed file detection but before file content reading
152+
- Excluded files are logged with count and list for verification
153+
- Windows path normalization for cross-platform consistency
154+
155+
**Example Output:**
156+
157+
```
158+
Collecting source files
159+
160+
Excluded 3 file(s):
161+
- assets/index.js.map
162+
- README.md
163+
- test/unit.test.js
164+
165+
Translation to header file
166+
[index.html] ✓ gzip used (472 -> 308 = 65%)
167+
...
168+
```
169+
120170
## Development Environment
121171

122172
### Build System

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,71 @@ At the same time, it can be an advantage that the content is cached by the brows
303303

304304
Typically, the entry point for web applications is the **index.htm or index.html** file. This does not need to be listed in the browser's address bar because web servers know that this file should be served by default. Svelteesp32 also does this: if there is an index.htm or index.html file, it sets it as the main file to be served. So using `http://esp_xxx.local` or just entering the `http://x.y.w.z/` IP address will serve this main file.
305305

306+
### File Exclusion
307+
308+
The `--exclude` option allows you to exclude files from being embedded in the ESP32 firmware using glob patterns. This is useful for excluding source maps, documentation, and test files that shouldn't be part of the deployed application.
309+
310+
#### Basic Usage
311+
312+
```bash
313+
# Exclude source maps
314+
npx svelteesp32 -e psychic -s ./dist -o ./output.h --exclude="*.map"
315+
316+
# Exclude documentation files
317+
npx svelteesp32 -e psychic -s ./dist -o ./output.h --exclude="*.md"
318+
319+
# Exclude multiple file types (comma-separated)
320+
npx svelteesp32 -e psychic -s ./dist -o ./output.h --exclude="*.map,*.md,*.txt"
321+
322+
# Exclude using multiple flags
323+
npx svelteesp32 -e psychic -s ./dist -o ./output.h --exclude="*.map" --exclude="*.md"
324+
325+
# Exclude entire directories
326+
npx svelteesp32 -e psychic -s ./dist -o ./output.h --exclude="test/**/*"
327+
328+
# Combine multiple approaches
329+
npx svelteesp32 -e psychic -s ./dist -o ./output.h --exclude="*.map,*.md" --exclude="docs/**/*"
330+
```
331+
332+
#### Pattern Syntax
333+
334+
The exclude patterns use standard glob syntax:
335+
336+
- `*.map` - Match all files ending with `.map`
337+
- `**/*.test.js` - Match all `.test.js` files in any directory
338+
- `test/**/*` - Match all files in the `test` directory and subdirectories
339+
- `.DS_Store` - Match specific filename
340+
341+
#### Default Exclusions
342+
343+
By default, the following system and development files are automatically excluded:
344+
345+
- `.DS_Store` (macOS system file)
346+
- `Thumbs.db` (Windows thumbnail cache)
347+
- `.git` (Git directory)
348+
- `.svn` (SVN directory)
349+
- `*.swp` (Vim swap files)
350+
- `*~` (Backup files)
351+
- `.gitignore` (Git ignore file)
352+
- `.gitattributes` (Git attributes file)
353+
354+
Custom exclude patterns are added to these defaults.
355+
356+
#### Exclusion Output
357+
358+
When files are excluded, you'll see a summary in the build output:
359+
360+
```
361+
Excluded 5 file(s):
362+
- assets/index.js.map
363+
- assets/vendor.js.map
364+
- README.md
365+
- docs/guide.md
366+
- test/unit.test.js
367+
```
368+
369+
This helps you verify that the correct files are being excluded from your build.
370+
306371
### C++ defines
307372

308373
To make it easy to integrate into a larger c++ project, we have made a couple of variables available as c++ defines.
@@ -352,6 +417,7 @@ You can use the following c++ directives at the project level if you want to con
352417
| `-s` | **Source dist folder contains compiled web files** | (required) |
353418
| `-e` | The engine for which the include file is created (psychic/psychic2/async/espidf) | psychic |
354419
| `-o` | Generated output file with path | `svelteesp32.h` |
420+
| `--exclude` | Exclude files matching glob pattern (repeatable or comma-separated) | Default system files |
355421
| `--etag` | Use ETag header for cache (true/false/compiler) | false |
356422
| `--cachetime` | Override no-cache response with a max-age=\<cachetime\> response (seconds) | 0 |
357423
| `--gzip` | Compress content with gzip (true/false/compiler) | true |

0 commit comments

Comments
 (0)