@ollie-shop/cli 0.2.0 → 0.3.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 (182) hide show
  1. package/.turbo/turbo-build.log +2 -11
  2. package/CHANGELOG.md +13 -7
  3. package/CLAUDE_CLI.md +265 -0
  4. package/README.md +704 -8
  5. package/__tests__/mocks/console.ts +22 -0
  6. package/__tests__/mocks/core.ts +137 -0
  7. package/__tests__/mocks/index.ts +4 -0
  8. package/__tests__/mocks/inquirer.ts +16 -0
  9. package/__tests__/mocks/progress.ts +19 -0
  10. package/dist/__tests__/helpers/cli-test-helper.d.ts +89 -0
  11. package/dist/__tests__/helpers/cli-test-helper.d.ts.map +1 -0
  12. package/dist/__tests__/helpers/cli-test-helper.js +220 -0
  13. package/dist/__tests__/mocks/index.d.ts +69 -0
  14. package/dist/__tests__/mocks/index.d.ts.map +1 -0
  15. package/dist/__tests__/mocks/index.js +77 -0
  16. package/dist/actions/component.actions.d.ts +14 -0
  17. package/dist/actions/component.actions.d.ts.map +1 -0
  18. package/dist/actions/component.actions.js +273 -0
  19. package/dist/actions/function.actions.d.ts +15 -0
  20. package/dist/actions/function.actions.d.ts.map +1 -0
  21. package/dist/actions/function.actions.js +254 -0
  22. package/dist/actions/project.actions.d.ts +17 -0
  23. package/dist/actions/project.actions.d.ts.map +1 -0
  24. package/dist/actions/project.actions.js +97 -0
  25. package/dist/actions/version.actions.d.ts +19 -0
  26. package/dist/actions/version.actions.d.ts.map +1 -0
  27. package/dist/actions/version.actions.js +216 -0
  28. package/dist/commands/component.d.ts +3 -0
  29. package/dist/commands/component.d.ts.map +1 -0
  30. package/dist/commands/component.js +192 -0
  31. package/dist/commands/docs.d.ts +3 -0
  32. package/dist/commands/docs.d.ts.map +1 -0
  33. package/dist/commands/docs.js +16 -0
  34. package/dist/commands/function.d.ts +3 -0
  35. package/dist/commands/function.d.ts.map +1 -0
  36. package/dist/commands/function.js +243 -0
  37. package/dist/commands/help.d.ts +3 -0
  38. package/dist/commands/help.d.ts.map +1 -0
  39. package/dist/commands/help.js +20 -0
  40. package/dist/commands/index.d.ts +3 -0
  41. package/dist/commands/index.d.ts.map +1 -0
  42. package/dist/commands/index.js +26 -0
  43. package/dist/commands/login.d.ts +3 -0
  44. package/dist/commands/login.d.ts.map +1 -0
  45. package/dist/commands/login.js +175 -0
  46. package/dist/commands/project.d.ts +3 -0
  47. package/dist/commands/project.d.ts.map +1 -0
  48. package/dist/commands/project.js +78 -0
  49. package/dist/commands/store-version.d.ts +3 -0
  50. package/dist/commands/store-version.d.ts.map +1 -0
  51. package/dist/commands/store-version.js +241 -0
  52. package/dist/commands/version.d.ts +3 -0
  53. package/dist/commands/version.d.ts.map +1 -0
  54. package/dist/commands/version.js +46 -0
  55. package/dist/commands/whoami.d.ts +3 -0
  56. package/dist/commands/whoami.d.ts.map +1 -0
  57. package/dist/commands/whoami.js +41 -0
  58. package/dist/index.d.ts +3 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +88 -478
  61. package/dist/prompts/component.prompts.d.ts +14 -0
  62. package/dist/prompts/component.prompts.d.ts.map +1 -0
  63. package/dist/prompts/component.prompts.js +75 -0
  64. package/dist/prompts/function.prompts.d.ts +21 -0
  65. package/dist/prompts/function.prompts.d.ts.map +1 -0
  66. package/dist/prompts/function.prompts.js +127 -0
  67. package/dist/schemas/command.schema.d.ts +516 -0
  68. package/dist/schemas/command.schema.d.ts.map +1 -0
  69. package/dist/schemas/command.schema.js +267 -0
  70. package/dist/types/index.d.ts +147 -0
  71. package/dist/types/index.d.ts.map +1 -0
  72. package/dist/types/index.js +18 -0
  73. package/dist/utils/auth.d.ts +4 -0
  74. package/dist/utils/auth.d.ts.map +1 -0
  75. package/dist/utils/auth.js +26 -0
  76. package/dist/utils/cli-progress-reporter.d.ts +12 -0
  77. package/dist/utils/cli-progress-reporter.d.ts.map +1 -0
  78. package/dist/utils/cli-progress-reporter.js +77 -0
  79. package/dist/utils/command-builder.d.ts +22 -0
  80. package/dist/utils/command-builder.d.ts.map +1 -0
  81. package/dist/utils/command-builder.js +268 -0
  82. package/dist/utils/command-helpers.d.ts +19 -0
  83. package/dist/utils/command-helpers.d.ts.map +1 -0
  84. package/dist/utils/command-helpers.js +79 -0
  85. package/dist/utils/command-parser.d.ts +146 -0
  86. package/dist/utils/command-parser.d.ts.map +1 -0
  87. package/dist/utils/command-parser.js +179 -0
  88. package/dist/utils/command-suggestions.d.ts +35 -0
  89. package/dist/utils/command-suggestions.d.ts.map +1 -0
  90. package/dist/utils/command-suggestions.js +152 -0
  91. package/dist/utils/console.d.ts +44 -0
  92. package/dist/utils/console.d.ts.map +1 -0
  93. package/dist/utils/console.js +233 -0
  94. package/dist/utils/constants.d.ts +8 -0
  95. package/dist/utils/constants.d.ts.map +1 -0
  96. package/dist/utils/constants.js +10 -0
  97. package/dist/utils/context-detector.d.ts +12 -0
  98. package/dist/utils/context-detector.d.ts.map +1 -0
  99. package/dist/utils/context-detector.js +155 -0
  100. package/dist/utils/enhanced-error-handler.d.ts +47 -0
  101. package/dist/utils/enhanced-error-handler.d.ts.map +1 -0
  102. package/dist/utils/enhanced-error-handler.js +221 -0
  103. package/dist/utils/error-handler.d.ts +3 -0
  104. package/dist/utils/error-handler.d.ts.map +1 -0
  105. package/dist/utils/error-handler.js +55 -0
  106. package/dist/utils/errors.d.ts +44 -0
  107. package/dist/utils/errors.d.ts.map +1 -0
  108. package/dist/utils/errors.js +76 -0
  109. package/dist/utils/interactive-builder.d.ts +22 -0
  110. package/dist/utils/interactive-builder.d.ts.map +1 -0
  111. package/dist/utils/interactive-builder.js +246 -0
  112. package/dist/utils/rich-progress.d.ts +59 -0
  113. package/dist/utils/rich-progress.d.ts.map +1 -0
  114. package/dist/utils/rich-progress.js +234 -0
  115. package/dist/utils/store.d.ts +11 -0
  116. package/dist/utils/store.d.ts.map +1 -0
  117. package/dist/utils/store.js +19 -0
  118. package/dist/utils/validation-error-formatter.d.ts +25 -0
  119. package/dist/utils/validation-error-formatter.d.ts.map +1 -0
  120. package/dist/utils/validation-error-formatter.js +258 -0
  121. package/dist/utils/validation-helpers.d.ts +60 -0
  122. package/dist/utils/validation-helpers.d.ts.map +1 -0
  123. package/dist/utils/validation-helpers.js +152 -0
  124. package/package.json +43 -11
  125. package/src/__tests__/helpers/cli-test-helper.ts +281 -0
  126. package/src/__tests__/mocks/index.ts +142 -0
  127. package/src/actions/component.actions.ts +334 -0
  128. package/src/actions/function.actions.ts +313 -0
  129. package/src/actions/project.actions.ts +126 -0
  130. package/src/actions/version.actions.ts +233 -0
  131. package/src/commands/__tests__/component-validation.test.ts +250 -0
  132. package/src/commands/__tests__/component.test.ts +321 -0
  133. package/src/commands/__tests__/function-validation.test.ts +220 -0
  134. package/src/commands/__tests__/function.test.ts +286 -0
  135. package/src/commands/__tests__/store-version-validation.test.ts +414 -0
  136. package/src/commands/__tests__/store-version.test.ts +405 -0
  137. package/src/commands/__tests__/version.test.ts +71 -0
  138. package/src/commands/component.ts +188 -0
  139. package/src/commands/docs.ts +11 -11
  140. package/src/commands/function.ts +252 -0
  141. package/src/commands/help.ts +8 -18
  142. package/src/commands/index.ts +14 -7
  143. package/src/commands/login.ts +19 -79
  144. package/src/commands/project.ts +107 -0
  145. package/src/commands/store-version.ts +242 -0
  146. package/src/commands/version.ts +45 -8
  147. package/src/commands/whoami.ts +8 -13
  148. package/src/index.ts +108 -34
  149. package/src/prompts/component.prompts.ts +94 -0
  150. package/src/prompts/function.prompts.ts +168 -0
  151. package/src/schemas/command.schema.ts +354 -0
  152. package/src/types/index.ts +183 -0
  153. package/src/utils/__tests__/command-parser.test.ts +159 -0
  154. package/src/utils/__tests__/command-suggestions.test.ts +185 -0
  155. package/src/utils/__tests__/console.test.ts +192 -0
  156. package/src/utils/__tests__/context-detector.test.ts +258 -0
  157. package/src/utils/__tests__/enhanced-error-handler.test.ts +137 -0
  158. package/src/utils/__tests__/error-handler.test.ts +107 -0
  159. package/src/utils/__tests__/rich-progress.test.ts +170 -0
  160. package/src/utils/__tests__/validation-error-formatter.test.ts +175 -0
  161. package/src/utils/__tests__/validation-helpers.test.ts +125 -0
  162. package/src/utils/auth.ts +0 -1
  163. package/src/utils/cli-progress-reporter.ts +84 -0
  164. package/src/utils/command-builder.ts +390 -0
  165. package/src/utils/command-helpers.ts +83 -0
  166. package/src/utils/command-parser.ts +250 -0
  167. package/src/utils/command-suggestions.ts +176 -0
  168. package/src/utils/console.ts +291 -0
  169. package/src/utils/context-detector.ts +177 -0
  170. package/src/utils/enhanced-error-handler.ts +264 -0
  171. package/src/utils/error-handler.ts +60 -0
  172. package/src/utils/errors.ts +125 -0
  173. package/src/utils/interactive-builder.ts +271 -0
  174. package/src/utils/rich-progress.ts +320 -0
  175. package/src/utils/validation-error-formatter.ts +337 -0
  176. package/src/utils/validation-helpers.ts +192 -0
  177. package/tsconfig.json +13 -7
  178. package/vitest.config.ts +28 -0
  179. package/vitest.setup.ts +29 -0
  180. package/src/commands/validate.ts +0 -62
  181. package/src/utils/core.ts +0 -105
  182. package/tsup.config.ts +0 -15
