@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.
Files changed (139) hide show
  1. package/.turbo/turbo-build.log +14 -2
  2. package/CHANGELOG.md +48 -0
  3. package/__tests__/mocks/core.ts +1 -1
  4. package/dist/index.d.ts +0 -2
  5. package/dist/index.js +40631 -75
  6. package/package.json +7 -6
  7. package/src/actions/component.actions.ts +148 -204
  8. package/src/actions/function.actions.ts +78 -171
  9. package/src/actions/project.actions.ts +16 -11
  10. package/src/commands/__tests__/component.test.ts +4 -7
  11. package/src/commands/__tests__/function.test.ts +1 -1
  12. package/src/commands/__tests__/store-version.test.ts +1 -4
  13. package/src/commands/component.ts +0 -10
  14. package/src/commands/function.ts +5 -56
  15. package/src/schemas/command.schema.ts +296 -6
  16. package/src/utils/__tests__/rich-progress.test.ts +22 -11
  17. package/src/utils/cli-progress-reporter.ts +2 -2
  18. package/src/utils/command-parser.ts +0 -5
  19. package/src/utils/console.ts +33 -4
  20. package/src/utils/constants.ts +32 -0
  21. package/src/utils/deploy-helpers.ts +357 -0
  22. package/src/utils/errors.ts +133 -2
  23. package/src/utils/interactive-builder.ts +61 -7
  24. package/src/utils/rich-progress.ts +25 -14
  25. package/src/utils/validation-helpers.ts +145 -12
  26. package/tsup.config.ts +15 -0
  27. package/dist/__tests__/helpers/cli-test-helper.d.ts +0 -89
  28. package/dist/__tests__/helpers/cli-test-helper.d.ts.map +0 -1
  29. package/dist/__tests__/helpers/cli-test-helper.js +0 -220
  30. package/dist/__tests__/mocks/index.d.ts +0 -69
  31. package/dist/__tests__/mocks/index.d.ts.map +0 -1
  32. package/dist/__tests__/mocks/index.js +0 -77
  33. package/dist/actions/component.actions.d.ts +0 -14
  34. package/dist/actions/component.actions.d.ts.map +0 -1
  35. package/dist/actions/component.actions.js +0 -273
  36. package/dist/actions/function.actions.d.ts +0 -15
  37. package/dist/actions/function.actions.d.ts.map +0 -1
  38. package/dist/actions/function.actions.js +0 -254
  39. package/dist/actions/project.actions.d.ts +0 -17
  40. package/dist/actions/project.actions.d.ts.map +0 -1
  41. package/dist/actions/project.actions.js +0 -97
  42. package/dist/actions/version.actions.d.ts +0 -19
  43. package/dist/actions/version.actions.d.ts.map +0 -1
  44. package/dist/actions/version.actions.js +0 -216
  45. package/dist/commands/component.d.ts +0 -3
  46. package/dist/commands/component.d.ts.map +0 -1
  47. package/dist/commands/component.js +0 -192
  48. package/dist/commands/docs.d.ts +0 -3
  49. package/dist/commands/docs.d.ts.map +0 -1
  50. package/dist/commands/docs.js +0 -16
  51. package/dist/commands/function.d.ts +0 -3
  52. package/dist/commands/function.d.ts.map +0 -1
  53. package/dist/commands/function.js +0 -243
  54. package/dist/commands/help.d.ts +0 -3
  55. package/dist/commands/help.d.ts.map +0 -1
  56. package/dist/commands/help.js +0 -20
  57. package/dist/commands/index.d.ts +0 -3
  58. package/dist/commands/index.d.ts.map +0 -1
  59. package/dist/commands/index.js +0 -26
  60. package/dist/commands/login.d.ts +0 -3
  61. package/dist/commands/login.d.ts.map +0 -1
  62. package/dist/commands/login.js +0 -175
  63. package/dist/commands/project.d.ts +0 -3
  64. package/dist/commands/project.d.ts.map +0 -1
  65. package/dist/commands/project.js +0 -78
  66. package/dist/commands/store-version.d.ts +0 -3
  67. package/dist/commands/store-version.d.ts.map +0 -1
  68. package/dist/commands/store-version.js +0 -241
  69. package/dist/commands/version.d.ts +0 -3
  70. package/dist/commands/version.d.ts.map +0 -1
  71. package/dist/commands/version.js +0 -46
  72. package/dist/commands/whoami.d.ts +0 -3
  73. package/dist/commands/whoami.d.ts.map +0 -1
  74. package/dist/commands/whoami.js +0 -41
  75. package/dist/index.d.ts.map +0 -1
  76. package/dist/prompts/component.prompts.d.ts +0 -14
  77. package/dist/prompts/component.prompts.d.ts.map +0 -1
  78. package/dist/prompts/component.prompts.js +0 -75
  79. package/dist/prompts/function.prompts.d.ts +0 -21
  80. package/dist/prompts/function.prompts.d.ts.map +0 -1
  81. package/dist/prompts/function.prompts.js +0 -127
  82. package/dist/schemas/command.schema.d.ts +0 -516
  83. package/dist/schemas/command.schema.d.ts.map +0 -1
  84. package/dist/schemas/command.schema.js +0 -267
  85. package/dist/types/index.d.ts +0 -147
  86. package/dist/types/index.d.ts.map +0 -1
  87. package/dist/types/index.js +0 -18
  88. package/dist/utils/auth.d.ts +0 -4
  89. package/dist/utils/auth.d.ts.map +0 -1
  90. package/dist/utils/auth.js +0 -26
  91. package/dist/utils/cli-progress-reporter.d.ts +0 -12
  92. package/dist/utils/cli-progress-reporter.d.ts.map +0 -1
  93. package/dist/utils/cli-progress-reporter.js +0 -77
  94. package/dist/utils/command-builder.d.ts +0 -22
  95. package/dist/utils/command-builder.d.ts.map +0 -1
  96. package/dist/utils/command-builder.js +0 -268
  97. package/dist/utils/command-helpers.d.ts +0 -19
  98. package/dist/utils/command-helpers.d.ts.map +0 -1
  99. package/dist/utils/command-helpers.js +0 -79
  100. package/dist/utils/command-parser.d.ts +0 -146
  101. package/dist/utils/command-parser.d.ts.map +0 -1
  102. package/dist/utils/command-parser.js +0 -179
  103. package/dist/utils/command-suggestions.d.ts +0 -35
  104. package/dist/utils/command-suggestions.d.ts.map +0 -1
  105. package/dist/utils/command-suggestions.js +0 -152
  106. package/dist/utils/console.d.ts +0 -44
  107. package/dist/utils/console.d.ts.map +0 -1
  108. package/dist/utils/console.js +0 -233
  109. package/dist/utils/constants.d.ts +0 -8
  110. package/dist/utils/constants.d.ts.map +0 -1
  111. package/dist/utils/constants.js +0 -10
  112. package/dist/utils/context-detector.d.ts +0 -12
  113. package/dist/utils/context-detector.d.ts.map +0 -1
  114. package/dist/utils/context-detector.js +0 -155
  115. package/dist/utils/enhanced-error-handler.d.ts +0 -47
  116. package/dist/utils/enhanced-error-handler.d.ts.map +0 -1
  117. package/dist/utils/enhanced-error-handler.js +0 -221
  118. package/dist/utils/error-handler.d.ts +0 -3
  119. package/dist/utils/error-handler.d.ts.map +0 -1
  120. package/dist/utils/error-handler.js +0 -55
  121. package/dist/utils/errors.d.ts +0 -44
  122. package/dist/utils/errors.d.ts.map +0 -1
  123. package/dist/utils/errors.js +0 -76
  124. package/dist/utils/interactive-builder.d.ts +0 -22
  125. package/dist/utils/interactive-builder.d.ts.map +0 -1
  126. package/dist/utils/interactive-builder.js +0 -246
  127. package/dist/utils/rich-progress.d.ts +0 -59
  128. package/dist/utils/rich-progress.d.ts.map +0 -1
  129. package/dist/utils/rich-progress.js +0 -234
  130. package/dist/utils/store.d.ts +0 -11
  131. package/dist/utils/store.d.ts.map +0 -1
  132. package/dist/utils/store.js +0 -19
  133. package/dist/utils/validation-error-formatter.d.ts +0 -25
  134. package/dist/utils/validation-error-formatter.d.ts.map +0 -1
  135. package/dist/utils/validation-error-formatter.js +0 -258
  136. package/dist/utils/validation-helpers.d.ts +0 -60
  137. package/dist/utils/validation-helpers.d.ts.map +0 -1
  138. package/dist/utils/validation-helpers.js +0 -152
  139. package/src/commands/__tests__/version.test.ts +0 -71
