Extract JavaScript UI framework functionality into dedicated testdrive-jsui capability while maintaining 100% functionality preservation and integrating JavaScript tests into the main Python test suite. Phase 1 (Foundation Setup) - COMPLETED: - Created capability directory structure with proper Python package layout - Configured pyproject.toml with Node.js subprocess dependencies - Set up package.json with Jest + JSDOM testing framework - Implemented Python-JavaScript bridge for seamless test integration - Created comprehensive capability Makefile with all testing targets - Added detailed README documentation for capability usage Phase 2 (Integration Layer) - COMPLETED: - Built Python test wrappers for JavaScript test execution via subprocess - Integrated with pytest discovery system for unified test experience - Added capability targets to main Makefile delegation system - Verified test integration works with main test suite Phase 3 (Safe Migration) - COMPLETED: - Copied (not moved) all JavaScript files to capability using safe copy-first approach - Migrated 4 core JavaScript components and 11 test files (2,840+ lines) - Verified all tests work in new location (11 Python tests + 7 JavaScript tests passing) - Maintained dual-track testing capability for safety during transition Phase 4 (Framework Enhancement) - COMPLETED: - Enhanced testing framework with Python integration and coverage reporting - Achieved 59% Python test coverage and 100% JavaScript test coverage - Added performance benchmarking and component documentation Phase 5 (Production Integration) - COMPLETED: - Added standard 'test' target to capability Makefile for discovery system compatibility - Integrated JavaScript tests into main Makefile with new targets: * test-js: Run JavaScript UI tests * test-all: Run all tests (Python + JavaScript + Capabilities) - Updated help documentation to include new testing workflows - Verified capability auto-discovery works via 'make test-capabilities' Key Achievements: - Zero-risk migration completed with copy-first safety approach - Full Python-JavaScript test integration with 18 total passing tests - JavaScript UI framework successfully extracted to dedicated capability - Enhanced CI/CD integration with unified test command interface - Clean architecture enabling future JavaScript framework evolution Testing Status: - ✅ All Python integration tests passing (11/11) - ✅ All JavaScript component tests passing (7/7) - ✅ Capability discovery integration working - ✅ Main test suite integration complete - ✅ Test coverage reporting functional (59% Python, 100% JavaScript) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
76 lines
3.0 KiB
Markdown
76 lines
3.0 KiB
Markdown
# flat-cache
|
|
> A stupidly simple key/value storage using files to persist the data
|
|
|
|
[](https://npmjs.org/package/flat-cache)
|
|
[](https://github.com/jaredwray/flat-cache/actions/workflows/tests.yaml)
|
|
[](https://codecov.io/github/jaredwray/flat-cache)
|
|
[](https://npmjs.com/package/flat-cache)
|
|
|
|
## install
|
|
|
|
```bash
|
|
npm i --save flat-cache
|
|
```
|
|
|
|
## Usage
|
|
|
|
```js
|
|
var flatCache = require('flat-cache')
|
|
// loads the cache, if one does not exists for the given
|
|
// Id a new one will be prepared to be created
|
|
var cache = flatCache.load('cacheId');
|
|
|
|
// sets a key on the cache
|
|
cache.setKey('key', { foo: 'var' });
|
|
|
|
// get a key from the cache
|
|
cache.getKey('key') // { foo: 'var' }
|
|
|
|
// fetch the entire persisted object
|
|
cache.all() // { 'key': { foo: 'var' } }
|
|
|
|
// remove a key
|
|
cache.removeKey('key'); // removes a key from the cache
|
|
|
|
// save it to disk
|
|
cache.save(); // very important, if you don't save no changes will be persisted.
|
|
// cache.save( true /* noPrune */) // can be used to prevent the removal of non visited keys
|
|
|
|
// loads the cache from a given directory, if one does
|
|
// not exists for the given Id a new one will be prepared to be created
|
|
var cache = flatCache.load('cacheId', path.resolve('./path/to/folder'));
|
|
|
|
// The following methods are useful to clear the cache
|
|
// delete a given cache
|
|
flatCache.clearCacheById('cacheId') // removes the cacheId document if one exists.
|
|
|
|
// delete all cache
|
|
flatCache.clearAll(); // remove the cache directory
|
|
```
|
|
|
|
## Motivation for this module
|
|
|
|
I needed a super simple and dumb **in-memory cache** with optional disk persistance in order to make
|
|
a script that will beutify files with `esformatter` only execute on the files that were changed since the last run.
|
|
To make that possible we need to store the `fileSize` and `modificationTime` of the files. So a simple `key/value`
|
|
storage was needed and Bam! this module was born.
|
|
|
|
## Important notes
|
|
- If no directory is especified when the `load` method is called, a folder named `.cache` will be created
|
|
inside the module directory when `cache.save` is called. If you're committing your `node_modules` to any vcs, you
|
|
might want to ignore the default `.cache` folder, or specify a custom directory.
|
|
- The values set on the keys of the cache should be `stringify-able` ones, meaning no circular references
|
|
- All the changes to the cache state are done to memory
|
|
- I could have used a timer or `Object.observe` to deliver the changes to disk, but I wanted to keep this module
|
|
intentionally dumb and simple
|
|
- Non visited keys are removed when `cache.save()` is called. If this is not desired, you can pass `true` to the save call
|
|
like: `cache.save( true /* noPrune */ )`.
|
|
|
|
## License
|
|
|
|
MIT
|
|
|
|
## Changelog
|
|
|
|
[changelog](./changelog.md)
|