@ollie-shop/cli 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/.turbo/turbo-build.log +2 -11
  2. package/CHANGELOG.md +13 -7
  3. package/CLAUDE_CLI.md +265 -0
  4. package/README.md +704 -8
  5. package/__tests__/mocks/console.ts +22 -0
  6. package/__tests__/mocks/core.ts +137 -0
  7. package/__tests__/mocks/index.ts +4 -0
  8. package/__tests__/mocks/inquirer.ts +16 -0
  9. package/__tests__/mocks/progress.ts +19 -0
  10. package/dist/__tests__/helpers/cli-test-helper.d.ts +89 -0
  11. package/dist/__tests__/helpers/cli-test-helper.d.ts.map +1 -0
  12. package/dist/__tests__/helpers/cli-test-helper.js +220 -0
  13. package/dist/__tests__/mocks/index.d.ts +69 -0
  14. package/dist/__tests__/mocks/index.d.ts.map +1 -0
  15. package/dist/__tests__/mocks/index.js +77 -0
  16. package/dist/actions/component.actions.d.ts +14 -0
  17. package/dist/actions/component.actions.d.ts.map +1 -0
  18. package/dist/actions/component.actions.js +273 -0
  19. package/dist/actions/function.actions.d.ts +15 -0
  20. package/dist/actions/function.actions.d.ts.map +1 -0
  21. package/dist/actions/function.actions.js +254 -0
  22. package/dist/actions/project.actions.d.ts +17 -0
  23. package/dist/actions/project.actions.d.ts.map +1 -0
  24. package/dist/actions/project.actions.js +97 -0
  25. package/dist/actions/version.actions.d.ts +19 -0
  26. package/dist/actions/version.actions.d.ts.map +1 -0
  27. package/dist/actions/version.actions.js +216 -0
  28. package/dist/commands/component.d.ts +3 -0
  29. package/dist/commands/component.d.ts.map +1 -0
  30. package/dist/commands/component.js +192 -0
  31. package/dist/commands/docs.d.ts +3 -0
  32. package/dist/commands/docs.d.ts.map +1 -0
  33. package/dist/commands/docs.js +16 -0
  34. package/dist/commands/function.d.ts +3 -0
  35. package/dist/commands/function.d.ts.map +1 -0
  36. package/dist/commands/function.js +243 -0
  37. package/dist/commands/help.d.ts +3 -0
  38. package/dist/commands/help.d.ts.map +1 -0
  39. package/dist/commands/help.js +20 -0
  40. package/dist/commands/index.d.ts +3 -0
  41. package/dist/commands/index.d.ts.map +1 -0
  42. package/dist/commands/index.js +26 -0
  43. package/dist/commands/login.d.ts +3 -0
  44. package/dist/commands/login.d.ts.map +1 -0
  45. package/dist/commands/login.js +175 -0
  46. package/dist/commands/project.d.ts +3 -0
  47. package/dist/commands/project.d.ts.map +1 -0
  48. package/dist/commands/project.js +78 -0
  49. package/dist/commands/store-version.d.ts +3 -0
  50. package/dist/commands/store-version.d.ts.map +1 -0
  51. package/dist/commands/store-version.js +241 -0
  52. package/dist/commands/version.d.ts +3 -0
  53. package/dist/commands/version.d.ts.map +1 -0
  54. package/dist/commands/version.js +46 -0
  55. package/dist/commands/whoami.d.ts +3 -0
  56. package/dist/commands/whoami.d.ts.map +1 -0
  57. package/dist/commands/whoami.js +41 -0
  58. package/dist/index.d.ts +3 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +88 -478
  61. package/dist/prompts/component.prompts.d.ts +14 -0
  62. package/dist/prompts/component.prompts.d.ts.map +1 -0
  63. package/dist/prompts/component.prompts.js +75 -0
  64. package/dist/prompts/function.prompts.d.ts +21 -0
  65. package/dist/prompts/function.prompts.d.ts.map +1 -0
  66. package/dist/prompts/function.prompts.js +127 -0
  67. package/dist/schemas/command.schema.d.ts +516 -0
  68. package/dist/schemas/command.schema.d.ts.map +1 -0
  69. package/dist/schemas/command.schema.js +267 -0
  70. package/dist/types/index.d.ts +147 -0
  71. package/dist/types/index.d.ts.map +1 -0
  72. package/dist/types/index.js +18 -0
  73. package/dist/utils/auth.d.ts +4 -0
  74. package/dist/utils/auth.d.ts.map +1 -0
  75. package/dist/utils/auth.js +26 -0
  76. package/dist/utils/cli-progress-reporter.d.ts +12 -0
  77. package/dist/utils/cli-progress-reporter.d.ts.map +1 -0
  78. package/dist/utils/cli-progress-reporter.js +77 -0
  79. package/dist/utils/command-builder.d.ts +22 -0
  80. package/dist/utils/command-builder.d.ts.map +1 -0
  81. package/dist/utils/command-builder.js +268 -0
  82. package/dist/utils/command-helpers.d.ts +19 -0
  83. package/dist/utils/command-helpers.d.ts.map +1 -0
  84. package/dist/utils/command-helpers.js +79 -0
  85. package/dist/utils/command-parser.d.ts +146 -0
  86. package/dist/utils/command-parser.d.ts.map +1 -0
  87. package/dist/utils/command-parser.js +179 -0
  88. package/dist/utils/command-suggestions.d.ts +35 -0
  89. package/dist/utils/command-suggestions.d.ts.map +1 -0
  90. package/dist/utils/command-suggestions.js +152 -0
  91. package/dist/utils/console.d.ts +44 -0
  92. package/dist/utils/console.d.ts.map +1 -0
  93. package/dist/utils/console.js +233 -0
  94. package/dist/utils/constants.d.ts +8 -0
  95. package/dist/utils/constants.d.ts.map +1 -0
  96. package/dist/utils/constants.js +10 -0
  97. package/dist/utils/context-detector.d.ts +12 -0
  98. package/dist/utils/context-detector.d.ts.map +1 -0
  99. package/dist/utils/context-detector.js +155 -0
  100. package/dist/utils/enhanced-error-handler.d.ts +47 -0
  101. package/dist/utils/enhanced-error-handler.d.ts.map +1 -0
  102. package/dist/utils/enhanced-error-handler.js +221 -0
  103. package/dist/utils/error-handler.d.ts +3 -0
  104. package/dist/utils/error-handler.d.ts.map +1 -0
  105. package/dist/utils/error-handler.js +55 -0
  106. package/dist/utils/errors.d.ts +44 -0
  107. package/dist/utils/errors.d.ts.map +1 -0
  108. package/dist/utils/errors.js +76 -0
  109. package/dist/utils/interactive-builder.d.ts +22 -0
  110. package/dist/utils/interactive-builder.d.ts.map +1 -0
  111. package/dist/utils/interactive-builder.js +246 -0
  112. package/dist/utils/rich-progress.d.ts +59 -0
  113. package/dist/utils/rich-progress.d.ts.map +1 -0
  114. package/dist/utils/rich-progress.js +234 -0
  115. package/dist/utils/store.d.ts +11 -0
  116. package/dist/utils/store.d.ts.map +1 -0
  117. package/dist/utils/store.js +19 -0
  118. package/dist/utils/validation-error-formatter.d.ts +25 -0
  119. package/dist/utils/validation-error-formatter.d.ts.map +1 -0
  120. package/dist/utils/validation-error-formatter.js +258 -0
  121. package/dist/utils/validation-helpers.d.ts +60 -0
  122. package/dist/utils/validation-helpers.d.ts.map +1 -0
  123. package/dist/utils/validation-helpers.js +152 -0
  124. package/package.json +43 -11
  125. package/src/__tests__/helpers/cli-test-helper.ts +281 -0
  126. package/src/__tests__/mocks/index.ts +142 -0
  127. package/src/actions/component.actions.ts +334 -0
  128. package/src/actions/function.actions.ts +313 -0
  129. package/src/actions/project.actions.ts +126 -0
  130. package/src/actions/version.actions.ts +233 -0
  131. package/src/commands/__tests__/component-validation.test.ts +250 -0
  132. package/src/commands/__tests__/component.test.ts +321 -0
  133. package/src/commands/__tests__/function-validation.test.ts +220 -0
  134. package/src/commands/__tests__/function.test.ts +286 -0
  135. package/src/commands/__tests__/store-version-validation.test.ts +414 -0
  136. package/src/commands/__tests__/store-version.test.ts +405 -0
  137. package/src/commands/__tests__/version.test.ts +71 -0
  138. package/src/commands/component.ts +188 -0
  139. package/src/commands/docs.ts +11 -11
  140. package/src/commands/function.ts +252 -0
  141. package/src/commands/help.ts +8 -18
  142. package/src/commands/index.ts +14 -7
  143. package/src/commands/login.ts +19 -79
  144. package/src/commands/project.ts +107 -0
  145. package/src/commands/store-version.ts +242 -0
  146. package/src/commands/version.ts +45 -8
  147. package/src/commands/whoami.ts +8 -13
  148. package/src/index.ts +108 -34
  149. package/src/prompts/component.prompts.ts +94 -0
  150. package/src/prompts/function.prompts.ts +168 -0
  151. package/src/schemas/command.schema.ts +354 -0
  152. package/src/types/index.ts +183 -0
  153. package/src/utils/__tests__/command-parser.test.ts +159 -0
  154. package/src/utils/__tests__/command-suggestions.test.ts +185 -0
  155. package/src/utils/__tests__/console.test.ts +192 -0
  156. package/src/utils/__tests__/context-detector.test.ts +258 -0
  157. package/src/utils/__tests__/enhanced-error-handler.test.ts +137 -0
  158. package/src/utils/__tests__/error-handler.test.ts +107 -0
  159. package/src/utils/__tests__/rich-progress.test.ts +170 -0
  160. package/src/utils/__tests__/validation-error-formatter.test.ts +175 -0
  161. package/src/utils/__tests__/validation-helpers.test.ts +125 -0
  162. package/src/utils/auth.ts +0 -1
  163. package/src/utils/cli-progress-reporter.ts +84 -0
  164. package/src/utils/command-builder.ts +390 -0
  165. package/src/utils/command-helpers.ts +83 -0
  166. package/src/utils/command-parser.ts +250 -0
  167. package/src/utils/command-suggestions.ts +176 -0
  168. package/src/utils/console.ts +291 -0
  169. package/src/utils/context-detector.ts +177 -0
  170. package/src/utils/enhanced-error-handler.ts +264 -0
  171. package/src/utils/error-handler.ts +60 -0
  172. package/src/utils/errors.ts +125 -0
  173. package/src/utils/interactive-builder.ts +271 -0
  174. package/src/utils/rich-progress.ts +320 -0
  175. package/src/utils/validation-error-formatter.ts +337 -0
  176. package/src/utils/validation-helpers.ts +192 -0
  177. package/tsconfig.json +13 -7
  178. package/vitest.config.ts +28 -0
  179. package/vitest.setup.ts +29 -0
  180. package/src/commands/validate.ts +0 -62
  181. package/src/utils/core.ts +0 -105
  182. package/tsup.config.ts +0 -15
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COMMON_OPTIONS = exports.parsePriority = exports.parseVersionName = exports.parseStoreId = exports.parseUUID = exports.parsePath = exports.parseFunctionInvocation = exports.parseComponentSlot = exports.parseFunctionName = exports.parseComponentName = void 0;
4
+ exports.createOptionParser = createOptionParser;
5
+ exports.parseBooleanOption = parseBooleanOption;
6
+ const extra_typings_1 = require("@commander-js/extra-typings");
7
+ const core_1 = require("@ollie-shop/core");
8
+ const zod_1 = require("zod");
9
+ const command_schema_1 = require("../schemas/command.schema");
10
+ /**
11
+ * Create a Commander option parser that validates with Zod schema
12
+ */
13
+ function createOptionParser(schema, fieldName, helpText) {
14
+ return (value) => {
15
+ const result = schema.safeParse(value);
16
+ if (!result.success) {
17
+ const errors = result.error.errors.map((err) => err.message).join(", ");
18
+ let errorMessage = `Invalid ${fieldName}: ${errors}`;
19
+ if (helpText) {
20
+ errorMessage += `\n\n${helpText}`;
21
+ }
22
+ throw new extra_typings_1.InvalidArgumentError(errorMessage);
23
+ }
24
+ return result.data;
25
+ };
26
+ }
27
+ /**
28
+ * Parse component name with validation
29
+ */
30
+ exports.parseComponentName = createOptionParser(command_schema_1.ComponentNameSchema, "component name", "Examples: header-nav, shopping-cart, product-list");
31
+ /**
32
+ * Parse function name with validation
33
+ */
34
+ exports.parseFunctionName = createOptionParser(command_schema_1.FunctionNameSchema, "function name", "Examples: validate-order, apply-discount, check-inventory");
35
+ /**
36
+ * Parse component slot with validation
37
+ */
38
+ exports.parseComponentSlot = createOptionParser(core_1.ComponentSlot, "component slot", "Valid slots: header, footer, sidebar, main, checkout-summary, payment-method, shipping-method, customer-info, order-confirmation");
39
+ /**
40
+ * Parse function invocation with validation
41
+ */
42
+ exports.parseFunctionInvocation = createOptionParser(core_1.FunctionInvocationType, "function invocation", "Valid invocations: request, response");
43
+ /**
44
+ * Parse boolean option with better error handling
45
+ */
46
+ function parseBooleanOption(value) {
47
+ const normalized = value.toLowerCase().trim();
48
+ if (["true", "1", "yes", "y"].includes(normalized)) {
49
+ return true;
50
+ }
51
+ if (["false", "0", "no", "n"].includes(normalized)) {
52
+ return false;
53
+ }
54
+ throw new extra_typings_1.InvalidArgumentError(`Invalid boolean value: "${value}". Use true/false, yes/no, or 1/0`);
55
+ }
56
+ /**
57
+ * Parse path option with validation
58
+ */
59
+ exports.parsePath = createOptionParser(command_schema_1.PathSchema, "path");
60
+ /**
61
+ * Parse UUID with validation
62
+ */
63
+ exports.parseUUID = createOptionParser(zod_1.z
64
+ .string()
65
+ .uuid("Must be a valid UUID (e.g., 123e4567-e89b-12d3-a456-426614174000)"), "ID", "Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
66
+ /**
67
+ * Parse store ID with validation
68
+ */
69
+ exports.parseStoreId = createOptionParser(command_schema_1.StoreIdSchema, "store ID", "Example: 123e4567-e89b-12d3-a456-426614174000");
70
+ /**
71
+ * Parse version name with validation
72
+ */
73
+ exports.parseVersionName = createOptionParser(command_schema_1.VersionNameSchema, "version name", "Examples: v1.0.0, summer-sale-2024, black-friday");
74
+ /**
75
+ * Parse priority with validation
76
+ */
77
+ const parsePriority = (value) => {
78
+ const numValue = Number(value);
79
+ if (Number.isNaN(numValue)) {
80
+ throw new extra_typings_1.InvalidArgumentError(`Priority must be a number, received: ${value}`);
81
+ }
82
+ const result = command_schema_1.PrioritySchema.safeParse(numValue);
83
+ if (!result.success) {
84
+ const errors = result.error.errors.map((err) => err.message).join(", ");
85
+ throw new extra_typings_1.InvalidArgumentError(`Invalid priority: ${errors}`);
86
+ }
87
+ return result.data;
88
+ };
89
+ exports.parsePriority = parsePriority;
90
+ /**
91
+ * Common option configurations
92
+ */
93
+ exports.COMMON_OPTIONS = {
94
+ componentName: {
95
+ flags: "-n, --name <name>",
96
+ description: "Component name (lowercase with hyphens)",
97
+ parser: exports.parseComponentName,
98
+ required: true,
99
+ },
100
+ functionName: {
101
+ flags: "-n, --name <name>",
102
+ description: "Function name (lowercase with hyphens)",
103
+ parser: exports.parseFunctionName,
104
+ required: true,
105
+ },
106
+ componentSlot: {
107
+ flags: "-s, --slot <slot>",
108
+ description: "Component slot (header|footer|sidebar|main|checkout-summary|payment-method|shipping-method|customer-info|order-confirmation)",
109
+ parser: exports.parseComponentSlot,
110
+ defaultValue: "main",
111
+ },
112
+ functionInvocation: {
113
+ flags: "-i, --invocation <invocation>",
114
+ description: "Function invocation type (request|response)",
115
+ parser: exports.parseFunctionInvocation,
116
+ defaultValue: "request",
117
+ },
118
+ tests: {
119
+ flags: "--tests",
120
+ description: "Include test files (default: true)",
121
+ defaultValue: true,
122
+ },
123
+ noTests: {
124
+ flags: "--no-tests",
125
+ description: "Skip test file generation",
126
+ },
127
+ path: {
128
+ flags: "-p, --path <path>",
129
+ description: "Path to component or function directory",
130
+ parser: exports.parsePath,
131
+ },
132
+ wait: {
133
+ flags: "-w, --wait",
134
+ description: "Wait for operation to complete",
135
+ defaultValue: false,
136
+ },
137
+ storeId: {
138
+ flags: "-s, --store <id>",
139
+ description: "Store ID (UUID format)",
140
+ parser: exports.parseStoreId,
141
+ required: true,
142
+ },
143
+ versionName: {
144
+ flags: "-n, --name <name>",
145
+ description: "Version name",
146
+ parser: exports.parseVersionName,
147
+ required: true,
148
+ },
149
+ template: {
150
+ flags: "-t, --template <template>",
151
+ description: "Template to use (default|grocery|sales)",
152
+ defaultValue: "default",
153
+ },
154
+ active: {
155
+ flags: "--active",
156
+ description: "Make version active (default: true)",
157
+ defaultValue: true,
158
+ },
159
+ noActive: {
160
+ flags: "--no-active",
161
+ description: "Create inactive version",
162
+ },
163
+ force: {
164
+ flags: "-f, --force",
165
+ description: "Skip confirmation prompts",
166
+ defaultValue: false,
167
+ },
168
+ watch: {
169
+ flags: "--watch",
170
+ description: "Watch for changes and rebuild automatically",
171
+ defaultValue: false,
172
+ },
173
+ priority: {
174
+ flags: "-p, --priority <priority>",
175
+ description: "Execution priority (0-100)",
176
+ parser: exports.parsePriority,
177
+ defaultValue: 0,
178
+ },
179
+ };
@@ -0,0 +1,35 @@
1
+ import type { CliConsole } from "./console.js";
2
+ export declare class CommandSuggestions {
3
+ private console;
4
+ constructor(console: CliConsole);
5
+ /**
6
+ * Show context-aware command suggestions
7
+ */
8
+ show(): void;
9
+ /**
10
+ * Show current directory context
11
+ */
12
+ private showCurrentContext;
13
+ /**
14
+ * Show commands relevant to current context
15
+ */
16
+ private showContextCommands;
17
+ /**
18
+ * Show recently used commands
19
+ */
20
+ private showRecentCommands;
21
+ /**
22
+ * Show helpful tip based on context
23
+ */
24
+ private showTip;
25
+ /**
26
+ * Get mock recent commands for demo
27
+ * TODO: Implement actual command history
28
+ */
29
+ private getMockRecentCommands;
30
+ }
31
+ /**
32
+ * Show command suggestions for the current context
33
+ */
34
+ export declare function showCommandSuggestions(console: CliConsole): void;
35
+ //# sourceMappingURL=command-suggestions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-suggestions.d.ts","sourceRoot":"","sources":["../../src/utils/command-suggestions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ/C,qBAAa,kBAAkB;IACjB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,UAAU;IAEvC;;OAEG;IACH,IAAI,IAAI,IAAI;IAmBZ;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAsB1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA4C3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;OAEG;IACH,OAAO,CAAC,OAAO;IAiBf;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAkB9B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,UAAU,GAAG,IAAI,CAGhE"}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CommandSuggestions = void 0;
7
+ exports.showCommandSuggestions = showCommandSuggestions;
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const context_detector_js_1 = require("./context-detector.js");
10
+ class CommandSuggestions {
11
+ constructor(console) {
12
+ this.console = console;
13
+ }
14
+ /**
15
+ * Show context-aware command suggestions
16
+ */
17
+ show() {
18
+ const context = (0, context_detector_js_1.detectProjectContext)();
19
+ // Show header
20
+ this.console.log("");
21
+ // Show current context
22
+ this.showCurrentContext(context);
23
+ // Show relevant commands
24
+ this.showContextCommands(context);
25
+ // Show recent commands if available
26
+ this.showRecentCommands();
27
+ // Show helpful tip
28
+ this.showTip(context);
29
+ }
30
+ /**
31
+ * Show current directory context
32
+ */
33
+ showCurrentContext(context) {
34
+ this.console.log(chalk_1.default.blue("📍 Current location:"));
35
+ if (context.type === "component") {
36
+ this.console.log(` You're in a component directory: ${chalk_1.default.cyan(context.name || "unknown")}`);
37
+ }
38
+ else if (context.type === "function") {
39
+ this.console.log(` You're in a function directory: ${chalk_1.default.cyan(context.name || "unknown")}`);
40
+ }
41
+ else if (context.parentPath) {
42
+ this.console.log(` You're in the project root`);
43
+ }
44
+ else {
45
+ this.console.log(` ${process.cwd()}`);
46
+ }
47
+ this.console.log("");
48
+ }
49
+ /**
50
+ * Show commands relevant to current context
51
+ */
52
+ showContextCommands(context) {
53
+ let commands = [];
54
+ if (context.type === "component") {
55
+ commands = [
56
+ { command: "validate", description: "Check component validity" },
57
+ { command: "build", description: "Build for production" },
58
+ { command: "dev", description: "Start development server" },
59
+ { command: "deploy", description: "Deploy to cloud" },
60
+ ];
61
+ this.console.log(chalk_1.default.blue("Common commands for this component:"));
62
+ }
63
+ else if (context.type === "function") {
64
+ commands = [
65
+ { command: "validate", description: "Check function validity" },
66
+ { command: "build", description: "Build function" },
67
+ { command: "test", description: "Run function tests" },
68
+ { command: "deploy", description: "Deploy to cloud" },
69
+ ];
70
+ this.console.log(chalk_1.default.blue("Common commands for this function:"));
71
+ }
72
+ else {
73
+ commands = [
74
+ { command: "component create", description: "Create a new component" },
75
+ { command: "function create", description: "Create a new function" },
76
+ { command: "component list", description: "List all components" },
77
+ { command: "function list", description: "List all functions" },
78
+ ];
79
+ this.console.log(chalk_1.default.blue("Common commands:"));
80
+ }
81
+ // Display commands
82
+ const maxCmdLength = Math.max(...commands.map((c) => c.command.length));
83
+ for (const { command, description } of commands) {
84
+ const paddedCmd = command.padEnd(maxCmdLength + 2);
85
+ this.console.log(` ${chalk_1.default.cyan(paddedCmd)} ${chalk_1.default.dim(description)}`);
86
+ }
87
+ this.console.log("");
88
+ }
89
+ /**
90
+ * Show recently used commands
91
+ */
92
+ showRecentCommands() {
93
+ // TODO: In a real implementation, we'd read from a history file
94
+ // For now, we'll show some common commands
95
+ const recentCommands = this.getMockRecentCommands();
96
+ if (recentCommands.length > 0) {
97
+ this.console.log(chalk_1.default.blue("Recent commands:"));
98
+ for (const { command, timeAgo } of recentCommands) {
99
+ this.console.log(chalk_1.default.dim(` ollieshop ${command} ${chalk_1.default.dim(`(${timeAgo})`)}`));
100
+ }
101
+ this.console.log("");
102
+ }
103
+ }
104
+ /**
105
+ * Show helpful tip based on context
106
+ */
107
+ showTip(context) {
108
+ let tip = "";
109
+ if (context.type === "component") {
110
+ tip = "Run 'ollieshop dev' to start developing this component";
111
+ }
112
+ else if (context.type === "function") {
113
+ tip = "Run 'ollieshop test' to test this function locally";
114
+ }
115
+ else if (context.parentPath) {
116
+ tip =
117
+ "Navigate to a component with 'cd components/<name>' or create one with 'ollieshop component create'";
118
+ }
119
+ else {
120
+ tip = "Run 'ollieshop --help' to see all available commands";
121
+ }
122
+ this.console.log(chalk_1.default.yellow(`💡 Tip: ${tip}`));
123
+ }
124
+ /**
125
+ * Get mock recent commands for demo
126
+ * TODO: Implement actual command history
127
+ */
128
+ getMockRecentCommands() {
129
+ const context = (0, context_detector_js_1.detectProjectContext)();
130
+ if (context.type === "component") {
131
+ return [
132
+ { command: "validate --fix", timeAgo: "2 min ago" },
133
+ { command: "build --watch", timeAgo: "1 hour ago" },
134
+ ];
135
+ }
136
+ if (context.type === "function") {
137
+ return [
138
+ { command: "test", timeAgo: "5 min ago" },
139
+ { command: "validate", timeAgo: "30 min ago" },
140
+ ];
141
+ }
142
+ return [];
143
+ }
144
+ }
145
+ exports.CommandSuggestions = CommandSuggestions;
146
+ /**
147
+ * Show command suggestions for the current context
148
+ */
149
+ function showCommandSuggestions(console) {
150
+ const suggestions = new CommandSuggestions(console);
151
+ suggestions.show();
152
+ }
@@ -0,0 +1,44 @@
1
+ import { type Ora } from "ora";
2
+ import type { OllieShopCLIError } from "./errors";
3
+ export interface ConsoleOptions {
4
+ quiet?: boolean;
5
+ verbose?: boolean;
6
+ noColor?: boolean;
7
+ }
8
+ export declare class Console {
9
+ private options;
10
+ private prefix;
11
+ setOptions(options?: ConsoleOptions): void;
12
+ hint(message: string): string;
13
+ status(message: string): void;
14
+ info(message: string): string;
15
+ warn(message: string): string;
16
+ success(message: string): string;
17
+ error(message: string | OllieShopCLIError): string;
18
+ prompt(message: string): string;
19
+ header(message: string): string;
20
+ processing(message: string): string;
21
+ cancelled(message: string): string;
22
+ important(path: string): string;
23
+ code(message: string): string;
24
+ debug(message: string): string | undefined;
25
+ log(message: string): string;
26
+ newLine(): void;
27
+ nextSteps(title: string, steps: Array<{
28
+ description: string;
29
+ command?: string;
30
+ }>): void;
31
+ suggestions(items: string[]): void;
32
+ dim(message: string): string;
33
+ bold(message: string): string;
34
+ table(data: Array<Record<string, string | number | boolean>>): void;
35
+ json(data: Record<string, unknown> | Array<unknown>): void;
36
+ confirm(message: string): Promise<boolean>;
37
+ listResults<T>(items: T[], formatter: (item: T) => string): void;
38
+ spinner(options: {
39
+ text: string;
40
+ } | string): Ora;
41
+ }
42
+ export type CliConsole = Console;
43
+ export declare const console: Console;
44
+ //# sourceMappingURL=console.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/utils/console.ts"],"names":[],"mappings":"AACA,OAAY,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,qBAAa,OAAO;IAClB,OAAO,CAAC,OAAO,CAIb;IACF,OAAO,CAAC,MAAM,CAA8B;IAE5C,UAAU,CAAC,OAAO,GAAE,cAAmB;IAQvC,IAAI,CAAC,OAAO,EAAE,MAAM;IASpB,MAAM,CAAC,OAAO,EAAE,MAAM;IAItB,IAAI,CAAC,OAAO,EAAE,MAAM;IAUpB,IAAI,CAAC,OAAO,EAAE,MAAM;IASpB,OAAO,CAAC,OAAO,EAAE,MAAM;IASvB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB;IAsCzC,MAAM,CAAC,OAAO,EAAE,MAAM;IAStB,MAAM,CAAC,OAAO,EAAE,MAAM;IAStB,UAAU,CAAC,OAAO,EAAE,MAAM;IAS1B,SAAS,CAAC,OAAO,EAAE,MAAM;IASzB,SAAS,CAAC,IAAI,EAAE,MAAM;IAStB,IAAI,CAAC,OAAO,EAAE,MAAM;IAUpB,KAAK,CAAC,OAAO,EAAE,MAAM;IASrB,GAAG,CAAC,OAAO,EAAE,MAAM;IAQnB,OAAO;IAMP,SAAS,CACP,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAgBzD,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE;IAY3B,GAAG,CAAC,OAAO,EAAE,MAAM;IAQnB,IAAI,CAAC,OAAO,EAAE,MAAM;IAIpB,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;IAK5D,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;IAK7C,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAOhD,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM;IAiBzD,OAAO,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,GAAG;CA0BjD;AAGD,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AAEjC,eAAO,MAAM,OAAO,SAAgB,CAAC"}
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.console = exports.Console = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const ora_1 = __importDefault(require("ora"));
9
+ class Console {
10
+ constructor() {
11
+ this.options = {
12
+ quiet: false,
13
+ verbose: false,
14
+ noColor: false,
15
+ };
16
+ this.prefix = chalk_1.default.blue.bold("[ollie]");
17
+ }
18
+ setOptions(options = {}) {
19
+ this.options = { ...this.options, ...options };
20
+ if (options.noColor) {
21
+ chalk_1.default.level = 0;
22
+ }
23
+ }
24
+ hint(message) {
25
+ const text = chalk_1.default.gray(message);
26
+ if (!this.options.quiet) {
27
+ global.console.log(`${this.prefix} ${text}`);
28
+ }
29
+ return text;
30
+ }
31
+ status(message) {
32
+ global.console.log(`${this.prefix} ${message}`);
33
+ }
34
+ info(message) {
35
+ const text = `${chalk_1.default.blue("ℹ")} ${message}`;
36
+ if (!this.options.quiet) {
37
+ global.console.log(`${this.prefix} ${text}`);
38
+ }
39
+ return text;
40
+ }
41
+ warn(message) {
42
+ const text = `${chalk_1.default.yellow("⚠")} ${chalk_1.default.yellow(message)}`;
43
+ if (!this.options.quiet) {
44
+ global.console.warn(`${this.prefix} ${text}`);
45
+ }
46
+ return text;
47
+ }
48
+ success(message) {
49
+ const text = `${chalk_1.default.green("✓")} ${chalk_1.default.green(message)}`;
50
+ if (!this.options.quiet) {
51
+ global.console.log(`${this.prefix} ${text}`);
52
+ }
53
+ return text;
54
+ }
55
+ error(message) {
56
+ if (typeof message === "string") {
57
+ const text = `${chalk_1.default.red("✗")} ${chalk_1.default.red.bold(message)}`;
58
+ global.console.error(`${this.prefix} ${text}`);
59
+ return text;
60
+ }
61
+ // Handle OllieShopCLIError with rich context
62
+ const text = `${chalk_1.default.red("✗")} ${chalk_1.default.red.bold(message.message)}`;
63
+ global.console.error(`${this.prefix} ${text}`);
64
+ if (message.context.command) {
65
+ global.console.error(`${this.prefix} Command: ${chalk_1.default.cyan(message.context.command)}`);
66
+ }
67
+ if (message.context.file) {
68
+ global.console.error(`${this.prefix} File: ${chalk_1.default.cyan(message.context.file)}`);
69
+ }
70
+ if (message.recoveryActions.length > 0) {
71
+ global.console.error(`${this.prefix} ${chalk_1.default.yellow("💡 Suggestions")}:`);
72
+ for (const action of message.recoveryActions) {
73
+ global.console.error(`${this.prefix} • ${action.description}`);
74
+ if (action.command) {
75
+ global.console.error(`${this.prefix} ${chalk_1.default.gray("$")} ${chalk_1.default.yellow(action.command)}`);
76
+ }
77
+ }
78
+ }
79
+ return text;
80
+ }
81
+ prompt(message) {
82
+ const text = chalk_1.default.cyan(message);
83
+ if (!this.options.quiet) {
84
+ process.stdout.write(`${this.prefix} ${text}`);
85
+ }
86
+ return text;
87
+ }
88
+ header(message) {
89
+ const text = chalk_1.default.bold.blue(message);
90
+ if (!this.options.quiet) {
91
+ global.console.log(`${this.prefix} ${text}`);
92
+ }
93
+ return text;
94
+ }
95
+ processing(message) {
96
+ const text = chalk_1.default.blue(message);
97
+ if (!this.options.quiet) {
98
+ global.console.log(`${this.prefix} ${text}`);
99
+ }
100
+ return text;
101
+ }
102
+ cancelled(message) {
103
+ const text = chalk_1.default.red(message);
104
+ if (!this.options.quiet) {
105
+ global.console.log(`${this.prefix} ${text}`);
106
+ }
107
+ return text;
108
+ }
109
+ important(path) {
110
+ const text = chalk_1.default.bold(path);
111
+ if (!this.options.quiet) {
112
+ global.console.log(`${this.prefix} ${text}`);
113
+ }
114
+ return text;
115
+ }
116
+ code(message) {
117
+ const text = chalk_1.default.cyan(message);
118
+ if (!this.options.quiet) {
119
+ global.console.log(`${this.prefix} ${text}`);
120
+ }
121
+ return text;
122
+ }
123
+ // Additional methods needed by CLI commands
124
+ debug(message) {
125
+ if (this.options.quiet || !this.options.verbose)
126
+ return;
127
+ const text = `${chalk_1.default.gray("🐛")} ${chalk_1.default.gray(message)}`;
128
+ global.console.log(`${this.prefix} ${text}`);
129
+ return text;
130
+ }
131
+ log(message) {
132
+ if (!this.options.quiet) {
133
+ global.console.log(`${this.prefix} ${message}`);
134
+ }
135
+ return message;
136
+ }
137
+ newLine() {
138
+ if (!this.options.quiet) {
139
+ global.console.log("");
140
+ }
141
+ }
142
+ nextSteps(title, steps) {
143
+ if (this.options.quiet)
144
+ return;
145
+ this.newLine();
146
+ this.info(title);
147
+ for (const step of steps) {
148
+ this.log(` • ${step.description}`);
149
+ if (step.command) {
150
+ this.log(` ${chalk_1.default.gray("$")} ${chalk_1.default.yellow(step.command)}`);
151
+ }
152
+ }
153
+ this.newLine();
154
+ }
155
+ suggestions(items) {
156
+ if (this.options.quiet)
157
+ return;
158
+ this.newLine();
159
+ this.info("Suggestions:");
160
+ for (const item of items) {
161
+ this.log(` • ${item}`);
162
+ }
163
+ this.newLine();
164
+ }
165
+ dim(message) {
166
+ const text = chalk_1.default.dim(message);
167
+ if (!this.options.quiet) {
168
+ global.console.log(text);
169
+ }
170
+ return text;
171
+ }
172
+ bold(message) {
173
+ return chalk_1.default.bold(message);
174
+ }
175
+ table(data) {
176
+ if (this.options.quiet || data.length === 0)
177
+ return;
178
+ global.console.table(data);
179
+ }
180
+ json(data) {
181
+ if (this.options.quiet)
182
+ return;
183
+ global.console.log(JSON.stringify(data, null, 2));
184
+ }
185
+ async confirm(message) {
186
+ // For now, return false in non-interactive mode
187
+ // TODO: Implement interactive confirmation
188
+ this.warn(`${message} (y/N)`);
189
+ return false;
190
+ }
191
+ listResults(items, formatter) {
192
+ if (this.options.quiet)
193
+ return;
194
+ if (items.length === 0) {
195
+ this.warn("No items found");
196
+ return;
197
+ }
198
+ this.info(`Found ${items.length} item(s):`);
199
+ this.newLine();
200
+ for (const item of items) {
201
+ this.log(formatter(item));
202
+ }
203
+ }
204
+ // Clean spinner implementation using ora with proper cleanup
205
+ spinner(options) {
206
+ const text = typeof options === "string" ? options : options.text;
207
+ if (this.options.quiet) {
208
+ // Return a mock spinner for quiet mode
209
+ return {
210
+ start: () => this.spinner(options),
211
+ stop: () => this.spinner(options),
212
+ succeed: (msg) => {
213
+ if (msg)
214
+ this.success(msg);
215
+ return this.spinner(options);
216
+ },
217
+ fail: (msg) => {
218
+ if (msg)
219
+ this.error(msg);
220
+ return this.spinner(options);
221
+ },
222
+ };
223
+ }
224
+ // Create a real spinner using ora with prefix
225
+ return (0, ora_1.default)({
226
+ text,
227
+ color: "cyan",
228
+ prefixText: this.prefix,
229
+ });
230
+ }
231
+ }
232
+ exports.Console = Console;
233
+ exports.console = new Console();
@@ -0,0 +1,8 @@
1
+ export declare const SRC_DIR = "src";
2
+ export declare const COMPONENTS_DIR = "components";
3
+ export declare const DIST_DIR = "dist";
4
+ export declare const META_FILE = "meta.json";
5
+ export declare const CONFIG_FILE = "ollie.json";
6
+ export declare const OLLIE_SHOP_ASSETS_DIR = "node_modules/.ollie-shop";
7
+ export declare const TEMPLATES_DIR = "templates";
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,QAAQ,CAAC;AAC7B,eAAO,MAAM,cAAc,eAAe,CAAC;AAC3C,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,WAAW,eAAe,CAAC;AACxC,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAChE,eAAO,MAAM,aAAa,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEMPLATES_DIR = exports.OLLIE_SHOP_ASSETS_DIR = exports.CONFIG_FILE = exports.META_FILE = exports.DIST_DIR = exports.COMPONENTS_DIR = exports.SRC_DIR = void 0;
4
+ exports.SRC_DIR = "src";
5
+ exports.COMPONENTS_DIR = "components";
6
+ exports.DIST_DIR = "dist";
7
+ exports.META_FILE = "meta.json";
8
+ exports.CONFIG_FILE = "ollie.json";
9
+ exports.OLLIE_SHOP_ASSETS_DIR = "node_modules/.ollie-shop";
10
+ exports.TEMPLATES_DIR = "templates";