@@ -1,12 +0,0 @@
1
- export interface ProjectContext {
2
- type: "component" | "function" | "unknown";
3
- path: string;
4
- name?: string;
5
- parentPath?: string;
6
- }
7
- export declare function detectProjectContext(cwd?: string): ProjectContext;
8
- /**
9
- * Get the appropriate path for a command based on context
10
- */
11
- export declare function getContextualPath(explicitPath: string | undefined, expectedType: "component" | "function"): string;
12
- //# sourceMappingURL=context-detector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"context-detector.d.ts","sourceRoot":"","sources":["../../src/utils/context-detector.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA0FD,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAsB,GAC1B,cAAc,CAoChB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,YAAY,EAAE,WAAW,GAAG,UAAU,GACrC,MAAM,CAgCR"}
@@ -1,155 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.detectProjectContext = detectProjectContext;
37
- exports.getContextualPath = getContextualPath;
38
- const fs = __importStar(require("node:fs"));
39
- const path = __importStar(require("node:path"));
40
- /**
41
- * Detect if we're in a component or function directory
42
- * by looking for characteristic files
43
- */
44
- function checkForMetaType(cwd, hasComponentIndex, hasFunctionIndex) {
45
- try {
46
- const metaContent = fs.readFileSync(path.join(cwd, "meta.json"), "utf-8");
47
- const meta = JSON.parse(metaContent);
48
- const name = meta.name || path.basename(cwd);
49
- if (meta.type === "component" || hasComponentIndex) {
50
- return { type: "component", path: cwd, name };
51
- }
52
- if (meta.type === "function" || hasFunctionIndex) {
53
- return { type: "function", path: cwd, name };
54
- }
55
- }
56
- catch (_error) {
57
- // If meta.json is invalid, return null to fall back
58
- }
59
- return null;
60
- }
61
- function checkByFilePresence(cwd, hasComponentIndex, hasFunctionIndex) {
62
- const name = path.basename(cwd);
63
- if (hasComponentIndex) {
64
- return { type: "component", path: cwd, name };
65
- }
66
- if (hasFunctionIndex) {
67
- return { type: "function", path: cwd, name };
68
- }
69
- return null;
70
- }
71
- function checkParentDirectory(cwd) {
72
- const componentsDir = path.join(cwd, "components");
73
- const functionsDir = path.join(cwd, "functions");
74
- if (fs.existsSync(componentsDir) &&
75
- fs.statSync(componentsDir).isDirectory()) {
76
- return { type: "unknown", path: cwd, parentPath: cwd };
77
- }
78
- if (fs.existsSync(functionsDir) && fs.statSync(functionsDir).isDirectory()) {
79
- return { type: "unknown", path: cwd, parentPath: cwd };
80
- }
81
- return null;
82
- }
83
- function checkInsideSubdirectory(cwd) {
84
- const pathParts = cwd.split(path.sep);
85
- const componentsIndex = pathParts.lastIndexOf("components");
86
- const functionsIndex = pathParts.lastIndexOf("functions");
87
- if (componentsIndex !== -1 && componentsIndex === pathParts.length - 2) {
88
- return {
89
- type: "component",
90
- path: cwd,
91
- name: pathParts[componentsIndex + 1],
92
- };
93
- }
94
- if (functionsIndex !== -1 && functionsIndex === pathParts.length - 2) {
95
- return {
96
- type: "function",
97
- path: cwd,
98
- name: pathParts[functionsIndex + 1],
99
- };
100
- }
101
- return null;
102
- }
103
- function detectProjectContext(cwd = process.cwd()) {
104
- const hasPackageJson = fs.existsSync(path.join(cwd, "package.json"));
105
- const hasMetaJson = fs.existsSync(path.join(cwd, "meta.json"));
106
- const hasComponentIndex = fs.existsSync(path.join(cwd, "index.tsx")) ||
107
- fs.existsSync(path.join(cwd, "index.jsx"));
108
- const hasFunctionIndex = fs.existsSync(path.join(cwd, "index.ts")) ||
109
- fs.existsSync(path.join(cwd, "index.js"));
110
- // If we have the basic files, determine the type
111
- if (hasPackageJson && hasMetaJson) {
112
- const metaResult = checkForMetaType(cwd, hasComponentIndex, hasFunctionIndex);
113
- if (metaResult)
114
- return metaResult;
115
- const fileResult = checkByFilePresence(cwd, hasComponentIndex, hasFunctionIndex);
116
- if (fileResult)
117
- return fileResult;
118
- }
119
- // Check parent directory
120
- const parentResult = checkParentDirectory(cwd);
121
- if (parentResult)
122
- return parentResult;
123
- // Check if inside subdirectory
124
- const subdirResult = checkInsideSubdirectory(cwd);
125
- if (subdirResult)
126
- return subdirResult;
127
- return { type: "unknown", path: cwd };
128
- }
129
- /**
130
- * Get the appropriate path for a command based on context
131
- */
132
- function getContextualPath(explicitPath, expectedType) {
133
- // If explicit path provided, use it
134
- if (explicitPath) {
135
- return explicitPath;
136
- }
137
- // Detect current context
138
- const context = detectProjectContext();
139
- // If we're in the right type of directory, use current directory
140
- if (context.type === expectedType) {
141
- return context.path;
142
- }
143
- // If we're in a parent directory, provide helpful error
144
- if (context.type === "unknown" && context.parentPath) {
145
- const subdir = expectedType === "component" ? "components" : "functions";
146
- throw new Error(`No ${expectedType} found in current directory.\nTry navigating to a ${expectedType} directory:\n cd ${subdir}/<${expectedType}-name>\nOr specify the path:\n --path ./${subdir}/<${expectedType}-name>`);
147
- }
148
- // Wrong context type
149
- if (context.type !== "unknown" && context.type !== expectedType) {
150
- throw new Error(`Current directory appears to be a ${context.type}, not a ${expectedType}.\n` +
151
- `Please navigate to a ${expectedType} directory or specify --path`);
152
- }
153
- // Default to current directory
154
- return process.cwd();
155
- }
@@ -1,47 +0,0 @@
1
- import type { ErrorContext } from "../types";
2
- import type { CliConsole } from "./console.js";
3
- export declare class EnhancedErrorHandler {
4
- private console;
5
- constructor(console: CliConsole);
6
- /**
7
- * Common error patterns with recovery suggestions
8
- */
9
- private readonly errorPatterns;
10
- /**
11
- * Handle errors with enhanced recovery suggestions
12
- */
13
- handle(error: Error, context?: ErrorContext): void;
14
- /**
15
- * Get recovery suggestions based on error
16
- */
17
- private getRecoverySuggestions;
18
- /**
19
- * Display recovery suggestions
20
- */
21
- private displayRecoverySuggestions;
22
- /**
23
- * Display contextual information
24
- */
25
- private displayContextualInfo;
26
- /**
27
- * Format suggestion with context values
28
- */
29
- private formatSuggestion;
30
- /**
31
- * Check if this is a command-related error
32
- */
33
- private isCommandError;
34
- /**
35
- * Suggest similar commands
36
- */
37
- private suggestSimilarCommands;
38
- /**
39
- * Find similar commands using basic string matching
40
- */
41
- private findSimilarCommands;
42
- }
43
- /**
44
- * Create an error with additional context
45
- */
46
- export declare function createContextualError(message: string, code?: string, context?: Record<string, unknown>): Error;
47
- //# sourceMappingURL=enhanced-error-handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"enhanced-error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/enhanced-error-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAS/C,qBAAa,oBAAoB;IACnB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,UAAU;IAEvC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAyD3B;IAEH;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;IAoBlD;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAgB9B;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAqBlC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAQtB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAkC5B;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,KAAK,CAUP"}
@@ -1,221 +0,0 @@
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.EnhancedErrorHandler = void 0;
7
- exports.createContextualError = createContextualError;
8
- const chalk_1 = __importDefault(require("chalk"));
9
- const types_1 = require("../types");
10
- const context_detector_js_1 = require("./context-detector.js");
11
- class EnhancedErrorHandler {
12
- constructor(console) {
13
- this.console = console;
14
- /**
15
- * Common error patterns with recovery suggestions
16
- */
17
- this.errorPatterns = new Map([
18
- [
19
- "ENOENT",
20
- {
21
- message: "File or directory not found",
22
- suggestions: [
23
- "Check if the path exists",
24
- "Use --path to specify the correct location",
25
- ],
26
- commands: ["ls", "pwd"],
27
- },
28
- ],
29
- [
30
- "EACCES",
31
- {
32
- message: "Permission denied",
33
- suggestions: [
34
- "Check file permissions",
35
- "Try running with appropriate permissions",
36
- ],
37
- commands: ["ls -la"],
38
- },
39
- ],
40
- [
41
- "ECONNREFUSED",
42
- {
43
- message: "Connection refused",
44
- suggestions: [
45
- "Check your internet connection",
46
- "Verify your authentication",
47
- "Check if backend services are running",
48
- ],
49
- commands: ["ollieshop login", "ollieshop status"],
50
- },
51
- ],
52
- [
53
- /Component .* already exists/,
54
- {
55
- message: "Component already exists",
56
- suggestions: [
57
- "Use a different name",
58
- "Delete the existing component first",
59
- "Update the existing component instead",
60
- ],
61
- commands: ["ollieshop component list", "rm -rf ./components/{name}"],
62
- },
63
- ],
64
- [
65
- /Invalid component name/,
66
- {
67
- message: "Component name validation failed",
68
- suggestions: [
69
- "Use lowercase letters and hyphens only",
70
- "Examples: header-nav, shopping-cart, product-list",
71
- ],
72
- },
73
- ],
74
- ]);
75
- }
76
- /**
77
- * Handle errors with enhanced recovery suggestions
78
- */
79
- handle(error, context) {
80
- // Display the main error
81
- this.console.error(`\n❌ ${error.message}\n`);
82
- // Get recovery suggestions
83
- const recovery = this.getRecoverySuggestions(error);
84
- if (recovery) {
85
- this.displayRecoverySuggestions(recovery, context);
86
- }
87
- // Show contextual information
88
- this.displayContextualInfo(error, context);
89
- // Suggest similar commands if applicable
90
- if (this.isCommandError(error)) {
91
- this.suggestSimilarCommands(context);
92
- }
93
- }
94
- /**
95
- * Get recovery suggestions based on error
96
- */
97
- getRecoverySuggestions(error) {
98
- // Check error code
99
- if ((0, types_1.isNodeError)(error) && this.errorPatterns.has(error.code)) {
100
- return this.errorPatterns.get(error.code);
101
- }
102
- // Check error message patterns
103
- for (const [pattern, recovery] of this.errorPatterns) {
104
- if (pattern instanceof RegExp && pattern.test(error.message)) {
105
- return recovery;
106
- }
107
- }
108
- return undefined;
109
- }
110
- /**
111
- * Display recovery suggestions
112
- */
113
- displayRecoverySuggestions(recovery, context) {
114
- this.console.warn("💡 Possible solutions:\n");
115
- for (const [index, suggestion] of recovery.suggestions.entries()) {
116
- // Replace placeholders in suggestions
117
- const formatted = this.formatSuggestion(suggestion, context);
118
- this.console.log(chalk_1.default.yellow(` ${index + 1}. ${formatted}`));
119
- }
120
- if (recovery.commands && recovery.commands.length > 0) {
121
- this.console.log(chalk_1.default.dim("\n📍 Helpful commands:"));
122
- for (const cmd of recovery.commands) {
123
- const formatted = this.formatSuggestion(cmd, context);
124
- this.console.log(chalk_1.default.dim(` $ ${formatted}`));
125
- }
126
- }
127
- }
128
- /**
129
- * Display contextual information
130
- */
131
- displayContextualInfo(_error, context) {
132
- const projectContext = (0, context_detector_js_1.detectProjectContext)();
133
- this.console.log(chalk_1.default.dim("\n📍 Context:"));
134
- this.console.log(chalk_1.default.dim(` Current directory: ${process.cwd()}`));
135
- if (projectContext.type !== "unknown") {
136
- this.console.log(chalk_1.default.dim(` Project type: ${projectContext.type}`));
137
- if (projectContext.name) {
138
- this.console.log(chalk_1.default.dim(` ${projectContext.type} name: ${projectContext.name}`));
139
- }
140
- }
141
- if (context?.path) {
142
- this.console.log(chalk_1.default.dim(` Target path: ${context.path}`));
143
- }
144
- }
145
- /**
146
- * Format suggestion with context values
147
- */
148
- formatSuggestion(suggestion, context) {
149
- if (!context)
150
- return suggestion;
151
- return suggestion.replace(/{(\w+)}/g, (match, key) => {
152
- const value = context[key];
153
- return typeof value === "string" ? value : match;
154
- });
155
- }
156
- /**
157
- * Check if this is a command-related error
158
- */
159
- isCommandError(error) {
160
- return (error.message.includes("Unknown command") ||
161
- error.message.includes("not found") ||
162
- ((0, types_1.isNodeError)(error) && error.code === "COMMAND_NOT_FOUND"));
163
- }
164
- /**
165
- * Suggest similar commands
166
- */
167
- suggestSimilarCommands(context) {
168
- if (!context?.attemptedCommand)
169
- return;
170
- const suggestions = this.findSimilarCommands(String(context.attemptedCommand));
171
- if (suggestions.length > 0) {
172
- this.console.log(chalk_1.default.dim("\n💡 Did you mean:"));
173
- for (const cmd of suggestions) {
174
- this.console.log(chalk_1.default.dim(` $ ollieshop ${cmd}`));
175
- }
176
- }
177
- }
178
- /**
179
- * Find similar commands using basic string matching
180
- */
181
- findSimilarCommands(attempted) {
182
- const commands = [
183
- "component create",
184
- "component validate",
185
- "component build",
186
- "component deploy",
187
- "component list",
188
- "function create",
189
- "function validate",
190
- "function build",
191
- "function test",
192
- "function deploy",
193
- "store-version create",
194
- "store-version list",
195
- "template list",
196
- "login",
197
- "whoami",
198
- ];
199
- return commands
200
- .filter((cmd) => {
201
- // Simple similarity check
202
- const cmdParts = cmd.toLowerCase().split(" ");
203
- const attemptedParts = attempted.toLowerCase().split(" ");
204
- // Check if any part matches
205
- return cmdParts.some((part) => attemptedParts.some((aPart) => part.startsWith(aPart) || aPart.startsWith(part)));
206
- })
207
- .slice(0, 3); // Show top 3 suggestions
208
- }
209
- }
210
- exports.EnhancedErrorHandler = EnhancedErrorHandler;
211
- /**
212
- * Create an error with additional context
213
- */
214
- function createContextualError(message, code, context) {
215
- const error = new Error(message);
216
- if (code)
217
- error.code = code;
218
- if (context)
219
- error.context = context;
220
- return error;
221
- }
@@ -1,3 +0,0 @@
1
- import type { ErrorContext } from "../types";
2
- export declare function handleError(error: unknown, context?: ErrorContext): never;
3
- //# sourceMappingURL=error-handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AA+C7C,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAYzE"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleError = handleError;
4
- const console_1 = require("./console");
5
- const enhanced_error_handler_js_1 = require("./enhanced-error-handler.js");
6
- const errors_1 = require("./errors");
7
- function handleOllieShopError(error) {
8
- console_1.console.error(`\n${error.message}`);
9
- if (error.details) {
10
- displayErrorDetails(error.details);
11
- }
12
- if (error.suggestions && error.suggestions.length > 0) {
13
- displayRecoveryActions(error.suggestions);
14
- }
15
- }
16
- function displayErrorDetails(details) {
17
- console_1.console.dim("\nContext:");
18
- for (const [key, value] of Object.entries(details)) {
19
- if (key === "fields" && Array.isArray(value)) {
20
- displayFieldErrors(value);
21
- }
22
- else {
23
- console_1.console.dim(` ${key}: ${value}`);
24
- }
25
- }
26
- }
27
- function displayFieldErrors(fields) {
28
- console_1.console.dim(" fields:");
29
- for (const field of fields) {
30
- console_1.console.dim(` ${field.field}: ${field.message}`);
31
- }
32
- }
33
- function displayRecoveryActions(actions) {
34
- console_1.console.info("\nSuggestions:");
35
- for (const action of actions) {
36
- console_1.console.dim(` • ${action.description}`);
37
- if (action.command) {
38
- console_1.console.dim(` $ ${action.command}`);
39
- }
40
- }
41
- }
42
- function handleError(error, context) {
43
- if (error instanceof errors_1.OllieShopCLIError) {
44
- handleOllieShopError(error);
45
- }
46
- else if (error instanceof Error) {
47
- const enhancedHandler = new enhanced_error_handler_js_1.EnhancedErrorHandler(console_1.console);
48
- enhancedHandler.handle(error, context);
49
- }
50
- else {
51
- console_1.console.error("\nAn unexpected error occurred");
52
- console_1.console.dim(String(error));
53
- }
54
- process.exit(1);
55
- }
@@ -1,44 +0,0 @@
1
- import type { ZodError } from "zod";
2
- import type { ErrorContext } from "../types";
3
- export interface RecoveryAction {
4
- description: string;
5
- command?: string;
6
- }
7
- export declare class OllieShopCLIError extends Error {
8
- readonly context: ErrorContext;
9
- readonly recoveryActions: RecoveryAction[];
10
- constructor(message: string, context?: ErrorContext, recoveryActions?: RecoveryAction[]);
11
- get details(): ErrorContext;
12
- get suggestions(): RecoveryAction[];
13
- static fromZodError(error: ZodError, context?: ErrorContext): OllieShopCLIError;
14
- static fromUnknown(error: unknown, context?: ErrorContext): OllieShopCLIError;
15
- static fileNotFound(path: string, context?: ErrorContext): OllieShopCLIError;
16
- }
17
- export declare const CLIError: typeof OllieShopCLIError;
18
- /**
19
- * Command execution error
20
- */
21
- export declare class CommandError extends OllieShopCLIError {
22
- readonly code: string;
23
- constructor(message: string, code: string, context?: ErrorContext);
24
- }
25
- /**
26
- * Validation error with detailed field information
27
- */
28
- export declare class ValidationError extends OllieShopCLIError {
29
- readonly fields: Array<{
30
- field: string;
31
- message: string;
32
- }>;
33
- constructor(message: string, fields?: Array<{
34
- field: string;
35
- message: string;
36
- }>, context?: ErrorContext);
37
- get details(): ErrorContext & {
38
- fields: Array<{
39
- field: string;
40
- message: string;
41
- }>;
42
- };
43
- }
44
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,OAAO,EAAE,YAAY,CAAC;IACtC,SAAgB,eAAe,EAAE,cAAc,EAAE,CAAC;gBAGhD,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,YAAiB,EAC1B,eAAe,GAAE,cAAc,EAAO;IAQxC,IAAI,OAAO,IAAI,YAAY,CAE1B;IAED,IAAI,WAAW,IAAI,cAAc,EAAE,CAElC;IAED,MAAM,CAAC,YAAY,CACjB,KAAK,EAAE,QAAQ,EACf,OAAO,GAAE,YAAiB,GACzB,iBAAiB;IAgBpB,MAAM,CAAC,WAAW,CAChB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,YAAiB,GACzB,iBAAiB;IAiBpB,MAAM,CAAC,YAAY,CACjB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,YAAiB,GACzB,iBAAiB;CAUrB;AAED,eAAO,MAAM,QAAQ,0BAAoB,CAAC;AAE1C;;GAEG;AACH,qBAAa,YAAa,SAAQ,iBAAiB;IACjD,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAKtE;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,iBAAiB;IACpD,SAAgB,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;gBAGhE,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAM,EACtD,OAAO,GAAE,YAAiB;IAO5B,IAAI,OAAO,IAAI,YAAY,GAAG;QAC5B,MAAM,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;KACnD,CAKA;CACF"}
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationError = exports.CommandError = exports.CLIError = exports.OllieShopCLIError = void 0;
4
- class OllieShopCLIError extends Error {
5
- constructor(message, context = {}, recoveryActions = []) {
6
- super(message);
7
- this.name = "OllieShopCLIError";
8
- this.context = context;
9
- this.recoveryActions = recoveryActions;
10
- }
11
- get details() {
12
- return this.context;
13
- }
14
- get suggestions() {
15
- return this.recoveryActions;
16
- }
17
- static fromZodError(error, context = {}) {
18
- const firstIssue = error.issues[0];
19
- if (!firstIssue) {
20
- return new OllieShopCLIError("Validation failed", context);
21
- }
22
- const message = error.issues.length > 1
23
- ? `${firstIssue.message} (and ${error.issues.length - 1} more error${error.issues.length === 2 ? "" : "s"})`
24
- : firstIssue.message;
25
- return new OllieShopCLIError(message, context, [
26
- { description: "Check the command documentation for valid formats" },
27
- ]);
28
- }
29
- static fromUnknown(error, context = {}) {
30
- if (error instanceof OllieShopCLIError) {
31
- return error;
32
- }
33
- if (error instanceof Error) {
34
- return new OllieShopCLIError(error.message, context, [
35
- { description: "Check the command syntax and try again" },
36
- ]);
37
- }
38
- return new OllieShopCLIError(String(error) || "Unknown error occurred", context);
39
- }
40
- static fileNotFound(path, context = {}) {
41
- return new OllieShopCLIError(`File not found: ${path}`, { ...context, file: path }, [
42
- { description: "Check if the file path is correct" },
43
- { description: "Ensure the file exists in the specified location" },
44
- ]);
45
- }
46
- }
47
- exports.OllieShopCLIError = OllieShopCLIError;
48
- exports.CLIError = OllieShopCLIError;
49
- /**
50
- * Command execution error
51
- */
52
- class CommandError extends OllieShopCLIError {
53
- constructor(message, code, context = {}) {
54
- super(message, context);
55
- this.name = "CommandError";
56
- this.code = code;
57
- }
58
- }
59
- exports.CommandError = CommandError;
60
- /**
61
- * Validation error with detailed field information
62
- */
63
- class ValidationError extends OllieShopCLIError {
64
- constructor(message, fields = [], context = {}) {
65
- super(message, context);
66
- this.name = "ValidationError";
67
- this.fields = fields;
68
- }
69
- get details() {
70
- return {
71
- ...this.context,
72
- fields: this.fields,
73
- };
74
- }
75
- }
76
- exports.ValidationError = ValidationError;
@@ -1,22 +0,0 @@
1
- import type { CliConsole } from "./console.js";
2
- export declare class InteractiveCommandBuilder {
3
- private console;
4
- constructor(console: CliConsole);
5
- /**
6
- * Build component deploy command interactively
7
- */
8
- buildDeployComponentCommand(): Promise<void>;
9
- /**
10
- * Build component create command interactively
11
- */
12
- buildCreateComponentCommand(): Promise<void>;
13
- /**
14
- * Get available components (mock for now)
15
- */
16
- private getAvailableComponents;
17
- }
18
- /**
19
- * Create an interactive command builder
20
- */
21
- export declare function runInteractiveCommand(command: string, console: CliConsole): Promise<void>;
22
- //# sourceMappingURL=interactive-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interactive-builder.d.ts","sourceRoot":"","sources":["../../src/utils/interactive-builder.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,qBAAa,yBAAyB;IACxB,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,UAAU;IAEvC;;OAEG;IACG,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAsFlD;;OAEG;IACG,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IA2GlD;;OAEG;YACW,sBAAsB;CAmCrC;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAef"}