@ollie-shop/cli 0.3.3 → 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.
Files changed (79) hide show
  1. package/.turbo/turbo-build.log +6 -9
  2. package/CHANGELOG.md +27 -0
  3. package/dist/index.js +1003 -40565
  4. package/package.json +15 -37
  5. package/src/README.md +126 -0
  6. package/src/cli.tsx +45 -0
  7. package/src/commands/help.tsx +79 -0
  8. package/src/commands/login.tsx +92 -0
  9. package/src/commands/start.tsx +411 -0
  10. package/src/index.tsx +8 -0
  11. package/src/utils/auth.ts +218 -21
  12. package/src/utils/bundle.ts +177 -0
  13. package/src/utils/config.ts +123 -0
  14. package/src/utils/esbuild.ts +533 -0
  15. package/tsconfig.json +10 -15
  16. package/tsup.config.ts +8 -10
  17. package/CLAUDE_CLI.md +0 -265
  18. package/README.md +0 -711
  19. package/__tests__/mocks/console.ts +0 -22
  20. package/__tests__/mocks/core.ts +0 -137
  21. package/__tests__/mocks/index.ts +0 -4
  22. package/__tests__/mocks/inquirer.ts +0 -16
  23. package/__tests__/mocks/progress.ts +0 -19
  24. package/dist/index.d.ts +0 -1
  25. package/src/__tests__/helpers/cli-test-helper.ts +0 -281
  26. package/src/__tests__/mocks/index.ts +0 -142
  27. package/src/actions/component.actions.ts +0 -278
  28. package/src/actions/function.actions.ts +0 -220
  29. package/src/actions/project.actions.ts +0 -131
  30. package/src/actions/version.actions.ts +0 -233
  31. package/src/commands/__tests__/component-validation.test.ts +0 -250
  32. package/src/commands/__tests__/component.test.ts +0 -318
  33. package/src/commands/__tests__/function-validation.test.ts +0 -220
  34. package/src/commands/__tests__/function.test.ts +0 -286
  35. package/src/commands/__tests__/store-version-validation.test.ts +0 -414
  36. package/src/commands/__tests__/store-version.test.ts +0 -402
  37. package/src/commands/component.ts +0 -178
  38. package/src/commands/docs.ts +0 -24
  39. package/src/commands/function.ts +0 -201
  40. package/src/commands/help.ts +0 -18
  41. package/src/commands/index.ts +0 -27
  42. package/src/commands/login.ts +0 -267
  43. package/src/commands/project.ts +0 -107
  44. package/src/commands/store-version.ts +0 -242
  45. package/src/commands/version.ts +0 -51
  46. package/src/commands/whoami.ts +0 -46
  47. package/src/index.ts +0 -116
  48. package/src/prompts/component.prompts.ts +0 -94
  49. package/src/prompts/function.prompts.ts +0 -168
  50. package/src/schemas/command.schema.ts +0 -644
  51. package/src/types/index.ts +0 -183
  52. package/src/utils/__tests__/command-parser.test.ts +0 -159
  53. package/src/utils/__tests__/command-suggestions.test.ts +0 -185
  54. package/src/utils/__tests__/console.test.ts +0 -192
  55. package/src/utils/__tests__/context-detector.test.ts +0 -258
  56. package/src/utils/__tests__/enhanced-error-handler.test.ts +0 -137
  57. package/src/utils/__tests__/error-handler.test.ts +0 -107
  58. package/src/utils/__tests__/rich-progress.test.ts +0 -181
  59. package/src/utils/__tests__/validation-error-formatter.test.ts +0 -175
  60. package/src/utils/__tests__/validation-helpers.test.ts +0 -125
  61. package/src/utils/cli-progress-reporter.ts +0 -84
  62. package/src/utils/command-builder.ts +0 -390
  63. package/src/utils/command-helpers.ts +0 -83
  64. package/src/utils/command-parser.ts +0 -245
  65. package/src/utils/command-suggestions.ts +0 -176
  66. package/src/utils/console.ts +0 -320
  67. package/src/utils/constants.ts +0 -39
  68. package/src/utils/context-detector.ts +0 -177
  69. package/src/utils/deploy-helpers.ts +0 -357
  70. package/src/utils/enhanced-error-handler.ts +0 -264
  71. package/src/utils/error-handler.ts +0 -60
  72. package/src/utils/errors.ts +0 -256
  73. package/src/utils/interactive-builder.ts +0 -325
  74. package/src/utils/rich-progress.ts +0 -331
  75. package/src/utils/store.ts +0 -23
  76. package/src/utils/validation-error-formatter.ts +0 -337
  77. package/src/utils/validation-helpers.ts +0 -325
  78. package/vitest.config.ts +0 -35
  79. package/vitest.setup.ts +0 -29
