create-maedow-arch-app 0.1.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.
- package/LICENSE +21 -0
- package/README.md +63 -0
- package/bin/create-maedow-arch-app.mjs +77 -0
- package/package.json +39 -0
- package/templates/base/_gitignore +9 -0
- package/templates/base/eslint.config.mjs +8 -0
- package/templates/base/next.config.mjs +6 -0
- package/templates/base/package.json.template +34 -0
- package/templates/base/scripts/scaffold-domain.mjs +40 -0
- package/templates/base/scripts/scaffold-feature.mjs +46 -0
- package/templates/base/src/app/layout.tsx +14 -0
- package/templates/base/src/app/page.tsx +19 -0
- package/templates/base/src/components/ui/.gitkeep +0 -0
- package/templates/base/src/core/common/result.ts +21 -0
- package/templates/base/src/features/_shared/.gitkeep +0 -0
- package/templates/base/src/lib/.gitkeep +0 -0
- package/templates/base/src/tests/e2e/.gitkeep +0 -0
- package/templates/base/src/tests/integration/.gitkeep +0 -0
- package/templates/base/src/tests/unit/.gitkeep +0 -0
- package/templates/base/tsconfig.json +28 -0
- package/templates/base/vitest.config.ts +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jean-Marc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# create-maedow-arch-app
|
|
2
|
+
|
|
3
|
+
CLI de scaffolding de [Maedow Arch](https://github.com/maedow-arch/maedow-arch-docs) — un standard d'architecture logicielle modulaire, découplé et agnostique de l'infrastructure, pour TypeScript / React / Next.js.
|
|
4
|
+
|
|
5
|
+
## Démarrage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx create-maedow-arch-app mon-projet
|
|
9
|
+
cd mon-projet
|
|
10
|
+
npm install
|
|
11
|
+
npm run dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Ce qui est généré
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
mon-projet/
|
|
18
|
+
├── src/
|
|
19
|
+
│ ├── app/ # Routes et orchestration — peut tout importer
|
|
20
|
+
│ ├── features/ # Écrans et logique de vue
|
|
21
|
+
│ │ └── _shared/ # Composants métier transverses
|
|
22
|
+
│ ├── core/ # Domaine métier — zéro dépendance UI
|
|
23
|
+
│ │ └── common/
|
|
24
|
+
│ │ └── result.ts # Result Pattern + helpers unwrapOr / mapResult / match
|
|
25
|
+
│ ├── components/ui/ # Présentationnel pur
|
|
26
|
+
│ ├── lib/ # Utilitaires sans dépendance
|
|
27
|
+
│ └── tests/ # unit / integration / e2e
|
|
28
|
+
├── scripts/ # Générateurs de domaine et de feature
|
|
29
|
+
├── eslint.config.mjs # Frontières architecturales appliquées au lint
|
|
30
|
+
├── tsconfig.json # TypeScript strict (noUncheckedIndexedAccess, exactOptionalPropertyTypes…)
|
|
31
|
+
└── vitest.config.ts
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Générateurs
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run generate:domain billing # src/core/billing/ — types, validation Zod, service
|
|
38
|
+
npm run generate:feature checkout # src/features/checkout/ — Screen, hook, types, test
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Le domaine généré applique la **Règle de Lazy Abstraction** : accès direct à la donnée, et pas de `contract.ts` ni d'adapters tant qu'une deuxième implémentation réelle n'est pas nécessaire.
|
|
42
|
+
|
|
43
|
+
## Frontières architecturales
|
|
44
|
+
|
|
45
|
+
Le flux de dépendance est unidirectionnel — `app → features → core → lib` — et vérifié au lint :
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run lint
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
Maedow Arch : core ne peut pas importer components. Voir architecture.md §6.
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Les règles vivent dans [`eslint-config-maedow-arch`](https://www.npmjs.com/package/eslint-config-maedow-arch), installé par défaut dans le projet généré.
|
|
56
|
+
|
|
57
|
+
## Documentation
|
|
58
|
+
|
|
59
|
+
Le corpus complet — les 4 couches, la typologie des modèles, le Result Pattern, les conventions et les modes Light / Full — est sur [github.com/maedow-arch/maedow-arch-docs](https://github.com/maedow-arch/maedow-arch-docs).
|
|
60
|
+
|
|
61
|
+
## Licence
|
|
62
|
+
|
|
63
|
+
MIT
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { cpSync, readFileSync, writeFileSync, existsSync, mkdirSync, renameSync, rmSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
|
|
6
|
+
const DOCS_URL = "https://github.com/maedow-arch/maedow-arch-docs";
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const templateDir = join(__dirname, "..", "templates", "base");
|
|
10
|
+
|
|
11
|
+
const projectName = process.argv[2];
|
|
12
|
+
if (!projectName) {
|
|
13
|
+
console.error("Usage: npx create-maedow-arch-app <nom-du-projet>");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Le nom finit dans un package.json : on refuse ce que npm refuserait.
|
|
18
|
+
if (!/^[a-z0-9][a-z0-9._-]*$/.test(projectName)) {
|
|
19
|
+
console.error(
|
|
20
|
+
`❌ "${projectName}" n'est pas un nom de package valide.\n` +
|
|
21
|
+
" Minuscules, chiffres, tirets, points et underscores ; commence par une lettre ou un chiffre."
|
|
22
|
+
);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const targetDir = join(process.cwd(), projectName);
|
|
27
|
+
|
|
28
|
+
if (existsSync(targetDir)) {
|
|
29
|
+
console.error(`❌ Le dossier "${projectName}" existe déjà.`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(`📦 Création du projet Maedow Arch "${projectName}"...`);
|
|
34
|
+
|
|
35
|
+
mkdirSync(targetDir, { recursive: true });
|
|
36
|
+
cpSync(templateDir, targetDir, { recursive: true });
|
|
37
|
+
|
|
38
|
+
// package.json.template -> package.json, avec le vrai nom du projet.
|
|
39
|
+
const pkgTemplatePath = join(targetDir, "package.json.template");
|
|
40
|
+
writeFileSync(
|
|
41
|
+
join(targetDir, "package.json"),
|
|
42
|
+
readFileSync(pkgTemplatePath, "utf-8").replaceAll("__PROJECT_NAME__", projectName)
|
|
43
|
+
);
|
|
44
|
+
rmSync(pkgTemplatePath);
|
|
45
|
+
|
|
46
|
+
// npm exclut les fichiers nommés `.gitignore` des packages publiés :
|
|
47
|
+
// le template le transporte sous le nom `_gitignore`.
|
|
48
|
+
const gitignoreSource = join(targetDir, "_gitignore");
|
|
49
|
+
if (existsSync(gitignoreSource)) {
|
|
50
|
+
renameSync(gitignoreSource, join(targetDir, ".gitignore"));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Le nom du projet apparaît aussi dans les fichiers de l'app.
|
|
54
|
+
for (const relativePath of ["src/app/layout.tsx", "src/app/page.tsx"]) {
|
|
55
|
+
const filePath = join(targetDir, relativePath);
|
|
56
|
+
if (existsSync(filePath)) {
|
|
57
|
+
writeFileSync(
|
|
58
|
+
filePath,
|
|
59
|
+
readFileSync(filePath, "utf-8").replaceAll("__PROJECT_NAME__", projectName)
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
console.log(`✅ Projet créé dans ./${projectName}`);
|
|
65
|
+
console.log("");
|
|
66
|
+
console.log("Prochaines étapes :");
|
|
67
|
+
console.log(` cd ${projectName}`);
|
|
68
|
+
console.log(" npm install");
|
|
69
|
+
console.log(" npm run dev");
|
|
70
|
+
console.log("");
|
|
71
|
+
console.log("Générateurs :");
|
|
72
|
+
console.log(" npm run generate:domain <mon-premier-domaine> # une entité métier dans src/core/");
|
|
73
|
+
console.log(" npm run generate:feature <ma-premiere-feature> # un écran dans src/features/");
|
|
74
|
+
console.log("");
|
|
75
|
+
console.log(" npm run lint # vérifie les frontières architecturales");
|
|
76
|
+
console.log("");
|
|
77
|
+
console.log(`📖 Doc complète : ${DOCS_URL}`);
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-maedow-arch-app",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scaffold un projet suivant Maedow Arch (app/features/core/components/lib, Result Pattern, ESLint boundaries)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-maedow-arch-app": "./bin/create-maedow-arch-app.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"templates",
|
|
12
|
+
"README.md",
|
|
13
|
+
"LICENSE"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"maedow-arch",
|
|
17
|
+
"architecture",
|
|
18
|
+
"scaffold",
|
|
19
|
+
"cli",
|
|
20
|
+
"boilerplate",
|
|
21
|
+
"nextjs",
|
|
22
|
+
"clean-architecture",
|
|
23
|
+
"typescript"
|
|
24
|
+
],
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"author": "Jean-Marc",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/maedow-arch/maedow-arch-docs.git",
|
|
30
|
+
"directory": "packages/create-maedow-arch-app"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/maedow-arch/maedow-arch-docs#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/maedow-arch/maedow-arch-docs/issues"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import maedowArchConfig from "eslint-config-maedow-arch";
|
|
2
|
+
import tseslint from "typescript-eslint";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{ ignores: [".next/**", "node_modules/**"] },
|
|
6
|
+
{ files: ["**/*.{ts,tsx}"], languageOptions: { parser: tseslint.parser } },
|
|
7
|
+
...maedowArchConfig,
|
|
8
|
+
];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "__PROJECT_NAME__",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "next dev",
|
|
8
|
+
"build": "next build",
|
|
9
|
+
"start": "next start",
|
|
10
|
+
"lint": "eslint .",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"generate:feature": "node scripts/scaffold-feature.mjs",
|
|
14
|
+
"generate:domain": "node scripts/scaffold-domain.mjs"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"next": "^15.5.0",
|
|
18
|
+
"react": "^19.0.0",
|
|
19
|
+
"react-dom": "^19.0.0",
|
|
20
|
+
"zod": "^4.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^22.10.0",
|
|
24
|
+
"@types/react": "^19.0.0",
|
|
25
|
+
"@types/react-dom": "^19.0.0",
|
|
26
|
+
"eslint": "^9.39.0",
|
|
27
|
+
"eslint-config-maedow-arch": "^0.1.0",
|
|
28
|
+
"eslint-import-resolver-typescript": "^4.4.0",
|
|
29
|
+
"eslint-plugin-boundaries": "^7.2.0",
|
|
30
|
+
"typescript": "^5.7.0",
|
|
31
|
+
"typescript-eslint": "^8.68.0",
|
|
32
|
+
"vitest": "^2.1.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdirSync, writeFileSync, existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const name = process.argv[2];
|
|
6
|
+
if (!name) {
|
|
7
|
+
console.error("Usage: npm run generate:domain <nom>");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const pascal = name.charAt(0).toUpperCase() + name.slice(1);
|
|
12
|
+
const dir = join("src", "core", name);
|
|
13
|
+
|
|
14
|
+
if (existsSync(dir)) {
|
|
15
|
+
console.error(`Le domaine "${name}" existe déjà dans ${dir}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
mkdirSync(dir, { recursive: true });
|
|
20
|
+
|
|
21
|
+
writeFileSync(
|
|
22
|
+
join(dir, "types.ts"),
|
|
23
|
+
`// Entité métier du domaine "${name}"\n\nexport interface ${pascal} {\n id: string;\n // TODO: champs métier\n}\n`
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
writeFileSync(
|
|
27
|
+
join(dir, "validation.ts"),
|
|
28
|
+
`import { z } from "zod";\n\nexport const Create${pascal}Schema = z.object({\n // TODO: champs à valider\n});\n\nexport type Create${pascal}DTO = z.infer<typeof Create${pascal}Schema>;\n`
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
writeFileSync(
|
|
32
|
+
join(dir, "service.ts"),
|
|
33
|
+
`import type { Result } from "../common/result";\nimport type { ${pascal} } from "./types";\nimport type { Create${pascal}DTO } from "./validation";\n\n// ⚠️ Règle de Lazy Abstraction : n'introduis un contract.ts + adapters\n// que lorsqu'une deuxième implémentation réelle est nécessaire.\n// Tant qu'un seul fournisseur de données existe, accède-y directement ici.\n\nexport async function create${pascal}(input: Create${pascal}DTO): Promise<Result<${pascal}>> {\n // TODO: logique métier\n return { ok: false, error: "not_implemented" };\n}\n`
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
console.log(`✅ Domaine "${name}" généré dans ${dir}/`);
|
|
37
|
+
console.log(` - types.ts`);
|
|
38
|
+
console.log(` - validation.ts`);
|
|
39
|
+
console.log(` - service.ts (accès direct — voir la Règle de Lazy Abstraction)`);
|
|
40
|
+
console.log(` Rappel : n'ajoute contract.ts + repository.ts que si un 2ème fournisseur devient réel.`);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { mkdirSync, writeFileSync, existsSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
const name = process.argv[2];
|
|
6
|
+
if (!name) {
|
|
7
|
+
console.error("Usage: npm run generate:feature <nom>");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const pascal = name.charAt(0).toUpperCase() + name.slice(1);
|
|
12
|
+
const dir = join("src", "features", name);
|
|
13
|
+
|
|
14
|
+
if (existsSync(dir)) {
|
|
15
|
+
console.error(`La feature "${name}" existe déjà dans ${dir}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
mkdirSync(join(dir, "hooks"), { recursive: true });
|
|
20
|
+
mkdirSync(join(dir, "components"), { recursive: true });
|
|
21
|
+
|
|
22
|
+
writeFileSync(
|
|
23
|
+
join(dir, "types.ts"),
|
|
24
|
+
`// Types d'affichage locaux à la feature "${name}"\n\nexport interface ${pascal}View {\n // TODO\n}\n`
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
writeFileSync(
|
|
28
|
+
join(dir, "hooks", `use${pascal}.ts`),
|
|
29
|
+
`import { useState } from "react";\nimport type { ${pascal}View } from "../types";\n\nexport function use${pascal}() {\n const [state, setState] = useState<${pascal}View | null>(null);\n return { state, isLoading: false };\n}\n`
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
writeFileSync(
|
|
33
|
+
join(dir, "Screen.tsx"),
|
|
34
|
+
`import { use${pascal} } from "./hooks/use${pascal}";\n\nexport function ${pascal}Screen() {\n const { state, isLoading } = use${pascal}();\n\n if (isLoading) return <p>Chargement...</p>;\n\n return <div>{/* TODO: rendu de ${pascal} */}</div>;\n}\n`
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
writeFileSync(
|
|
38
|
+
join(dir, `${pascal}.test.tsx`),
|
|
39
|
+
`import { describe, it, expect } from "vitest";\n\ndescribe("${pascal}Screen", () => {\n it.todo("affiche l'écran ${name}");\n});\n`
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
console.log(`✅ Feature "${name}" générée dans ${dir}/`);
|
|
43
|
+
console.log(` - types.ts`);
|
|
44
|
+
console.log(` - hooks/use${pascal}.ts`);
|
|
45
|
+
console.log(` - Screen.tsx`);
|
|
46
|
+
console.log(` - ${pascal}.test.tsx`);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
title: "__PROJECT_NAME__",
|
|
5
|
+
description: "Application suivant Maedow Arch",
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default function RootLayout({ children }: { children: ReactNode }) {
|
|
9
|
+
return (
|
|
10
|
+
<html lang="fr">
|
|
11
|
+
<body>{children}</body>
|
|
12
|
+
</html>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default function HomePage() {
|
|
2
|
+
return (
|
|
3
|
+
<main style={{ fontFamily: "system-ui, sans-serif", padding: "3rem", lineHeight: 1.6 }}>
|
|
4
|
+
<h1>__PROJECT_NAME__</h1>
|
|
5
|
+
<p>Projet généré avec Maedow Arch.</p>
|
|
6
|
+
<ol>
|
|
7
|
+
<li>
|
|
8
|
+
<code>npm run generate:domain <nom></code> — crée un domaine métier dans <code>src/core/</code>
|
|
9
|
+
</li>
|
|
10
|
+
<li>
|
|
11
|
+
<code>npm run generate:feature <nom></code> — crée une feature dans <code>src/features/</code>
|
|
12
|
+
</li>
|
|
13
|
+
<li>
|
|
14
|
+
<code>npm run lint</code> — vérifie les frontières architecturales
|
|
15
|
+
</li>
|
|
16
|
+
</ol>
|
|
17
|
+
</main>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type Result<TData, TError = string> =
|
|
2
|
+
| { ok: true; data: TData }
|
|
3
|
+
| { ok: false; error: TError };
|
|
4
|
+
|
|
5
|
+
export function unwrapOr<TData, TError>(result: Result<TData, TError>, fallback: TData): TData {
|
|
6
|
+
return result.ok ? result.data : fallback;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function mapResult<TData, TMapped, TError>(
|
|
10
|
+
result: Result<TData, TError>,
|
|
11
|
+
fn: (data: TData) => TMapped
|
|
12
|
+
): Result<TMapped, TError> {
|
|
13
|
+
return result.ok ? { ok: true, data: fn(result.data) } : result;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function match<TData, TError, TReturn>(
|
|
17
|
+
result: Result<TData, TError>,
|
|
18
|
+
handlers: { ok: (data: TData) => TReturn; err: (error: TError) => TReturn }
|
|
19
|
+
): TReturn {
|
|
20
|
+
return result.ok ? handlers.ok(result.data) : handlers.err(result.error);
|
|
21
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
4
|
+
"noUncheckedIndexedAccess": true,
|
|
5
|
+
"noImplicitOverride": true,
|
|
6
|
+
"noFallthroughCasesInSwitch": true,
|
|
7
|
+
"exactOptionalPropertyTypes": true,
|
|
8
|
+
"target": "ES2022",
|
|
9
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
10
|
+
"module": "ESNext",
|
|
11
|
+
"moduleResolution": "Bundler",
|
|
12
|
+
"jsx": "preserve",
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"esModuleInterop": true,
|
|
16
|
+
"resolveJsonModule": true,
|
|
17
|
+
"isolatedModules": true,
|
|
18
|
+
"noEmit": true,
|
|
19
|
+
"incremental": true,
|
|
20
|
+
"baseUrl": ".",
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["src/*"]
|
|
23
|
+
},
|
|
24
|
+
"plugins": [{ "name": "next" }]
|
|
25
|
+
},
|
|
26
|
+
"include": ["src", "next-env.d.ts", ".next/types/**/*.ts"],
|
|
27
|
+
"exclude": ["node_modules"]
|
|
28
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
// Le domaine (core/) se teste sans monter d'arbre React : c'est tout
|
|
6
|
+
// l'intérêt de la règle « Zéro Modèle dans le JSX ».
|
|
7
|
+
include: ["src/**/*.test.{ts,tsx}"],
|
|
8
|
+
},
|
|
9
|
+
});
|