@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,168 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FunctionInvocationType,
|
|
3
|
-
type FunctionInvocationTypeType,
|
|
4
|
-
OnErrorBehavior,
|
|
5
|
-
type OnErrorBehaviorType,
|
|
6
|
-
} from "@ollie-shop/core";
|
|
7
|
-
import inquirer from "inquirer";
|
|
8
|
-
import { validateFunctionName } from "../utils/validation-helpers";
|
|
9
|
-
|
|
10
|
-
export interface FunctionCreationAnswers {
|
|
11
|
-
name: string;
|
|
12
|
-
invocation: FunctionInvocationTypeType;
|
|
13
|
-
priority: number;
|
|
14
|
-
onError: OnErrorBehaviorType;
|
|
15
|
-
includeTests: boolean;
|
|
16
|
-
description?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface FunctionDeploymentAnswers {
|
|
20
|
-
versionId: string;
|
|
21
|
-
confirm: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface FunctionTestAnswers {
|
|
25
|
-
pattern: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Generate function invocation choices from core enum
|
|
29
|
-
const invocationChoices = FunctionInvocationType.options.map((type) => ({
|
|
30
|
-
name:
|
|
31
|
-
type === "request"
|
|
32
|
-
? "Request (before forwarding to target)"
|
|
33
|
-
: "Response (after receiving from target)",
|
|
34
|
-
value: type,
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
// Generate error behavior choices from core enum
|
|
38
|
-
const errorBehaviorChoices = OnErrorBehavior.options.map((behavior) => ({
|
|
39
|
-
name:
|
|
40
|
-
behavior === "throw"
|
|
41
|
-
? "Throw error and stop execution"
|
|
42
|
-
: "Skip and continue with next function",
|
|
43
|
-
value: behavior,
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
export async function promptFunctionCreation(
|
|
47
|
-
name?: string,
|
|
48
|
-
invocation?: string,
|
|
49
|
-
priority?: number,
|
|
50
|
-
onError?: string,
|
|
51
|
-
): Promise<FunctionCreationAnswers> {
|
|
52
|
-
const questions = [];
|
|
53
|
-
|
|
54
|
-
if (!name) {
|
|
55
|
-
questions.push({
|
|
56
|
-
type: "input",
|
|
57
|
-
name: "name",
|
|
58
|
-
message: "What's the name of your function?",
|
|
59
|
-
validate: (input: string) => {
|
|
60
|
-
return validateFunctionName(input);
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!invocation) {
|
|
66
|
-
questions.push({
|
|
67
|
-
type: "list",
|
|
68
|
-
name: "invocation",
|
|
69
|
-
message: "When should this function execute?",
|
|
70
|
-
choices: invocationChoices,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (priority === undefined) {
|
|
75
|
-
questions.push({
|
|
76
|
-
type: "number",
|
|
77
|
-
name: "priority",
|
|
78
|
-
message: "Priority (0-100, higher = executes first):",
|
|
79
|
-
default: 0,
|
|
80
|
-
validate: (input: number) => {
|
|
81
|
-
if (input < 0 || input > 100)
|
|
82
|
-
return "Priority must be between 0 and 100";
|
|
83
|
-
return true;
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (!onError) {
|
|
89
|
-
questions.push({
|
|
90
|
-
type: "list",
|
|
91
|
-
name: "onError",
|
|
92
|
-
message: "What should happen if this function fails?",
|
|
93
|
-
choices: errorBehaviorChoices,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
questions.push(
|
|
98
|
-
{
|
|
99
|
-
type: "input",
|
|
100
|
-
name: "description",
|
|
101
|
-
message: "Enter a description (optional):",
|
|
102
|
-
default: "",
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
type: "confirm",
|
|
106
|
-
name: "includeTests",
|
|
107
|
-
message: "Include test files?",
|
|
108
|
-
default: true,
|
|
109
|
-
},
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
const answers = await inquirer.prompt(questions);
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
name: name || answers.name,
|
|
116
|
-
invocation: invocation || answers.invocation,
|
|
117
|
-
priority: priority ?? answers.priority,
|
|
118
|
-
onError: onError || answers.onError,
|
|
119
|
-
description: answers.description || undefined,
|
|
120
|
-
includeTests: answers.includeTests,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export async function promptFunctionDeployment(): Promise<FunctionDeploymentAnswers> {
|
|
125
|
-
const answers = await inquirer.prompt([
|
|
126
|
-
{
|
|
127
|
-
type: "input",
|
|
128
|
-
name: "versionId",
|
|
129
|
-
message: "Enter the version ID to deploy to:",
|
|
130
|
-
validate: (input: string) => {
|
|
131
|
-
if (!input.trim()) return "Version ID is required";
|
|
132
|
-
return true;
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
type: "confirm",
|
|
137
|
-
name: "confirm",
|
|
138
|
-
message: "Are you sure you want to deploy this function?",
|
|
139
|
-
default: false,
|
|
140
|
-
},
|
|
141
|
-
]);
|
|
142
|
-
|
|
143
|
-
return answers;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export async function promptFunctionTest(): Promise<FunctionTestAnswers> {
|
|
147
|
-
const answers = await inquirer.prompt([
|
|
148
|
-
{
|
|
149
|
-
type: "input",
|
|
150
|
-
name: "pattern",
|
|
151
|
-
message: "Enter test file pattern:",
|
|
152
|
-
default: "**/*.test.{js,ts}",
|
|
153
|
-
},
|
|
154
|
-
]);
|
|
155
|
-
|
|
156
|
-
return answers;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function getInvocationDescription(
|
|
160
|
-
invocation: FunctionInvocationTypeType,
|
|
161
|
-
): string {
|
|
162
|
-
const descriptions: Record<FunctionInvocationTypeType, string> = {
|
|
163
|
-
request: "Executes before forwarding request to target URL",
|
|
164
|
-
response: "Executes after receiving response from target URL",
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
return descriptions[invocation] || "Custom invocation handler";
|
|
168
|
-
}
|