package/README.md DELETED
@@ -1,711 +0,0 @@
1
- # @ollie-shop/cli
2
-
3
- Internal CLI for managing Ollie Shop components, functions, store versions, and projects.
4
-
5
- ## Quick Start
6
-
7
- ```bash
8
- # Run CLI from monorepo root
9
- pnpm --filter @ollie-shop/cli cli
10
-
11
- # Or from the CLI package directory
12
- cd packages/cli
13
- npm run cli
14
-
15
- # With arguments
16
- npm run cli -- component create --name my-component
17
- npm run cli -- store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name "Holiday Theme"
18
-
19
- # Enable debug output
20
- DEBUG=ollie:* npm run cli -- login
21
- ```
22
-
23
- ## Features Overview
24
-
25
- ### 🏪 Store Version Management
26
- - Create, manage, and deploy different store configurations
27
- - A/B testing and gradual rollouts
28
- - Template-based version creation
29
-
30
- ### 🧩 Component System
31
- - Create React components for checkout customization
32
- - Build, validate, and deploy components
33
- - Slot-based component architecture (header, main, sidebar, footer)
34
- - **NEW**: Interactive component creation wizard
35
- - **NEW**: Rich deployment progress visualization
36
-
37
- ### ⚡ Function Management
38
- - Create serverless functions for checkout logic
39
- - Event-driven architecture (cart, customer, shipping, payment, order)
40
- - Local testing and cloud deployment
41
-
42
- ### 📋 Template System
43
- - Pre-built checkout templates
44
- - Apply templates to store versions
45
- - Preview before applying
46
-
47
- ### 🚀 Enhanced Developer Experience (Phase 1)
48
- - **Smart Error Recovery**: Actionable suggestions for common errors
49
- - **Context-Aware Commands**: Shows relevant commands based on current directory
50
- - **Interactive Mode**: Step-by-step wizards for complex operations
51
- - **Rich Progress Visualization**: Detailed deployment progress with stats
52
-
53
- ## Architecture Overview
54
-
55
- ### Command Flow
56
-
57
- ```
58
- User Input
59
-
60
-
61
- CLI Entry (src/index.ts)
62
-
63
- ├─> Command Parser (Commander.js)
64
- │ └─> Global Options (--verbose, --quiet, etc.)
65
-
66
- ├─> Command Registration (src/commands/*.ts)
67
- │ └─> Option Schemas (Zod validation)
68
-
69
- ├─> Action Execution (src/actions/*.ts)
70
- │ ├─> Console Output (utils/cliConsole.ts)
71
- │ ├─> Spinner Management
72
- │ └─> Lazy Load @ollie-shop/core
73
-
74
- └─> Error Handling
75
- └─> Recovery Suggestions
76
- ```
77
-
78
- ### Core Files
79
-
80
- #### `src/index.ts` - CLI Entry Point
81
- ```typescript
82
- export class OllieShopCLI {
83
- private program: Command;
84
-
85
- constructor() {
86
- // Sets up Commander instance
87
- // Registers global options
88
- // Configures error handling
89
- }
90
-
91
- async run(argv: string[]): Promise<void> {
92
- // Parses arguments
93
- // Validates global options
94
- // Executes command
95
- }
96
- }
97
- ```
98
-
99
- #### `src/commands/` - Command Registration
100
- Each command file exports a function that:
101
- 1. Creates a Commander command
102
- 2. Defines options with Zod schemas
103
- 3. Binds to action handler
104
-
105
- ```typescript
106
- // Example: component.ts
107
- export function registerComponentCommands(program: Command) {
108
- const cmd = program.command('component');
109
-
110
- cmd.command('create')
111
- .option('--name <name>', 'Component name')
112
- .option('--slot <slot>', 'Component slot')
113
- .action(async (options) => {
114
- const validated = componentOptionsSchema.parse(options);
115
- await componentActions.createComponent(validated, cliConsole);
116
- });
117
- }
118
- ```
119
-
120
- #### `src/actions/` - Business Logic Delegation
121
- Actions handle:
122
- - User feedback (spinners, messages)
123
- - Core service delegation
124
- - Error transformation
125
-
126
- ```typescript
127
- // Example: component.actions.ts
128
- export async function createComponent(options: ComponentOptions, cliConsole: CliConsole) {
129
- const spinner = cliConsole.spinner('Creating component...');
130
- try {
131
- // Lazy load core service
132
- const { createComponent: createComponentService } = await import('@ollie-shop/core');
133
-
134
- const result = await createComponentService(options);
135
- spinner.succeed('Component created');
136
-
137
- // Show next steps
138
- cliConsole.nextSteps('Next steps', [
139
- { description: 'Navigate to directory', command: `cd ${result}` },
140
- { description: 'Install dependencies', command: 'npm install' },
141
- { description: 'Start development', command: 'npm run dev' }
142
- ]);
143
- } catch (error) {
144
- spinner.fail('Failed to create component');
145
- throw error;
146
- }
147
- }
148
- ```
149
-
150
- ### CLI Console Utility
151
-
152
- The `cliConsole` utility (`src/utils/cliConsole.ts`) provides consistent output formatting:
153
-
154
- ```typescript
155
- interface CliConsole {
156
- // Basic output
157
- log(message: string): void;
158
- error(message: string): void;
159
- warn(message: string): void;
160
- info(message: string): void;
161
- success(message: string): void;
162
-
163
- // Formatting
164
- dim(message: string): void;
165
- bold(message: string): void;
166
-
167
- // Complex output
168
- list(items: string[]): void;
169
- table(data: any[]): void;
170
- json(data: any): void;
171
-
172
- // Interactive
173
- spinner(message: string): Ora;
174
- confirm(message: string): Promise<boolean>;
175
- prompt(questions: any[]): Promise<any>;
176
- }
177
- ```
178
-
179
- Usage patterns:
180
- ```typescript
181
- // Simple messages
182
- cliConsole.success('✓ Build completed');
183
- cliConsole.error('✗ Validation failed');
184
-
185
- // Formatted lists
186
- cliConsole.info('Available templates:');
187
- cliConsole.list(['default', 'grocery', 'sales']);
188
-
189
- // Spinners for async operations
190
- const spinner = cliConsole.spinner('Building...');
191
- await longOperation();
192
- spinner.succeed('Build complete');
193
-
194
- // Interactive prompts
195
- const confirm = await cliConsole.confirm('Deploy to production?');
196
- ```
197
-
198
- ### Authentication Flow
199
-
200
- ```typescript
201
- // src/actions/auth.actions.ts
202
- 1. Start local server on port 7777
203
- 2. Open browser to auth endpoint
204
- 3. Wait for callback with credentials
205
- 4. Save to ~/.ollie-shop/credentials.json
206
- 5. Return user info (currently mocked)
207
- ```
208
-
209
- ### Error Handling
210
-
211
- Custom error class with recovery suggestions:
212
-
213
- ```typescript
214
- class OllieShopCLIError extends Error {
215
- constructor(
216
- message: string,
217
- public context?: Record<string, any>,
218
- public suggestions?: string[]
219
- ) {
220
- super(message);
221
- }
222
- }
223
-
224
- // Usage
225
- throw new OllieShopCLIError(
226
- 'Component not found',
227
- { path: './src/components' },
228
- [
229
- 'Run "ollieshop component create" to create a new component',
230
- 'Check that you are in the correct directory'
231
- ]
232
- );
233
- ```
234
-
235
- ### Input Validation & DX Enhancements
236
-
237
- All CLI commands now feature enhanced validation with helpful error messages:
238
-
239
- #### Component Name Validation
240
- ```bash
241
- # ❌ Invalid: uppercase letters
242
- $ ollieshop component create --name TestComponent
243
- Error: Invalid component name: Must be lowercase with hyphens only
244
- Examples: header-nav, shopping-cart, product-list
245
-
246
- # ✅ Valid: kebab-case
247
- $ ollieshop component create --name test-component
248
- ```
249
-
250
- #### Function Validation
251
- ```bash
252
- # ❌ Invalid: wrong invocation type
253
- $ ollieshop function create --name test --invocation invalid
254
- Error: Invalid function invocation type
255
- Valid invocations: request, response
256
-
257
- # ✅ Valid: proper invocation
258
- $ ollieshop function create --name validate-order --invocation request
259
- ```
260
-
261
- #### UUID Validation (Store Versions)
262
- ```bash
263
- # ❌ Invalid: not a UUID
264
- $ ollieshop store-version create --store abc123 --name v2
265
- Error: Invalid store ID: Must be a valid store ID
266
- Example: 123e4567-e89b-12d3-a456-426614174000
267
-
268
- # ✅ Valid: proper UUID format
269
- $ ollieshop store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name v2
270
- ```
271
-
272
- #### Validation Features
273
- - **Early validation**: Errors caught at parse time, not after processing
274
- - **Helpful examples**: Error messages include valid examples
275
- - **Format hints**: Shows expected formats (kebab-case, UUID, etc.)
276
- - **Enum suggestions**: Lists all valid options for enums
277
- - **Required fields**: Clear indication when fields are missing
278
- - **Help integration**: `--help` shows examples for each command
279
-
280
- ### Component Validation
281
-
282
- The `component validate` command checks for:
283
- - **Required files**: `index.tsx`, `package.json`, `meta.json`
284
- - **Valid TypeScript/JavaScript**: Source files compile without errors
285
- - **Component metadata**: Valid meta.json structure
286
- - **Package dependencies**: All required dependencies present
287
-
288
- ```bash
289
- # Validate a component (components are created in ./components/<name>/)
290
- $ ollieshop component validate --path ./components/my-component
291
-
292
- # Or validate from within component directory (automatic path detection)
293
- $ cd components/my-component
294
- $ ollieshop component validate
295
- ```
296
-
297
- ### Automatic Path Detection
298
-
299
- The CLI now automatically detects when you're inside a component or function directory:
300
-
301
- ```bash
302
- # Navigate to component directory
303
- $ cd components/header-nav
304
-
305
- # These commands automatically use the current directory
306
- $ ollieshop component validate # No --path needed
307
- $ ollieshop component build # No --path needed
308
- $ ollieshop component deploy # No --path needed
309
-
310
- # Same works for functions
311
- $ cd functions/validate-order
312
- $ ollieshop function validate # No --path needed
313
- $ ollieshop function build # No --path needed
314
- $ ollieshop function test # No --path needed
315
- $ ollieshop function deploy # No --path needed
316
- ```
317
-
318
- The CLI detects the project type by looking for:
319
- - **Components**: `meta.json` with type "component" or presence of `index.tsx`/`index.jsx`
320
- - **Functions**: `meta.json` with type "function" or presence of `index.ts`/`index.js`
321
-
322
- If you're not in the right directory type, you'll get helpful error messages:
323
- ```bash
324
- # In a function directory trying to run component command
325
- $ ollieshop component validate
326
- Error: Current directory appears to be a function, not a component.
327
- Please navigate to a component directory or specify --path
328
-
329
- # In project root
330
- $ ollieshop component validate
331
- Error: No component found in current directory.
332
- Try navigating to a component directory:
333
- cd components/<component-name>
334
- Or specify the path:
335
- --path ./components/<component-name>
336
- ```
337
-
338
- ### 🚀 Enhanced Developer Experience Features
339
-
340
- #### Smart Error Recovery
341
- When errors occur, the CLI now provides actionable suggestions:
342
-
343
- ```bash
344
- $ ollieshop component create --name MyComponent
345
-
346
- ❌ Component name validation failed
347
-
348
- 💡 Possible solutions:
349
- 1. Use lowercase letters and hyphens only (e.g., header-nav)
350
- 2. Examples: shopping-cart, product-list
351
-
352
- 📍 Context:
353
- Current directory: /Users/dev/project
354
- ```
355
-
356
- #### Context-Aware Command Suggestions
357
- Running `ollieshop` without arguments shows context-aware suggestions:
358
-
359
- ```bash
360
- $ ollieshop
361
-
362
- 📍 Current location:
363
- You're in a component directory: header-nav
364
-
365
- Common commands for this component:
366
- validate Check component validity
367
- build Build for production
368
- dev Start development server
369
- deploy Deploy to cloud
370
-
371
- Recent commands:
372
- ollieshop validate --fix (2 min ago)
373
- ollieshop build --watch (1 hour ago)
374
-
375
- 💡 Tip: Run 'ollieshop dev' to start developing this component
376
- ```
377
-
378
- #### Interactive Mode
379
- Use `--interactive` flag for step-by-step guidance:
380
-
381
- ```bash
382
- $ ollieshop component create --interactive
383
-
384
- 🎨 Component Creation Wizard
385
-
386
- ? Component name: shopping-cart
387
- ? Component slot: ›
388
- ❯ Header
389
- Main (default)
390
- Sidebar
391
- Footer
392
-
393
- ? Language: ›
394
- ❯ TypeScript (recommended)
395
- JavaScript
396
-
397
- ? Include test files? (Y/n)
398
-
399
- [Preview] This will run: ollieshop component create --name shopping-cart --slot header
400
-
401
- ? Create this component? (Y/n)
402
- ```
403
-
404
- #### Rich Progress Visualization
405
- Deployment now shows detailed progress:
406
-
407
- ```bash
408
- $ ollieshop component deploy --wait
409
-
410
- 🚀 Starting deployment...
411
-
412
- 🔍 Validating ████████████████████ 100% | 0.3s ✓
413
- 🔨 Building ███████████░░░░░░░░░ 60% | 1.2s | Bundling dependencies...
414
- ⚡ Optimizing ░░░░░░░░░░░░░░░░░░░░ 0% | Queued
415
- 🚀 Deploying ░░░░░░░░░░░░░░░░░░░░ 0% | Queued
416
- ✅ Verifying ░░░░░░░░░░░░░░░░░░░░ 0% | Queued
417
-
418
- 📊 Build Stats:
419
- • Bundle size: 127KB (gzipped: 42KB)
420
- • Tree shaking: Removed 18 unused exports
421
- • Dependencies: 12 (3 updated)
422
-
423
- ✅ Deployment completed successfully!
424
-
425
- Deployment URL: https://cdn.ollie.shop/components/header-nav-v1.2.0.js
426
- Total time: 3.4s
427
- ```
428
-
429
- ### Function Validation
430
-
431
- The `function validate` command checks for:
432
- - **Required files**: `index.ts` or `index.js`, `package.json`, `meta.json`
433
- - **Valid exports**: Handler function properly exported
434
- - **Function metadata**: Valid meta.json structure
435
- - **Package dependencies**: All required dependencies present
436
-
437
- ```bash
438
- # Validate a function (functions are created in ./functions/<name>/)
439
- $ ollieshop function validate --path ./functions/my-function
440
-
441
- # Or validate from within function directory
442
- $ cd functions/my-function
443
- $ ollieshop function validate
444
- ```
445
-
446
- ## Command Implementation Status
447
-
448
- ### ✅ Fully Implemented & Delegated to Core
449
- These commands are fully functional and delegate to `@ollie-shop/core`:
450
-
451
- **Store Version Management**
452
- - `store-version create` - Create new store version
453
- - `store-version list` - List all versions for a store
454
- - `store-version get` - Get version details
455
- - `store-version activate/deactivate` - Toggle version status
456
- - `store-version set-default` - Set default version
457
- - `store-version clone` - Clone existing version
458
- - `store-version delete` - Delete version
459
-
460
- **Component Management**
461
- - `component create` - Create new component
462
- - `component build` - Build component
463
- - `component validate` - Validate component structure
464
- - `component deploy` - Deploy component with build status polling
465
- - `component deploy-status` - Check deployment status
466
-
467
- **Function Management**
468
- - `function create` - Create new function
469
- - `function build` - Build function
470
- - `function validate` - Validate function structure
471
- - `function test` - Test function locally
472
- - `function deploy` - Deploy function with build status polling
473
- - `function deploy-status` - Check deployment status
474
-
475
- **Template Management**
476
- - `template list` - List available templates
477
- - `template apply` - Apply template to version
478
- - `template preview` - Preview template
479
-
480
- **Project Management**
481
- - `project init` - Initialize new project
482
- - `project info` - Show project information
483
- - `project link` - Link to existing project
484
-
485
- ### 🔄 Partially Implemented
486
- These commands have basic functionality but need database integration:
487
- - `component list` - Shows empty list (needs Supabase)
488
- - `function list` - Shows empty list (needs Supabase)
489
-
490
- ### 🔧 CLI-Only Features
491
- - `login` - OAuth flow with local server
492
- - `whoami` - Shows current user (mocked)
493
- - `docs` - Opens documentation
494
- - `help` - Shows command help
495
- - `version` - Shows CLI version
496
-
497
- ## Testing the CLI Locally
498
-
499
- ### Manual Testing Checklist
500
-
501
- ```bash
502
- # 1. Test authentication
503
- npm run cli -- login
504
- npm run cli -- whoami
505
-
506
- # 2. Test store version commands
507
- npm run cli -- store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name "Test Version"
508
- npm run cli -- store-version list --store 123e4567-e89b-12d3-a456-426614174000
509
- npm run cli -- store-version get <version-id>
510
- npm run cli -- store-version activate <version-id>
511
- npm run cli -- store-version set-default <version-id>
512
-
513
- # 3. Test component commands
514
- npm run cli -- component create --name test-component --slot header
515
- # Note: Components are created in ./components/<name>/ directory
516
- npm run cli -- component validate --path ./components/test-component
517
- npm run cli -- component build --path ./components/test-component
518
- npm run cli -- component deploy --path ./components/test-component
519
- npm run cli -- component deploy-status <build-id>
520
- npm run cli -- component list
521
-
522
- # 4. Test function commands
523
- npm run cli -- function create --name test-function --event cart --timing before
524
- # Note: Functions are created in ./functions/<name>/ directory
525
- npm run cli -- function validate --path ./functions/test-function
526
- npm run cli -- function build --path ./functions/test-function
527
- npm run cli -- function test --path ./functions/test-function
528
- npm run cli -- function deploy --path ./functions/test-function
529
- npm run cli -- function deploy-status <build-id>
530
- npm run cli -- function list
531
-
532
- # 5. Test template commands
533
- npm run cli -- template list
534
- npm run cli -- template preview default
535
- npm run cli -- template apply minimal --version <version-id>
536
-
537
- # 6. Test project commands
538
- npm run cli -- project init test-project --template default
539
- npm run cli -- project info
540
- npm run cli -- project link <project-id>
541
-
542
- # 7. Test error handling
543
- npm run cli -- component create # Missing required --name
544
- npm run cli -- invalid-command # Unknown command
545
-
546
- # 8. Test global options
547
- npm run cli -- --verbose component create --name test-component
548
- npm run cli -- --quiet component build
549
- npm run cli -- --no-color component list
550
- ```
551
-
552
- ### Debugging
553
-
554
- ```bash
555
- # Enable debug output
556
- DEBUG=ollie:* npm run cli -- component create --name Test
557
-
558
- # Use Node debugger
559
- node --inspect-brk ./dist/bin/cli.js component create --name Test
560
-
561
- # Check generated files
562
- ls -la ~/.ollie-shop/
563
- cat ~/.ollie-shop/credentials.json
564
- ```
565
-
566
- ## Adding New Commands
567
-
568
- 1. **Create command file** in `src/commands/`:
569
- ```typescript
570
- // src/commands/newfeature.command.ts
571
- export const newFeatureCommand = (program: Command) => {
572
- const cmd = program
573
- .command('newfeature')
574
- .description('New feature description');
575
-
576
- // Add subcommands
577
- cmd.command('action')
578
- .option('--param <value>', 'Parameter description')
579
- .action(newFeatureActions.action);
580
- };
581
- ```
582
-
583
- 2. **Create action file** in `src/actions/`:
584
- ```typescript
585
- // src/actions/newfeature.actions.ts
586
- export const action = async (options: NewFeatureOptions) => {
587
- const spinner = cliConsole.spinner('Processing...');
588
-
589
- try {
590
- // Delegate to core
591
- const { NewFeatureService } = await import('@ollie-shop/core');
592
- const service = new NewFeatureService();
593
- await service.process(options);
594
-
595
- spinner.succeed('Complete');
596
- } catch (error) {
597
- spinner.fail('Failed');
598
- throw error;
599
- }
600
- };
601
- ```
602
-
603
- 3. **Register in main CLI**:
604
- ```typescript
605
- // src/commands/index.ts
606
- export * from './newfeature.command';
607
- ```
608
-
609
- ## Core Integration Pattern
610
-
611
- The CLI follows a strict delegation pattern:
612
-
613
- ```typescript
614
- // CLI Layer - User interaction only
615
- async function createComponent(options) {
616
- // 1. Show spinner
617
- const spinner = cliConsole.spinner('Creating...');
618
-
619
- try {
620
- // 2. Lazy load core service
621
- const { ComponentService } = await import('@ollie-shop/core');
622
-
623
- // 3. Delegate all logic to core
624
- const service = new ComponentService();
625
- const result = await service.create(options);
626
-
627
- // 4. Show success and next steps
628
- spinner.succeed('Created');
629
- showNextSteps(result);
630
-
631
- } catch (error) {
632
- // 5. Handle errors with context
633
- spinner.fail('Failed');
634
- handleError(error);
635
- }
636
- }
637
- ```
638
-
639
- ## Configuration Files
640
-
641
- ### `ollie.json` Structure
642
- ```json
643
- {
644
- "storeId": "uuid",
645
- "versionId": "uuid",
646
- "platform": "vtex",
647
- "platformStoreId": "string",
648
- "sessionId": "uuid",
649
- "props": {},
650
- "theme": {}
651
- }
652
- ```
653
-
654
- ### Credentials Storage
655
- ```json
656
- // ~/.ollie-shop/credentials.json
657
- {
658
- "accessToken": "jwt-token",
659
- "refreshToken": "refresh-token",
660
- "expiresAt": "2024-01-01T00:00:00Z"
661
- }
662
- ```
663
-
664
- ## Development Workflow
665
-
666
- ```bash
667
- # 1. Make changes to CLI
668
- cd packages/cli
669
- vim src/commands/component.command.ts
670
-
671
- # 2. Build and test
672
- pnpm build
673
- npm run cli -- component create --name Test
674
-
675
- # 3. Test with core changes
676
- cd ../core
677
- pnpm build
678
- cd ../cli
679
- npm run cli -- component create --name Test
680
-
681
- # 4. Run tests (when implemented)
682
- pnpm test
683
- ```
684
-
685
- ## Known Issues & TODOs
686
-
687
- ### High Priority
688
- 1. Implement real authentication (currently returns mock user)
689
- 2. Add Supabase integration for list commands
690
- 3. Connect to AWS Builder service
691
- 4. Implement dev server with Vite
692
-
693
- ### Medium Priority
694
- 1. Add comprehensive test suite
695
- 2. Implement progress bars for long operations
696
- 3. Add command aliases (e.g., `oc` for `ollieshop component`)
697
- 4. Cache command results where appropriate
698
-
699
- ### Low Priority
700
- 1. Add shell completion
701
- 2. Implement update notifications
702
- 3. Add telemetry (with opt-out)
703
- 4. Create interactive mode
704
-
705
- ## Debugging Tips
706
-
707
- 1. **Check core delegation**: Most issues are in `@ollie-shop/core`, not CLI
708
- 2. **Validate schemas**: Zod errors show what's missing
709
- 3. **Use verbose mode**: `--verbose` shows additional output
710
- 4. **Check credentials**: `cat ~/.ollie-shop/credentials.json`
711
- 5. **Clear state**: `rm -rf ~/.ollie-shop` to start fresh