@ollie-shop/cli 0.3.0 → 0.3.3
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 +14 -2
- package/CHANGELOG.md +48 -0
- package/__tests__/mocks/core.ts +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +40631 -75
- package/package.json +7 -6
- package/src/actions/component.actions.ts +148 -204
- package/src/actions/function.actions.ts +78 -171
- package/src/actions/project.actions.ts +16 -11
- package/src/commands/__tests__/component.test.ts +4 -7
- package/src/commands/__tests__/function.test.ts +1 -1
- package/src/commands/__tests__/store-version.test.ts +1 -4
- package/src/commands/component.ts +0 -10
- package/src/commands/function.ts +5 -56
- package/src/schemas/command.schema.ts +296 -6
- package/src/utils/__tests__/rich-progress.test.ts +22 -11
- package/src/utils/cli-progress-reporter.ts +2 -2
- package/src/utils/command-parser.ts +0 -5
- package/src/utils/console.ts +33 -4
- package/src/utils/constants.ts +32 -0
- package/src/utils/deploy-helpers.ts +357 -0
- package/src/utils/errors.ts +133 -2
- package/src/utils/interactive-builder.ts +61 -7
- package/src/utils/rich-progress.ts +25 -14
- package/src/utils/validation-helpers.ts +145 -12
- package/tsup.config.ts +15 -0
- package/dist/__tests__/helpers/cli-test-helper.d.ts +0 -89
- package/dist/__tests__/helpers/cli-test-helper.d.ts.map +0 -1
- package/dist/__tests__/helpers/cli-test-helper.js +0 -220
- package/dist/__tests__/mocks/index.d.ts +0 -69
- package/dist/__tests__/mocks/index.d.ts.map +0 -1
- package/dist/__tests__/mocks/index.js +0 -77
- package/dist/actions/component.actions.d.ts +0 -14
- package/dist/actions/component.actions.d.ts.map +0 -1
- package/dist/actions/component.actions.js +0 -273
- package/dist/actions/function.actions.d.ts +0 -15
- package/dist/actions/function.actions.d.ts.map +0 -1
- package/dist/actions/function.actions.js +0 -254
- package/dist/actions/project.actions.d.ts +0 -17
- package/dist/actions/project.actions.d.ts.map +0 -1
- package/dist/actions/project.actions.js +0 -97
- package/dist/actions/version.actions.d.ts +0 -19
- package/dist/actions/version.actions.d.ts.map +0 -1
- package/dist/actions/version.actions.js +0 -216
- package/dist/commands/component.d.ts +0 -3
- package/dist/commands/component.d.ts.map +0 -1
- package/dist/commands/component.js +0 -192
- package/dist/commands/docs.d.ts +0 -3
- package/dist/commands/docs.d.ts.map +0 -1
- package/dist/commands/docs.js +0 -16
- package/dist/commands/function.d.ts +0 -3
- package/dist/commands/function.d.ts.map +0 -1
- package/dist/commands/function.js +0 -243
- package/dist/commands/help.d.ts +0 -3
- package/dist/commands/help.d.ts.map +0 -1
- package/dist/commands/help.js +0 -20
- package/dist/commands/index.d.ts +0 -3
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js +0 -26
- package/dist/commands/login.d.ts +0 -3
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -175
- package/dist/commands/project.d.ts +0 -3
- package/dist/commands/project.d.ts.map +0 -1
- package/dist/commands/project.js +0 -78
- package/dist/commands/store-version.d.ts +0 -3
- package/dist/commands/store-version.d.ts.map +0 -1
- package/dist/commands/store-version.js +0 -241
- package/dist/commands/version.d.ts +0 -3
- package/dist/commands/version.d.ts.map +0 -1
- package/dist/commands/version.js +0 -46
- package/dist/commands/whoami.d.ts +0 -3
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js +0 -41
- package/dist/index.d.ts.map +0 -1
- package/dist/prompts/component.prompts.d.ts +0 -14
- package/dist/prompts/component.prompts.d.ts.map +0 -1
- package/dist/prompts/component.prompts.js +0 -75
- package/dist/prompts/function.prompts.d.ts +0 -21
- package/dist/prompts/function.prompts.d.ts.map +0 -1
- package/dist/prompts/function.prompts.js +0 -127
- package/dist/schemas/command.schema.d.ts +0 -516
- package/dist/schemas/command.schema.d.ts.map +0 -1
- package/dist/schemas/command.schema.js +0 -267
- package/dist/types/index.d.ts +0 -147
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -18
- package/dist/utils/auth.d.ts +0 -4
- package/dist/utils/auth.d.ts.map +0 -1
- package/dist/utils/auth.js +0 -26
- package/dist/utils/cli-progress-reporter.d.ts +0 -12
- package/dist/utils/cli-progress-reporter.d.ts.map +0 -1
- package/dist/utils/cli-progress-reporter.js +0 -77
- package/dist/utils/command-builder.d.ts +0 -22
- package/dist/utils/command-builder.d.ts.map +0 -1
- package/dist/utils/command-builder.js +0 -268
- package/dist/utils/command-helpers.d.ts +0 -19
- package/dist/utils/command-helpers.d.ts.map +0 -1
- package/dist/utils/command-helpers.js +0 -79
- package/dist/utils/command-parser.d.ts +0 -146
- package/dist/utils/command-parser.d.ts.map +0 -1
- package/dist/utils/command-parser.js +0 -179
- package/dist/utils/command-suggestions.d.ts +0 -35
- package/dist/utils/command-suggestions.d.ts.map +0 -1
- package/dist/utils/command-suggestions.js +0 -152
- package/dist/utils/console.d.ts +0 -44
- package/dist/utils/console.d.ts.map +0 -1
- package/dist/utils/console.js +0 -233
- package/dist/utils/constants.d.ts +0 -8
- package/dist/utils/constants.d.ts.map +0 -1
- package/dist/utils/constants.js +0 -10
- package/dist/utils/context-detector.d.ts +0 -12
- package/dist/utils/context-detector.d.ts.map +0 -1
- package/dist/utils/context-detector.js +0 -155
- package/dist/utils/enhanced-error-handler.d.ts +0 -47
- package/dist/utils/enhanced-error-handler.d.ts.map +0 -1
- package/dist/utils/enhanced-error-handler.js +0 -221
- package/dist/utils/error-handler.d.ts +0 -3
- package/dist/utils/error-handler.d.ts.map +0 -1
- package/dist/utils/error-handler.js +0 -55
- package/dist/utils/errors.d.ts +0 -44
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -76
- package/dist/utils/interactive-builder.d.ts +0 -22
- package/dist/utils/interactive-builder.d.ts.map +0 -1
- package/dist/utils/interactive-builder.js +0 -246
- package/dist/utils/rich-progress.d.ts +0 -59
- package/dist/utils/rich-progress.d.ts.map +0 -1
- package/dist/utils/rich-progress.js +0 -234
- package/dist/utils/store.d.ts +0 -11
- package/dist/utils/store.d.ts.map +0 -1
- package/dist/utils/store.js +0 -19
- package/dist/utils/validation-error-formatter.d.ts +0 -25
- package/dist/utils/validation-error-formatter.d.ts.map +0 -1
- package/dist/utils/validation-error-formatter.js +0 -258
- package/dist/utils/validation-helpers.d.ts +0 -60
- package/dist/utils/validation-helpers.d.ts.map +0 -1
- package/dist/utils/validation-helpers.js +0 -152
- package/src/commands/__tests__/version.test.ts +0 -71
|
@@ -1,23 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildAndDeployFunctionFromDirectory,
|
|
3
|
+
buildFunction as buildFunctionService,
|
|
4
|
+
createFunction as createFunctionService,
|
|
5
|
+
testFunction as testFunctionService,
|
|
6
|
+
validateFunction as validateFunctionService,
|
|
7
|
+
} from "@ollie-shop/core";
|
|
1
8
|
import type {
|
|
2
9
|
FunctionBuildOptions,
|
|
3
10
|
FunctionCreateOptions,
|
|
4
11
|
FunctionDeployOptions,
|
|
5
|
-
FunctionListItem,
|
|
6
12
|
FunctionTestOptions,
|
|
7
13
|
} from "../schemas/command.schema";
|
|
8
|
-
import { FunctionListItemSchema } from "../schemas/command.schema";
|
|
9
14
|
import type { CliConsole } from "../utils/console";
|
|
15
|
+
import { ERROR_MESSAGES } from "../utils/constants";
|
|
16
|
+
import { getContextualPath } from "../utils/context-detector.js";
|
|
17
|
+
import {
|
|
18
|
+
configureBuilderUrl,
|
|
19
|
+
handleDeploymentError,
|
|
20
|
+
handleDeploymentResult,
|
|
21
|
+
showDeploymentSuccess,
|
|
22
|
+
waitForDeploymentWithProgress,
|
|
23
|
+
} from "../utils/deploy-helpers";
|
|
10
24
|
import { handleValidationResult } from "../utils/validation-helpers";
|
|
11
25
|
|
|
12
26
|
export async function createFunction(
|
|
13
27
|
options: FunctionCreateOptions,
|
|
14
28
|
cliConsole: CliConsole,
|
|
15
29
|
): Promise<void> {
|
|
16
|
-
// Lazy import - only loaded when this function is called
|
|
17
|
-
const { createFunction: createFunctionService } = await import(
|
|
18
|
-
"@ollie-shop/core"
|
|
19
|
-
);
|
|
20
|
-
|
|
21
30
|
const spinner = cliConsole.spinner({
|
|
22
31
|
text: "Creating function...",
|
|
23
32
|
});
|
|
@@ -55,6 +64,14 @@ export async function createFunction(
|
|
|
55
64
|
]);
|
|
56
65
|
} catch (error) {
|
|
57
66
|
spinner.fail("Failed to create function");
|
|
67
|
+
const { message, stack } =
|
|
68
|
+
error instanceof Error
|
|
69
|
+
? error
|
|
70
|
+
: { message: "Unexpected error", stack: undefined };
|
|
71
|
+
cliConsole.error(`Error details: ${message}`);
|
|
72
|
+
if (stack) {
|
|
73
|
+
cliConsole.debug(`Stack trace: ${stack}`);
|
|
74
|
+
}
|
|
58
75
|
throw error;
|
|
59
76
|
}
|
|
60
77
|
}
|
|
@@ -63,12 +80,6 @@ export async function buildFunction(
|
|
|
63
80
|
options: FunctionBuildOptions,
|
|
64
81
|
cliConsole: CliConsole,
|
|
65
82
|
): Promise<void> {
|
|
66
|
-
// Lazy import - only loaded when this function is called
|
|
67
|
-
const { buildFunction: buildFunctionService } = await import(
|
|
68
|
-
"@ollie-shop/core"
|
|
69
|
-
);
|
|
70
|
-
const { getContextualPath } = await import("../utils/context-detector.js");
|
|
71
|
-
|
|
72
83
|
const targetPath = getContextualPath(options.path, "function");
|
|
73
84
|
const spinner = cliConsole.spinner({ text: "Building function..." });
|
|
74
85
|
|
|
@@ -93,11 +104,6 @@ export async function testFunction(
|
|
|
93
104
|
options: FunctionTestOptions,
|
|
94
105
|
cliConsole: CliConsole,
|
|
95
106
|
): Promise<void> {
|
|
96
|
-
const { testFunction: testFunctionService } = await import(
|
|
97
|
-
"@ollie-shop/core"
|
|
98
|
-
);
|
|
99
|
-
const { getContextualPath } = await import("../utils/context-detector.js");
|
|
100
|
-
|
|
101
107
|
const targetPath = getContextualPath(options.path, "function");
|
|
102
108
|
const spinner = cliConsole.spinner({ text: "Testing function..." });
|
|
103
109
|
|
|
@@ -116,6 +122,14 @@ export async function testFunction(
|
|
|
116
122
|
}
|
|
117
123
|
} catch (error) {
|
|
118
124
|
spinner.fail("Tests failed");
|
|
125
|
+
const { message, stack } =
|
|
126
|
+
error instanceof Error
|
|
127
|
+
? error
|
|
128
|
+
: { message: "Unexpected error", stack: undefined };
|
|
129
|
+
cliConsole.error(`Error details: ${message}`);
|
|
130
|
+
if (stack) {
|
|
131
|
+
cliConsole.debug(`Stack trace: ${stack}`);
|
|
132
|
+
}
|
|
119
133
|
throw error;
|
|
120
134
|
}
|
|
121
135
|
}
|
|
@@ -124,12 +138,6 @@ export async function validateFunction(
|
|
|
124
138
|
options: { path?: string; strict?: boolean; fix?: boolean },
|
|
125
139
|
cliConsole: CliConsole,
|
|
126
140
|
): Promise<void> {
|
|
127
|
-
// Lazy import - only loaded when this function is called
|
|
128
|
-
const { validateFunction: validateFunctionService } = await import(
|
|
129
|
-
"@ollie-shop/core"
|
|
130
|
-
);
|
|
131
|
-
const { getContextualPath } = await import("../utils/context-detector.js");
|
|
132
|
-
|
|
133
141
|
const targetPath = getContextualPath(options.path, "function");
|
|
134
142
|
const spinner = cliConsole.spinner({ text: "Validating function..." });
|
|
135
143
|
|
|
@@ -138,176 +146,75 @@ export async function validateFunction(
|
|
|
138
146
|
handleValidationResult(result, spinner, cliConsole, "Function");
|
|
139
147
|
} catch (error) {
|
|
140
148
|
spinner.fail("Validation failed");
|
|
149
|
+
const { message, stack } =
|
|
150
|
+
error instanceof Error
|
|
151
|
+
? error
|
|
152
|
+
: { message: "Unexpected error", stack: undefined };
|
|
153
|
+
cliConsole.error(`Error details: ${message}`);
|
|
154
|
+
if (stack) {
|
|
155
|
+
cliConsole.debug(`Stack trace: ${stack}`);
|
|
156
|
+
}
|
|
141
157
|
throw error;
|
|
142
158
|
}
|
|
143
159
|
}
|
|
144
160
|
|
|
145
161
|
export async function deployFunction(
|
|
146
|
-
options: FunctionDeployOptions
|
|
162
|
+
options: FunctionDeployOptions,
|
|
147
163
|
cliConsole: CliConsole,
|
|
148
164
|
): Promise<void> {
|
|
149
165
|
if (!options.functionId) {
|
|
150
|
-
throw new Error(
|
|
166
|
+
throw new Error(ERROR_MESSAGES.FUNCTION_ID_REQUIRED);
|
|
151
167
|
}
|
|
152
168
|
|
|
169
|
+
configureBuilderUrl();
|
|
170
|
+
|
|
153
171
|
const spinner = cliConsole.spinner({
|
|
154
|
-
text: "
|
|
172
|
+
text: "Preparing function for deployment...",
|
|
155
173
|
});
|
|
156
174
|
|
|
157
175
|
try {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
status: "IN_PROGRESS" as const,
|
|
164
|
-
startTime: new Date().toISOString(),
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
spinner.succeed("Function deployment initiated!");
|
|
168
|
-
cliConsole.success(`Build ID: ${result.buildId}`);
|
|
169
|
-
cliConsole.info(`Initial Status: ${result.status}`);
|
|
176
|
+
const functionPath = options.path || process.cwd();
|
|
177
|
+
const result = await buildAndDeployFunctionFromDirectory(
|
|
178
|
+
options.functionId,
|
|
179
|
+
functionPath,
|
|
180
|
+
);
|
|
170
181
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// Stop spinner and use rich progress reporter
|
|
174
|
-
spinner.stop();
|
|
182
|
+
handleDeploymentResult(result, "function", cliConsole, spinner);
|
|
183
|
+
spinner.stop();
|
|
175
184
|
|
|
176
|
-
|
|
177
|
-
|
|
185
|
+
try {
|
|
186
|
+
const { completedBuild, duration } = await waitForDeploymentWithProgress(
|
|
187
|
+
result.buildId,
|
|
188
|
+
"function",
|
|
189
|
+
cliConsole,
|
|
178
190
|
);
|
|
179
|
-
const progressReporter = new RichProgressReporter();
|
|
180
|
-
progressReporter.start();
|
|
181
|
-
|
|
182
|
-
try {
|
|
183
|
-
// Simulate deployment progress for demo
|
|
184
|
-
const phases = [
|
|
185
|
-
{
|
|
186
|
-
phase: "validate",
|
|
187
|
-
message: "Validating function...",
|
|
188
|
-
progress: 0.1,
|
|
189
|
-
},
|
|
190
|
-
{ phase: "build", message: "Building function...", progress: 0.3 },
|
|
191
|
-
{
|
|
192
|
-
phase: "bundle",
|
|
193
|
-
message: "Creating deployment package...",
|
|
194
|
-
progress: 0.5,
|
|
195
|
-
metadata: { bundleSize: 85000, gzippedSize: 28000 },
|
|
196
|
-
},
|
|
197
|
-
{ phase: "upload", message: "Uploading to Lambda...", progress: 0.7 },
|
|
198
|
-
{
|
|
199
|
-
phase: "deploy",
|
|
200
|
-
message: "Configuring function...",
|
|
201
|
-
progress: 0.9,
|
|
202
|
-
},
|
|
203
|
-
{ phase: "complete", message: "Deployment complete!", progress: 1.0 },
|
|
204
|
-
];
|
|
205
191
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
cliConsole.success(`\nFunction URL: ${functionUrl}`);
|
|
218
|
-
cliConsole.info(`Duration: ${duration}s`);
|
|
219
|
-
} catch (error) {
|
|
220
|
-
progressReporter.stop(false);
|
|
221
|
-
throw error;
|
|
222
|
-
}
|
|
223
|
-
} else {
|
|
224
|
-
// Async mode - just show next steps
|
|
225
|
-
cliConsole.nextSteps("Monitor deployment", [
|
|
226
|
-
{
|
|
227
|
-
description: "Check deployment status",
|
|
228
|
-
command: `ollieshop function deploy-status ${result.buildId}`,
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
description: "Or deploy with --wait flag to wait for completion",
|
|
232
|
-
command: `ollieshop function deploy --id ${options.functionId} --wait`,
|
|
233
|
-
},
|
|
234
|
-
]);
|
|
192
|
+
showDeploymentSuccess(
|
|
193
|
+
completedBuild,
|
|
194
|
+
duration,
|
|
195
|
+
options.functionId,
|
|
196
|
+
"function",
|
|
197
|
+
cliConsole,
|
|
198
|
+
);
|
|
199
|
+
} catch (error) {
|
|
200
|
+
handleDeploymentError(error, result.buildId, "function", cliConsole);
|
|
201
|
+
throw error;
|
|
235
202
|
}
|
|
236
203
|
} catch (error) {
|
|
237
|
-
spinner.
|
|
204
|
+
if (spinner.isSpinning) {
|
|
205
|
+
spinner.fail("Deployment failed");
|
|
206
|
+
}
|
|
238
207
|
throw error;
|
|
239
208
|
}
|
|
240
209
|
}
|
|
241
210
|
|
|
242
211
|
export async function listFunctions(cliConsole: CliConsole): Promise<void> {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
name: "validate-cart",
|
|
252
|
-
active: true,
|
|
253
|
-
createdAt: new Date().toISOString(),
|
|
254
|
-
invocation: "request",
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
id: "func-2",
|
|
258
|
-
name: "apply-discount",
|
|
259
|
-
active: true,
|
|
260
|
-
createdAt: new Date(Date.now() - 86400000).toISOString(),
|
|
261
|
-
invocation: "response",
|
|
262
|
-
},
|
|
263
|
-
];
|
|
264
|
-
|
|
265
|
-
// Map core function types to CLI display format
|
|
266
|
-
const functions: FunctionListItem[] = rawFunctions.map((func) =>
|
|
267
|
-
FunctionListItemSchema.parse({
|
|
268
|
-
id: func.id,
|
|
269
|
-
name: func.name,
|
|
270
|
-
runtime: "nodejs18.x", // TODO: Get from function metadata
|
|
271
|
-
version: "1.0.0", // TODO: Get version from function metadata
|
|
272
|
-
enabled: func.active,
|
|
273
|
-
createdAt: func.createdAt,
|
|
274
|
-
invocation: "request",
|
|
275
|
-
priority: 0,
|
|
276
|
-
onError: "throw",
|
|
277
|
-
description: "Function description", // TODO: Get from metadata
|
|
278
|
-
}),
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
spinner.succeed();
|
|
282
|
-
|
|
283
|
-
if (functions.length === 0) {
|
|
284
|
-
cliConsole.warn("No functions found");
|
|
285
|
-
cliConsole.suggestions([
|
|
286
|
-
"Create your first function with: ollieshop function create",
|
|
287
|
-
"Check our documentation at: https://docs.ollie.shop/functions",
|
|
288
|
-
]);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
cliConsole.info(
|
|
293
|
-
`Found ${functions.length} function${functions.length === 1 ? "" : "s"}:\n`,
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
cliConsole.table(
|
|
297
|
-
functions.map((f) => ({
|
|
298
|
-
ID: f.id,
|
|
299
|
-
Name: f.name,
|
|
300
|
-
Runtime: f.runtime || "nodejs18.x",
|
|
301
|
-
Version: f.version || "N/A",
|
|
302
|
-
Enabled: f.enabled ? "✓" : "✗",
|
|
303
|
-
Created: new Date(f.createdAt).toLocaleDateString(),
|
|
304
|
-
Invocation: f.invocation || "N/A",
|
|
305
|
-
Priority: f.priority || "N/A",
|
|
306
|
-
"On Error": f.onError || "N/A",
|
|
307
|
-
})),
|
|
308
|
-
);
|
|
309
|
-
} catch (error) {
|
|
310
|
-
spinner.fail("Failed to list functions");
|
|
311
|
-
throw error;
|
|
312
|
-
}
|
|
212
|
+
cliConsole.info(
|
|
213
|
+
"Function listing is currently only available through the admin dashboard.",
|
|
214
|
+
);
|
|
215
|
+
cliConsole.suggestions([
|
|
216
|
+
"Create your first function with: ollieshop function create",
|
|
217
|
+
"Deploy functions with: ollieshop function deploy --id <function-id>",
|
|
218
|
+
"Visit the admin dashboard to view existing functions",
|
|
219
|
+
]);
|
|
313
220
|
}
|
|
@@ -87,21 +87,23 @@ export async function buildProject(
|
|
|
87
87
|
options: { path?: string; watch?: boolean },
|
|
88
88
|
cliConsole: CliConsole,
|
|
89
89
|
): Promise<void> {
|
|
90
|
-
// TODO: Implement project building functionality
|
|
91
|
-
// This function needs to be implemented in the core package
|
|
92
|
-
|
|
93
90
|
const targetPath = options.path || process.cwd();
|
|
94
91
|
|
|
95
|
-
cliConsole.
|
|
92
|
+
cliConsole.info(
|
|
93
|
+
"Project building is available through individual component and function builds.",
|
|
94
|
+
);
|
|
96
95
|
cliConsole.info(`Target path: ${targetPath}`);
|
|
97
96
|
|
|
98
97
|
if (options.watch) {
|
|
99
|
-
cliConsole.info(
|
|
98
|
+
cliConsole.info(
|
|
99
|
+
"Use watch mode on individual components and functions for development.",
|
|
100
|
+
);
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
cliConsole.suggestions([
|
|
103
104
|
"Build components individually with: ollieshop component build",
|
|
104
105
|
"Build functions individually with: ollieshop function build",
|
|
106
|
+
"Use watch mode: ollieshop component build --watch",
|
|
105
107
|
]);
|
|
106
108
|
}
|
|
107
109
|
|
|
@@ -109,18 +111,21 @@ export async function startDevServer(
|
|
|
109
111
|
options: { port?: number; open?: boolean },
|
|
110
112
|
cliConsole: CliConsole,
|
|
111
113
|
): Promise<void> {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
cliConsole.
|
|
116
|
-
cliConsole.info(`Would start server on port ${options.port || 3000}`);
|
|
114
|
+
cliConsole.info(
|
|
115
|
+
"Development server functionality is available through individual component and function development.",
|
|
116
|
+
);
|
|
117
|
+
cliConsole.info(`Target port: ${options.port || 3000}`);
|
|
117
118
|
|
|
118
119
|
if (options.open) {
|
|
119
|
-
cliConsole.info(
|
|
120
|
+
cliConsole.info(
|
|
121
|
+
"Use --open flag with individual component development servers.",
|
|
122
|
+
);
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
cliConsole.suggestions([
|
|
123
126
|
"Start component development with: cd components/[name] && npm run dev",
|
|
124
127
|
"Start function development with: cd functions/[name] && npm run dev",
|
|
128
|
+
"Create components with: ollieshop component create",
|
|
129
|
+
"Create functions with: ollieshop function create",
|
|
125
130
|
]);
|
|
126
131
|
}
|
|
@@ -14,7 +14,6 @@ vi.mock("../../actions/component.actions", () => ({
|
|
|
14
14
|
listComponents: vi.fn(),
|
|
15
15
|
deployComponent: vi.fn(),
|
|
16
16
|
validateComponent: vi.fn(),
|
|
17
|
-
checkDeployStatus: vi.fn(),
|
|
18
17
|
}));
|
|
19
18
|
|
|
20
19
|
// Import mocked actions
|
|
@@ -223,7 +222,7 @@ describe("Component Command", () => {
|
|
|
223
222
|
"--path",
|
|
224
223
|
"./my-component",
|
|
225
224
|
"--id",
|
|
226
|
-
"
|
|
225
|
+
"123e4567-e89b-12d3-a456-426614174000",
|
|
227
226
|
]);
|
|
228
227
|
|
|
229
228
|
// Assert
|
|
@@ -231,7 +230,7 @@ describe("Component Command", () => {
|
|
|
231
230
|
expect(componentActions.deployComponent).toHaveBeenCalledWith(
|
|
232
231
|
expect.objectContaining({
|
|
233
232
|
path: "./my-component",
|
|
234
|
-
|
|
233
|
+
componentId: "123e4567-e89b-12d3-a456-426614174000",
|
|
235
234
|
}),
|
|
236
235
|
expect.any(Object),
|
|
237
236
|
);
|
|
@@ -246,16 +245,14 @@ describe("Component Command", () => {
|
|
|
246
245
|
"component",
|
|
247
246
|
"deploy",
|
|
248
247
|
"--id",
|
|
249
|
-
"
|
|
250
|
-
"--wait",
|
|
248
|
+
"123e4567-e89b-12d3-a456-426614174000",
|
|
251
249
|
]);
|
|
252
250
|
|
|
253
251
|
// Assert
|
|
254
252
|
expect(result.exitCode).toBe(0);
|
|
255
253
|
expect(componentActions.deployComponent).toHaveBeenCalledWith(
|
|
256
254
|
expect.objectContaining({
|
|
257
|
-
componentId: "
|
|
258
|
-
wait: true,
|
|
255
|
+
componentId: "123e4567-e89b-12d3-a456-426614174000",
|
|
259
256
|
}),
|
|
260
257
|
expect.any(Object),
|
|
261
258
|
);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { Command } from "@commander-js/extra-typings";
|
|
2
|
-
import {
|
|
3
|
-
storeFactory,
|
|
4
|
-
versionFactory,
|
|
5
|
-
} from "@ollie-shop/core/__tests__/factories";
|
|
2
|
+
import { storeFactory, versionFactory } from "@ollie-shop/core/testing";
|
|
6
3
|
import {
|
|
7
4
|
createTestProgram,
|
|
8
5
|
executeCLI,
|
|
@@ -140,11 +140,6 @@ export function registerComponentCommands(program: Command): void {
|
|
|
140
140
|
required: true,
|
|
141
141
|
},
|
|
142
142
|
COMMON_OPTIONS.path,
|
|
143
|
-
{
|
|
144
|
-
flags: "--wait",
|
|
145
|
-
description: "Wait for deployment to complete",
|
|
146
|
-
defaultValue: false,
|
|
147
|
-
},
|
|
148
143
|
],
|
|
149
144
|
schema: ComponentDeployOptionsSchema,
|
|
150
145
|
examples: [
|
|
@@ -152,17 +147,12 @@ export function registerComponentCommands(program: Command): void {
|
|
|
152
147
|
description: "Deploy a component",
|
|
153
148
|
command: "ollieshop component deploy --id comp-123",
|
|
154
149
|
},
|
|
155
|
-
{
|
|
156
|
-
description: "Deploy and wait for completion",
|
|
157
|
-
command: "ollieshop component deploy --id comp-123 --wait",
|
|
158
|
-
},
|
|
159
150
|
],
|
|
160
151
|
handler: async (options: ComponentDeployOptions, console) => {
|
|
161
152
|
// Map id to componentId if provided
|
|
162
153
|
const deployOptions = {
|
|
163
154
|
path: options.path,
|
|
164
155
|
componentId: options.id || options.componentId,
|
|
165
|
-
wait: options.wait,
|
|
166
156
|
};
|
|
167
157
|
await componentActions.deployComponent(deployOptions, console);
|
|
168
158
|
},
|
package/src/commands/function.ts
CHANGED
|
@@ -158,21 +158,17 @@ export function registerFunctionCommands(program: Command): void {
|
|
|
158
158
|
description: "Function ID for deployment",
|
|
159
159
|
required: true,
|
|
160
160
|
},
|
|
161
|
-
COMMON_OPTIONS.wait,
|
|
162
161
|
],
|
|
163
162
|
schema: FunctionDeployOptionsSchema,
|
|
164
163
|
examples: [
|
|
165
164
|
{
|
|
166
165
|
description: "Deploy current directory",
|
|
167
|
-
command: "ollieshop function deploy",
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
description: "Deploy specific function and wait",
|
|
171
|
-
command: "ollieshop function deploy --path ./my-function --wait",
|
|
166
|
+
command: "ollieshop function deploy --id func_123abc",
|
|
172
167
|
},
|
|
173
168
|
{
|
|
174
|
-
description: "Deploy
|
|
175
|
-
command:
|
|
169
|
+
description: "Deploy specific function",
|
|
170
|
+
command:
|
|
171
|
+
"ollieshop function deploy --path ./my-function --id func_123abc",
|
|
176
172
|
},
|
|
177
173
|
],
|
|
178
174
|
handler: async (options: FunctionDeployOptions, console) => {
|
|
@@ -180,7 +176,6 @@ export function registerFunctionCommands(program: Command): void {
|
|
|
180
176
|
const deployOptions = {
|
|
181
177
|
path: options.path || process.cwd(),
|
|
182
178
|
functionId: options.id || options.functionId,
|
|
183
|
-
wait: options.wait,
|
|
184
179
|
};
|
|
185
180
|
await functionActions.deployFunction(deployOptions, console);
|
|
186
181
|
},
|
|
@@ -202,51 +197,5 @@ export function registerFunctionCommands(program: Command): void {
|
|
|
202
197
|
},
|
|
203
198
|
});
|
|
204
199
|
|
|
205
|
-
//
|
|
206
|
-
cmd
|
|
207
|
-
.command("deploy-status <buildId>")
|
|
208
|
-
.description("Check the status of a function deployment")
|
|
209
|
-
.action(async (buildId) => {
|
|
210
|
-
try {
|
|
211
|
-
const { getBuildStatus } = await import("@ollie-shop/core");
|
|
212
|
-
const { console: cliConsole } = await import("../utils/console.js");
|
|
213
|
-
const spinner = cliConsole.spinner("Checking deployment status...");
|
|
214
|
-
|
|
215
|
-
const build = await getBuildStatus(buildId);
|
|
216
|
-
|
|
217
|
-
if (!build) {
|
|
218
|
-
spinner.fail("Build not found");
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
spinner.succeed();
|
|
223
|
-
|
|
224
|
-
cliConsole.info("Deployment Status:");
|
|
225
|
-
cliConsole.log(` Build ID: ${build.id}`);
|
|
226
|
-
cliConsole.log(` Status: ${build.status}`);
|
|
227
|
-
cliConsole.log(
|
|
228
|
-
` Started: ${new Date(build.startTime).toLocaleString()}`,
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
if (build.endTime) {
|
|
232
|
-
cliConsole.log(
|
|
233
|
-
` Completed: ${new Date(build.endTime).toLocaleString()}`,
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (build.deploymentUrl) {
|
|
238
|
-
cliConsole.success(`\nFunction URL: ${build.deploymentUrl}`);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (build.error) {
|
|
242
|
-
cliConsole.error(`\nError: ${build.error}`);
|
|
243
|
-
}
|
|
244
|
-
} catch (error) {
|
|
245
|
-
const { console: cliConsole } = await import("../utils/console.js");
|
|
246
|
-
cliConsole.error(
|
|
247
|
-
`Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
248
|
-
);
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
});
|
|
200
|
+
// deploy-status command removed - no longer needed since deployments always wait for completion
|
|
252
201
|
}
|