@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.
- package/.turbo/turbo-build.log +6 -9
- package/CHANGELOG.md +27 -0
- package/dist/index.js +993 -3956
- package/package.json +15 -37
- package/src/README.md +126 -0
- package/src/cli.tsx +45 -0
- package/src/commands/help.tsx +79 -0
- package/src/commands/login.tsx +92 -0
- package/src/commands/start.tsx +411 -0
- package/src/index.tsx +8 -0
- package/src/utils/auth.ts +218 -21
- package/src/utils/bundle.ts +177 -0
- package/src/utils/config.ts +123 -0
- package/src/utils/esbuild.ts +541 -0
- package/tsconfig.json +10 -15
- package/tsup.config.ts +7 -7
- package/CLAUDE_CLI.md +0 -265
- package/README.md +0 -711
- package/__tests__/mocks/console.ts +0 -22
- package/__tests__/mocks/core.ts +0 -137
- package/__tests__/mocks/index.ts +0 -4
- package/__tests__/mocks/inquirer.ts +0 -16
- package/__tests__/mocks/progress.ts +0 -19
- package/dist/index.d.ts +0 -1
- package/src/__tests__/helpers/cli-test-helper.ts +0 -281
- package/src/__tests__/mocks/index.ts +0 -142
- package/src/actions/component.actions.ts +0 -278
- package/src/actions/function.actions.ts +0 -220
- package/src/actions/project.actions.ts +0 -131
- package/src/actions/version.actions.ts +0 -233
- package/src/commands/__tests__/component-validation.test.ts +0 -250
- package/src/commands/__tests__/component.test.ts +0 -318
- package/src/commands/__tests__/function-validation.test.ts +0 -220
- package/src/commands/__tests__/function.test.ts +0 -286
- package/src/commands/__tests__/store-version-validation.test.ts +0 -414
- package/src/commands/__tests__/store-version.test.ts +0 -402
- package/src/commands/component.ts +0 -178
- package/src/commands/docs.ts +0 -24
- package/src/commands/function.ts +0 -201
- package/src/commands/help.ts +0 -18
- package/src/commands/index.ts +0 -27
- package/src/commands/login.ts +0 -267
- package/src/commands/project.ts +0 -107
- package/src/commands/store-version.ts +0 -242
- package/src/commands/version.ts +0 -51
- package/src/commands/whoami.ts +0 -46
- package/src/index.ts +0 -116
- package/src/prompts/component.prompts.ts +0 -94
- package/src/prompts/function.prompts.ts +0 -168
- package/src/schemas/command.schema.ts +0 -644
- package/src/types/index.ts +0 -183
- package/src/utils/__tests__/command-parser.test.ts +0 -159
- package/src/utils/__tests__/command-suggestions.test.ts +0 -185
- package/src/utils/__tests__/console.test.ts +0 -192
- package/src/utils/__tests__/context-detector.test.ts +0 -258
- package/src/utils/__tests__/enhanced-error-handler.test.ts +0 -137
- package/src/utils/__tests__/error-handler.test.ts +0 -107
- package/src/utils/__tests__/rich-progress.test.ts +0 -181
- package/src/utils/__tests__/validation-error-formatter.test.ts +0 -175
- package/src/utils/__tests__/validation-helpers.test.ts +0 -125
- package/src/utils/cli-progress-reporter.ts +0 -84
- package/src/utils/command-builder.ts +0 -390
- package/src/utils/command-helpers.ts +0 -83
- package/src/utils/command-parser.ts +0 -245
- package/src/utils/command-suggestions.ts +0 -176
- package/src/utils/console.ts +0 -320
- package/src/utils/constants.ts +0 -39
- package/src/utils/context-detector.ts +0 -177
- package/src/utils/deploy-helpers.ts +0 -357
- package/src/utils/enhanced-error-handler.ts +0 -264
- package/src/utils/error-handler.ts +0 -60
- package/src/utils/errors.ts +0 -256
- package/src/utils/interactive-builder.ts +0 -325
- package/src/utils/rich-progress.ts +0 -331
- package/src/utils/store.ts +0 -23
- package/src/utils/validation-error-formatter.ts +0 -337
- package/src/utils/validation-helpers.ts +0 -325
- package/vitest.config.ts +0 -35
- package/vitest.setup.ts +0 -29
|
@@ -1,644 +0,0 @@
|
|
|
1
|
-
// Following TypeScript Discipline: Import schemas from core instead of duplicating
|
|
2
|
-
import {
|
|
3
|
-
BuildStatus,
|
|
4
|
-
ComponentNameSchema,
|
|
5
|
-
ComponentSlot,
|
|
6
|
-
FunctionInvocationType,
|
|
7
|
-
FunctionNameSchema,
|
|
8
|
-
OnErrorBehavior,
|
|
9
|
-
Template,
|
|
10
|
-
} from "@ollie-shop/core";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
|
|
13
|
-
// Re-export schemas from core for CLI use
|
|
14
|
-
export { ComponentNameSchema, FunctionNameSchema };
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* CLI-specific schemas (only for CLI-specific concerns)
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Schema for file system paths
|
|
22
|
-
* @example "./src/components/header"
|
|
23
|
-
* @example "/absolute/path/to/component"
|
|
24
|
-
*/
|
|
25
|
-
export const PathSchema = z.string().min(1, "Path cannot be empty");
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Schema for store identifiers
|
|
29
|
-
* Must be a valid UUID v4 format
|
|
30
|
-
* @example "123e4567-e89b-12d3-a456-426614174000"
|
|
31
|
-
*/
|
|
32
|
-
export const StoreIdSchema = z.string().uuid("Invalid store ID format");
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Schema for version names
|
|
36
|
-
* @example "Production v2.0"
|
|
37
|
-
* @example "Holiday Sale Version"
|
|
38
|
-
* @minLength 1
|
|
39
|
-
* @maxLength 100
|
|
40
|
-
*/
|
|
41
|
-
export const VersionNameSchema = z
|
|
42
|
-
.string()
|
|
43
|
-
.min(1, "Version name is required")
|
|
44
|
-
.max(100, "Version name is too long (max 100 characters)");
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Schema for function execution priority
|
|
48
|
-
* Higher numbers execute first
|
|
49
|
-
* @minimum 0
|
|
50
|
-
* @maximum 100
|
|
51
|
-
* @example 50 - Default priority
|
|
52
|
-
* @example 90 - High priority (executes early)
|
|
53
|
-
* @example 10 - Low priority (executes late)
|
|
54
|
-
*/
|
|
55
|
-
export const PrioritySchema = z
|
|
56
|
-
.number()
|
|
57
|
-
.int("Priority must be a whole number")
|
|
58
|
-
.min(0, "Priority must be between 0 and 100")
|
|
59
|
-
.max(100, "Priority must be between 0 and 100");
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Schema for URLs and URL patterns
|
|
63
|
-
* Supports both full URLs and path patterns
|
|
64
|
-
* @example "https://api.example.com/webhook"
|
|
65
|
-
* @example "/api/cart/*"
|
|
66
|
-
* @example "/*" - Matches all paths
|
|
67
|
-
*/
|
|
68
|
-
export const UrlSchema = z
|
|
69
|
-
.string()
|
|
70
|
-
.min(1, "URL is required")
|
|
71
|
-
.refine((url) => {
|
|
72
|
-
// Allow URL patterns like /api/* or /*
|
|
73
|
-
if (url.startsWith("/")) {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
// Validate full URLs
|
|
77
|
-
try {
|
|
78
|
-
const parsed = new URL(url);
|
|
79
|
-
return ["http:", "https:"].includes(parsed.protocol);
|
|
80
|
-
} catch {
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
}, "URL must be a valid URL or path pattern");
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Schema for semantic version numbers
|
|
87
|
-
* @pattern ^\d+\.\d+\.\d+$
|
|
88
|
-
* @example "1.0.0"
|
|
89
|
-
* @example "2.4.6"
|
|
90
|
-
* @see https://semver.org/
|
|
91
|
-
*/
|
|
92
|
-
export const SemverSchema = z
|
|
93
|
-
.string()
|
|
94
|
-
.regex(
|
|
95
|
-
/^\d+\.\d+\.\d+$/,
|
|
96
|
-
"Version must follow semantic versioning format (e.g., 1.0.0)",
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Component command schemas
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Options for creating a new component
|
|
105
|
-
* @property {string} [name] - Component name in kebab-case (e.g., "header-banner")
|
|
106
|
-
* @property {"header"|"main"|"footer"|"sidebar"} [slot="main"] - Where the component renders in the checkout
|
|
107
|
-
* @property {boolean} [tests=true] - Whether to generate test files
|
|
108
|
-
* @property {string} [template] - Custom template to use for generation
|
|
109
|
-
* @property {boolean} [interactive] - Use interactive mode with prompts
|
|
110
|
-
* @example
|
|
111
|
-
* // CLI usage:
|
|
112
|
-
* ollieshop component create --name header-banner --slot header
|
|
113
|
-
* ollieshop component create --interactive
|
|
114
|
-
*/
|
|
115
|
-
export const ComponentCreateOptionsSchema = z
|
|
116
|
-
.object({
|
|
117
|
-
name: ComponentNameSchema.optional(), // Optional for interactive mode
|
|
118
|
-
slot: ComponentSlot.optional().default("main"),
|
|
119
|
-
tests: z.boolean().optional().default(true),
|
|
120
|
-
template: z.string().optional(),
|
|
121
|
-
interactive: z.boolean().optional(),
|
|
122
|
-
})
|
|
123
|
-
.refine((data) => data.interactive || data.name, {
|
|
124
|
-
message: "Component name is required when not in interactive mode",
|
|
125
|
-
path: ["name"],
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Options for building a component
|
|
130
|
-
* @property {string} [path] - Path to component directory (defaults to current directory)
|
|
131
|
-
* @property {boolean} [watch=false] - Watch for file changes and rebuild automatically
|
|
132
|
-
* @property {boolean} [minify=true] - Minify the output bundle
|
|
133
|
-
* @property {boolean} [sourcemap=true] - Generate source maps for debugging
|
|
134
|
-
* @example
|
|
135
|
-
* // CLI usage:
|
|
136
|
-
* ollieshop component build
|
|
137
|
-
* ollieshop component build --watch
|
|
138
|
-
* ollieshop component build --path ./components/header --no-minify
|
|
139
|
-
*/
|
|
140
|
-
export const ComponentBuildOptionsSchema = z.object({
|
|
141
|
-
path: PathSchema.optional(),
|
|
142
|
-
watch: z.boolean().optional(),
|
|
143
|
-
minify: z.boolean().optional(),
|
|
144
|
-
sourcemap: z.boolean().optional(),
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Options for validating a component
|
|
149
|
-
* @property {string} [path] - Path to component directory (defaults to current directory)
|
|
150
|
-
* @property {boolean} [strict=false] - Enable strict validation mode with additional checks
|
|
151
|
-
* @property {boolean} [fix=false] - Automatically fix fixable validation issues
|
|
152
|
-
* @example
|
|
153
|
-
* // CLI usage:
|
|
154
|
-
* ollieshop component validate
|
|
155
|
-
* ollieshop component validate --strict
|
|
156
|
-
* ollieshop component validate --fix
|
|
157
|
-
*/
|
|
158
|
-
export const ComponentValidateOptionsSchema = z.object({
|
|
159
|
-
path: PathSchema.optional(),
|
|
160
|
-
strict: z.boolean().optional(),
|
|
161
|
-
fix: z.boolean().optional(),
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Options for deploying a component
|
|
166
|
-
* @property {string} [path] - Path to component directory (defaults to current directory)
|
|
167
|
-
* @property {string} [componentId] - UUID of the component to deploy (internal use)
|
|
168
|
-
* @property {string} [id] - UUID of the component to deploy (CLI flag)
|
|
169
|
-
* @example
|
|
170
|
-
* // CLI usage:
|
|
171
|
-
* ollieshop component deploy --id 123e4567-e89b-12d3-a456-426614174000
|
|
172
|
-
* ollieshop component deploy --id 123e4567-e89b-12d3-a456-426614174000 --path ./dist
|
|
173
|
-
*/
|
|
174
|
-
export const ComponentDeployOptionsSchema = z.object({
|
|
175
|
-
path: PathSchema.optional(),
|
|
176
|
-
componentId: z.string().uuid("Invalid component ID format").optional(),
|
|
177
|
-
id: z.string().uuid("Invalid component ID format").optional(), // CLI uses --id flag
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Function command schemas
|
|
182
|
-
*/
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Options for creating a new function
|
|
186
|
-
* @property {string} name - Function name in kebab-case (e.g., "validate-cart")
|
|
187
|
-
* @property {"request"|"response"} [invocation="request"] - When the function executes in the request lifecycle
|
|
188
|
-
* @property {number} [priority=0] - Execution priority (0-100, higher executes first)
|
|
189
|
-
* @property {"throw"|"skip"} [onError="throw"] - Error handling behavior
|
|
190
|
-
* @property {boolean} [tests=true] - Whether to generate test files
|
|
191
|
-
* @property {string} [template] - Custom template to use for generation
|
|
192
|
-
* @property {string} [description] - Human-readable description of function purpose
|
|
193
|
-
* @example
|
|
194
|
-
* // CLI usage:
|
|
195
|
-
* ollieshop function create --name validate-cart --invocation request --priority 90
|
|
196
|
-
* ollieshop function create --name apply-discount --on-error skip
|
|
197
|
-
*/
|
|
198
|
-
export const FunctionCreateOptionsSchema = z.object({
|
|
199
|
-
name: FunctionNameSchema,
|
|
200
|
-
invocation: FunctionInvocationType.optional().default("request"),
|
|
201
|
-
priority: PrioritySchema.optional().default(0),
|
|
202
|
-
onError: OnErrorBehavior.optional().default("throw"),
|
|
203
|
-
tests: z.boolean().optional().default(true),
|
|
204
|
-
template: z.string().optional(),
|
|
205
|
-
description: z.string().optional(),
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Options for building a function
|
|
210
|
-
* @property {string} [path] - Path to function directory (defaults to current directory)
|
|
211
|
-
* @property {boolean} [watch=false] - Watch for file changes and rebuild automatically
|
|
212
|
-
* @property {boolean} [minify=true] - Minify the output bundle
|
|
213
|
-
* @property {"node16"|"node18"|"node20"} [target="node18"] - Target Node.js runtime version
|
|
214
|
-
* @example
|
|
215
|
-
* // CLI usage:
|
|
216
|
-
* ollieshop function build
|
|
217
|
-
* ollieshop function build --watch --target node20
|
|
218
|
-
* ollieshop function build --no-minify
|
|
219
|
-
*/
|
|
220
|
-
export const FunctionBuildOptionsSchema = z.object({
|
|
221
|
-
path: PathSchema.optional(),
|
|
222
|
-
watch: z.boolean().optional(),
|
|
223
|
-
minify: z.boolean().optional(),
|
|
224
|
-
target: z.enum(["node16", "node18", "node20"]).optional(),
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
export const FunctionValidateOptionsSchema = z.object({
|
|
228
|
-
path: PathSchema.optional(),
|
|
229
|
-
strict: z.boolean().optional(),
|
|
230
|
-
fix: z.boolean().optional(),
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Options for testing a function
|
|
235
|
-
* @property {string} [path] - Path to function directory (defaults to current directory)
|
|
236
|
-
* @property {string} [payload] - JSON payload to send to the function
|
|
237
|
-
* @property {number} [timeout=30000] - Test timeout in milliseconds
|
|
238
|
-
* @property {boolean} [coverage=false] - Generate code coverage report
|
|
239
|
-
* @property {boolean} [watch=false] - Run tests in watch mode
|
|
240
|
-
* @example
|
|
241
|
-
* // CLI usage:
|
|
242
|
-
* ollieshop function test
|
|
243
|
-
* ollieshop function test --payload '{"cart": {"total": 100}}'
|
|
244
|
-
* ollieshop function test --watch --coverage
|
|
245
|
-
*/
|
|
246
|
-
export const FunctionTestOptionsSchema = z.object({
|
|
247
|
-
path: PathSchema.optional(),
|
|
248
|
-
payload: z.string().optional(),
|
|
249
|
-
timeout: z.number().optional(),
|
|
250
|
-
coverage: z.boolean().optional(),
|
|
251
|
-
watch: z.boolean().optional(),
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Options for deploying a function
|
|
256
|
-
* @property {string} [path] - Path to function directory (defaults to current directory)
|
|
257
|
-
* @property {string} [functionId] - UUID of the function to deploy (internal use)
|
|
258
|
-
* @property {string} [id] - UUID of the function to deploy (CLI flag)
|
|
259
|
-
* @example
|
|
260
|
-
* // CLI usage:
|
|
261
|
-
* ollieshop function deploy --id 123e4567-e89b-12d3-a456-426614174000
|
|
262
|
-
* ollieshop function deploy --id 123e4567-e89b-12d3-a456-426614174000 --path ./dist
|
|
263
|
-
*/
|
|
264
|
-
export const FunctionDeployOptionsSchema = z.object({
|
|
265
|
-
path: PathSchema.optional(),
|
|
266
|
-
functionId: z.string().uuid("Invalid function ID format").optional(),
|
|
267
|
-
id: z.string().uuid("Invalid function ID format").optional(), // CLI uses --id flag
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Development server schemas
|
|
272
|
-
*/
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Options for running a development server
|
|
276
|
-
* @property {number} [port=3000] - Port number to run the server on (1000-65535)
|
|
277
|
-
* @property {string} [host="localhost"] - Host to bind the server to
|
|
278
|
-
* @property {boolean} [open=true] - Open browser automatically when server starts
|
|
279
|
-
* @property {string} [component] - Path to specific component to develop
|
|
280
|
-
* @property {string} [function] - Path to specific function to develop
|
|
281
|
-
* @property {string} [mockData] - Path to mock data file for testing
|
|
282
|
-
* @property {boolean} [hot=true] - Enable hot module replacement
|
|
283
|
-
* @property {boolean} [https=false] - Enable HTTPS with self-signed certificate
|
|
284
|
-
* @example
|
|
285
|
-
* // CLI usage:
|
|
286
|
-
* ollieshop dev
|
|
287
|
-
* ollieshop dev --port 8080 --no-open
|
|
288
|
-
* ollieshop dev --component ./components/header --hot
|
|
289
|
-
*/
|
|
290
|
-
export const DevServerOptionsSchema = z.object({
|
|
291
|
-
port: z.number().min(1000).max(65535).default(3000),
|
|
292
|
-
host: z.string().default("localhost"),
|
|
293
|
-
open: z.boolean().default(true),
|
|
294
|
-
component: PathSchema.optional(),
|
|
295
|
-
function: PathSchema.optional(),
|
|
296
|
-
mockData: PathSchema.optional(),
|
|
297
|
-
hot: z.boolean().default(true),
|
|
298
|
-
https: z.boolean().default(false),
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Global CLI options schemas
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Global options available for all CLI commands
|
|
307
|
-
* @property {boolean} [verbose=false] - Show detailed output and debug information
|
|
308
|
-
* @property {boolean} [quiet=false] - Suppress all output except errors
|
|
309
|
-
* @property {boolean} [color=true] - Enable colored output (use --no-color to disable)
|
|
310
|
-
* @property {string} [config] - Path to custom configuration file
|
|
311
|
-
* @property {"error"|"warn"|"info"|"debug"} [logLevel="info"] - Minimum log level to display
|
|
312
|
-
* @example
|
|
313
|
-
* // CLI usage:
|
|
314
|
-
* ollieshop --verbose component create --name header
|
|
315
|
-
* ollieshop --quiet function deploy --id abc-123
|
|
316
|
-
* ollieshop --no-color --log-level debug component build
|
|
317
|
-
*/
|
|
318
|
-
export const GlobalOptionsSchema = z.object({
|
|
319
|
-
verbose: z.boolean().default(false),
|
|
320
|
-
quiet: z.boolean().default(false),
|
|
321
|
-
color: z.boolean().default(true), // --no-color sets this to false
|
|
322
|
-
config: PathSchema.optional(),
|
|
323
|
-
logLevel: z.enum(["error", "warn", "info", "debug"]).default("info"),
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Build command schemas
|
|
328
|
-
*/
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Options for building projects, components, or functions
|
|
332
|
-
* @property {string} [path] - Path to build (defaults to current directory)
|
|
333
|
-
* @property {string} [output] - Output directory for build artifacts
|
|
334
|
-
* @property {boolean} [minify=true] - Minify the output
|
|
335
|
-
* @property {boolean} [sourcemap=true] - Generate source maps
|
|
336
|
-
* @property {boolean} [watch=false] - Watch mode for continuous builds
|
|
337
|
-
* @property {boolean} [clean=true] - Clean output directory before building
|
|
338
|
-
* @example
|
|
339
|
-
* // CLI usage:
|
|
340
|
-
* ollieshop build
|
|
341
|
-
* ollieshop build --output ./dist --no-minify
|
|
342
|
-
* ollieshop build --watch --no-clean
|
|
343
|
-
*/
|
|
344
|
-
export const BuildOptionsSchema = z.object({
|
|
345
|
-
path: PathSchema.optional(),
|
|
346
|
-
output: PathSchema.optional(),
|
|
347
|
-
minify: z.boolean().default(true),
|
|
348
|
-
sourcemap: z.boolean().default(true),
|
|
349
|
-
watch: z.boolean().default(false),
|
|
350
|
-
clean: z.boolean().default(true),
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Login/Auth schemas
|
|
355
|
-
*/
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Options for CLI authentication
|
|
359
|
-
* @property {string} [token] - Authentication token (if not using interactive login)
|
|
360
|
-
* @property {boolean} [interactive=true] - Use interactive browser-based login
|
|
361
|
-
* @property {boolean} [save=true] - Save credentials for future use
|
|
362
|
-
* @example
|
|
363
|
-
* // CLI usage:
|
|
364
|
-
* ollieshop login
|
|
365
|
-
* ollieshop login --token abc123
|
|
366
|
-
* ollieshop login --no-save
|
|
367
|
-
*/
|
|
368
|
-
export const LoginOptionsSchema = z.object({
|
|
369
|
-
token: z.string().optional(),
|
|
370
|
-
interactive: z.boolean().default(true),
|
|
371
|
-
save: z.boolean().default(true),
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
/**
|
|
375
|
-
* Init project schemas
|
|
376
|
-
*/
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Options for initializing a new Ollie Shop project
|
|
380
|
-
* @property {string} [name="my-ollie-shop"] - Project name
|
|
381
|
-
* @property {"default"|"grocery"|"sales"} [template="default"] - Checkout template to use
|
|
382
|
-
* @property {boolean} [git=true] - Initialize git repository
|
|
383
|
-
* @property {boolean} [install=true] - Install dependencies automatically
|
|
384
|
-
* @property {string} [path] - Where to create the project (defaults to project name)
|
|
385
|
-
* @example
|
|
386
|
-
* // CLI usage:
|
|
387
|
-
* ollieshop init --name my-checkout
|
|
388
|
-
* ollieshop init --template grocery --no-install
|
|
389
|
-
* ollieshop init --name holiday-sale --path ./projects/holiday
|
|
390
|
-
*/
|
|
391
|
-
export const InitOptionsSchema = z.object({
|
|
392
|
-
name: z.string().optional(),
|
|
393
|
-
template: Template.optional().default("default"),
|
|
394
|
-
git: z.boolean().default(true),
|
|
395
|
-
install: z.boolean().default(true),
|
|
396
|
-
path: PathSchema.optional(),
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
/**
|
|
400
|
-
* Store version command schemas
|
|
401
|
-
*/
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Options for creating a store version
|
|
405
|
-
* @property {string} store - UUID of the store
|
|
406
|
-
* @property {string} name - Version name (1-100 characters)
|
|
407
|
-
* @property {"default"|"grocery"|"sales"} [template] - Checkout template
|
|
408
|
-
* @property {boolean} [active=true] - Whether version is active immediately
|
|
409
|
-
* @example
|
|
410
|
-
* // CLI usage:
|
|
411
|
-
* ollieshop version create --store 123e4567-e89b-12d3-a456-426614174000 --name "Black Friday"
|
|
412
|
-
* ollieshop version create --store abc-123 --name "Test" --template grocery --no-active
|
|
413
|
-
*/
|
|
414
|
-
export const StoreVersionCreateOptionsSchema = z.object({
|
|
415
|
-
store: StoreIdSchema,
|
|
416
|
-
name: VersionNameSchema,
|
|
417
|
-
template: Template.optional(),
|
|
418
|
-
active: z.boolean().optional(),
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
export const StoreVersionListOptionsSchema = z.object({
|
|
422
|
-
store: StoreIdSchema,
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
export const StoreVersionCloneOptionsSchema = z.object({
|
|
426
|
-
store: StoreIdSchema,
|
|
427
|
-
sourceId: z.string().uuid("Invalid source version ID"),
|
|
428
|
-
name: VersionNameSchema,
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
export const StoreVersionActivateOptionsSchema = z.object({
|
|
432
|
-
store: StoreIdSchema,
|
|
433
|
-
versionId: z.string().uuid("Invalid version ID"),
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
export const StoreVersionSetDefaultOptionsSchema = z.object({
|
|
437
|
-
store: StoreIdSchema,
|
|
438
|
-
versionId: z.string().uuid("Invalid version ID"),
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
// Type exports
|
|
442
|
-
export type ComponentCreateOptions = z.infer<
|
|
443
|
-
typeof ComponentCreateOptionsSchema
|
|
444
|
-
>;
|
|
445
|
-
export type ComponentBuildOptions = z.infer<typeof ComponentBuildOptionsSchema>;
|
|
446
|
-
export type ComponentValidateOptions = z.infer<
|
|
447
|
-
typeof ComponentValidateOptionsSchema
|
|
448
|
-
>;
|
|
449
|
-
export type ComponentDeployOptions = z.infer<
|
|
450
|
-
typeof ComponentDeployOptionsSchema
|
|
451
|
-
>;
|
|
452
|
-
|
|
453
|
-
export type FunctionCreateOptions = z.infer<typeof FunctionCreateOptionsSchema>;
|
|
454
|
-
export type FunctionBuildOptions = z.infer<typeof FunctionBuildOptionsSchema>;
|
|
455
|
-
export type FunctionValidateOptions = z.infer<
|
|
456
|
-
typeof FunctionValidateOptionsSchema
|
|
457
|
-
>;
|
|
458
|
-
export type FunctionTestOptions = z.infer<typeof FunctionTestOptionsSchema>;
|
|
459
|
-
export type FunctionDeployOptions = z.infer<typeof FunctionDeployOptionsSchema>;
|
|
460
|
-
|
|
461
|
-
export type DevServerOptions = z.infer<typeof DevServerOptionsSchema>;
|
|
462
|
-
export type GlobalOptions = z.infer<typeof GlobalOptionsSchema>;
|
|
463
|
-
export type BuildOptions = z.infer<typeof BuildOptionsSchema>;
|
|
464
|
-
export type LoginOptions = z.infer<typeof LoginOptionsSchema>;
|
|
465
|
-
export type InitOptions = z.infer<typeof InitOptionsSchema>;
|
|
466
|
-
|
|
467
|
-
export type StoreVersionCreateOptions = z.infer<
|
|
468
|
-
typeof StoreVersionCreateOptionsSchema
|
|
469
|
-
>;
|
|
470
|
-
export type StoreVersionListOptions = z.infer<
|
|
471
|
-
typeof StoreVersionListOptionsSchema
|
|
472
|
-
>;
|
|
473
|
-
export type StoreVersionCloneOptions = z.infer<
|
|
474
|
-
typeof StoreVersionCloneOptionsSchema
|
|
475
|
-
>;
|
|
476
|
-
export type StoreVersionActivateOptions = z.infer<
|
|
477
|
-
typeof StoreVersionActivateOptionsSchema
|
|
478
|
-
>;
|
|
479
|
-
export type StoreVersionSetDefaultOptions = z.infer<
|
|
480
|
-
typeof StoreVersionSetDefaultOptionsSchema
|
|
481
|
-
>;
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* Validation helper functions
|
|
485
|
-
*/
|
|
486
|
-
// NOTE: For component and function name validation, use validation functions from core:
|
|
487
|
-
// import { validateComponentName, validateFunctionName } from "@ollie-shop/core/schemas"
|
|
488
|
-
|
|
489
|
-
export function validatePath(path: string): boolean {
|
|
490
|
-
return PathSchema.safeParse(path).success;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
export function validateStoreId(storeId: string): boolean {
|
|
494
|
-
return StoreIdSchema.safeParse(storeId).success;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
export function validateVersionName(name: string): boolean {
|
|
498
|
-
return VersionNameSchema.safeParse(name).success;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
export function validatePriority(priority: number): boolean {
|
|
502
|
-
return PrioritySchema.safeParse(priority).success;
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
export function validateUrl(url: string): boolean {
|
|
506
|
-
return UrlSchema.safeParse(url).success;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
export function validateSemver(version: string): boolean {
|
|
510
|
-
return SemverSchema.safeParse(version).success;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
export function validateUUID(id: string): boolean {
|
|
514
|
-
const uuidSchema = z.string().uuid();
|
|
515
|
-
return uuidSchema.safeParse(id).success;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
/**
|
|
519
|
-
* Environment variable validation schemas and helpers
|
|
520
|
-
*/
|
|
521
|
-
export const BuilderApiUrlSchema = z
|
|
522
|
-
.string()
|
|
523
|
-
.url("BUILDER_API_URL must be a valid URL")
|
|
524
|
-
.refine(
|
|
525
|
-
(url) => {
|
|
526
|
-
try {
|
|
527
|
-
const parsed = new URL(url);
|
|
528
|
-
return ["http:", "https:"].includes(parsed.protocol);
|
|
529
|
-
} catch {
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
message: "BUILDER_API_URL must use http or https protocol",
|
|
535
|
-
},
|
|
536
|
-
);
|
|
537
|
-
|
|
538
|
-
export const EnvironmentVariablesSchema = z.object({
|
|
539
|
-
BUILDER_API_URL: BuilderApiUrlSchema.optional(),
|
|
540
|
-
DEBUG: z.string().optional(),
|
|
541
|
-
NODE_ENV: z.enum(["development", "test", "production"]).optional(),
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Validates all CLI environment variables
|
|
546
|
-
* @returns {Object} Validation result with success flag and optional errors
|
|
547
|
-
* @returns {boolean} result.success - True if all env vars are valid
|
|
548
|
-
* @returns {string[]} [result.errors] - Array of validation error messages
|
|
549
|
-
* @example
|
|
550
|
-
* const result = validateEnvironmentVariables();
|
|
551
|
-
* if (!result.success) {
|
|
552
|
-
* console.error("Invalid environment:", result.errors);
|
|
553
|
-
* }
|
|
554
|
-
*/
|
|
555
|
-
export function validateEnvironmentVariables(): {
|
|
556
|
-
success: boolean;
|
|
557
|
-
errors?: string[];
|
|
558
|
-
} {
|
|
559
|
-
const envVars = {
|
|
560
|
-
BUILDER_API_URL: process.env.BUILDER_API_URL,
|
|
561
|
-
DEBUG: process.env.DEBUG,
|
|
562
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
const result = EnvironmentVariablesSchema.safeParse(envVars);
|
|
566
|
-
|
|
567
|
-
if (!result.success) {
|
|
568
|
-
return {
|
|
569
|
-
success: false,
|
|
570
|
-
errors: result.error.issues.map(
|
|
571
|
-
(issue) => `${issue.path.join(".")}: ${issue.message}`,
|
|
572
|
-
),
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
return { success: true };
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
export function validateBuilderApiUrl(url?: string): boolean {
|
|
580
|
-
if (!url) return true; // Optional
|
|
581
|
-
return BuilderApiUrlSchema.safeParse(url).success;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
/**
|
|
585
|
-
* CLI Data Display Schemas
|
|
586
|
-
* These schemas define the structure for data displayed in CLI commands
|
|
587
|
-
*/
|
|
588
|
-
|
|
589
|
-
// Function list item schema for CLI display
|
|
590
|
-
export const FunctionListItemSchema = z.object({
|
|
591
|
-
id: z.string(),
|
|
592
|
-
name: z.string(),
|
|
593
|
-
runtime: z.string().optional(),
|
|
594
|
-
version: z.string().optional(),
|
|
595
|
-
enabled: z.boolean(),
|
|
596
|
-
createdAt: z.union([z.string(), z.date()]),
|
|
597
|
-
invocation: FunctionInvocationType.optional(),
|
|
598
|
-
priority: z.number().optional(),
|
|
599
|
-
onError: OnErrorBehavior.optional(),
|
|
600
|
-
description: z.string().optional(),
|
|
601
|
-
});
|
|
602
|
-
|
|
603
|
-
// Component list item schema for CLI display
|
|
604
|
-
export const ComponentListItemSchema = z.object({
|
|
605
|
-
id: z.string(),
|
|
606
|
-
name: z.string(),
|
|
607
|
-
slot: ComponentSlot,
|
|
608
|
-
version: z.string().optional(),
|
|
609
|
-
enabled: z.boolean(),
|
|
610
|
-
createdAt: z.union([z.string(), z.date()]),
|
|
611
|
-
description: z.string().optional(),
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
// Build status schema
|
|
615
|
-
export const BuildStatusSchema = z.object({
|
|
616
|
-
id: z.string(),
|
|
617
|
-
status: BuildStatus,
|
|
618
|
-
startTime: z.union([z.string(), z.date()]),
|
|
619
|
-
endTime: z.union([z.string(), z.date()]).optional(),
|
|
620
|
-
deploymentUrl: z.string().optional(),
|
|
621
|
-
artifactLocation: z.string().optional(),
|
|
622
|
-
logs: z.string().optional(),
|
|
623
|
-
error: z.string().optional(),
|
|
624
|
-
resourceId: z.string(),
|
|
625
|
-
resourceType: z.enum(["component", "function"]),
|
|
626
|
-
});
|
|
627
|
-
|
|
628
|
-
// Version list item schema for CLI display
|
|
629
|
-
export const VersionListItemSchema = z.object({
|
|
630
|
-
id: z.string(),
|
|
631
|
-
name: z.string(),
|
|
632
|
-
template: z.string().nullable().optional(),
|
|
633
|
-
active: z.boolean(),
|
|
634
|
-
default: z.boolean(),
|
|
635
|
-
createdAt: z.union([z.string(), z.date()]),
|
|
636
|
-
updatedAt: z.union([z.string(), z.date()]),
|
|
637
|
-
storeId: z.string(),
|
|
638
|
-
});
|
|
639
|
-
|
|
640
|
-
// Type exports derived from schemas
|
|
641
|
-
export type FunctionListItem = z.infer<typeof FunctionListItemSchema>;
|
|
642
|
-
export type ComponentListItem = z.infer<typeof ComponentListItemSchema>;
|
|
643
|
-
export type BuildStatusItem = z.infer<typeof BuildStatusSchema>;
|
|
644
|
-
export type VersionListItem = z.infer<typeof VersionListItemSchema>;
|