@ingenioz-it/caits 0.0.0-stage → 0.5.0

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 (92) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +36 -2
  3. package/bin/caits.js +184 -0
  4. package/bin/init.js +359 -0
  5. package/package.json +114 -4
  6. package/quality/architecture/adapters/marko.mjs +23 -0
  7. package/quality/architecture/adapters/scss.mjs +52 -0
  8. package/quality/architecture/adapters/typescript.mjs +13 -0
  9. package/quality/architecture/facts.mjs +159 -0
  10. package/quality/architecture/project.mjs +148 -0
  11. package/quality/architecture.mjs +116 -0
  12. package/quality/check.mjs +104 -0
  13. package/quality/dev.mjs +110 -0
  14. package/quality/e2e.mjs +125 -0
  15. package/quality/mutation-suite.mjs +31 -0
  16. package/quality/mutation-summary.mjs +41 -0
  17. package/quality/route-types.mjs +40 -0
  18. package/quality/test-docs/page.mjs +301 -0
  19. package/quality/test-docs/playwright-reporter.mjs +55 -0
  20. package/quality/test-docs/test-docs.mjs +180 -0
  21. package/quality/test-docs/vitest-reporter.mjs +38 -0
  22. package/src/DomainEvent.ts +4 -0
  23. package/src/Result.ts +6 -0
  24. package/src/Token.ts +8 -0
  25. package/src/di/Container.ts +123 -0
  26. package/src/di/DataDirectory.ts +6 -0
  27. package/src/di/Fetcher.ts +6 -0
  28. package/src/di/RequestContext.ts +6 -0
  29. package/src/di/backend.ts +19 -0
  30. package/src/di/createBackend.ts +106 -0
  31. package/src/di/createFrontend.ts +53 -0
  32. package/src/di/declareDependencies.js +93 -0
  33. package/src/di/discover.ts +39 -0
  34. package/src/di/discoverFrontends.ts +36 -0
  35. package/src/di/discovered.ts +6 -0
  36. package/src/di/discoveredFrontends.ts +6 -0
  37. package/src/di/frontend.ts +33 -0
  38. package/src/http/failureOf.ts +10 -0
  39. package/src/messaging/BackendEventBus.ts +60 -0
  40. package/src/messaging/ContextMap.ts +22 -0
  41. package/src/messaging/Controller.ts +109 -0
  42. package/src/messaging/EventPublisher.ts +12 -0
  43. package/src/messaging/EventSubscriber.ts +4 -0
  44. package/src/messaging/FrontendEventBus.ts +38 -0
  45. package/src/messaging/InProcessMessageBus.ts +35 -0
  46. package/src/messaging/Input.ts +4 -0
  47. package/src/messaging/MessageBus.ts +12 -0
  48. package/src/messaging/ReportError.ts +9 -0
  49. package/src/state/Loadable.ts +13 -0
  50. package/src/state/createStore.ts +45 -0
  51. package/src/state/follow.ts +7 -0
  52. package/src/state/request.ts +21 -0
  53. package/src/testing/backend/application.ts +12 -0
  54. package/src/testing/backend/applicationScenario.ts +60 -0
  55. package/src/testing/backend/applications.ts +62 -0
  56. package/src/testing/backend/context-map.ts +12 -0
  57. package/src/testing/backend/infra.ts +6 -0
  58. package/src/testing/backend/integration.ts +8 -0
  59. package/src/testing/backend/presentation.ts +14 -0
  60. package/src/testing/backend/presentationApplication.ts +25 -0
  61. package/src/testing/backend/presentationScenario.ts +47 -0
  62. package/src/testing/frontend/application.ts +12 -0
  63. package/src/testing/frontend/applicationScenario.ts +36 -0
  64. package/src/testing/frontend/applications.ts +70 -0
  65. package/src/testing/frontend/frontends.ts +28 -0
  66. package/src/testing/frontend/infra.ts +2 -0
  67. package/src/testing/frontend/marko.ts +12 -0
  68. package/src/testing/frontend/presentation.ts +7 -0
  69. package/src/testing/shared/FakeMessageBus.ts +58 -0
  70. package/src/testing/shared/tempDirectories.ts +15 -0
  71. package/src/virtual-modules.d.ts +33 -0
  72. package/src/vite.js +162 -0
  73. package/src/vite.types.d.ts +14 -0
  74. package/template/caits/architecture.mjs +467 -0
  75. package/template/caits/eslint.js +32 -0
  76. package/template/caits/marko-modules.d.ts +4 -0
  77. package/template/caits/playwright.ts +35 -0
  78. package/template/caits/stryker.mjs +20 -0
  79. package/template/caits/tsconfig.json +21 -0
  80. package/template/caits/tsconfig.mutation.json +5 -0
  81. package/template/caits/vite.ts +34 -0
  82. package/template/empty/src/routes/_frontend/+page.marko +9 -0
  83. package/template/empty/test/e2e/home.spec.ts +6 -0
  84. package/template/project/AGENTS +28 -0
  85. package/template/project/gitignore +16 -0
  86. package/template/project/nvmrc +1 -0
  87. package/template/project/quality/architecture.mjs +9 -0
  88. package/template/project/quality/eslint.config.js +6 -0
  89. package/template/project/quality/playwright.config.ts +10 -0
  90. package/template/project/quality/stryker.config.mjs +6 -0
  91. package/template/project/quality/vite.config.ts +5 -0
  92. package/template/project/tsconfig.json +4 -0
