@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,242 +0,0 @@
|
|
|
1
|
-
import type { Command } from "@commander-js/extra-typings";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import * as versionActions from "../actions/version.actions";
|
|
4
|
-
import { buildCommand, buildCommandGroup } from "../utils/command-builder";
|
|
5
|
-
import { COMMON_OPTIONS, parseUUID } from "../utils/command-parser";
|
|
6
|
-
import { console as cliConsole } from "../utils/console";
|
|
7
|
-
|
|
8
|
-
const StoreVersionCreateOptionsSchema = z.object({
|
|
9
|
-
store: z.string().uuid("Invalid store ID format"),
|
|
10
|
-
name: z.string().min(1, "Version name is required"),
|
|
11
|
-
template: z.string().optional(),
|
|
12
|
-
active: z.boolean().optional(),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const StoreVersionListOptionsSchema = z.object({
|
|
16
|
-
store: z.string().uuid("Invalid store ID format"),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export function registerStoreVersionCommands(program: Command): void {
|
|
20
|
-
const cmd = buildCommandGroup(
|
|
21
|
-
program,
|
|
22
|
-
"store-version",
|
|
23
|
-
"Manage store versions",
|
|
24
|
-
["sv"],
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
// Create version command
|
|
28
|
-
buildCommand(cmd, {
|
|
29
|
-
name: "create",
|
|
30
|
-
description: "Create a new version for a store",
|
|
31
|
-
options: [
|
|
32
|
-
COMMON_OPTIONS.storeId,
|
|
33
|
-
COMMON_OPTIONS.versionName,
|
|
34
|
-
COMMON_OPTIONS.template,
|
|
35
|
-
COMMON_OPTIONS.active,
|
|
36
|
-
COMMON_OPTIONS.noActive,
|
|
37
|
-
],
|
|
38
|
-
schema: StoreVersionCreateOptionsSchema,
|
|
39
|
-
examples: [
|
|
40
|
-
{
|
|
41
|
-
description: "Create an active version",
|
|
42
|
-
command:
|
|
43
|
-
"ollieshop store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name v2.0.0",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
description: "Create version with grocery template",
|
|
47
|
-
command:
|
|
48
|
-
"ollieshop store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name grocery-v1 --template grocery",
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
description: "Create inactive version for testing",
|
|
52
|
-
command:
|
|
53
|
-
"ollieshop store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name test-version --no-active",
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
handler: async (options) => {
|
|
57
|
-
await versionActions.create(options);
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// List versions command
|
|
62
|
-
buildCommand(cmd, {
|
|
63
|
-
name: "list",
|
|
64
|
-
description: "List all versions for a store",
|
|
65
|
-
options: [COMMON_OPTIONS.storeId],
|
|
66
|
-
schema: StoreVersionListOptionsSchema,
|
|
67
|
-
examples: [
|
|
68
|
-
{
|
|
69
|
-
description: "List all versions for a store",
|
|
70
|
-
command:
|
|
71
|
-
"ollieshop store-version list --store 123e4567-e89b-12d3-a456-426614174000",
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
handler: async (options) => {
|
|
75
|
-
await versionActions.list(options);
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
// Get version command with argument parser
|
|
80
|
-
const _getCmd = cmd
|
|
81
|
-
.command("get <versionId>")
|
|
82
|
-
.description("Get version details")
|
|
83
|
-
.addHelpText("after", "\nExamples:")
|
|
84
|
-
.addHelpText("after", " Get version details:")
|
|
85
|
-
.addHelpText(
|
|
86
|
-
"after",
|
|
87
|
-
" $ ollieshop store-version get 987fcdeb-51a2-43b7-9abc-123456789012",
|
|
88
|
-
)
|
|
89
|
-
.action(async (versionId) => {
|
|
90
|
-
try {
|
|
91
|
-
const validated = parseUUID(versionId);
|
|
92
|
-
await versionActions.get(validated);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
if (error instanceof Error) {
|
|
95
|
-
cliConsole.error(`❌ ${error.message}`);
|
|
96
|
-
if (error.message.includes("UUID")) {
|
|
97
|
-
cliConsole.info("💡 Version IDs must be in UUID format");
|
|
98
|
-
cliConsole.log(" Example: 123e4567-e89b-12d3-a456-426614174000");
|
|
99
|
-
}
|
|
100
|
-
} else {
|
|
101
|
-
cliConsole.error(`Error: ${String(error)}`);
|
|
102
|
-
}
|
|
103
|
-
process.exit(1);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Set default version command
|
|
108
|
-
const _setDefaultCmd = cmd
|
|
109
|
-
.command("set-default <versionId>")
|
|
110
|
-
.description("Set a version as the default for the store")
|
|
111
|
-
.addHelpText("after", "\nExamples:")
|
|
112
|
-
.addHelpText("after", " Set version as default:")
|
|
113
|
-
.addHelpText(
|
|
114
|
-
"after",
|
|
115
|
-
" $ ollieshop store-version set-default 987fcdeb-51a2-43b7-9abc-123456789012",
|
|
116
|
-
)
|
|
117
|
-
.action(async (versionId) => {
|
|
118
|
-
try {
|
|
119
|
-
const validated = parseUUID(versionId);
|
|
120
|
-
await versionActions.setDefault(validated);
|
|
121
|
-
} catch (error) {
|
|
122
|
-
if (error instanceof Error) {
|
|
123
|
-
cliConsole.error(`❌ ${error.message}`);
|
|
124
|
-
} else {
|
|
125
|
-
cliConsole.error(`Error: ${String(error)}`);
|
|
126
|
-
}
|
|
127
|
-
process.exit(1);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// Activate version command
|
|
132
|
-
const _activateCmd = cmd
|
|
133
|
-
.command("activate <versionId>")
|
|
134
|
-
.description("Activate a version")
|
|
135
|
-
.addHelpText("after", "\nExamples:")
|
|
136
|
-
.addHelpText("after", " Activate a version:")
|
|
137
|
-
.addHelpText(
|
|
138
|
-
"after",
|
|
139
|
-
" $ ollieshop store-version activate 987fcdeb-51a2-43b7-9abc-123456789012",
|
|
140
|
-
)
|
|
141
|
-
.action(async (versionId) => {
|
|
142
|
-
try {
|
|
143
|
-
const validated = parseUUID(versionId);
|
|
144
|
-
await versionActions.activate(validated);
|
|
145
|
-
} catch (error) {
|
|
146
|
-
if (error instanceof Error) {
|
|
147
|
-
cliConsole.error(`❌ ${error.message}`);
|
|
148
|
-
} else {
|
|
149
|
-
cliConsole.error(`Error: ${String(error)}`);
|
|
150
|
-
}
|
|
151
|
-
process.exit(1);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// Deactivate version command
|
|
156
|
-
const _deactivateCmd = cmd
|
|
157
|
-
.command("deactivate <versionId>")
|
|
158
|
-
.description("Deactivate a version")
|
|
159
|
-
.addHelpText("after", "\nExamples:")
|
|
160
|
-
.addHelpText("after", " Deactivate a version:")
|
|
161
|
-
.addHelpText(
|
|
162
|
-
"after",
|
|
163
|
-
" $ ollieshop store-version deactivate 987fcdeb-51a2-43b7-9abc-123456789012",
|
|
164
|
-
)
|
|
165
|
-
.action(async (versionId) => {
|
|
166
|
-
try {
|
|
167
|
-
const validated = parseUUID(versionId);
|
|
168
|
-
await versionActions.deactivate(validated);
|
|
169
|
-
} catch (error) {
|
|
170
|
-
if (error instanceof Error) {
|
|
171
|
-
cliConsole.error(`❌ ${error.message}`);
|
|
172
|
-
} else {
|
|
173
|
-
cliConsole.error(`Error: ${String(error)}`);
|
|
174
|
-
}
|
|
175
|
-
process.exit(1);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
// Clone version command
|
|
180
|
-
const _cloneCmd = cmd
|
|
181
|
-
.command("clone <versionId>")
|
|
182
|
-
.description("Clone an existing version")
|
|
183
|
-
.requiredOption(
|
|
184
|
-
"-n, --name <name>",
|
|
185
|
-
"Name for the cloned version",
|
|
186
|
-
COMMON_OPTIONS.versionName.parser,
|
|
187
|
-
)
|
|
188
|
-
.addHelpText("after", "\nExamples:")
|
|
189
|
-
.addHelpText("after", " Clone a version:")
|
|
190
|
-
.addHelpText(
|
|
191
|
-
"after",
|
|
192
|
-
" $ ollieshop store-version clone 987fcdeb-51a2-43b7-9abc-123456789012 --name v2.1.0",
|
|
193
|
-
)
|
|
194
|
-
.addHelpText("after", "\n Clone for A/B testing:")
|
|
195
|
-
.addHelpText(
|
|
196
|
-
"after",
|
|
197
|
-
" $ ollieshop store-version clone 987fcdeb-51a2-43b7-9abc-123456789012 --name experiment-checkout",
|
|
198
|
-
)
|
|
199
|
-
.action(async (versionId, options) => {
|
|
200
|
-
try {
|
|
201
|
-
const validatedId = parseUUID(versionId);
|
|
202
|
-
await versionActions.clone(validatedId, options.name);
|
|
203
|
-
} catch (error) {
|
|
204
|
-
if (error instanceof Error) {
|
|
205
|
-
cliConsole.error(`❌ ${error.message}`);
|
|
206
|
-
} else {
|
|
207
|
-
cliConsole.error(`Error: ${String(error)}`);
|
|
208
|
-
}
|
|
209
|
-
process.exit(1);
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
// Delete version command
|
|
214
|
-
const _deleteCmd = cmd
|
|
215
|
-
.command("delete <versionId>")
|
|
216
|
-
.description("Delete a version")
|
|
217
|
-
.option("-f, --force", "Skip confirmation")
|
|
218
|
-
.addHelpText("after", "\nExamples:")
|
|
219
|
-
.addHelpText("after", " Delete with confirmation:")
|
|
220
|
-
.addHelpText(
|
|
221
|
-
"after",
|
|
222
|
-
" $ ollieshop store-version delete 987fcdeb-51a2-43b7-9abc-123456789012",
|
|
223
|
-
)
|
|
224
|
-
.addHelpText("after", "\n Delete without confirmation:")
|
|
225
|
-
.addHelpText(
|
|
226
|
-
"after",
|
|
227
|
-
" $ ollieshop store-version delete 987fcdeb-51a2-43b7-9abc-123456789012 --force",
|
|
228
|
-
)
|
|
229
|
-
.action(async (versionId, options) => {
|
|
230
|
-
try {
|
|
231
|
-
const validated = parseUUID(versionId);
|
|
232
|
-
await versionActions.deleteVersion(validated, options.force);
|
|
233
|
-
} catch (error) {
|
|
234
|
-
if (error instanceof Error) {
|
|
235
|
-
cliConsole.error(`❌ ${error.message}`);
|
|
236
|
-
} else {
|
|
237
|
-
cliConsole.error(`Error: ${String(error)}`);
|
|
238
|
-
}
|
|
239
|
-
process.exit(1);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
package/src/commands/version.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Command } from "@commander-js/extra-typings";
|
|
2
|
-
import { console as cliConsole } from "../utils/console";
|
|
3
|
-
|
|
4
|
-
const pkg = require("../../package.json");
|
|
5
|
-
|
|
6
|
-
export function configureVersionCommand(program: Command): void {
|
|
7
|
-
// Simple version command
|
|
8
|
-
program
|
|
9
|
-
.command("version")
|
|
10
|
-
.alias("v")
|
|
11
|
-
.description("Display CLI version and environment information")
|
|
12
|
-
.option("-d, --detailed", "Show detailed version information", false)
|
|
13
|
-
.option("-j, --json", "Output version information as JSON", false)
|
|
14
|
-
.action(async (options) => {
|
|
15
|
-
if (options.json) {
|
|
16
|
-
const versionInfo = {
|
|
17
|
-
cli: pkg.version,
|
|
18
|
-
node: process.version,
|
|
19
|
-
platform: process.platform,
|
|
20
|
-
arch: process.arch,
|
|
21
|
-
};
|
|
22
|
-
console.log(JSON.stringify(versionInfo, null, 2));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
cliConsole.info(`Ollie Shop CLI version: ${pkg.version}`);
|
|
27
|
-
|
|
28
|
-
if (options.detailed) {
|
|
29
|
-
cliConsole.log("");
|
|
30
|
-
cliConsole.log("Environment:");
|
|
31
|
-
cliConsole.log(` Node.js: ${process.version}`);
|
|
32
|
-
cliConsole.log(` Platform: ${process.platform}`);
|
|
33
|
-
cliConsole.log(` Architecture: ${process.arch}`);
|
|
34
|
-
|
|
35
|
-
// Check for core package version
|
|
36
|
-
try {
|
|
37
|
-
const corePkg = require("@ollie-shop/core/package.json");
|
|
38
|
-
cliConsole.log(` Core: v${corePkg.version}`);
|
|
39
|
-
} catch {
|
|
40
|
-
// Core package might not be available
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
cliConsole.log("");
|
|
44
|
-
cliConsole.log("For help, run: ollieshop --help");
|
|
45
|
-
cliConsole.log("Documentation: https://docs.ollie.shop");
|
|
46
|
-
cliConsole.log(
|
|
47
|
-
"Report issues: https://github.com/ollie-shop/cli/issues",
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
package/src/commands/whoami.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Command } from "@commander-js/extra-typings";
|
|
2
|
-
import { getCurrentUser } from "../utils/auth";
|
|
3
|
-
import { console as cliConsole } from "../utils/console";
|
|
4
|
-
import { type OllieConfig, getOllieConfig } from "../utils/store";
|
|
5
|
-
|
|
6
|
-
async function getUserInfo(): Promise<{ email?: string; store?: OllieConfig }> {
|
|
7
|
-
try {
|
|
8
|
-
const user = await getCurrentUser();
|
|
9
|
-
const store = await getOllieConfig();
|
|
10
|
-
|
|
11
|
-
if (!user || !user.email) {
|
|
12
|
-
cliConsole.error("No user authenticated");
|
|
13
|
-
return {};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
email: user.email,
|
|
18
|
-
store: store ?? undefined,
|
|
19
|
-
};
|
|
20
|
-
} catch {
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function configureWhoamiCommand(program: Command) {
|
|
26
|
-
program
|
|
27
|
-
.command("whoami")
|
|
28
|
-
.description("Show logged-in user and current store")
|
|
29
|
-
.action(async () => {
|
|
30
|
-
const { email, store } = await getUserInfo();
|
|
31
|
-
|
|
32
|
-
if (!email) {
|
|
33
|
-
cliConsole.error("You are not authenticated");
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
cliConsole.newLine();
|
|
38
|
-
cliConsole.info(`You are logged in as: ${email}`);
|
|
39
|
-
|
|
40
|
-
if (store) {
|
|
41
|
-
cliConsole.info(`Current store: ${store.platformStoreId ?? "unknown"}`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
cliConsole.newLine();
|
|
45
|
-
});
|
|
46
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { Command } from "@commander-js/extra-typings";
|
|
4
|
-
import packageJson from "../package.json";
|
|
5
|
-
import { registerCommands } from "./commands";
|
|
6
|
-
import {
|
|
7
|
-
type GlobalOptions,
|
|
8
|
-
GlobalOptionsSchema,
|
|
9
|
-
} from "./schemas/command.schema";
|
|
10
|
-
import { console as cliConsole } from "./utils/console";
|
|
11
|
-
|
|
12
|
-
class OllieShopCLI {
|
|
13
|
-
private program = new Command();
|
|
14
|
-
|
|
15
|
-
constructor() {
|
|
16
|
-
this.setupProgram();
|
|
17
|
-
this.registerCommands();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private setupProgram(): void {
|
|
21
|
-
this.program
|
|
22
|
-
.name("ollieshop")
|
|
23
|
-
.description(
|
|
24
|
-
"Ollie Shop CLI - Build and manage your e-commerce components and functions",
|
|
25
|
-
)
|
|
26
|
-
.version(packageJson.version)
|
|
27
|
-
.option("-v, --verbose", "Enable verbose logging", false)
|
|
28
|
-
.option("-q, --quiet", "Suppress non-essential output", false)
|
|
29
|
-
.option("--no-color", "Disable colored output", false)
|
|
30
|
-
.option("-c, --config <path>", "Path to configuration file")
|
|
31
|
-
.option(
|
|
32
|
-
"--log-level <level>",
|
|
33
|
-
"Set log level (error|warn|info|debug)",
|
|
34
|
-
"info",
|
|
35
|
-
)
|
|
36
|
-
.hook("preAction", (thisCommand: Command) => {
|
|
37
|
-
this.setupGlobalOptions(thisCommand);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
private setupGlobalOptions(thisCommand: Command): void {
|
|
42
|
-
try {
|
|
43
|
-
const options = thisCommand.opts();
|
|
44
|
-
const parsedOptions = this.validateGlobalOptions(options);
|
|
45
|
-
|
|
46
|
-
cliConsole.setOptions({
|
|
47
|
-
quiet: parsedOptions.quiet,
|
|
48
|
-
verbose: parsedOptions.verbose,
|
|
49
|
-
noColor: !parsedOptions.color, // --no-color sets color to false
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (parsedOptions.verbose) {
|
|
53
|
-
process.env.DEBUG = "ollieshop:*";
|
|
54
|
-
}
|
|
55
|
-
} catch (error) {
|
|
56
|
-
cliConsole.error("Invalid global options:");
|
|
57
|
-
if (error instanceof Error) {
|
|
58
|
-
cliConsole.error(error.message);
|
|
59
|
-
}
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private validateGlobalOptions(options: unknown): GlobalOptions {
|
|
65
|
-
const result = GlobalOptionsSchema.safeParse(options);
|
|
66
|
-
if (!result.success) {
|
|
67
|
-
const errors = result.error.issues.map(
|
|
68
|
-
(issue) => `${issue.path.join(".")}: ${issue.message}`,
|
|
69
|
-
);
|
|
70
|
-
throw new Error(errors.join("\n"));
|
|
71
|
-
}
|
|
72
|
-
return result.data;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private registerCommands(): void {
|
|
76
|
-
try {
|
|
77
|
-
registerCommands(this.program);
|
|
78
|
-
} catch (error) {
|
|
79
|
-
cliConsole.error("Failed to register commands:");
|
|
80
|
-
if (error instanceof Error) {
|
|
81
|
-
cliConsole.error(error.message);
|
|
82
|
-
}
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async run(): Promise<void> {
|
|
88
|
-
try {
|
|
89
|
-
// Show command suggestions if no args provided
|
|
90
|
-
if (process.argv.length <= 2) {
|
|
91
|
-
const { showCommandSuggestions } = await import(
|
|
92
|
-
"./utils/command-suggestions.js"
|
|
93
|
-
);
|
|
94
|
-
showCommandSuggestions(cliConsole);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
await this.program.parseAsync();
|
|
99
|
-
} catch (error) {
|
|
100
|
-
cliConsole.error("CLI execution failed:");
|
|
101
|
-
if (error instanceof Error) {
|
|
102
|
-
cliConsole.error(error.message);
|
|
103
|
-
if (process.env.DEBUG) {
|
|
104
|
-
cliConsole.info(`Stack trace: ${error.stack || ""}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
process.exit(1);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const cli = new OllieShopCLI();
|
|
113
|
-
cli.run().catch((error) => {
|
|
114
|
-
cliConsole.error(`Unexpected error: ${error}`);
|
|
115
|
-
process.exit(1);
|
|
116
|
-
});
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ComponentSlot, type ComponentSlotType } from "@ollie-shop/core";
|
|
2
|
-
import inquirer from "inquirer";
|
|
3
|
-
import { validateComponentName } from "../utils/validation-helpers";
|
|
4
|
-
|
|
5
|
-
export interface ComponentCreationAnswers {
|
|
6
|
-
name: string;
|
|
7
|
-
slot: ComponentSlotType;
|
|
8
|
-
includeTests: boolean;
|
|
9
|
-
description?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface ComponentDeploymentAnswers {
|
|
13
|
-
versionId: string;
|
|
14
|
-
confirm: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Generate component slot choices from core enum
|
|
18
|
-
const componentSlotChoices = ComponentSlot.options.map((slot) => ({
|
|
19
|
-
name: slot.charAt(0).toUpperCase() + slot.slice(1).replace(/-/g, " "),
|
|
20
|
-
value: slot,
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
export async function promptComponentCreation(
|
|
24
|
-
name?: string,
|
|
25
|
-
slot?: string,
|
|
26
|
-
): Promise<ComponentCreationAnswers> {
|
|
27
|
-
const questions = [];
|
|
28
|
-
|
|
29
|
-
if (!name) {
|
|
30
|
-
questions.push({
|
|
31
|
-
type: "input",
|
|
32
|
-
name: "name",
|
|
33
|
-
message: "What's the name of your component?",
|
|
34
|
-
validate: (input: string) => {
|
|
35
|
-
return validateComponentName(input);
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!slot) {
|
|
41
|
-
questions.push({
|
|
42
|
-
type: "list",
|
|
43
|
-
name: "slot",
|
|
44
|
-
message: "Which slot will this component occupy?",
|
|
45
|
-
choices: componentSlotChoices,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
questions.push(
|
|
50
|
-
{
|
|
51
|
-
type: "input",
|
|
52
|
-
name: "description",
|
|
53
|
-
message: "Enter a description (optional):",
|
|
54
|
-
default: "",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
type: "confirm",
|
|
58
|
-
name: "includeTests",
|
|
59
|
-
message: "Include test files?",
|
|
60
|
-
default: true,
|
|
61
|
-
},
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const answers = await inquirer.prompt(questions);
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
name: name || answers.name,
|
|
68
|
-
slot: slot || answers.slot,
|
|
69
|
-
description: answers.description || undefined,
|
|
70
|
-
includeTests: answers.includeTests,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export async function promptComponentDeployment(): Promise<ComponentDeploymentAnswers> {
|
|
75
|
-
const answers = await inquirer.prompt([
|
|
76
|
-
{
|
|
77
|
-
type: "input",
|
|
78
|
-
name: "versionId",
|
|
79
|
-
message: "Enter the version ID to deploy to:",
|
|
80
|
-
validate: (input: string) => {
|
|
81
|
-
if (!input.trim()) return "Version ID is required";
|
|
82
|
-
return true;
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
type: "confirm",
|
|
87
|
-
name: "confirm",
|
|
88
|
-
message: "Are you sure you want to deploy this component?",
|
|
89
|
-
default: false,
|
|
90
|
-
},
|
|
91
|
-
]);
|
|
92
|
-
|
|
93
|
-
return answers;
|
|
94
|
-
}
|