@ollie-shop/cli 0.3.4 → 1.0.1

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 +993 -3956
  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 +541 -0
  15. package/tsconfig.json +10 -15
  16. package/tsup.config.ts +7 -7
  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/CLAUDE_CLI.md DELETED
@@ -1,265 +0,0 @@
1
- # Claude CLI Guidance
2
-
3
- ## Core Architecture Principle
4
-
5
- The CLI is a **thin presentation layer** that delegates ALL business logic to `@ollie-shop/core`.
6
-
7
- ### Architecture Flow
8
-
9
- ```
10
- User Input → CLI (presentation) → @ollie-shop/core (business logic) → External Services
11
- ↓ ↓
12
- Format Output Handles all integrations:
13
- Show Progress - Supabase database
14
- Display Errors - AWS Builder service
15
- Provide Next Steps - File operations
16
- - Validation logic
17
- ```
18
-
19
- ## Critical Rule: No Business Logic in CLI
20
-
21
- ### ❌ NEVER do this in CLI:
22
-
23
- ```typescript
24
- // BAD: Business logic in CLI
25
- import { createClient } from '@supabase/supabase-js';
26
-
27
- export class DatabaseService {
28
- async listComponents() {
29
- const supabase = createClient(...);
30
- const { data } = await supabase.from('components').select();
31
- return data;
32
- }
33
- }
34
- ```
35
-
36
- ### ✅ ALWAYS do this:
37
-
38
- ```typescript
39
- // GOOD: Delegate to core
40
- import { ComponentService } from '@ollie-shop/core';
41
-
42
- export const list = async (options: ListOptions) => {
43
- const spinner = cliConsole.spinner('Loading components...');
44
-
45
- try {
46
- const service = new ComponentService();
47
- const components = await service.list(options);
48
-
49
- spinner.succeed();
50
- cliConsole.table(components);
51
- } catch (error) {
52
- spinner.fail();
53
- throw error;
54
- }
55
- };
56
- ```
57
-
58
- ## What Belongs in CLI vs Core
59
-
60
- ### CLI Package (`packages/cli/src/`)
61
- - **Command parsing** - Commander.js setup
62
- - **Option validation** - Zod schemas for CLI options
63
- - **User feedback** - Spinners, progress bars, tables
64
- - **Error formatting** - User-friendly error messages
65
- - **Authentication flow** - OAuth callback server
66
- - **File paths** - Resolve user-provided paths
67
- - **Next steps** - Guide users after operations
68
-
69
- ### Core Package (`packages/core/src/services/`)
70
- - **All database operations** - Supabase queries
71
- - **Builder integration** - AWS CodeBuild client
72
- - **File operations** - Zip creation, validation
73
- - **Business validation** - Component/function rules
74
- - **API integrations** - External service calls
75
- - **State management** - Version handling
76
- - **Template rendering** - Component scaffolding
77
-
78
- ## Current Core Services
79
-
80
- Based on the core package structure:
81
-
82
- ```typescript
83
- // Available in @ollie-shop/core
84
- - ComponentService // Component CRUD operations
85
- - FunctionService // Function CRUD operations
86
- - ProjectService // Project initialization
87
- - TemplateService // Template rendering
88
-
89
- // Need to be added to core (not CLI):
90
- - VersionService // Version management
91
- - DatabaseService // Supabase operations
92
- - BuilderService // AWS Builder integration
93
- - OrganizationService // Org management
94
- - StoreService // Store management
95
- ```
96
-
97
- ## Implementation Pattern
98
-
99
- ### 1. CLI Action Structure
100
-
101
- ```typescript
102
- // packages/cli/src/actions/component.actions.ts
103
- export const deploy = async (options: DeployOptions) => {
104
- // 1. User feedback
105
- const spinner = cliConsole.spinner('Deploying component...');
106
-
107
- try {
108
- // 2. Resolve paths
109
- const componentPath = path.resolve(options.path);
110
-
111
- // 3. Delegate to core
112
- const { ComponentService } = await import('@ollie-shop/core');
113
- const service = new ComponentService();
114
-
115
- const result = await service.deploy({
116
- path: componentPath,
117
- versionId: options.versionId
118
- });
119
-
120
- // 4. Format output
121
- spinner.succeed('Component deployed successfully');
122
-
123
- cliConsole.info('Deployment details:');
124
- cliConsole.list([
125
- `Build ID: ${result.buildId}`,
126
- `Status: ${result.status}`,
127
- `URL: ${result.url}`
128
- ]);
129
-
130
- // 5. Next steps
131
- cliConsole.dim('\nNext steps:');
132
- cliConsole.list([
133
- 'View deployment status: ollieshop deploy status ' + result.buildId,
134
- 'Test component: ollieshop component test --id ' + result.componentId
135
- ]);
136
-
137
- } catch (error) {
138
- spinner.fail('Deployment failed');
139
-
140
- // 6. Error handling with suggestions
141
- if (error instanceof BuildInProgressError) {
142
- throw new OllieShopCLIError(
143
- 'A deployment is already in progress',
144
- { componentId: error.componentId },
145
- [
146
- 'Check status: ollieshop deploy status',
147
- 'Wait for completion or cancel the current build'
148
- ]
149
- );
150
- }
151
-
152
- throw error;
153
- }
154
- };
155
- ```
156
-
157
- ### 2. Core Service Pattern
158
-
159
- ```typescript
160
- // packages/core/src/services/component.service.ts
161
- export class ComponentService {
162
- constructor(
163
- private db: DatabaseService,
164
- private builder: BuilderService
165
- ) {}
166
-
167
- async deploy(options: DeployOptions) {
168
- // All business logic here
169
- const component = await this.db.getComponent(options.versionId);
170
- const zipFile = await this.createZip(options.path);
171
- const build = await this.builder.createBuild({
172
- type: 'component',
173
- resourceId: component.id,
174
- code: zipFile
175
- });
176
-
177
- return {
178
- buildId: build.id,
179
- componentId: component.id,
180
- status: build.status,
181
- url: component.url
182
- };
183
- }
184
- }
185
- ```
186
-
187
- ## Services to Add to Core
188
-
189
- Based on the improvement plan, these services should be created in `@ollie-shop/core`, NOT in CLI:
190
-
191
- ### 1. DatabaseService
192
- ```typescript
193
- // packages/core/src/services/database.service.ts
194
- export class DatabaseService {
195
- async listComponents(versionId: string);
196
- async listFunctions(versionId: string);
197
- async getComponent(componentId: string);
198
- async updateComponent(id: string, data: Partial<Component>);
199
- // ... all database operations
200
- }
201
- ```
202
-
203
- ### 2. BuilderService
204
- ```typescript
205
- // packages/core/src/services/builder.service.ts
206
- export class BuilderService {
207
- async deployComponent(componentId: string, zipFile: File);
208
- async deployFunction(functionId: string, zipFile: File);
209
- async getBuildStatus(buildId: string);
210
- async getBuildLogs(buildId: string);
211
- }
212
- ```
213
-
214
- ### 3. VersionService
215
- ```typescript
216
- // packages/core/src/services/version.service.ts
217
- export class VersionService {
218
- async create(storeId: string, options: CreateVersionOptions);
219
- async list(storeId: string);
220
- async setDefault(versionId: string);
221
- async activate(versionId: string);
222
- async delete(versionId: string);
223
- }
224
- ```
225
-
226
- ## Testing Strategy
227
-
228
- ### CLI Tests
229
- Focus on:
230
- - Command parsing
231
- - Option validation
232
- - Output formatting
233
- - Error message formatting
234
- - User flow (spinners, prompts)
235
-
236
- ### Core Tests
237
- Focus on:
238
- - Business logic
239
- - Database operations
240
- - External service integration
241
- - Validation rules
242
- - Error conditions
243
-
244
- ## Key Principles
245
-
246
- 1. **CLI is disposable** - Could be replaced with a GUI without losing functionality
247
- 2. **Core is essential** - Contains all business rules and integrations
248
- 3. **Reusability** - Other tools (SDK, admin) can use core services
249
- 4. **Testability** - Core services are easier to test without CLI layer
250
- 5. **Maintainability** - Business logic changes happen in one place
251
-
252
- ## Common Mistakes to Avoid
253
-
254
- 1. **Don't create database queries in CLI** - Use core services
255
- 2. **Don't implement validation logic in CLI** - Belongs in core
256
- 3. **Don't call external APIs from CLI** - Core handles integrations
257
- 4. **Don't manage state in CLI** - Core manages application state
258
- 5. **Don't duplicate core functionality** - Always check if it exists first
259
-
260
- ## Next Steps for Implementation
261
-
262
- 1. **Audit existing core services** - See what's already available
263
- 2. **Create missing services in core** - DatabaseService, BuilderService, etc.
264
- 3. **Update CLI to use core services** - Remove any direct integrations
265
- 4. **Add comprehensive tests** - Both CLI presentation and core logic