@@ -0,0 +1,6 @@
1
+ import { expect, test } from "@playwright/test";
2
+
3
+ test("Given a visitor, When they open the home page, Then it shows the name of the app", async ({ page }) => {
4
+ await page.goto("/");
5
+ await expect(page.getByRole("heading", { level: 1 })).toHaveText("My app");
6
+ });
@@ -0,0 +1,28 @@
1
+ # AGENTS.md
2
+
3
+ A CAITS project (Clean Architecture In TypeScript): a Marko app with a backend and a frontend. A harness checks every change.
4
+
5
+ ## Commands
6
+
7
+ - `npm run check`: all the checks at once: types, lint, architecture rules, unit tests (100% coverage), mutation tests (100% score), end-to-end tests. The work is done only when it passes. It prints only the output of the checks that fail.
8
+ - `npm run tdd`: the unit tests, then at each save the tests of the changed files. In an AI agent, Vitest runs them once and stops: run it again after a change.
9
+ - `npm run lint:architecture`: the architecture rules alone, fast.
10
+ - `npx caits mutation-summary --survivors`: the mutants that survived the last mutation run.
11
+
12
+ ## Where the code goes
13
+
14
+ - The business lives in bounded contexts: `src/backend/<context>/` and `src/frontend/<context>/`, each with `domain/`, `application/`, `infra/`, `presentation/` and a `di.ts`. To add one, copy the shape of an existing one.
15
+ - Domain: entities, value objects, errors, domain events, and ports (`domain/port/<port>/`), each with its contract (`<Port>.contract.ts`).
16
+ - Application: one folder per use case, `command/<use-case>/` or `query/<use-case>/`, with its DTOs, its handler and its test.
17
+ - Infra: the adapters of the ports, in `infra/<port>/`. The test of each adapter runs the contract of its port.
18
+ - Presentation: the controllers in the backend; the views and the store in the frontend.
19
+ - Dependencies point to the domain. A context imports its own files with `#context/`, never with `../`.
20
+ - `src/routes/` holds the pages and the HTTP handlers: a page places views, a handler gives the request to a controller.
21
+
22
+ ## Rules
23
+
24
+ - Write the test first. The coverage and the mutation score stay at 100%.
25
+ - A check that fails names the file and the rule: fix the code, not the rule.
26
+ - Do not change `quality/` (the rules, the thresholds, the configuration of the tools) without asking.
27
+
28
+ Documentation: https://caits.dev/docs
@@ -0,0 +1,16 @@
1
+ # Dependencies
2
+ node_modules/
3
+
4
+ # Build output
5
+ dist/
6
+ .marko-run/
7
+ tsconfig.tsbuildinfo
8
+
9
+ # Data that the app writes while it runs
10
+ tmp/
11
+
12
+ # Test, coverage and mutation output
13
+ reports/
14
+ test-results/
15
+ .stryker-tmp/
16
+ playwright-report/
@@ -0,0 +1 @@
1
+ 26
@@ -0,0 +1,9 @@
1
+ import { rules } from "./caits/architecture.mjs";
2
+
3
+ /**
4
+ * The rules of the architecture of this project, which `caits architecture` checks. They start from those of CAITS
5
+ * (quality/caits/architecture.mjs). Remove, replace or add rules here, for example:
6
+ * export default [...rules.filter(rule => rule.name !== "routes-folders"), myRule];
7
+ * A rule of your own can use what @ingenioz-it/caits/quality/architecture gives (locate, portOf…).
8
+ */
9
+ export default rules;
@@ -0,0 +1,6 @@
1
+ import caits from "./caits/eslint.js";
2
+
3
+ /** The ESLint configuration of this project: that of CAITS (quality/caits/eslint.js), then the changes of this project, which win. */
4
+ export default [
5
+ ...caits
6
+ ];
@@ -0,0 +1,10 @@
1
+ import { defineConfig } from "@playwright/test";
2
+ import caits from "./caits/playwright.ts";
3
+
4
+ /**
5
+ * The Playwright configuration of this project: that of CAITS (quality/caits/playwright.ts), with the changes of this project, which
6
+ * replace its values. To change one value of an object, copy the others: `use: { ...caits.use, locale: "fr-FR" }`.
7
+ */
8
+ export default defineConfig({
9
+ ...caits
10
+ });
@@ -0,0 +1,6 @@
1
+ import caits from "./caits/stryker.mjs";
2
+
3
+ /** The Stryker configuration of this project: that of CAITS (quality/caits/stryker.mjs), with the changes of this project. */
4
+ export default {
5
+ ...caits
6
+ };
@@ -0,0 +1,5 @@
1
+ import { mergeConfig } from "vitest/config";
2
+ import caits from "./caits/vite.ts";
3
+
4
+ /** The configuration of Vite (build, dev server) and Vitest of this project: that of CAITS (quality/caits/vite.ts), with the changes of this project. */
5
+ export default mergeConfig(caits, {});
@@ -0,0 +1,4 @@
1
+ {
2
+ // The TypeScript configuration of this project: that of CAITS (quality/caits/tsconfig.json), with the changes of this project.
3
+ "extends": "./quality/caits/tsconfig.json"
4
+ }