@@ -1,13 +1,4 @@
1
1
 
2
- > @ollie-shop/cli@0.2.0 build /home/runner/work/ollie-shop/ollie-shop/packages/cli
3
- > tsup
2
+ > @ollie-shop/cli@0.3.0 build /home/runner/work/ollie-shop/ollie-shop/packages/cli
3
+ > tsc
4
4
 
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- CLI Using tsup config: /home/runner/work/ollie-shop/ollie-shop/packages/cli/tsup.config.ts
9
- CLI Target: esnext
10
- CLI Cleaning output folder
11
- CJS Build start
12
- CJS dist/index.js 16.06 KB
13
- CJS ⚡️ Build success in 543ms
package/CHANGELOG.md CHANGED
@@ -1,19 +1,25 @@
1
1
  # @ollie-shop/cli
2
2
 
3
- ## 0.2.0
3
+ ## 0.3.0
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 8f99b17: new CLI commands—docs, help, whoami, and validate—to the Ollie Shop CLI, along with supporting utility modules
7
+ - 202ff86: Major changes to cli, enabling new features such as components, functions, list, deploy, etc.
8
8
 
9
- ## 0.1.3
9
+ ## 0.3.0
10
10
 
11
- ### Patch Changes
11
+ ### Minor Changes
12
12
 
13
- - 8d43054: Change browser opening to use open package
13
+ - d97446b: Complete architectural overhaul with new command system and developer experience improvements:
14
14
 
15
- ## 0.1.2
15
+ - **New command structure**: Component, function, and store-version management commands
16
+ - **Action-based architecture**: Separation of CLI from business logic using @ollie-shop/core
17
+ - **Smart error recovery**: Actionable suggestions and solutions
18
+ - **Interactive mode**: Guided flows for all complex operations
19
+ - **Rich console output**: Progress indicators, formatted tables, and styled messages
20
+ - **Removed deployment environment concept**: Simplified deployment workflow
16
21
 
17
22
  ### Patch Changes
18
23
 
19
- - 906b57d: First Release
24
+ - Updated dependencies [d97446b]
25
+ - @ollie-shop/core@1.0.0
package/CLAUDE_CLI.md ADDED
@@ -0,0 +1,265 @@
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