Skip to content

Commit 74f6240

Browse files
committed
refactor: reorganize the app around DDD layers
1 parent 13f348e commit 74f6240

77 files changed

Lines changed: 1922 additions & 1083 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*.swp
22
node_modules
3+
dist
4+
coverage
35
js/compiled.js
46
css/_compiled_main.css
57
css/merged.css

README.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
[![Tests and build](https://img.shields.io/github/actions/workflow/status/ciembor/4bit/pages.yml?branch=master&label=tests%20%26%20build&style=flat-square)](https://github.com/ciembor/4bit/actions/workflows/pages.yml)
55
[![Live site](https://img.shields.io/badge/live%20site-ciembor.github.io%2F4bit-2ea44f?style=flat-square)](https://ciembor.github.io/4bit/)
6+
<!-- coverage-badge:start -->
7+
[![Coverage](https://img.shields.io/badge/coverage-95.27%25-brightgreen?style=flat-square)](#coverage)
8+
<!-- coverage-badge:end -->
69
[![License: GPL v3](https://img.shields.io/badge/license-GPLv3-blue.svg?style=flat-square)](LICENSE.md)
710
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/ciembor/4bit/pulls)
811

@@ -63,17 +66,27 @@ Useful commands:
6366
3. Build production assets with `npm run build`
6467
4. Preview the production build with `npm run preview`
6568
5. Run the test suite with `npm test`
66-
6. Run lint fixes with `npm run lint`
69+
6. Measure unit-test coverage with `npm run test:coverage`
70+
7. Refresh the README coverage badge with `npm run coverage:badge`
71+
8. Run lint fixes with `npm run lint`
6772

6873
Project structure:
6974

70-
* `src/components` - UI components
71-
* `src/stores` - Pinia stores for editable scheme state and calculated colors
72-
* `src/services` - color calculation and export logic
73-
* `src/lib/jquery.ui.colorPicker.js` - wrapped legacy color picker plugin
74-
* `src/assets/styles` - global base styles and imported third-party CSS
75+
* `src/domain` - pure scheme rules, defaults, color naming, and color-mode logic
76+
* `src/application` - synchronization/use-case layer that applies domain logic to app state
77+
* `src/infrastructure` - URL/query codecs, export serializers, browser sync, and wrapped legacy vendor code
78+
* `src/presentation` - Vue components, Pinia stores, fonts, and styles
7579
* `public` - static assets copied to the final build, including images and SEO files
7680

81+
Coverage
82+
---------
83+
84+
`npm run test:coverage` writes HTML, LCOV, and JSON summary reports to `coverage/`.
85+
86+
The coverage badge above is generated from the line coverage in `coverage/coverage-summary.json` by `npm run coverage:badge`.
87+
88+
Coverage is measured for `src/**/*.js`, excluding `src/main.js` and the vendored jQuery color picker wrapper in `src/infrastructure/vendor`.
89+
7790
Author
7891
---------
7992

package-lock.json

Lines changed: 189 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"devDependencies": {
1313
"@eslint/js": "^10.0.1",
1414
"@vitejs/plugin-vue": "^6.0.6",
15+
"@vitest/coverage-v8": "^4.1.5",
1516
"eslint": "^10.2.1",
1617
"eslint-plugin-vue": "^10.9.0",
1718
"globals": "^17.5.0",
@@ -25,6 +26,8 @@
2526
"build": "vite build",
2627
"preview": "vite preview",
2728
"test": "vitest run --pool=threads",
29+
"test:coverage": "vitest run --pool=threads --coverage",
30+
"coverage:badge": "node scripts/update-coverage-badge.mjs",
2831
"lint": "eslint src --fix"
2932
}
3033
}

scripts/update-coverage-badge.mjs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { readFileSync, writeFileSync } from 'node:fs';
2+
3+
const README_PATH = new URL('../README.md', import.meta.url);
4+
const SUMMARY_PATH = new URL('../coverage/coverage-summary.json', import.meta.url);
5+
6+
const BADGE_START = '<!-- coverage-badge:start -->';
7+
const BADGE_END = '<!-- coverage-badge:end -->';
8+
9+
function badgeColor(percentage) {
10+
if (percentage >= 90) {
11+
return 'brightgreen';
12+
}
13+
14+
if (percentage >= 80) {
15+
return 'green';
16+
}
17+
18+
if (percentage >= 70) {
19+
return 'yellowgreen';
20+
}
21+
22+
if (percentage >= 60) {
23+
return 'yellow';
24+
}
25+
26+
if (percentage >= 50) {
27+
return 'orange';
28+
}
29+
30+
return 'red';
31+
}
32+
33+
function formatPercentage(value) {
34+
return Number(value.toFixed(2)).toString();
35+
}
36+
37+
const coverageSummary = JSON.parse(readFileSync(SUMMARY_PATH, 'utf8'));
38+
const lineCoverage = Number(coverageSummary.total.lines.pct);
39+
const formattedCoverage = formatPercentage(lineCoverage);
40+
const color = badgeColor(lineCoverage);
41+
const badge = `[![Coverage](https://img.shields.io/badge/coverage-${encodeURIComponent(`${formattedCoverage}%`)}-${color}?style=flat-square)](#coverage)`;
42+
43+
const readme = readFileSync(README_PATH, 'utf8');
44+
const startIndex = readme.indexOf(BADGE_START);
45+
const endIndex = readme.indexOf(BADGE_END);
46+
47+
if (startIndex === -1 || endIndex === -1 || startIndex > endIndex) {
48+
throw new Error('Coverage badge markers not found in README.md');
49+
}
50+
51+
const updatedReadme = [
52+
readme.slice(0, startIndex + BADGE_START.length),
53+
`\n${badge}\n`,
54+
readme.slice(endIndex),
55+
].join('');
56+
57+
writeFileSync(README_PATH, updatedReadme);

0 commit comments

Comments
 (0)