wexample-filestate-javascript 6.6.1__tar.gz → 6.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. wexample_filestate_javascript-6.6.3/PKG-INFO +279 -0
  2. wexample_filestate_javascript-6.6.3/README.md +261 -0
  3. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/pyproject.toml +3 -2
  4. wexample_filestate_javascript-6.6.1/PKG-INFO +0 -459
  5. wexample_filestate_javascript-6.6.1/README.md +0 -442
  6. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/__init__.py +0 -0
  7. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/config_option/__init__.py +0 -0
  8. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/config_option/biome_config_option.py +0 -0
  9. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/config_value/__init__.py +0 -0
  10. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/config_value/javascript_config_value.py +0 -0
  11. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/const/__init__.py +0 -0
  12. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/const/javascript_file.py +0 -0
  13. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/file/__init__.py +0 -0
  14. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/file/javascript_file.py +0 -0
  15. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/operation/__init__.py +0 -0
  16. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/operation/npm_package_lock_operation.py +0 -0
  17. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/option/__init__.py +0 -0
  18. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/option/javascript/__init__.py +0 -0
  19. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/option/javascript/abstract_javascript_file_content_option.py +0 -0
  20. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/option/javascript/biome_option.py +0 -0
  21. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/option/javascript/npm_package_lock_option.py +0 -0
  22. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/option/javascript_option.py +0 -0
  23. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/options_provider/__init__.py +0 -0
  24. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/options_provider/javascript_options_provider.py +0 -0
  25. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/py.typed +0 -0
  26. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/resources/__init__.py +0 -0
  27. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/resources/docker/Dockerfile.javascript-option +0 -0
  28. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/resources/docker/__init__.py +0 -0
  29. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/src/wexample_filestate_javascript/resources/docker/biome.json +0 -0
  30. {wexample_filestate_javascript-6.6.1 → wexample_filestate_javascript-6.6.3}/tests/.gitkeep +0 -0
