@ollie-shop/cli 0.1.3 → 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 (181) hide show
  1. package/.turbo/turbo-build.log +2 -11
  2. package/CHANGELOG.md +17 -5
  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 +93 -226
  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 +44 -9
  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 +24 -0
  140. package/src/commands/function.ts +252 -0
  141. package/src/commands/help.ts +18 -0
  142. package/src/commands/index.ts +21 -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 +51 -0
  147. package/src/commands/whoami.ts +46 -0
  148. package/src/index.ts +110 -15
  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 +41 -0
  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/store.ts +23 -0
  176. package/src/utils/validation-error-formatter.ts +337 -0
  177. package/src/utils/validation-helpers.ts +192 -0
  178. package/tsconfig.json +13 -7
  179. package/vitest.config.ts +28 -0
  180. package/vitest.setup.ts +29 -0
  181. package/tsup.config.ts +0 -15
@@ -0,0 +1,241 @@
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.registerStoreVersionCommands = registerStoreVersionCommands;
37
+ const zod_1 = require("zod");
38
+ const versionActions = __importStar(require("../actions/version.actions"));
39
+ const command_builder_1 = require("../utils/command-builder");
40
+ const command_parser_1 = require("../utils/command-parser");
41
+ const console_1 = require("../utils/console");
42
+ const StoreVersionCreateOptionsSchema = zod_1.z.object({
43
+ store: zod_1.z.string().uuid("Invalid store ID format"),
44
+ name: zod_1.z.string().min(1, "Version name is required"),
45
+ template: zod_1.z.string().optional(),
46
+ active: zod_1.z.boolean().optional(),
47
+ });
48
+ const StoreVersionListOptionsSchema = zod_1.z.object({
49
+ store: zod_1.z.string().uuid("Invalid store ID format"),
50
+ });
51
+ function registerStoreVersionCommands(program) {
52
+ const cmd = (0, command_builder_1.buildCommandGroup)(program, "store-version", "Manage store versions", ["sv"]);
53
+ // Create version command
54
+ (0, command_builder_1.buildCommand)(cmd, {
55
+ name: "create",
56
+ description: "Create a new version for a store",
57
+ options: [
58
+ command_parser_1.COMMON_OPTIONS.storeId,
59
+ command_parser_1.COMMON_OPTIONS.versionName,
60
+ command_parser_1.COMMON_OPTIONS.template,
61
+ command_parser_1.COMMON_OPTIONS.active,
62
+ command_parser_1.COMMON_OPTIONS.noActive,
63
+ ],
64
+ schema: StoreVersionCreateOptionsSchema,
65
+ examples: [
66
+ {
67
+ description: "Create an active version",
68
+ command: "ollieshop store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name v2.0.0",
69
+ },
70
+ {
71
+ description: "Create version with grocery template",
72
+ command: "ollieshop store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name grocery-v1 --template grocery",
73
+ },
74
+ {
75
+ description: "Create inactive version for testing",
76
+ command: "ollieshop store-version create --store 123e4567-e89b-12d3-a456-426614174000 --name test-version --no-active",
77
+ },
78
+ ],
79
+ handler: async (options) => {
80
+ await versionActions.create(options);
81
+ },
82
+ });
83
+ // List versions command
84
+ (0, command_builder_1.buildCommand)(cmd, {
85
+ name: "list",
86
+ description: "List all versions for a store",
87
+ options: [command_parser_1.COMMON_OPTIONS.storeId],
88
+ schema: StoreVersionListOptionsSchema,
89
+ examples: [
90
+ {
91
+ description: "List all versions for a store",
92
+ command: "ollieshop store-version list --store 123e4567-e89b-12d3-a456-426614174000",
93
+ },
94
+ ],
95
+ handler: async (options) => {
96
+ await versionActions.list(options);
97
+ },
98
+ });
99
+ // Get version command with argument parser
100
+ const _getCmd = cmd
101
+ .command("get <versionId>")
102
+ .description("Get version details")
103
+ .addHelpText("after", "\nExamples:")
104
+ .addHelpText("after", " Get version details:")
105
+ .addHelpText("after", " $ ollieshop store-version get 987fcdeb-51a2-43b7-9abc-123456789012")
106
+ .action(async (versionId) => {
107
+ try {
108
+ const validated = (0, command_parser_1.parseUUID)(versionId);
109
+ await versionActions.get(validated);
110
+ }
111
+ catch (error) {
112
+ if (error instanceof Error) {
113
+ console_1.console.error(`❌ ${error.message}`);
114
+ if (error.message.includes("UUID")) {
115
+ console_1.console.info("💡 Version IDs must be in UUID format");
116
+ console_1.console.log(" Example: 123e4567-e89b-12d3-a456-426614174000");
117
+ }
118
+ }
119
+ else {
120
+ console_1.console.error(`Error: ${String(error)}`);
121
+ }
122
+ process.exit(1);
123
+ }
124
+ });
125
+ // Set default version command
126
+ const _setDefaultCmd = cmd
127
+ .command("set-default <versionId>")
128
+ .description("Set a version as the default for the store")
129
+ .addHelpText("after", "\nExamples:")
130
+ .addHelpText("after", " Set version as default:")
131
+ .addHelpText("after", " $ ollieshop store-version set-default 987fcdeb-51a2-43b7-9abc-123456789012")
132
+ .action(async (versionId) => {
133
+ try {
134
+ const validated = (0, command_parser_1.parseUUID)(versionId);
135
+ await versionActions.setDefault(validated);
136
+ }
137
+ catch (error) {
138
+ if (error instanceof Error) {
139
+ console_1.console.error(`❌ ${error.message}`);
140
+ }
141
+ else {
142
+ console_1.console.error(`Error: ${String(error)}`);
143
+ }
144
+ process.exit(1);
145
+ }
146
+ });
147
+ // Activate version command
148
+ const _activateCmd = cmd
149
+ .command("activate <versionId>")
150
+ .description("Activate a version")
151
+ .addHelpText("after", "\nExamples:")
152
+ .addHelpText("after", " Activate a version:")
153
+ .addHelpText("after", " $ ollieshop store-version activate 987fcdeb-51a2-43b7-9abc-123456789012")
154
+ .action(async (versionId) => {
155
+ try {
156
+ const validated = (0, command_parser_1.parseUUID)(versionId);
157
+ await versionActions.activate(validated);
158
+ }
159
+ catch (error) {
160
+ if (error instanceof Error) {
161
+ console_1.console.error(`❌ ${error.message}`);
162
+ }
163
+ else {
164
+ console_1.console.error(`Error: ${String(error)}`);
165
+ }
166
+ process.exit(1);
167
+ }
168
+ });
169
+ // Deactivate version command
170
+ const _deactivateCmd = cmd
171
+ .command("deactivate <versionId>")
172
+ .description("Deactivate a version")
173
+ .addHelpText("after", "\nExamples:")
174
+ .addHelpText("after", " Deactivate a version:")
175
+ .addHelpText("after", " $ ollieshop store-version deactivate 987fcdeb-51a2-43b7-9abc-123456789012")
176
+ .action(async (versionId) => {
177
+ try {
178
+ const validated = (0, command_parser_1.parseUUID)(versionId);
179
+ await versionActions.deactivate(validated);
180
+ }
181
+ catch (error) {
182
+ if (error instanceof Error) {
183
+ console_1.console.error(`❌ ${error.message}`);
184
+ }
185
+ else {
186
+ console_1.console.error(`Error: ${String(error)}`);
187
+ }
188
+ process.exit(1);
189
+ }
190
+ });
191
+ // Clone version command
192
+ const _cloneCmd = cmd
193
+ .command("clone <versionId>")
194
+ .description("Clone an existing version")
195
+ .requiredOption("-n, --name <name>", "Name for the cloned version", command_parser_1.COMMON_OPTIONS.versionName.parser)
196
+ .addHelpText("after", "\nExamples:")
197
+ .addHelpText("after", " Clone a version:")
198
+ .addHelpText("after", " $ ollieshop store-version clone 987fcdeb-51a2-43b7-9abc-123456789012 --name v2.1.0")
199
+ .addHelpText("after", "\n Clone for A/B testing:")
200
+ .addHelpText("after", " $ ollieshop store-version clone 987fcdeb-51a2-43b7-9abc-123456789012 --name experiment-checkout")
201
+ .action(async (versionId, options) => {
202
+ try {
203
+ const validatedId = (0, command_parser_1.parseUUID)(versionId);
204
+ await versionActions.clone(validatedId, options.name);
205
+ }
206
+ catch (error) {
207
+ if (error instanceof Error) {
208
+ console_1.console.error(`❌ ${error.message}`);
209
+ }
210
+ else {
211
+ console_1.console.error(`Error: ${String(error)}`);
212
+ }
213
+ process.exit(1);
214
+ }
215
+ });
216
+ // Delete version command
217
+ const _deleteCmd = cmd
218
+ .command("delete <versionId>")
219
+ .description("Delete a version")
220
+ .option("-f, --force", "Skip confirmation")
221
+ .addHelpText("after", "\nExamples:")
222
+ .addHelpText("after", " Delete with confirmation:")
223
+ .addHelpText("after", " $ ollieshop store-version delete 987fcdeb-51a2-43b7-9abc-123456789012")
224
+ .addHelpText("after", "\n Delete without confirmation:")
225
+ .addHelpText("after", " $ ollieshop store-version delete 987fcdeb-51a2-43b7-9abc-123456789012 --force")
226
+ .action(async (versionId, options) => {
227
+ try {
228
+ const validated = (0, command_parser_1.parseUUID)(versionId);
229
+ await versionActions.deleteVersion(validated, options.force);
230
+ }
231
+ catch (error) {
232
+ if (error instanceof Error) {
233
+ console_1.console.error(`❌ ${error.message}`);
234
+ }
235
+ else {
236
+ console_1.console.error(`Error: ${String(error)}`);
237
+ }
238
+ process.exit(1);
239
+ }
240
+ });
241
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from "@commander-js/extra-typings";
2
+ export declare function configureVersionCommand(program: Command): void;
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAK3D,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6C9D"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureVersionCommand = configureVersionCommand;
4
+ const console_1 = require("../utils/console");
5
+ const pkg = require("../../package.json");
6
+ function configureVersionCommand(program) {
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
+ console_1.console.info(`Ollie Shop CLI version: ${pkg.version}`);
26
+ if (options.detailed) {
27
+ console_1.console.log("");
28
+ console_1.console.log("Environment:");
29
+ console_1.console.log(` Node.js: ${process.version}`);
30
+ console_1.console.log(` Platform: ${process.platform}`);
31
+ console_1.console.log(` Architecture: ${process.arch}`);
32
+ // Check for core package version
33
+ try {
34
+ const corePkg = require("@ollie-shop/core/package.json");
35
+ console_1.console.log(` Core: v${corePkg.version}`);
36
+ }
37
+ catch {
38
+ // Core package might not be available
39
+ }
40
+ console_1.console.log("");
41
+ console_1.console.log("For help, run: ollieshop --help");
42
+ console_1.console.log("Documentation: https://docs.ollie.shop");
43
+ console_1.console.log("Report issues: https://github.com/ollie-shop/cli/issues");
44
+ }
45
+ });
46
+ }
@@ -0,0 +1,3 @@
1
+ import type { Command } from "@commander-js/extra-typings";
2
+ export declare function configureWhoamiCommand(program: Command): void;
3
+ //# sourceMappingURL=whoami.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAwB3D,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,QAqBtD"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configureWhoamiCommand = configureWhoamiCommand;
4
+ const auth_1 = require("../utils/auth");
5
+ const console_1 = require("../utils/console");
6
+ const store_1 = require("../utils/store");
7
+ async function getUserInfo() {
8
+ try {
9
+ const user = await (0, auth_1.getCurrentUser)();
10
+ const store = await (0, store_1.getOllieConfig)();
11
+ if (!user || !user.email) {
12
+ console_1.console.error("No user authenticated");
13
+ return {};
14
+ }
15
+ return {
16
+ email: user.email,
17
+ store: store ?? undefined,
18
+ };
19
+ }
20
+ catch {
21
+ return {};
22
+ }
23
+ }
24
+ function configureWhoamiCommand(program) {
25
+ program
26
+ .command("whoami")
27
+ .description("Show logged-in user and current store")
28
+ .action(async () => {
29
+ const { email, store } = await getUserInfo();
30
+ if (!email) {
31
+ console_1.console.error("You are not authenticated");
32
+ return;
33
+ }
34
+ console_1.console.newLine();
35
+ console_1.console.info(`You are logged in as: ${email}`);
36
+ if (store) {
37
+ console_1.console.info(`Current store: ${store.platformStoreId ?? "unknown"}`);
38
+ }
39
+ console_1.console.newLine();
40
+ });
41
+ }
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}