@configjs/cli 1.0.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 ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Julien
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.
22
+
package/README.md ADDED
@@ -0,0 +1,431 @@
1
+ # confjs
2
+
3
+ <div align="center">
4
+
5
+ **Configure your frontend stack, instantly**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@configjs/cli.svg)](https://www.npmjs.com/package/@configjs/cli)
8
+ [![CI Tests](https://github.com/julien-lin/configjs/actions/workflows/test.yml/badge.svg)](https://github.com/julien-lin/configjs/actions/workflows/test.yml)
9
+ [![Publish](https://github.com/julien-lin/configjs/actions/workflows/publish.yml/badge.svg)](https://github.com/julien-lin/configjs/actions/workflows/publish.yml)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+ [![Node version](https://img.shields.io/node/v/@configjs/cli.svg)](https://nodejs.org)
12
+
13
+ Un utilitaire CLI intelligent pour installer et configurer automatiquement vos bibliothèques frontend par catégories fonctionnelles.
14
+
15
+ [Installation](#-installation) • [Usage](#-usage) • [Fonctionnalités](#-fonctionnalités) • [Documentation](#-documentation)
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## 🎯 Pourquoi confjs ?
22
+
23
+ Le bootstrap d'un projet frontend moderne prend **2-4 heures** entre l'installation des bibliothèques, leur configuration, et la résolution des conflits potentiels.
24
+
25
+ **confjs** réduit ce temps à **moins de 2 minutes** en :
26
+
27
+ - ✅ **Détectant automatiquement** votre environnement (React, TypeScript, Vite, etc.)
28
+ - ✅ **Installant ET configurant** les bibliothèques de votre choix
29
+ - ✅ **Validant les compatibilités** pour éviter les conflits
30
+ - ✅ **Générant le code initial** nécessaire (routes, stores, configs)
31
+ - ✅ Garantissant un **projet immédiatement utilisable**
32
+
33
+ ## 🚀 Installation
34
+
35
+ Aucune installation nécessaire ! Utilisez directement via `npx` :
36
+
37
+ ```bash
38
+ npx @configjs/cli react
39
+ ```
40
+
41
+ Ou installez globalement :
42
+
43
+ ```bash
44
+ npm install -g @configjs/cli
45
+ confjs react
46
+ ```
47
+
48
+ ## 📦 Usage
49
+
50
+ ### Mode interactif (recommandé)
51
+
52
+ ```bash
53
+ cd mon-projet-react
54
+ npx confjs react
55
+ ```
56
+
57
+ L'assistant vous guidera à travers les différentes catégories :
58
+
59
+ ```
60
+ 🔍 Détection du contexte...
61
+ ✓ Framework: React 18.2.0
62
+ ✓ TypeScript: Oui
63
+ ✓ Bundler: Vite 5.0.0
64
+
65
+ 📦 Sélectionnez vos bibliothèques :
66
+
67
+ ? Routing (recommandé)
68
+ ● react-router-dom
69
+ ○ @tanstack/router
70
+ ○ Aucun
71
+
72
+ ? State Management
73
+ ○ Redux Toolkit
74
+ ● zustand
75
+ ○ jotai
76
+ ○ Aucun
77
+
78
+ ...
79
+ ```
80
+
81
+ ### Mode configuration (CI/CD)
82
+
83
+ Créez un fichier `.confjs.json` :
84
+
85
+ ```json
86
+ {
87
+ "routing": "react-router-dom",
88
+ "state": "zustand",
89
+ "css": "tailwindcss",
90
+ "http": "axios",
91
+ "tooling": ["eslint", "prettier"]
92
+ }
93
+ ```
94
+
95
+ Puis exécutez :
96
+
97
+ ```bash
98
+ npx confjs react --config .confjs.json
99
+ ```
100
+
101
+ ### Mode dry-run (simulation)
102
+
103
+ Visualisez ce qui sera installé sans rien modifier :
104
+
105
+ ```bash
106
+ npx confjs react --dry-run
107
+ ```
108
+
109
+ ## ✨ Fonctionnalités
110
+
111
+ ### 🎯 Catégories supportées
112
+
113
+ | Catégorie | Bibliothèques disponibles |
114
+ |-----------|---------------------------|
115
+ | **Routing** | react-router-dom, @tanstack/router |
116
+ | **State Management** | Redux Toolkit, Zustand, Jotai |
117
+ | **HTTP Client** | Axios, Fetch wrapper |
118
+ | **CSS/UI** | TailwindCSS, Bootstrap |
119
+ | **Tooling** | ESLint, Prettier, Husky, lint-staged, commitlint |
120
+
121
+ ### 🧠 Détection intelligente
122
+
123
+ confjs détecte automatiquement :
124
+
125
+ - ✅ Framework et version (React)
126
+ - ✅ TypeScript
127
+ - ✅ Bundler (Vite, Create React App, Webpack)
128
+ - ✅ Package manager (npm, yarn, pnpm, bun)
129
+ - ✅ Structure du projet
130
+ - ✅ Bibliothèques déjà installées
131
+
132
+ ### ⚙️ Configuration automatique
133
+
134
+ Contrairement aux simples installers, **confjs configure réellement** vos bibliothèques :
135
+
136
+ **Exemple avec React Router :**
137
+ ```
138
+ ✓ Installation de react-router-dom
139
+ ✓ Création de src/router.tsx
140
+ ✓ Création de src/routes/Home.tsx
141
+ ✓ Intégration dans src/App.tsx
142
+ ✓ Configuration complète et fonctionnelle
143
+ ```
144
+
145
+ **Exemple avec TailwindCSS :**
146
+ ```
147
+ ✓ Installation de tailwindcss, postcss, autoprefixer
148
+ ✓ Création de tailwind.config.js
149
+ ✓ Création de postcss.config.js
150
+ ✓ Injection dans src/index.css
151
+ ✓ Configuration JIT activée
152
+ ```
153
+
154
+ ### 🛡️ Validation des compatibilités
155
+
156
+ confjs vérifie automatiquement :
157
+
158
+ - ❌ **Conflits exclusifs** : Redux + Zustand (un seul state manager)
159
+ - ⚠️ **Avertissements** : TailwindCSS + Bootstrap (approches différentes)
160
+ - ✅ **Dépendances croisées** : TailwindCSS → PostCSS (installé automatiquement)
161
+
162
+ ### 🔄 Rollback automatique
163
+
164
+ En cas d'erreur durant l'installation :
165
+
166
+ ```
167
+ ❌ Erreur détectée
168
+ ↺ Rollback en cours...
169
+ ✓ Fichiers restaurés
170
+ ✓ package.json restauré
171
+ ```
172
+
173
+ ## 🎨 Options CLI
174
+
175
+ ```bash
176
+ npx confjs react [options]
177
+ ```
178
+
179
+ | Option | Description |
180
+ |--------|-------------|
181
+ | `--yes`, `-y` | Accepte tous les choix par défaut |
182
+ | `--dry-run`, `-d` | Simule sans écrire sur le disque |
183
+ | `--silent`, `-s` | Mode non-interactif (CI/CD) |
184
+ | `--debug` | Active les logs détaillés |
185
+ | `--config <file>`, `-c` | Utilise un fichier de configuration |
186
+ | `--force`, `-f` | Force l'installation (écrase les configs) |
187
+
188
+ ### Exemples
189
+
190
+ ```bash
191
+ # Mode rapide avec valeurs par défaut
192
+ npx confjs react --yes
193
+
194
+ # Simulation uniquement
195
+ npx confjs react --dry-run
196
+
197
+ # Pour CI/CD
198
+ npx confjs react --silent --config .confjs.json
199
+
200
+ # Avec logs détaillés
201
+ npx confjs react --debug
202
+ ```
203
+
204
+ ## 📚 Commandes additionnelles
205
+
206
+ ### Liste des bibliothèques disponibles
207
+
208
+ ```bash
209
+ npx confjs list
210
+ ```
211
+
212
+ Filtrer par catégorie :
213
+
214
+ ```bash
215
+ npx confjs list --category routing
216
+ npx confjs list --category state
217
+ ```
218
+
219
+ ### Vérifier la compatibilité
220
+
221
+ ```bash
222
+ npx confjs check --config .confjs.json
223
+ ```
224
+
225
+ ### Aide
226
+
227
+ ```bash
228
+ npx confjs --help
229
+ npx confjs react --help
230
+ ```
231
+
232
+ ## 🎯 Exemples d'utilisation
233
+
234
+ ### Setup complet d'un projet React
235
+
236
+ ```bash
237
+ # Créer un nouveau projet
238
+ npm create vite@latest mon-app -- --template react-ts
239
+ cd mon-app
240
+
241
+ # Installer et configurer la stack
242
+ npx confjs react
243
+
244
+ # Sélectionner :
245
+ # - Routing: react-router-dom
246
+ # - State: zustand
247
+ # - CSS: tailwindcss
248
+ # - HTTP: axios
249
+ # - Tooling: eslint, prettier
250
+
251
+ # Démarrer
252
+ npm run dev
253
+ ```
254
+
255
+ ### Configuration pré-définie pour l'équipe
256
+
257
+ ```bash
258
+ # .confjs.json (à versionner dans Git)
259
+ {
260
+ "routing": "react-router-dom",
261
+ "state": "zustand",
262
+ "css": "tailwindcss",
263
+ "http": "axios",
264
+ "tooling": ["eslint", "prettier", "husky"]
265
+ }
266
+
267
+ # Chaque membre de l'équipe exécute :
268
+ npx confjs react --config .confjs.json
269
+ ```
270
+
271
+ ### Pipeline CI/CD
272
+
273
+ ```yaml
274
+ # .github/workflows/setup.yml
275
+ - name: Setup project
276
+ run: npx confjs react --silent --config .confjs.json
277
+ ```
278
+
279
+ ## 🏗️ Architecture
280
+
281
+ ### Système de plugins
282
+
283
+ confjs utilise une architecture modulaire où chaque bibliothèque est un plugin autonome :
284
+
285
+ ```typescript
286
+ interface Plugin {
287
+ name: string
288
+ category: Category
289
+ frameworks: Framework[]
290
+
291
+ // Compatibilité
292
+ compatibleWith?: string[]
293
+ incompatibleWith?: string[]
294
+
295
+ // Lifecycle
296
+ install: (ctx: ProjectContext) => Promise<void>
297
+ configure: (ctx: ProjectContext) => Promise<void>
298
+ rollback?: (ctx: ProjectContext) => Promise<void>
299
+ }
300
+ ```
301
+
302
+ ### Extensibilité
303
+
304
+ Créez vos propres plugins :
305
+
306
+ ```bash
307
+ npm install confjs-plugin-react-query
308
+ ```
309
+
310
+ confjs détectera et chargera automatiquement les plugins préfixés par `confjs-plugin-*`.
311
+
312
+ ## 🔧 Configuration
313
+
314
+ ### Fichier .confjs.json
315
+
316
+ ```json
317
+ {
318
+ "routing": "react-router-dom",
319
+ "state": "zustand",
320
+ "css": "tailwindcss",
321
+ "http": "axios",
322
+ "forms": "react-hook-form",
323
+ "tooling": ["eslint", "prettier", "husky"],
324
+
325
+ "options": {
326
+ "typescript": true,
327
+ "strict": true,
328
+ "examples": true
329
+ }
330
+ }
331
+ ```
332
+
333
+ ### Fichier .confjs.yaml (alternatif)
334
+
335
+ ```yaml
336
+ routing: react-router-dom
337
+ state: zustand
338
+ css: tailwindcss
339
+ http: axios
340
+
341
+ tooling:
342
+ - eslint
343
+ - prettier
344
+ - husky
345
+
346
+ options:
347
+ typescript: true
348
+ strict: true
349
+ examples: true
350
+ ```
351
+
352
+ ## 🤝 Contribuer
353
+
354
+ Les contributions sont les bienvenues ! Consultez [CONTRIBUTING.md](./docs/CONTRIBUTING.md) pour les guidelines.
355
+
356
+ ### Développer un plugin
357
+
358
+ Consultez [PLUGIN_DEVELOPMENT.md](./docs/PLUGIN_DEVELOPMENT.md) pour créer vos propres plugins.
359
+
360
+ ### Setup développement
361
+
362
+ ```bash
363
+ # Clone
364
+ git clone https://github.com/julien/confjs.git
365
+ cd confjs
366
+
367
+ # Install
368
+ npm install
369
+
370
+ # Dev mode
371
+ npm run dev
372
+
373
+ # Tests
374
+ npm run test
375
+ npm run test:watch
376
+
377
+ # Build
378
+ npm run build
379
+ ```
380
+
381
+ ## 📋 Requirements
382
+
383
+ - **Node.js** ≥ 18.0.0
384
+ - **npm** / **yarn** / **pnpm** / **bun**
385
+ - Un projet React existant
386
+
387
+ ## 🗺️ Roadmap
388
+
389
+ ### v1.0 (MVP) ✅
390
+ - [x] Support React
391
+ - [x] 12 plugins intégrés
392
+ - [x] Validation compatibilités
393
+ - [x] Configuration automatique
394
+
395
+ ### v1.1 (Q1 2026)
396
+ - [ ] Support Next.js
397
+ - [ ] Support Remix
398
+ - [ ] Plugins UI (MUI, Chakra, Radix)
399
+ - [ ] Plugins forms (React Hook Form, Formik)
400
+
401
+ ### v2.0 (Q2 2026)
402
+ - [ ] Support Vue 3
403
+ - [ ] Support Svelte
404
+ - [ ] Interface web de configuration
405
+
406
+ ### v2.x (Future)
407
+ - [ ] Templates personnalisables
408
+ - [ ] Marketplace de plugins
409
+ - [ ] React Native support
410
+
411
+ ## 📄 License
412
+
413
+ [MIT](./LICENSE) © Julien
414
+
415
+ ## 🙏 Remerciements
416
+
417
+ Inspiré par les meilleures pratiques de :
418
+ - [Vite](https://vitejs.dev)
419
+ - [Create T3 App](https://create.t3.gg)
420
+ - [Projen](https://projen.io)
421
+
422
+ ---
423
+
424
+ <div align="center">
425
+
426
+ **Fait avec ❤️ pour la communauté frontend**
427
+
428
+ [Changelog](./CHANGELOG.md) • [Issues](https://github.com/julien/confjs/issues) • [Contributing](./docs/CONTRIBUTING.md)
429
+
430
+ </div>
431
+
@@ -0,0 +1,126 @@
1
+ import {
2
+ CompatibilityValidator,
3
+ compatibilityRules
4
+ } from "./chunk-PQLKGF6I.js";
5
+ import {
6
+ logger,
7
+ pluginRegistry
8
+ } from "./chunk-5T664O5A.js";
9
+
10
+ // src/cli/commands/check.ts
11
+ import { readFile } from "fs/promises";
12
+ import { join } from "path";
13
+ import { existsSync } from "fs";
14
+ async function checkCompatibility(options) {
15
+ try {
16
+ console.log("\n\u{1F50D} V\xE9rification de la compatibilit\xE9\n");
17
+ const configPath = options.config || join(process.cwd(), ".confjs.json");
18
+ if (!existsSync(configPath)) {
19
+ console.error(`\u274C Fichier de configuration introuvable: ${configPath}`);
20
+ console.log("\n\u{1F4A1} Cr\xE9ez un fichier .confjs.json avec le format suivant:");
21
+ console.log(
22
+ JSON.stringify(
23
+ {
24
+ plugins: ["react-router-dom", "zustand", "tailwindcss"]
25
+ },
26
+ null,
27
+ 2
28
+ )
29
+ );
30
+ process.exit(1);
31
+ }
32
+ const configContent = await readFile(configPath, "utf-8");
33
+ let config;
34
+ try {
35
+ const parsed = JSON.parse(configContent);
36
+ config = parsed;
37
+ } catch {
38
+ console.error(
39
+ "\u274C Erreur de parsing JSON dans le fichier de configuration"
40
+ );
41
+ process.exit(1);
42
+ }
43
+ if (!config.plugins || !Array.isArray(config.plugins)) {
44
+ console.error("\u274C Format de configuration invalide");
45
+ console.log(
46
+ ' Le champ "plugins" doit \xEAtre un tableau de noms de packages'
47
+ );
48
+ process.exit(1);
49
+ }
50
+ const selectedPlugins = config.plugins.map((name) => pluginRegistry.find((p) => p.name === name)).filter(Boolean);
51
+ if (selectedPlugins.length === 0) {
52
+ console.error("\u274C Aucun plugin valide trouv\xE9 dans la configuration");
53
+ process.exit(1);
54
+ }
55
+ const notFound = config.plugins.filter(
56
+ (name) => !pluginRegistry.find((p) => p.name === name)
57
+ );
58
+ if (notFound.length > 0) {
59
+ console.warn("\n\u26A0\uFE0F Plugins non trouv\xE9s:");
60
+ for (const name of notFound) {
61
+ console.warn(` \u2022 ${name}`);
62
+ }
63
+ }
64
+ console.log(`\u{1F4E6} Plugins \xE0 v\xE9rifier: ${selectedPlugins.length}`);
65
+ for (const plugin of selectedPlugins) {
66
+ if (plugin) {
67
+ console.log(` \u2022 ${plugin.displayName} (${plugin.name})`);
68
+ }
69
+ }
70
+ console.log("\n\u{1F50D} Analyse de compatibilit\xE9...\n");
71
+ const validator = new CompatibilityValidator(compatibilityRules);
72
+ const validation = validator.validate(
73
+ selectedPlugins
74
+ );
75
+ if (validation.errors.length === 0) {
76
+ console.log("\u2705 Aucun conflit d\xE9tect\xE9\n");
77
+ } else {
78
+ console.error("\u274C Conflits d\xE9tect\xE9s:\n");
79
+ for (const error of validation.errors) {
80
+ console.error(` \u2022 ${error.message}`);
81
+ if ("plugins" in error && error.plugins) {
82
+ console.error(` Plugins: ${error.plugins.join(", ")}`);
83
+ }
84
+ }
85
+ console.log("");
86
+ }
87
+ if (validation.warnings.length > 0) {
88
+ console.warn("\u26A0\uFE0F Avertissements:\n");
89
+ for (const warning of validation.warnings) {
90
+ console.warn(` \u2022 ${warning.message}`);
91
+ if ("plugins" in warning && warning.plugins) {
92
+ console.warn(` Plugins: ${warning.plugins.join(", ")}`);
93
+ }
94
+ }
95
+ console.log("");
96
+ }
97
+ if (validation.suggestions.length > 0) {
98
+ console.log("\u{1F4A1} Suggestions:\n");
99
+ for (const suggestion of validation.suggestions) {
100
+ console.log(` \u2022 ${suggestion}`);
101
+ }
102
+ console.log("");
103
+ }
104
+ if (validation.valid) {
105
+ console.log(
106
+ "\u2728 Configuration valide ! Vous pouvez proc\xE9der \xE0 l'installation.\n"
107
+ );
108
+ process.exit(0);
109
+ } else {
110
+ console.error(
111
+ "\u274C Configuration invalide. Corrigez les erreurs avant d'installer.\n"
112
+ );
113
+ process.exit(2);
114
+ }
115
+ } catch (error) {
116
+ logger.error("Erreur lors de la v\xE9rification:", error);
117
+ if (error instanceof Error) {
118
+ console.error(`
119
+ \u274C ${error.message}`);
120
+ }
121
+ process.exit(1);
122
+ }
123
+ }
124
+ export {
125
+ checkCompatibility
126
+ };