@@ -0,0 +1,279 @@
1
+ Metadata-Version: 2.1
2
+ Name: wexample-filestate-javascript
3
+ Version: 6.6.3
4
+ Summary: Extends wexample-filestate with JavaScript targets: Biome formatting via Docker and npm package-lock.json management.
5
+ Author-Email: weeger <contact@wexample.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.10
11
+ Requires-Dist: attrs>=23.1.0
12
+ Requires-Dist: cattrs>=23.1.0
13
+ Requires-Dist: wexample-filestate>=17.1.0
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest; extra == "dev"
16
+ Requires-Dist: pytest-cov; extra == "dev"
17
+ Description-Content-Type: text/markdown
18
+
19
+ # filestate_javascript
20
+
21
+ Version: 6.6.3
22
+
23
+ `wexample-filestate-javascript` extends [wexample-filestate](https://pypi.org/project/wexample-filestate/) with two JavaScript-specific targets: it formats and lints `.js`, `.ts`, and related files through [Biome](https://biomejs.dev/) running in a managed Docker container, and it regenerates `package-lock.json` whenever the file is absent or older than `package.json`. It is for Python developers who describe JavaScript project structure with the filestate declarative model and want Biome formatting and npm lockfile freshness enforced automatically during the rectify cycle.
24
+
25
+ ## Table of Contents
26
+
27
+ - [Installation](#installation)
28
+ - [Quickstart](#quickstart)
29
+ - [Tests](#tests)
30
+ - [Architecture](#architecture)
31
+ - [Integration in the Suite](#integration-in-the-suite)
32
+ - [Dependencies](#dependencies)
33
+ - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
34
+ - [License](#license)
35
+ - [About us](#about-us)
36
+ - [Known Limitations & Roadmap](#known-limitations--roadmap)
37
+ - [Status & Compatibility](#status--compatibility)
38
+ - [Useful Links](#useful-links)
39
+ - [Migration Notes](#migration-notes)
40
+
41
+ ## Installation
42
+
43
+ ```bash
44
+ pip install wexample-filestate-javascript
45
+ ```
46
+
47
+ Requires Python >=3.10.
48
+
49
+ ## Quickstart
50
+
51
+ Install with pip:
52
+
53
+ ```bash
54
+ pip install wexample-filestate-javascript
55
+ ```
56
+
57
+ The package extends `wexample-filestate` through `JavascriptOptionsProvider`. Pass it when constructing your filestate tree so the framework discovers the `javascript` option key.
58
+
59
+ ```python
60
+ from wexample_filestate_javascript.options_provider.javascript_options_provider import JavascriptOptionsProvider
61
+ ```
62
+
63
+ Declare the `javascript` key on any target in your filestate config. It accepts a dict of sub-options or a plain list of sub-option names.
64
+
65
+ **Biome formatting** — set `biome: True` on a file or directory target:
66
+
67
+ ```python
68
+ {
69
+ "path": "/path/to/project",
70
+ "javascript": {"biome": True},
71
+ }
72
+ ```
73
+
74
+ On the rectify cycle the package builds and starts a Docker container from src/wexample_filestate_javascript/resources/docker/Dockerfile.javascript-option (`node:20-alpine` with `@biomejs/biome` installed globally). It then calls `biome format --write` against the target's `.js`, `.ts`, `.jsx`, and `.tsx` files in chunks of 30, using the Biome configuration baked into src/wexample_filestate_javascript/resources/docker/biome.json (2-space indent, line width 100, single quotes, semicolons always, trailing commas ES5, linter recommended rules plus `useConst: error`). Generated files — those ending in `.gen.ts`, `.generated.ts`, named `next-env.d.ts`, `vite-env.d.ts`, or located under `/__generated__/` — are skipped silently.
75
+
76
+ **npm lockfile freshness** — set `npm_package_lock: True` on a directory target that contains `package.json`:
77
+
78
+ ```python
79
+ {
80
+ "path": "/path/to/js-project",
81
+ "javascript": {"npm_package_lock": True},
82
+ }
83
+ ```
84
+
85
+ The operation runs only when `package-lock.json` is absent or its modification time is older than `package.json`. When it fires it deletes the stale lockfile and runs `npm install --package-lock-only --ignore-scripts --prefer-online` directly on the host in the target directory, writing a fresh `package-lock.json`.
86
+
87
+ Both options can be combined in a single declaration:
88
+
89
+ ```python
90
+ {
91
+ "path": "/path/to/js-project",
92
+ "javascript": {"biome": True, "npm_package_lock": True},
93
+ }
94
+ ```
95
+
96
+ ## Tests
97
+
98
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
99
+
100
+ ### Installation
101
+
102
+ First, install the required testing dependencies:
103
+ ```bash
104
+ .venv/bin/python -m pip install pytest pytest-cov
105
+ ```
106
+
107
+ ### Basic Usage
108
+
109
+ Run all tests with coverage:
110
+ ```bash
111
+ .venv/bin/python -m pytest --cov --cov-report=html
112
+ ```
113
+
114
+ ### Common Commands
115
+ ```bash
116
+ # Run tests with coverage for a specific module
117
+ .venv/bin/python -m pytest --cov=your_module
118
+
119
+ # Show which lines are not covered
120
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
121
+
122
+ # Generate an HTML coverage report
123
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
124
+
125
+ # Combine terminal and HTML reports
126
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
127
+
128
+ # Run specific test file with coverage
129
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
130
+ ```
131
+
132
+ ### Viewing HTML Reports
133
+
134
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
135
+
136
+ ### Coverage Threshold
137
+
138
+ To enforce a minimum coverage percentage:
139
+ ```bash
140
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
141
+ ```
142
+
143
+ This will cause the test suite to fail if coverage drops below 80%.
144
+
145
+ ## Architecture
146
+
147
+ The package extends `wexample-filestate` with two JavaScript-specific behaviours: formatting and linting `.js`/`.ts` files through [Biome](https://biomejs.dev/) running in a managed Docker container, and regenerating `package-lock.json` whenever it is absent or older than `package.json`. Everything in the package lives under `src/wexample_filestate_javascript/`.
148
+
149
+ ### Parts
150
+
151
+ **Entry point — options provider**
152
+
153
+ src/wexample_filestate_javascript/options_provider/javascript_options_provider.py is the package's registration point. `JavascriptOptionsProvider` extends `AbstractOptionsProvider`, advertises a single top-level option (`JavascriptOption`), and forwards the Docker image name from `AbstractJavascriptFileContentOption.DOCKER_IMAGE_NAME`.
154
+
155
+ **File type**
156
+
157
+ src/wexample_filestate_javascript/file/javascript_file.py defines `JavascriptFile`, which extends `ItemTargetFile` and sets `EXTENSION_ENV = "js"`. It owns the extension assertion; nothing else does.
158
+
159
+ **Top-level option**
160
+
161
+ src/wexample_filestate_javascript/option/javascript_option.py defines `JavascriptOption`, a `@base_class`-decorated `AbstractNestedConfigOption`. Its `get_allowed_options` returns `[BiomeOption, NpmPackageLockOption]`, making it a pure dispatcher: it accepts the raw value (list or dict), normalises a plain list to a dict, then delegates `create_required_operation` to `_create_child_required_operation`.
162
+
163
+ **Typed config value and config-option name**
164
+
165
+ src/wexample_filestate_javascript/config_value/javascript_config_value.py provides `JavascriptConfigValue`, a `ConfigValue` subclass with a single typed field `biome: bool | None`. Its `to_option_raw_value` converts that field to `{"biome": self.biome}`, bridging the typed API to the string-keyed option dispatch.
166
+
167
+ src/wexample_filestate_javascript/config_option/biome_config_option.py provides the canonical name string `"biome"` used as that key.
168
+
169
+ **File extension constants**
170
+
171
+ src/wexample_filestate_javascript/const/javascript_file.py collects `JAVASCRIPT_FILE_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]` and `JAVASCRIPT_FILE_EXTENSION = ".js"` in one place.
172
+
173
+ **Docker base for file-content options**
174
+
175
+ src/wexample_filestate_javascript/option/javascript/abstract_javascript_file_content_option.py defines `AbstractJavascriptFileContentOption`, which extends both `WithBatchDockerOptionMixin` and `AbstractFileContentOption`. It sets `DOCKER_IMAGE_NAME = "javascript-option"` and returns the path to src/wexample_filestate_javascript/resources/docker/Dockerfile.javascript-option via `_get_dockerfile_path`. Concrete options inherit this class to run inside that container.
176
+
177
+ **Biome option**
178
+
179
+ src/wexample_filestate_javascript/option/javascript/biome_option.py defines `BiomeOption`. `_is_excluded_from_batch` silently skips generated files (`.gen.ts`, `.generated.ts`, `next-env.d.ts`, paths under `/__generated__/`, etc.) to avoid non-idempotent output on large codegen trees. `_run_batch_on_paths` sends paths to the container in chunks of 30 (`_BATCH_CHUNK_SIZE = 30`) to avoid OOM kills, calling `biome format --write --config-path=/tmp/biome.json` per chunk. `_apply_content_change` reads the result from the batch cache built by that run.
180
+
181
+ **Npm package-lock option**
182
+
183
+ src/wexample_filestate_javascript/option/javascript/npm_package_lock_option.py defines `NpmPackageLockOption`. `create_required_operation` returns `None` immediately if the option value is false/none, if `package.json` is absent, or if `package-lock.json` already exists and its mtime is at least as recent as `package.json`. Otherwise it returns a `NpmPackageLockOperation`.
184
+
185
+ **Npm package-lock operation**
186
+
187
+ src/wexample_filestate_javascript/operation/npm_package_lock_operation.py defines `NpmPackageLockOperation`. `apply_operation` deletes any stale lockfile then runs `npm install --package-lock-only --ignore-scripts --prefer-online` in the package directory on the host (no Docker). `undo` is a no-op because lockfile creation is not reversible automatically.
188
+
189
+ **Docker resources**
190
+
191
+ src/wexample_filestate_javascript/resources/docker/Dockerfile.javascript-option builds the `javascript-option` image: `node:20-alpine` with `@biomejs/biome` installed globally, and src/wexample_filestate_javascript/resources/docker/biome.json copied to `/tmp/biome.json`. The container runs as UID/GID 1000 and stays alive with `tail -f /dev/null`.
192
+
193
+ src/wexample_filestate_javascript/resources/docker/biome.json configures Biome: formatter enabled with 2-space indent and line width 100, single quotes, semicolons always, trailing commas ES5; linter enabled with the recommended rule set plus `useConst: error` and `noUnusedVariables: warn`.
194
+
195
+ ### Call path: Biome formatting
196
+
197
+ 1. A filestate config declares `javascript: {biome: true}` for a target.
198
+ 2. `JavascriptOptionsProvider.get_options` surfaces `JavascriptOption`.
199
+ 3. `JavascriptOption.set_value` normalises the raw value; `get_allowed_options` routes it to `BiomeOption`.
200
+ 4. On the rectify cycle, `BiomeOption.create_required_operation` (via `AbstractFileContentOption`) collects all matching target paths, filters out generated files through `_is_excluded_from_batch`, and builds a batch operation.
201
+ 5. The batch operation calls `_run_batch_on_paths`, which calls `_ensure_docker_container` (building the `javascript-option` image from `Dockerfile.javascript-option` if it does not exist) and then runs `biome format --write` inside the container for each chunk of up to 30 paths.
202
+ 6. `_apply_content_change` reads back the formatted content from the in-memory cache populated by step 5.
203
+
204
+ ### Call path: npm package-lock
205
+
206
+ 1. A filestate config declares `npm_package_lock: true` for a directory target.
207
+ 2. `JavascriptOption.get_allowed_options` routes it to `NpmPackageLockOption`.
208
+ 3. `NpmPackageLockOption.create_required_operation` checks: is the option enabled? Does `package.json` exist? Is `package-lock.json` absent or older than `package.json`? If all conditions pass it returns a `NpmPackageLockOperation`.
209
+ 4. `NpmPackageLockOperation.apply_operation` deletes any stale lockfile and runs `npm install --package-lock-only --ignore-scripts --prefer-online` in the target directory directly on the host.
210
+
211
+ ## Integration in the Suite
212
+
213
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
214
+
215
+ ### Related Packages
216
+
217
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
218
+
219
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
220
+
221
+ ## Dependencies
222
+
223
+ - attrs: >=23.1.0
224
+ - cattrs: >=23.1.0
225
+ - wexample-filestate: >=17.1.0
226
+
227
+ ## Versioning & Compatibility Policy
228
+
229
+ Wexample packages follow **Semantic Versioning** (SemVer):
230
+
231
+ - **MAJOR**: Breaking changes
232
+ - **MINOR**: New features, backward compatible
233
+ - **PATCH**: Bug fixes, backward compatible
234
+
235
+ We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
236
+
237
+ ## License
238
+
239
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
240
+
241
+ Free to use in both personal and commercial projects.
242
+
243
+ ## About us
244
+
245
+ [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
246
+
247
+ This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
248
+
249
+ Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
250
+
251
+ ## Known Limitations & Roadmap
252
+
253
+ Current limitations and planned features are tracked in the GitHub issues.
254
+
255
+ See the [project roadmap](https://github.com/wexample/python-filestate_javascript/issues) for upcoming features and improvements.
256
+
257
+ ## Status & Compatibility
258
+
259
+ **Maturity**: Production-ready
260
+
261
+ **Python Support**: >=3.10
262
+
263
+ **OS Support**: Linux, macOS, Windows
264
+
265
+ **Status**: Actively maintained
266
+
267
+ ## Useful Links
268
+
269
+ - **Homepage**: https://github.com/wexample/python-filestate-javascript
270
+ - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
271
+ - **Issue Tracker**: https://github.com/wexample/python-filestate-javascript/issues
272
+ - **Discussions**: https://github.com/wexample/python-filestate-javascript/discussions
273
+ - **PyPI**: [pypi.org/project/wexample-filestate-javascript](https://pypi.org/project/wexample-filestate-javascript/)
274
+
275
+ ## Migration Notes
276
+
277
+ When upgrading between major versions, refer to the migration guides in the documentation.
278
+
279
+ Breaking changes are clearly documented with upgrade paths and examples.
@@ -0,0 +1,261 @@
1
+ # filestate_javascript
2
+
3
+ Version: 6.6.3
4
+
5
+ `wexample-filestate-javascript` extends [wexample-filestate](https://pypi.org/project/wexample-filestate/) with two JavaScript-specific targets: it formats and lints `.js`, `.ts`, and related files through [Biome](https://biomejs.dev/) running in a managed Docker container, and it regenerates `package-lock.json` whenever the file is absent or older than `package.json`. It is for Python developers who describe JavaScript project structure with the filestate declarative model and want Biome formatting and npm lockfile freshness enforced automatically during the rectify cycle.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Quickstart](#quickstart)
11
+ - [Tests](#tests)
12
+ - [Architecture](#architecture)
13
+ - [Integration in the Suite](#integration-in-the-suite)
14
+ - [Dependencies](#dependencies)
15
+ - [Versioning & Compatibility Policy](#versioning--compatibility-policy)
16
+ - [License](#license)
17
+ - [About us](#about-us)
18
+ - [Known Limitations & Roadmap](#known-limitations--roadmap)
19
+ - [Status & Compatibility](#status--compatibility)
20
+ - [Useful Links](#useful-links)
21
+ - [Migration Notes](#migration-notes)
22
+
23
+ ## Installation
24
+
25
+ ```bash
26
+ pip install wexample-filestate-javascript
27
+ ```
28
+
29
+ Requires Python >=3.10.
30
+
31
+ ## Quickstart
32
+
33
+ Install with pip:
34
+
35
+ ```bash
36
+ pip install wexample-filestate-javascript
37
+ ```
38
+
39
+ The package extends `wexample-filestate` through `JavascriptOptionsProvider`. Pass it when constructing your filestate tree so the framework discovers the `javascript` option key.
40
+
41
+ ```python
42
+ from wexample_filestate_javascript.options_provider.javascript_options_provider import JavascriptOptionsProvider
43
+ ```
44
+
45
+ Declare the `javascript` key on any target in your filestate config. It accepts a dict of sub-options or a plain list of sub-option names.
46
+
47
+ **Biome formatting** — set `biome: True` on a file or directory target:
48
+
49
+ ```python
50
+ {
51
+ "path": "/path/to/project",
52
+ "javascript": {"biome": True},
53
+ }
54
+ ```
55
+
56
+ On the rectify cycle the package builds and starts a Docker container from src/wexample_filestate_javascript/resources/docker/Dockerfile.javascript-option (`node:20-alpine` with `@biomejs/biome` installed globally). It then calls `biome format --write` against the target's `.js`, `.ts`, `.jsx`, and `.tsx` files in chunks of 30, using the Biome configuration baked into src/wexample_filestate_javascript/resources/docker/biome.json (2-space indent, line width 100, single quotes, semicolons always, trailing commas ES5, linter recommended rules plus `useConst: error`). Generated files — those ending in `.gen.ts`, `.generated.ts`, named `next-env.d.ts`, `vite-env.d.ts`, or located under `/__generated__/` — are skipped silently.
57
+
58
+ **npm lockfile freshness** — set `npm_package_lock: True` on a directory target that contains `package.json`:
59
+
60
+ ```python
61
+ {
62
+ "path": "/path/to/js-project",
63
+ "javascript": {"npm_package_lock": True},
64
+ }
65
+ ```
66
+
67
+ The operation runs only when `package-lock.json` is absent or its modification time is older than `package.json`. When it fires it deletes the stale lockfile and runs `npm install --package-lock-only --ignore-scripts --prefer-online` directly on the host in the target directory, writing a fresh `package-lock.json`.
68
+
69
+ Both options can be combined in a single declaration:
70
+
71
+ ```python
72
+ {
73
+ "path": "/path/to/js-project",
74
+ "javascript": {"biome": True, "npm_package_lock": True},
75
+ }
76
+ ```
77
+
78
+ ## Tests
79
+
80
+ This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.
81
+
82
+ ### Installation
83
+
84
+ First, install the required testing dependencies:
85
+ ```bash
86
+ .venv/bin/python -m pip install pytest pytest-cov
87
+ ```
88
+
89
+ ### Basic Usage
90
+
91
+ Run all tests with coverage:
92
+ ```bash
93
+ .venv/bin/python -m pytest --cov --cov-report=html
94
+ ```
95
+
96
+ ### Common Commands
97
+ ```bash
98
+ # Run tests with coverage for a specific module
99
+ .venv/bin/python -m pytest --cov=your_module
100
+
101
+ # Show which lines are not covered
102
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing
103
+
104
+ # Generate an HTML coverage report
105
+ .venv/bin/python -m pytest --cov=your_module --cov-report=html
106
+
107
+ # Combine terminal and HTML reports
108
+ .venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html
109
+
110
+ # Run specific test file with coverage
111
+ .venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
112
+ ```
113
+
114
+ ### Viewing HTML Reports
115
+
116
+ After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.
117
+
118
+ ### Coverage Threshold
119
+
120
+ To enforce a minimum coverage percentage:
121
+ ```bash
122
+ .venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
123
+ ```
124
+
125
+ This will cause the test suite to fail if coverage drops below 80%.
126
+
127
+ ## Architecture
128
+
129
+ The package extends `wexample-filestate` with two JavaScript-specific behaviours: formatting and linting `.js`/`.ts` files through [Biome](https://biomejs.dev/) running in a managed Docker container, and regenerating `package-lock.json` whenever it is absent or older than `package.json`. Everything in the package lives under `src/wexample_filestate_javascript/`.
130
+
131
+ ### Parts
132
+
133
+ **Entry point — options provider**
134
+
135
+ src/wexample_filestate_javascript/options_provider/javascript_options_provider.py is the package's registration point. `JavascriptOptionsProvider` extends `AbstractOptionsProvider`, advertises a single top-level option (`JavascriptOption`), and forwards the Docker image name from `AbstractJavascriptFileContentOption.DOCKER_IMAGE_NAME`.
136
+
137
+ **File type**
138
+
139
+ src/wexample_filestate_javascript/file/javascript_file.py defines `JavascriptFile`, which extends `ItemTargetFile` and sets `EXTENSION_ENV = "js"`. It owns the extension assertion; nothing else does.
140
+
141
+ **Top-level option**
142
+
143
+ src/wexample_filestate_javascript/option/javascript_option.py defines `JavascriptOption`, a `@base_class`-decorated `AbstractNestedConfigOption`. Its `get_allowed_options` returns `[BiomeOption, NpmPackageLockOption]`, making it a pure dispatcher: it accepts the raw value (list or dict), normalises a plain list to a dict, then delegates `create_required_operation` to `_create_child_required_operation`.
144
+
145
+ **Typed config value and config-option name**
146
+
147
+ src/wexample_filestate_javascript/config_value/javascript_config_value.py provides `JavascriptConfigValue`, a `ConfigValue` subclass with a single typed field `biome: bool | None`. Its `to_option_raw_value` converts that field to `{"biome": self.biome}`, bridging the typed API to the string-keyed option dispatch.
148
+
149
+ src/wexample_filestate_javascript/config_option/biome_config_option.py provides the canonical name string `"biome"` used as that key.
150
+
151
+ **File extension constants**
152
+
153
+ src/wexample_filestate_javascript/const/javascript_file.py collects `JAVASCRIPT_FILE_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs"]` and `JAVASCRIPT_FILE_EXTENSION = ".js"` in one place.
154
+
155
+ **Docker base for file-content options**
156
+
157
+ src/wexample_filestate_javascript/option/javascript/abstract_javascript_file_content_option.py defines `AbstractJavascriptFileContentOption`, which extends both `WithBatchDockerOptionMixin` and `AbstractFileContentOption`. It sets `DOCKER_IMAGE_NAME = "javascript-option"` and returns the path to src/wexample_filestate_javascript/resources/docker/Dockerfile.javascript-option via `_get_dockerfile_path`. Concrete options inherit this class to run inside that container.
158
+
159
+ **Biome option**
160
+
161
+ src/wexample_filestate_javascript/option/javascript/biome_option.py defines `BiomeOption`. `_is_excluded_from_batch` silently skips generated files (`.gen.ts`, `.generated.ts`, `next-env.d.ts`, paths under `/__generated__/`, etc.) to avoid non-idempotent output on large codegen trees. `_run_batch_on_paths` sends paths to the container in chunks of 30 (`_BATCH_CHUNK_SIZE = 30`) to avoid OOM kills, calling `biome format --write --config-path=/tmp/biome.json` per chunk. `_apply_content_change` reads the result from the batch cache built by that run.
162
+
163
+ **Npm package-lock option**
164
+
165
+ src/wexample_filestate_javascript/option/javascript/npm_package_lock_option.py defines `NpmPackageLockOption`. `create_required_operation` returns `None` immediately if the option value is false/none, if `package.json` is absent, or if `package-lock.json` already exists and its mtime is at least as recent as `package.json`. Otherwise it returns a `NpmPackageLockOperation`.
166
+
167
+ **Npm package-lock operation**
168
+
169
+ src/wexample_filestate_javascript/operation/npm_package_lock_operation.py defines `NpmPackageLockOperation`. `apply_operation` deletes any stale lockfile then runs `npm install --package-lock-only --ignore-scripts --prefer-online` in the package directory on the host (no Docker). `undo` is a no-op because lockfile creation is not reversible automatically.
170
+
171
+ **Docker resources**
172
+
173
+ src/wexample_filestate_javascript/resources/docker/Dockerfile.javascript-option builds the `javascript-option` image: `node:20-alpine` with `@biomejs/biome` installed globally, and src/wexample_filestate_javascript/resources/docker/biome.json copied to `/tmp/biome.json`. The container runs as UID/GID 1000 and stays alive with `tail -f /dev/null`.
174
+
175
+ src/wexample_filestate_javascript/resources/docker/biome.json configures Biome: formatter enabled with 2-space indent and line width 100, single quotes, semicolons always, trailing commas ES5; linter enabled with the recommended rule set plus `useConst: error` and `noUnusedVariables: warn`.
176
+
177
+ ### Call path: Biome formatting
178
+
179
+ 1. A filestate config declares `javascript: {biome: true}` for a target.
180
+ 2. `JavascriptOptionsProvider.get_options` surfaces `JavascriptOption`.
181
+ 3. `JavascriptOption.set_value` normalises the raw value; `get_allowed_options` routes it to `BiomeOption`.
182
+ 4. On the rectify cycle, `BiomeOption.create_required_operation` (via `AbstractFileContentOption`) collects all matching target paths, filters out generated files through `_is_excluded_from_batch`, and builds a batch operation.
183
+ 5. The batch operation calls `_run_batch_on_paths`, which calls `_ensure_docker_container` (building the `javascript-option` image from `Dockerfile.javascript-option` if it does not exist) and then runs `biome format --write` inside the container for each chunk of up to 30 paths.
184
+ 6. `_apply_content_change` reads back the formatted content from the in-memory cache populated by step 5.
185
+
186
+ ### Call path: npm package-lock
187
+
188
+ 1. A filestate config declares `npm_package_lock: true` for a directory target.
189
+ 2. `JavascriptOption.get_allowed_options` routes it to `NpmPackageLockOption`.
190
+ 3. `NpmPackageLockOption.create_required_operation` checks: is the option enabled? Does `package.json` exist? Is `package-lock.json` absent or older than `package.json`? If all conditions pass it returns a `NpmPackageLockOperation`.
191
+ 4. `NpmPackageLockOperation.apply_operation` deletes any stale lockfile and runs `npm install --package-lock-only --ignore-scripts --prefer-online` in the target directory directly on the host.
192
+
193
+ ## Integration in the Suite
194
+
195
+ This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.
196
+
197
+ ### Related Packages
198
+
199
+ The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.
200
+
201
+ Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.
202
+
203
+ ## Dependencies
204
+
205
+ - attrs: >=23.1.0
206
+ - cattrs: >=23.1.0
207
+ - wexample-filestate: >=17.1.0
208
+
209
+ ## Versioning & Compatibility Policy
210
+
211
+ Wexample packages follow **Semantic Versioning** (SemVer):
212
+
213
+ - **MAJOR**: Breaking changes
214
+ - **MINOR**: New features, backward compatible
215
+ - **PATCH**: Bug fixes, backward compatible
216
+
217
+ We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.
218
+
219
+ ## License
220
+
221
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
222
+
223
+ Free to use in both personal and commercial projects.
224
+
225
+ ## About us
226
+
227
+ [Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.
228
+
229
+ This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.
230
+
231
+ Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.
232
+
233
+ ## Known Limitations & Roadmap
234
+
235
+ Current limitations and planned features are tracked in the GitHub issues.
236
+
237
+ See the [project roadmap](https://github.com/wexample/python-filestate_javascript/issues) for upcoming features and improvements.
238
+
239
+ ## Status & Compatibility
240
+
241
+ **Maturity**: Production-ready
242
+
243
+ **Python Support**: >=3.10
244
+
245
+ **OS Support**: Linux, macOS, Windows
246
+
247
+ **Status**: Actively maintained
248
+
249
+ ## Useful Links
250
+
251
+ - **Homepage**: https://github.com/wexample/python-filestate-javascript
252
+ - **Documentation**: [docs.wexample.com](https://docs.wexample.com)
253
+ - **Issue Tracker**: https://github.com/wexample/python-filestate-javascript/issues
254
+ - **Discussions**: https://github.com/wexample/python-filestate-javascript/discussions
255
+ - **PyPI**: [pypi.org/project/wexample-filestate-javascript](https://pypi.org/project/wexample-filestate-javascript/)
256
+
257
+ ## Migration Notes
258
+
259
+ When upgrading between major versions, refer to the migration guides in the documentation.
260
+
261
+ Breaking changes are clearly documented with upgrade paths and examples.
@@ -6,7 +6,8 @@ build-backend = "pdm.backend"
6
6
 
7
7
  [project]
8
8
  name = "wexample-filestate-javascript"
9
- version = "6.6.1"
9
+ version = "6.6.3"
10
+ description = "Extends wexample-filestate with JavaScript targets: Biome formatting via Docker and npm package-lock.json management."
10
11
  authors = [
11
12
  { name = "weeger", email = "contact@wexample.com" },
12
13
  ]
@@ -19,7 +20,7 @@ classifiers = [
19
20
  dependencies = [
20
21
  "attrs>=23.1.0",
21
22
  "cattrs>=23.1.0",
22
- "wexample-filestate>=16.0.0",
23
+ "wexample-filestate>=17.1.0",
23
24
  ]
24
25
 
25
26
  [project.readme]