@coherent.js/cli 1.0.0-beta.2

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/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@coherent.js/cli",
3
+ "version": "1.0.0-beta.2",
4
+ "description": "Command-line interface for Coherent.js projects",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.js",
8
+ "types": "./types/index.d.ts",
9
+ "bin": {
10
+ "coherent": "./bin/coherent.js",
11
+ "coherentjs": "./bin/coherent.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./templates": "./templates/"
18
+ },
19
+ "files": [
20
+ "types/",
21
+ "dist/",
22
+ "bin/",
23
+ "templates/",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "engines": {
28
+ "node": ">=20.0.0"
29
+ },
30
+ "dependencies": {
31
+ "chalk": "^5.3.0",
32
+ "commander": "^12.1.0",
33
+ "fs-extra": "^11.2.0",
34
+ "glob": "11.0.3",
35
+ "inquirer": "^10.2.2",
36
+ "ora": "^8.1.0",
37
+ "picocolors": "^1.1.1",
38
+ "prompts": "^2.4.2"
39
+ },
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/Tomdrouv1/coherent.js.git"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public",
47
+ "registry": "https://registry.npmjs.org/"
48
+ },
49
+ "scripts": {
50
+ "build": "node build.mjs",
51
+ "clean": "rm -rf dist/",
52
+ "test": "vitest run",
53
+ "test:watch": "vitest",
54
+ "typecheck": "tsc --noEmit",
55
+ "test:coverage": "vitest run --coverage",
56
+ "test:vitest": "vitest run",
57
+ "test:node": "node --test test/*.test.js"
58
+ }
59
+ }
@@ -0,0 +1,488 @@
1
+ /**
2
+ * Coherent.js CLI Types
3
+ * TypeScript definitions for the CLI tools
4
+ *
5
+ * @version 1.0.0-beta.1
6
+ */
7
+
8
+ // ============================================================================
9
+ // Command Types
10
+ // ============================================================================
11
+
12
+ /** CLI command interface */
13
+ export interface CLICommand {
14
+ name: string;
15
+ description: string;
16
+ usage: string;
17
+ options: CLIOption[];
18
+ action: (args: string[], options: CLIOptions) => Promise<void> | void;
19
+ aliases?: string[];
20
+ examples?: string[];
21
+ }
22
+
23
+ /** CLI option definition */
24
+ export interface CLIOption {
25
+ name: string;
26
+ short?: string;
27
+ description: string;
28
+ type: 'string' | 'number' | 'boolean';
29
+ default?: any;
30
+ required?: boolean;
31
+ choices?: string[];
32
+ }
33
+
34
+ /** CLI options object */
35
+ export interface CLIOptions {
36
+ [key: string]: string | number | boolean | undefined;
37
+ help?: boolean;
38
+ version?: boolean;
39
+ verbose?: boolean;
40
+ quiet?: boolean;
41
+ config?: string;
42
+ }
43
+
44
+ // ============================================================================
45
+ // Project Creation Types
46
+ // ============================================================================
47
+
48
+ /** Project template configuration */
49
+ export interface ProjectTemplate {
50
+ name: string;
51
+ description: string;
52
+ path: string;
53
+ dependencies: string[];
54
+ devDependencies: string[];
55
+ scripts: Record<string, string>;
56
+ files: TemplateFile[];
57
+ prompts?: TemplatePrompt[];
58
+ postInstall?: string[];
59
+ }
60
+
61
+ /** Template file definition */
62
+ export interface TemplateFile {
63
+ src: string;
64
+ dest: string;
65
+ template?: boolean;
66
+ executable?: boolean;
67
+ encoding?: 'utf8' | 'binary';
68
+ }
69
+
70
+ /** Template prompt for user input */
71
+ export interface TemplatePrompt {
72
+ name: string;
73
+ type: 'input' | 'select' | 'multiselect' | 'confirm';
74
+ message: string;
75
+ default?: any;
76
+ choices?: Array<{ title: string; value: any }>;
77
+ validate?: (value: any) => boolean | string;
78
+ }
79
+
80
+ /** Project creation options */
81
+ export interface CreateProjectOptions {
82
+ template: string;
83
+ name: string;
84
+ directory?: string;
85
+ force?: boolean;
86
+ install?: boolean;
87
+ git?: boolean;
88
+ typescript?: boolean;
89
+ eslint?: boolean;
90
+ prettier?: boolean;
91
+ testing?: 'jest' | 'vitest' | 'none';
92
+ css?: 'none' | 'css' | 'scss' | 'tailwind';
93
+ }
94
+
95
+ // ============================================================================
96
+ // Generation Types
97
+ // ============================================================================
98
+
99
+ /** Component generation options */
100
+ export interface GenerateComponentOptions {
101
+ name: string;
102
+ type?: 'functional' | 'class';
103
+ directory?: string;
104
+ typescript?: boolean;
105
+ stories?: boolean;
106
+ tests?: boolean;
107
+ styles?: boolean;
108
+ props?: ComponentProp[];
109
+ }
110
+
111
+ /** Component property definition */
112
+ export interface ComponentProp {
113
+ name: string;
114
+ type: string;
115
+ required?: boolean;
116
+ default?: any;
117
+ description?: string;
118
+ }
119
+
120
+ /** Page generation options */
121
+ export interface GeneratePageOptions {
122
+ name: string;
123
+ route: string;
124
+ directory?: string;
125
+ layout?: string;
126
+ typescript?: boolean;
127
+ ssr?: boolean;
128
+ api?: boolean;
129
+ }
130
+
131
+ /** API generation options */
132
+ export interface GenerateApiOptions {
133
+ name: string;
134
+ route: string;
135
+ methods: ('GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH')[];
136
+ directory?: string;
137
+ typescript?: boolean;
138
+ validation?: boolean;
139
+ auth?: boolean;
140
+ database?: boolean;
141
+ }
142
+
143
+ /** Model generation options */
144
+ export interface GenerateModelOptions {
145
+ name: string;
146
+ fields: ModelField[];
147
+ directory?: string;
148
+ typescript?: boolean;
149
+ database?: 'postgresql' | 'mysql' | 'sqlite' | 'mongodb';
150
+ migration?: boolean;
151
+ }
152
+
153
+ /** Model field definition */
154
+ export interface ModelField {
155
+ name: string;
156
+ type: 'string' | 'number' | 'boolean' | 'date' | 'json' | 'array';
157
+ required?: boolean;
158
+ unique?: boolean;
159
+ index?: boolean;
160
+ default?: any;
161
+ length?: number;
162
+ relation?: {
163
+ type: 'hasOne' | 'hasMany' | 'belongsTo' | 'belongsToMany';
164
+ model: string;
165
+ };
166
+ }
167
+
168
+ // ============================================================================
169
+ // Development Server Types
170
+ // ============================================================================
171
+
172
+ /** Development server configuration */
173
+ export interface DevServerConfig {
174
+ port: number;
175
+ host: string;
176
+ https?: boolean;
177
+ open?: boolean;
178
+ proxy?: Record<string, string>;
179
+ watchFiles?: string[];
180
+ ignore?: string[];
181
+ hmr?: {
182
+ enabled: boolean;
183
+ port?: number;
184
+ overlay?: boolean;
185
+ };
186
+ }
187
+
188
+ /** Build configuration */
189
+ export interface BuildConfig {
190
+ entry: string;
191
+ output: {
192
+ path: string;
193
+ filename: string;
194
+ publicPath?: string;
195
+ };
196
+ target: 'web' | 'node';
197
+ mode: 'development' | 'production';
198
+ optimization?: {
199
+ minimize: boolean;
200
+ splitChunks: boolean;
201
+ };
202
+ externals?: Record<string, string>;
203
+ plugins?: any[];
204
+ }
205
+
206
+ // ============================================================================
207
+ // Configuration Types
208
+ // ============================================================================
209
+
210
+ /** Coherent.js project configuration */
211
+ export interface CoherentConfig {
212
+ // Project information
213
+ name: string;
214
+ version: string;
215
+ description?: string;
216
+
217
+ // Build settings
218
+ build: {
219
+ entry: string;
220
+ output: string;
221
+ target: 'web' | 'node' | 'both';
222
+ typescript: boolean;
223
+ sourceMaps: boolean;
224
+ minify: boolean;
225
+ };
226
+
227
+ // Development settings
228
+ dev: {
229
+ port: number;
230
+ host: string;
231
+ https: boolean;
232
+ open: boolean;
233
+ hmr: boolean;
234
+ overlay: boolean;
235
+ };
236
+
237
+ // Framework settings
238
+ framework?: {
239
+ type: 'express' | 'koa' | 'fastify' | 'nextjs' | 'none';
240
+ config?: any;
241
+ };
242
+
243
+ // Database settings
244
+ database?: {
245
+ type: 'postgresql' | 'mysql' | 'sqlite' | 'mongodb';
246
+ connection: any;
247
+ migrations: string;
248
+ models: string;
249
+ };
250
+
251
+ // Testing settings
252
+ testing?: {
253
+ framework: 'jest' | 'vitest';
254
+ coverage: boolean;
255
+ watchMode: boolean;
256
+ };
257
+
258
+ // Linting and formatting
259
+ linting?: {
260
+ eslint: boolean;
261
+ prettier: boolean;
262
+ rules?: any;
263
+ };
264
+
265
+ // Directories
266
+ directories: {
267
+ src: string;
268
+ build: string;
269
+ public: string;
270
+ components: string;
271
+ pages: string;
272
+ api: string;
273
+ models: string;
274
+ tests: string;
275
+ };
276
+ }
277
+
278
+ // ============================================================================
279
+ // Generator Types
280
+ // ============================================================================
281
+
282
+ /** Code generator interface */
283
+ export interface CodeGenerator {
284
+ name: string;
285
+ description: string;
286
+ generate(options: any): Promise<GenerationResult>;
287
+ validate(options: any): string[];
288
+ }
289
+
290
+ /** Generation result */
291
+ export interface GenerationResult {
292
+ success: boolean;
293
+ files: GeneratedFile[];
294
+ errors?: string[];
295
+ warnings?: string[];
296
+ duration: number;
297
+ }
298
+
299
+ /** Generated file information */
300
+ export interface GeneratedFile {
301
+ path: string;
302
+ content: string;
303
+ action: 'create' | 'update' | 'skip';
304
+ size: number;
305
+ }
306
+
307
+ // ============================================================================
308
+ // Plugin System Types
309
+ // ============================================================================
310
+
311
+ /** CLI plugin interface */
312
+ export interface CLIPlugin {
313
+ name: string;
314
+ version: string;
315
+ commands?: CLICommand[];
316
+ generators?: CodeGenerator[];
317
+ templates?: ProjectTemplate[];
318
+ hooks?: {
319
+ beforeCommand?: (command: string, args: string[], options: CLIOptions) => void;
320
+ afterCommand?: (command: string, args: string[], options: CLIOptions) => void;
321
+ beforeGenerate?: (type: string, options: any) => void;
322
+ afterGenerate?: (type: string, result: GenerationResult) => void;
323
+ };
324
+ }
325
+
326
+ /** Plugin manager interface */
327
+ export interface PluginManager {
328
+ plugins: Map<string, CLIPlugin>;
329
+ install(name: string): Promise<void>;
330
+ uninstall(name: string): Promise<void>;
331
+ load(plugin: CLIPlugin): void;
332
+ unload(name: string): void;
333
+ getPlugin(name: string): CLIPlugin | undefined;
334
+ getAllPlugins(): CLIPlugin[];
335
+ }
336
+
337
+ // ============================================================================
338
+ // Validation Types
339
+ // ============================================================================
340
+
341
+ /** Validation rule for CLI inputs */
342
+ export interface ValidationRule {
343
+ name: string;
344
+ validate: (value: any) => boolean | string;
345
+ message?: string;
346
+ }
347
+
348
+ /** Project structure validator */
349
+ export interface ProjectValidator {
350
+ validateStructure(path: string): ValidationResult;
351
+ validateConfig(config: CoherentConfig): ValidationResult;
352
+ validateDependencies(dependencies: string[]): ValidationResult;
353
+ }
354
+
355
+ /** Validation result */
356
+ export interface ValidationResult {
357
+ valid: boolean;
358
+ errors: string[];
359
+ warnings: string[];
360
+ }
361
+
362
+ // ============================================================================
363
+ // Utilities Types
364
+ // ============================================================================
365
+
366
+ /** File system utilities */
367
+ export interface FileSystem {
368
+ exists(path: string): Promise<boolean>;
369
+ read(path: string, encoding?: string): Promise<string | Buffer>;
370
+ write(path: string, content: string | Buffer): Promise<void>;
371
+ mkdir(path: string, recursive?: boolean): Promise<void>;
372
+ copy(src: string, dest: string): Promise<void>;
373
+ remove(path: string): Promise<void>;
374
+ glob(pattern: string, options?: any): Promise<string[]>;
375
+ }
376
+
377
+ /** Logger interface */
378
+ export interface Logger {
379
+ debug(message: string, ...args: any[]): void;
380
+ info(message: string, ...args: any[]): void;
381
+ warn(message: string, ...args: any[]): void;
382
+ error(message: string, ...args: any[]): void;
383
+ success(message: string, ...args: any[]): void;
384
+
385
+ startSpinner(message: string): void;
386
+ stopSpinner(success?: boolean): void;
387
+ updateSpinner(message: string): void;
388
+ }
389
+
390
+ // ============================================================================
391
+ // Main CLI Functions
392
+ // ============================================================================
393
+
394
+ /** Create a new project */
395
+ export function createProject(options: CreateProjectOptions): Promise<void>;
396
+
397
+ /** Generate component */
398
+ export function generateComponent(options: GenerateComponentOptions): Promise<GenerationResult>;
399
+
400
+ /** Generate page */
401
+ export function generatePage(options: GeneratePageOptions): Promise<GenerationResult>;
402
+
403
+ /** Generate API route */
404
+ export function generateApi(options: GenerateApiOptions): Promise<GenerationResult>;
405
+
406
+ /** Generate model */
407
+ export function generateModel(options: GenerateModelOptions): Promise<GenerationResult>;
408
+
409
+ /** Start development server */
410
+ export function startDevServer(options?: Partial<DevServerConfig>): Promise<void>;
411
+
412
+ /** Build project */
413
+ export function buildProject(config?: Partial<BuildConfig>): Promise<void>;
414
+
415
+ /** Run tests */
416
+ export function runTests(options?: { watch?: boolean; coverage?: boolean }): Promise<void>;
417
+
418
+ /** Lint project */
419
+ export function lintProject(options?: { fix?: boolean }): Promise<void>;
420
+
421
+ /** Format project */
422
+ export function formatProject(): Promise<void>;
423
+
424
+ // ============================================================================
425
+ // CLI Utilities
426
+ // ============================================================================
427
+
428
+ /** Parse command line arguments */
429
+ export function parseArgs(argv: string[]): { command: string; args: string[]; options: CLIOptions };
430
+
431
+ /** Load project configuration */
432
+ export function loadConfig(path?: string): Promise<CoherentConfig>;
433
+
434
+ /** Save project configuration */
435
+ export function saveConfig(config: CoherentConfig, path?: string): Promise<void>;
436
+
437
+ /** Get project templates */
438
+ export function getTemplates(): ProjectTemplate[];
439
+
440
+ /** Get available generators */
441
+ export function getGenerators(): CodeGenerator[];
442
+
443
+ /** Create logger instance */
444
+ export function createLogger(level?: 'debug' | 'info' | 'warn' | 'error'): Logger;
445
+
446
+ /** Create file system utilities */
447
+ export function createFileSystem(): FileSystem;
448
+
449
+ /** Create plugin manager */
450
+ export function createPluginManager(): PluginManager;
451
+
452
+ /** Validate project structure */
453
+ export function validateProject(path: string): Promise<ValidationResult>;
454
+
455
+ // ============================================================================
456
+ // Default Export
457
+ // ============================================================================
458
+
459
+ declare const coherentCli: {
460
+ // Project creation
461
+ createProject: typeof createProject;
462
+
463
+ // Generators
464
+ generateComponent: typeof generateComponent;
465
+ generatePage: typeof generatePage;
466
+ generateApi: typeof generateApi;
467
+ generateModel: typeof generateModel;
468
+
469
+ // Development
470
+ startDevServer: typeof startDevServer;
471
+ buildProject: typeof buildProject;
472
+ runTests: typeof runTests;
473
+ lintProject: typeof lintProject;
474
+ formatProject: typeof formatProject;
475
+
476
+ // Utilities
477
+ parseArgs: typeof parseArgs;
478
+ loadConfig: typeof loadConfig;
479
+ saveConfig: typeof saveConfig;
480
+ getTemplates: typeof getTemplates;
481
+ getGenerators: typeof getGenerators;
482
+ createLogger: typeof createLogger;
483
+ createFileSystem: typeof createFileSystem;
484
+ createPluginManager: typeof createPluginManager;
485
+ validateProject: typeof validateProject;
486
+ };
487
+
488
+ export default coherentCli;