opkg 0.9.2 → 0.9.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 (140) hide show
  1. package/package.json +3 -1
  2. package/packages/cli/dist/add-U44SL3OR.js +624 -0
  3. package/packages/cli/dist/add-U44SL3OR.js.map +7 -0
  4. package/packages/cli/dist/chunk-4B5HJLP2.js +48 -0
  5. package/packages/cli/dist/chunk-4B5HJLP2.js.map +7 -0
  6. package/packages/cli/dist/chunk-BROJ6OUT.js +631 -0
  7. package/packages/cli/dist/chunk-BROJ6OUT.js.map +7 -0
  8. package/packages/cli/dist/chunk-CVA64SXK.js +1136 -0
  9. package/packages/cli/dist/chunk-CVA64SXK.js.map +7 -0
  10. package/packages/cli/dist/chunk-D6LEPODL.js +413 -0
  11. package/packages/cli/dist/chunk-D6LEPODL.js.map +7 -0
  12. package/packages/cli/dist/chunk-HTYHJA3B.js +61 -0
  13. package/packages/cli/dist/chunk-HTYHJA3B.js.map +7 -0
  14. package/packages/cli/dist/chunk-KI7FDU3H.js +99 -0
  15. package/packages/cli/dist/chunk-KI7FDU3H.js.map +7 -0
  16. package/packages/cli/dist/chunk-PSQXKAL4.js +371 -0
  17. package/packages/cli/dist/chunk-PSQXKAL4.js.map +7 -0
  18. package/packages/cli/dist/chunk-PUDRKDVZ.js +1419 -0
  19. package/packages/cli/dist/chunk-PUDRKDVZ.js.map +7 -0
  20. package/packages/cli/dist/chunk-U7FW7SXX.js +568 -0
  21. package/packages/cli/dist/chunk-U7FW7SXX.js.map +7 -0
  22. package/packages/cli/dist/configure-3AZUMDJZ.js +107 -0
  23. package/packages/cli/dist/configure-3AZUMDJZ.js.map +7 -0
  24. package/packages/cli/dist/index.js +15 -15
  25. package/packages/cli/dist/install-EZNWMLJR.js +7581 -0
  26. package/packages/cli/dist/install-EZNWMLJR.js.map +7 -0
  27. package/packages/cli/dist/list-XR7RSJFS.js +327 -0
  28. package/packages/cli/dist/list-XR7RSJFS.js.map +7 -0
  29. package/packages/cli/dist/login-NRKHXZKM.js +150 -0
  30. package/packages/cli/dist/login-NRKHXZKM.js.map +7 -0
  31. package/packages/cli/dist/logout-SYHXCVCQ.js +40 -0
  32. package/packages/cli/dist/logout-SYHXCVCQ.js.map +7 -0
  33. package/packages/cli/dist/new-F46OSD72.js +277 -0
  34. package/packages/cli/dist/new-F46OSD72.js.map +7 -0
  35. package/packages/cli/dist/publish-4H43PCSG.js +619 -0
  36. package/packages/cli/dist/publish-4H43PCSG.js.map +7 -0
  37. package/packages/cli/dist/remove-BD52BHR2.js +542 -0
  38. package/packages/cli/dist/remove-BD52BHR2.js.map +7 -0
  39. package/packages/cli/dist/save-N3QWF2WN.js +1728 -0
  40. package/packages/cli/dist/save-N3QWF2WN.js.map +7 -0
  41. package/packages/cli/dist/search-ABROK3UO.js +157 -0
  42. package/packages/cli/dist/search-ABROK3UO.js.map +7 -0
  43. package/packages/cli/dist/set-NGM2FIKF.js +251 -0
  44. package/packages/cli/dist/set-NGM2FIKF.js.map +7 -0
  45. package/packages/cli/dist/uninstall-Q3CP4UN5.js +539 -0
  46. package/packages/cli/dist/uninstall-Q3CP4UN5.js.map +7 -0
  47. package/packages/cli/dist/unpublish-VBTNTMS5.js +245 -0
  48. package/packages/cli/dist/unpublish-VBTNTMS5.js.map +7 -0
  49. package/packages/cli/dist/view-MXRBMXOG.js +488 -0
  50. package/packages/cli/dist/view-MXRBMXOG.js.map +7 -0
  51. package/packages/cli/package.json +2 -0
  52. package/packages/core/dist/core/install/conflicts/file-conflict-resolver.d.ts +5 -4
  53. package/packages/core/dist/core/install/conflicts/file-conflict-resolver.d.ts.map +1 -1
  54. package/packages/core/dist/core/install/conflicts/file-conflict-resolver.js +6 -5
  55. package/packages/core/dist/core/install/conflicts/file-conflict-resolver.js.map +1 -1
  56. package/packages/core/dist/core/install/install-reporting.js +1 -1
  57. package/packages/core/dist/core/install/install-reporting.js.map +1 -1
  58. package/packages/core/dist/core/install/list-handler.d.ts.map +1 -1
  59. package/packages/core/dist/core/install/list-handler.js +7 -0
  60. package/packages/core/dist/core/install/list-handler.js.map +1 -1
  61. package/packages/core/dist/core/install/marketplace-handler.d.ts.map +1 -1
  62. package/packages/core/dist/core/install/marketplace-handler.js.map +1 -1
  63. package/packages/core/dist/core/install/operations/conflict-handler.d.ts +2 -1
  64. package/packages/core/dist/core/install/operations/conflict-handler.d.ts.map +1 -1
  65. package/packages/core/dist/core/install/operations/conflict-handler.js +2 -2
  66. package/packages/core/dist/core/install/operations/conflict-handler.js.map +1 -1
  67. package/packages/core/dist/core/install/orchestrator/orchestrator.d.ts.map +1 -1
  68. package/packages/core/dist/core/install/orchestrator/orchestrator.js +22 -14
  69. package/packages/core/dist/core/install/orchestrator/orchestrator.js.map +1 -1
  70. package/packages/core/dist/core/install/orchestrator/strategies/git-strategy.d.ts +1 -0
  71. package/packages/core/dist/core/install/orchestrator/strategies/git-strategy.d.ts.map +1 -1
  72. package/packages/core/dist/core/install/orchestrator/strategies/git-strategy.js +11 -24
  73. package/packages/core/dist/core/install/orchestrator/strategies/git-strategy.js.map +1 -1
  74. package/packages/core/dist/core/install/orchestrator/strategies/path-strategy.d.ts +2 -0
  75. package/packages/core/dist/core/install/orchestrator/strategies/path-strategy.d.ts.map +1 -1
  76. package/packages/core/dist/core/install/orchestrator/strategies/path-strategy.js +14 -14
  77. package/packages/core/dist/core/install/orchestrator/strategies/path-strategy.js.map +1 -1
  78. package/packages/core/dist/core/install/orchestrator/strategies/registry-strategy.d.ts +7 -0
  79. package/packages/core/dist/core/install/orchestrator/strategies/registry-strategy.d.ts.map +1 -1
  80. package/packages/core/dist/core/install/orchestrator/strategies/registry-strategy.js +28 -0
  81. package/packages/core/dist/core/install/orchestrator/strategies/registry-strategy.js.map +1 -1
  82. package/packages/core/dist/core/install/platform-resolution.d.ts +3 -0
  83. package/packages/core/dist/core/install/platform-resolution.d.ts.map +1 -1
  84. package/packages/core/dist/core/install/platform-resolution.js +5 -2
  85. package/packages/core/dist/core/install/platform-resolution.js.map +1 -1
  86. package/packages/core/dist/core/install/preprocessing/context-population.d.ts +18 -0
  87. package/packages/core/dist/core/install/preprocessing/context-population.d.ts.map +1 -0
  88. package/packages/core/dist/core/install/preprocessing/context-population.js +36 -0
  89. package/packages/core/dist/core/install/preprocessing/context-population.js.map +1 -0
  90. package/packages/core/dist/core/install/preprocessing/convenience-preprocessor.d.ts +23 -0
  91. package/packages/core/dist/core/install/preprocessing/convenience-preprocessor.d.ts.map +1 -1
  92. package/packages/core/dist/core/install/preprocessing/convenience-preprocessor.js +44 -0
  93. package/packages/core/dist/core/install/preprocessing/convenience-preprocessor.js.map +1 -1
  94. package/packages/core/dist/core/install/sources/path-source.d.ts.map +1 -1
  95. package/packages/core/dist/core/install/sources/path-source.js +8 -0
  96. package/packages/core/dist/core/install/sources/path-source.js.map +1 -1
  97. package/packages/core/dist/core/install/unified/context-builders.d.ts +5 -0
  98. package/packages/core/dist/core/install/unified/context-builders.d.ts.map +1 -1
  99. package/packages/core/dist/core/install/unified/context-builders.js +13 -0
  100. package/packages/core/dist/core/install/unified/context-builders.js.map +1 -1
  101. package/packages/core/dist/core/install/unified/context-helpers.d.ts.map +1 -1
  102. package/packages/core/dist/core/install/unified/context-helpers.js +5 -0
  103. package/packages/core/dist/core/install/unified/context-helpers.js.map +1 -1
  104. package/packages/core/dist/core/install/unified/context.d.ts +6 -0
  105. package/packages/core/dist/core/install/unified/context.d.ts.map +1 -1
  106. package/packages/core/dist/core/install/unified/multi-context-pipeline.d.ts.map +1 -1
  107. package/packages/core/dist/core/install/unified/multi-context-pipeline.js +0 -2
  108. package/packages/core/dist/core/install/unified/multi-context-pipeline.js.map +1 -1
  109. package/packages/core/dist/core/install/unified/phases/conflicts.d.ts.map +1 -1
  110. package/packages/core/dist/core/install/unified/phases/conflicts.js +1 -1
  111. package/packages/core/dist/core/install/unified/phases/conflicts.js.map +1 -1
  112. package/packages/core/dist/core/install/unified/phases/execute.d.ts.map +1 -1
  113. package/packages/core/dist/core/install/unified/phases/execute.js +2 -1
  114. package/packages/core/dist/core/install/unified/phases/execute.js.map +1 -1
  115. package/packages/core/dist/core/install/unified/phases/report.js +1 -1
  116. package/packages/core/dist/core/install/unified/phases/report.js.map +1 -1
  117. package/packages/core/dist/core/install/unified/pipeline.d.ts.map +1 -1
  118. package/packages/core/dist/core/install/unified/pipeline.js +5 -2
  119. package/packages/core/dist/core/install/unified/pipeline.js.map +1 -1
  120. package/packages/core/dist/core/ports/resolve.d.ts +0 -13
  121. package/packages/core/dist/core/ports/resolve.d.ts.map +1 -1
  122. package/packages/core/dist/core/ports/resolve.js +0 -28
  123. package/packages/core/dist/core/ports/resolve.js.map +1 -1
  124. package/packages/core/dist/core/remove/removal-confirmation.d.ts +4 -1
  125. package/packages/core/dist/core/remove/removal-confirmation.d.ts.map +1 -1
  126. package/packages/core/dist/core/remove/removal-confirmation.js +5 -4
  127. package/packages/core/dist/core/remove/removal-confirmation.js.map +1 -1
  128. package/packages/core/dist/core/remove/remove-from-source-pipeline.d.ts.map +1 -1
  129. package/packages/core/dist/core/remove/remove-from-source-pipeline.js +1 -10
  130. package/packages/core/dist/core/remove/remove-from-source-pipeline.js.map +1 -1
  131. package/packages/core/dist/core/uninstall/uninstall-executor.js +1 -1
  132. package/packages/core/dist/core/uninstall/uninstall-executor.js.map +1 -1
  133. package/packages/core/dist/core/uninstall/uninstall-reporter.d.ts +2 -2
  134. package/packages/core/dist/core/uninstall/uninstall-reporter.d.ts.map +1 -1
  135. package/packages/core/dist/core/uninstall/uninstall-reporter.js +4 -4
  136. package/packages/core/dist/core/uninstall/uninstall-reporter.js.map +1 -1
  137. package/packages/core/dist/index.d.ts +1 -1
  138. package/packages/core/dist/index.d.ts.map +1 -1
  139. package/packages/core/dist/types/execution-context.d.ts +24 -10
  140. package/packages/core/dist/types/execution-context.d.ts.map +1 -1
@@ -0,0 +1,631 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ UserCancellationError
4
+ } from "./chunk-ID4SVDQZ.js";
5
+ import {
6
+ logger
7
+ } from "./chunk-5EFWGD33.js";
8
+
9
+ // ../core/src/core/ports/console-output.ts
10
+ var consoleOutput = {
11
+ info(message) {
12
+ console.log(message);
13
+ },
14
+ step(message) {
15
+ console.log(message);
16
+ },
17
+ connector() {
18
+ },
19
+ message(message) {
20
+ console.log(message);
21
+ },
22
+ success(message) {
23
+ console.log(`\u2713 ${message}`);
24
+ },
25
+ error(message) {
26
+ console.log(`\u2717 ${message}`);
27
+ },
28
+ warn(message) {
29
+ console.log(`\u26A0 ${message}`);
30
+ },
31
+ note(content, title) {
32
+ let indented = content.split(`
33
+ `).map((line) => ` ${line}`).join(`
34
+ `);
35
+ console.log(title ? `
36
+ ${title}
37
+ ${indented}` : `
38
+ ${indented}`);
39
+ },
40
+ async confirm(_message, options) {
41
+ return options?.initial ?? !1;
42
+ },
43
+ spinner() {
44
+ let msg = "";
45
+ return {
46
+ start(message) {
47
+ msg = message, console.log(`\u2026 ${message}`);
48
+ },
49
+ stop(finalMessage) {
50
+ console.log(finalMessage ? `\u2713 ${finalMessage}` : `\u2713 ${msg}`);
51
+ },
52
+ message(text2) {
53
+ msg = text2;
54
+ }
55
+ };
56
+ }
57
+ };
58
+
59
+ // ../core/src/core/ports/console-prompt.ts
60
+ var NonInteractivePromptError = class extends Error {
61
+ constructor(promptType) {
62
+ super(
63
+ `Cannot prompt for ${promptType} in non-interactive mode. Use specific flags or options to provide the required input.`
64
+ ), this.name = "NonInteractivePromptError";
65
+ }
66
+ }, nonInteractivePrompt = {
67
+ async confirm(_message, _initial) {
68
+ throw new NonInteractivePromptError("confirmation");
69
+ },
70
+ async select(_message, _choices, _hint) {
71
+ throw new NonInteractivePromptError("selection");
72
+ },
73
+ async multiselect(_message, _choices) {
74
+ throw new NonInteractivePromptError("multi-selection");
75
+ },
76
+ async groupMultiselect(_message, _groups) {
77
+ throw new NonInteractivePromptError("group selection");
78
+ },
79
+ async text(_message, _options) {
80
+ throw new NonInteractivePromptError("text input");
81
+ }
82
+ };
83
+
84
+ // ../core/src/core/ports/resolve.ts
85
+ function resolveOutput(ctx) {
86
+ return ctx?.output ?? consoleOutput;
87
+ }
88
+ function resolvePrompt(ctx) {
89
+ return ctx?.prompt ?? nonInteractivePrompt;
90
+ }
91
+
92
+ // ../core/src/core/execution-context.ts
93
+ import { resolve as resolve2 } from "path";
94
+ import { stat, access, constants as fsConstants } from "fs/promises";
95
+
96
+ // ../core/src/utils/home-directory.ts
97
+ import { homedir } from "os";
98
+ import { resolve, normalize } from "path";
99
+ function getHomeDirectory() {
100
+ return homedir();
101
+ }
102
+ function isHomeDirectory(path) {
103
+ let normalizedPath = normalize(resolve(path)), normalizedHome = normalize(getHomeDirectory());
104
+ return normalizedPath === normalizedHome;
105
+ }
106
+ function normalizePathWithTilde(path) {
107
+ let normalizedPath = normalize(resolve(path)), homeDir = getHomeDirectory(), normalizedHome = normalize(homeDir);
108
+ return normalizedPath === normalizedHome ? "~/" : normalizedPath.startsWith(normalizedHome + "/") ? "~/" + normalizedPath.slice(normalizedHome.length + 1) : normalizedPath;
109
+ }
110
+
111
+ // ../core/src/core/execution-context.ts
112
+ async function createExecutionContext(options = {}) {
113
+ let sourceCwd = process.cwd(), targetDir, isGlobal;
114
+ options.global ? (targetDir = getHomeDirectory(), isGlobal = !0, options.cwd && logger.info("--global option present, ignoring --cwd", {
115
+ cwd: options.cwd,
116
+ targetDir
117
+ })) : options.cwd ? (targetDir = resolve2(sourceCwd, options.cwd), isGlobal = isHomeDirectory(targetDir)) : (targetDir = sourceCwd, isGlobal = isHomeDirectory(targetDir));
118
+ let context = {
119
+ sourceCwd,
120
+ targetDir,
121
+ isGlobal,
122
+ interactive: options.interactive
123
+ };
124
+ return await validateExecutionContext(context), logger.debug("Created execution context", {
125
+ sourceCwd: context.sourceCwd,
126
+ targetDir: context.targetDir,
127
+ isGlobal: context.isGlobal
128
+ }), context;
129
+ }
130
+ async function validateExecutionContext(context) {
131
+ try {
132
+ if (!(await stat(context.targetDir)).isDirectory())
133
+ throw new Error(`Target path is not a directory: ${context.targetDir}`);
134
+ await access(context.targetDir, fsConstants.W_OK);
135
+ } catch (error) {
136
+ throw error.code === "ENOENT" ? new Error(
137
+ `Target directory does not exist: ${context.targetDir}
138
+
139
+ Hint: Create the directory or specify a different target with --cwd`
140
+ ) : error.code === "EACCES" ? new Error(
141
+ `Target directory is not writable: ${context.targetDir}
142
+
143
+ Hint: Check directory permissions`
144
+ ) : new Error(
145
+ `Invalid target directory: ${context.targetDir}
146
+ Error: ${error instanceof Error ? error.message : String(error)}`
147
+ );
148
+ }
149
+ try {
150
+ if (!(await stat(context.sourceCwd)).isDirectory())
151
+ throw new Error(`Source working directory is not a directory: ${context.sourceCwd}`);
152
+ await access(context.sourceCwd, fsConstants.R_OK);
153
+ } catch (error) {
154
+ throw new Error(
155
+ `Invalid source working directory: ${context.sourceCwd}
156
+ Error: ${error instanceof Error ? error.message : String(error)}`
157
+ );
158
+ }
159
+ }
160
+ function getDisplayTargetDir(context) {
161
+ return normalizePathWithTilde(context.targetDir);
162
+ }
163
+
164
+ // src/cli/clack-output-adapter.ts
165
+ import { log, spinner as clackSpinner, confirm as clackConfirm, note as clackNote, isCancel, cancel } from "@clack/prompts";
166
+
167
+ // src/utils/spinner.ts
168
+ var Spinner = class {
169
+ constructor(message = "Loading...") {
170
+ this.intervalId = null;
171
+ this.currentFrame = 0;
172
+ this.isRunning = !1;
173
+ this.message = message, this.frames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
174
+ }
175
+ /**
176
+ * Start the spinner animation
177
+ */
178
+ start() {
179
+ this.isRunning || (this.isRunning = !0, this.currentFrame = 0, process.stdout.write("\x1B[?25l"), this.intervalId = setInterval(() => {
180
+ let frame = this.frames[this.currentFrame % this.frames.length];
181
+ process.stdout.write(`\r${frame} ${this.message}`), this.currentFrame++;
182
+ }, 80));
183
+ }
184
+ /**
185
+ * Update the spinner message
186
+ */
187
+ update(message) {
188
+ this.message = message;
189
+ }
190
+ /**
191
+ * Stop the spinner
192
+ */
193
+ stop() {
194
+ this.isRunning && (this.isRunning = !1, this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), process.stdout.write("\r" + " ".repeat(process.stdout.columns || 80) + "\r"), process.stdout.write("\x1B[?25h"));
195
+ }
196
+ };
197
+
198
+ // src/cli/clack-output-adapter.ts
199
+ function createClackOutput() {
200
+ return {
201
+ info(message) {
202
+ log.info(message);
203
+ },
204
+ step(message) {
205
+ log.step(message);
206
+ },
207
+ connector() {
208
+ log.message(" ", { spacing: 0 });
209
+ },
210
+ message(message) {
211
+ log.message(message, { spacing: 0 });
212
+ },
213
+ success(message) {
214
+ log.success(message);
215
+ },
216
+ error(message) {
217
+ log.error(message);
218
+ },
219
+ warn(message) {
220
+ log.warn(message);
221
+ },
222
+ note(content, title) {
223
+ clackNote(content, title ?? "");
224
+ },
225
+ async confirm(message, options) {
226
+ let result = await clackConfirm({
227
+ message,
228
+ initialValue: options?.initial ?? !1
229
+ });
230
+ if (isCancel(result)) {
231
+ cancel("Operation cancelled.");
232
+ let { UserCancellationError: UserCancellationError2 } = await import("./errors-X5KO3GTP.js");
233
+ throw new UserCancellationError2("Operation cancelled by user");
234
+ }
235
+ return result;
236
+ },
237
+ spinner() {
238
+ let s = clackSpinner(), isStarted = !1;
239
+ return {
240
+ start(message) {
241
+ isStarted || (s.start(message), isStarted = !0);
242
+ },
243
+ stop(finalMessage) {
244
+ isStarted && (finalMessage ? s.stop(finalMessage) : s.stop(), isStarted = !1);
245
+ },
246
+ message(text2) {
247
+ isStarted && s.message(text2);
248
+ }
249
+ };
250
+ }
251
+ };
252
+ }
253
+ function createPlainOutput() {
254
+ return {
255
+ info(message) {
256
+ console.log(message);
257
+ },
258
+ step(message) {
259
+ console.log(message);
260
+ },
261
+ connector() {
262
+ },
263
+ message(message) {
264
+ console.log(message);
265
+ },
266
+ success(message) {
267
+ console.log(`\u2713 ${message}`);
268
+ },
269
+ error(message) {
270
+ console.log(`\u274C ${message}`);
271
+ },
272
+ warn(message) {
273
+ console.log(`\u26A0\uFE0F ${message}`);
274
+ },
275
+ note(content, title) {
276
+ let indented = content.split(`
277
+ `).map((line) => ` ${line}`).join(`
278
+ `);
279
+ console.log(title ? `
280
+ ${title}
281
+ ${indented}` : `
282
+ ${indented}`);
283
+ },
284
+ async confirm(_message, options) {
285
+ return console.log(`${_message} ${options?.initial ? "(Y)" : "(N)"}`), options?.initial ?? !1;
286
+ },
287
+ spinner() {
288
+ let s = null;
289
+ return {
290
+ start(message) {
291
+ s = new Spinner(message), s.start();
292
+ },
293
+ stop(finalMessage) {
294
+ s && (s.stop(), finalMessage && console.log(finalMessage), s = null);
295
+ },
296
+ message(text2) {
297
+ s && s.update(text2);
298
+ }
299
+ };
300
+ }
301
+ };
302
+ }
303
+
304
+ // src/cli/clack-prompt-adapter.ts
305
+ import * as clack from "@clack/prompts";
306
+ function handleCancel(result) {
307
+ if (clack.isCancel(result))
308
+ throw clack.cancel("Operation cancelled."), new UserCancellationError("Operation cancelled by user");
309
+ }
310
+ function createClackPrompt() {
311
+ return {
312
+ async confirm(message, initial) {
313
+ let result = await clack.confirm({
314
+ message,
315
+ initialValue: initial ?? !1
316
+ });
317
+ return handleCancel(result), result;
318
+ },
319
+ async select(message, choices, hint) {
320
+ let result = await clack.select({
321
+ message,
322
+ options: choices.map((c) => ({
323
+ label: c.title,
324
+ value: c.value,
325
+ ...c.description ? { hint: c.description } : {}
326
+ }))
327
+ });
328
+ return handleCancel(result), result;
329
+ },
330
+ async multiselect(message, choices, options) {
331
+ let result = await clack.multiselect({
332
+ message,
333
+ options: choices.map((c) => ({
334
+ label: c.title,
335
+ value: c.value,
336
+ ...c.description ? { hint: c.description } : {}
337
+ })),
338
+ required: options?.min ? options.min > 0 : !1
339
+ });
340
+ return handleCancel(result), result;
341
+ },
342
+ async groupMultiselect(message, groups) {
343
+ let result = await clack.groupMultiselect({
344
+ message,
345
+ options: groups
346
+ });
347
+ return handleCancel(result), result;
348
+ },
349
+ async text(message, options) {
350
+ let userValidate = options?.validate, isAsync = !1, syncValidate = userValidate ? (value) => {
351
+ let r = userValidate(value ?? "");
352
+ if (r && typeof r.then == "function") {
353
+ isAsync = !0;
354
+ return;
355
+ }
356
+ if (!(r === !0 || r === void 0))
357
+ return r;
358
+ } : void 0;
359
+ for (; ; ) {
360
+ let result = await clack.text({
361
+ message,
362
+ placeholder: options?.placeholder,
363
+ defaultValue: options?.initial,
364
+ validate: syncValidate
365
+ });
366
+ if (handleCancel(result), isAsync && userValidate) {
367
+ let asyncResult = await userValidate(result ?? "");
368
+ if (asyncResult !== !0 && asyncResult !== void 0) {
369
+ clack.log.error(asyncResult), isAsync = !1;
370
+ continue;
371
+ }
372
+ }
373
+ return result;
374
+ }
375
+ }
376
+ };
377
+ }
378
+
379
+ // src/cli/plain-prompt-adapter.ts
380
+ import prompts from "prompts";
381
+ function onCancel() {
382
+ throw new UserCancellationError("Prompt cancelled");
383
+ }
384
+ function createPlainPrompt() {
385
+ return {
386
+ // ── confirm ──────────────────────────────────────────────────────
387
+ async confirm(message, initial) {
388
+ let { value } = await prompts(
389
+ {
390
+ type: "confirm",
391
+ name: "value",
392
+ message,
393
+ initial: initial ?? !1
394
+ },
395
+ { onCancel }
396
+ );
397
+ return value;
398
+ },
399
+ // ── select ───────────────────────────────────────────────────────
400
+ async select(message, choices, hint) {
401
+ let { value } = await prompts(
402
+ {
403
+ type: "select",
404
+ name: "value",
405
+ message,
406
+ choices: choices.map((c) => ({
407
+ title: c.title,
408
+ value: c.value,
409
+ description: c.description
410
+ })),
411
+ hint
412
+ },
413
+ { onCancel }
414
+ );
415
+ return value;
416
+ },
417
+ // ── multiselect ──────────────────────────────────────────────────
418
+ async multiselect(message, choices, options) {
419
+ let { value } = await prompts(
420
+ {
421
+ type: "multiselect",
422
+ name: "value",
423
+ message,
424
+ choices: choices.map((c) => ({
425
+ title: c.title,
426
+ value: c.value,
427
+ description: c.description
428
+ })),
429
+ hint: options?.hint ?? "- Space: select/deselect, Enter: confirm",
430
+ min: options?.min
431
+ },
432
+ { onCancel }
433
+ );
434
+ return value;
435
+ },
436
+ // ── groupMultiselect ─────────────────────────────────────────────
437
+ async groupMultiselect(message, groups) {
438
+ let flatChoices = [];
439
+ for (let [groupLabel, items] of Object.entries(groups))
440
+ for (let item of items)
441
+ flatChoices.push({
442
+ title: `${groupLabel} / ${item.label}`,
443
+ value: item.value
444
+ });
445
+ let { value } = await prompts(
446
+ {
447
+ type: "multiselect",
448
+ name: "value",
449
+ message,
450
+ choices: flatChoices.map((c) => ({
451
+ title: c.title,
452
+ value: c.value
453
+ })),
454
+ hint: "- Space: select/deselect, Enter: confirm"
455
+ },
456
+ { onCancel }
457
+ );
458
+ return value;
459
+ },
460
+ // ── text ─────────────────────────────────────────────────────────
461
+ async text(message, options) {
462
+ let userValidate = options?.validate, isAsync = !1, syncValidate = userValidate ? (value) => {
463
+ let r = userValidate(value);
464
+ return r && typeof r.then == "function" ? (isAsync = !0, !0) : r === !0 || r === void 0 ? !0 : r;
465
+ } : void 0;
466
+ for (; ; ) {
467
+ let { value } = await prompts(
468
+ {
469
+ type: "text",
470
+ name: "value",
471
+ message,
472
+ initial: options?.initial,
473
+ validate: syncValidate
474
+ },
475
+ { onCancel }
476
+ ), result = value ?? "";
477
+ if (isAsync && userValidate) {
478
+ let asyncResult = await userValidate(result);
479
+ if (asyncResult !== !0 && asyncResult !== void 0) {
480
+ console.error(` Error: ${asyncResult}`), isAsync = !1;
481
+ continue;
482
+ }
483
+ }
484
+ return result;
485
+ }
486
+ }
487
+ };
488
+ }
489
+
490
+ // src/cli/clack-progress-adapter.ts
491
+ import { log as log3 } from "@clack/prompts";
492
+ function createClackProgress() {
493
+ return {
494
+ emit(event) {
495
+ switch (event.type) {
496
+ case "install:start":
497
+ log3.step(`Installing ${event.packages.length} package(s)`);
498
+ break;
499
+ case "install:resolve":
500
+ event.status === "failed" && log3.warn(`Failed to resolve ${event.package}${event.detail ? `: ${event.detail}` : ""}`);
501
+ break;
502
+ case "install:download":
503
+ event.status === "failed" && log3.warn(`Failed to download ${event.package}${event.detail ? `: ${event.detail}` : ""}`);
504
+ break;
505
+ case "install:extract":
506
+ event.status === "failed" && log3.warn(`Failed to extract ${event.package}${event.detail ? `: ${event.detail}` : ""}`);
507
+ break;
508
+ case "install:complete": {
509
+ let { installed, failed, skipped } = event.summary;
510
+ failed > 0 ? log3.warn(`Install complete: ${installed} installed, ${failed} failed, ${skipped} skipped`) : log3.info(`Install complete: ${installed} installed${skipped > 0 ? `, ${skipped} skipped` : ""}`);
511
+ break;
512
+ }
513
+ case "publish:start":
514
+ log3.step(`Publishing ${event.package}@${event.version}`);
515
+ break;
516
+ case "publish:upload":
517
+ event.status === "failed" && log3.warn(`Upload failed for ${event.package}${event.detail ? `: ${event.detail}` : ""}`);
518
+ break;
519
+ case "publish:complete":
520
+ event.success ? log3.info(`Published ${event.package}`) : log3.warn(`Failed to publish ${event.package}`);
521
+ break;
522
+ case "uninstall:start":
523
+ log3.step(`Uninstalling ${event.packages.length} package(s)`);
524
+ break;
525
+ case "uninstall:remove":
526
+ event.status === "failed" && log3.warn(`Failed to remove ${event.package}${event.detail ? `: ${event.detail}` : ""}`);
527
+ break;
528
+ case "uninstall:complete": {
529
+ let { removed, failed } = event.summary;
530
+ failed > 0 ? log3.warn(`Uninstall complete: ${removed} removed, ${failed} failed`) : log3.info(`Uninstall complete: ${removed} removed`);
531
+ break;
532
+ }
533
+ case "search:start":
534
+ break;
535
+ case "search:scanning":
536
+ break;
537
+ case "search:complete":
538
+ log3.info(`Found ${event.resultCount} result(s)`);
539
+ break;
540
+ case "pipeline:start":
541
+ log3.step(`${event.pipeline}${event.detail ? `: ${event.detail}` : ""}`);
542
+ break;
543
+ case "pipeline:step":
544
+ log3.info(`${event.step}${event.detail ? `: ${event.detail}` : ""}`);
545
+ break;
546
+ case "pipeline:complete":
547
+ event.success || log3.warn(`${event.pipeline} failed${event.detail ? `: ${event.detail}` : ""}`);
548
+ break;
549
+ }
550
+ },
551
+ log(level, message) {
552
+ switch (level) {
553
+ case "debug":
554
+ break;
555
+ case "info":
556
+ log3.info(message);
557
+ break;
558
+ case "warn":
559
+ log3.warn(message);
560
+ break;
561
+ case "error":
562
+ log3.error(message);
563
+ break;
564
+ }
565
+ }
566
+ };
567
+ }
568
+ function createPlainProgress() {
569
+ return {
570
+ emit(event) {
571
+ switch (event.type) {
572
+ case "install:complete":
573
+ console.log(`Installed: ${event.summary.installed}, failed: ${event.summary.failed}, skipped: ${event.summary.skipped}`);
574
+ break;
575
+ case "publish:complete":
576
+ console.log(`Publish ${event.package}: ${event.success ? "success" : "failed"}`);
577
+ break;
578
+ case "uninstall:complete":
579
+ console.log(`Removed: ${event.summary.removed}, failed: ${event.summary.failed}`);
580
+ break;
581
+ case "search:complete":
582
+ console.log(`Found ${event.resultCount} result(s)`);
583
+ break;
584
+ case "pipeline:complete":
585
+ event.success || console.log(`${event.pipeline} failed${event.detail ? `: ${event.detail}` : ""}`);
586
+ break;
587
+ default:
588
+ break;
589
+ }
590
+ },
591
+ log(level, message) {
592
+ switch (level) {
593
+ case "debug":
594
+ case "info":
595
+ break;
596
+ case "warn":
597
+ console.warn(message);
598
+ break;
599
+ case "error":
600
+ console.error(message);
601
+ break;
602
+ }
603
+ }
604
+ };
605
+ }
606
+
607
+ // src/cli/context.ts
608
+ var cachedClackOutput, cachedPlainOutput, cachedClackPrompt, cachedPlainPrompt, cachedClackProgress, cachedPlainProgress;
609
+ function detectInteractive() {
610
+ return process.stdin.isTTY === !0 && process.env.CI !== "true";
611
+ }
612
+ function applyOutputMode(ctx, mode, isTTY) {
613
+ ctx.outputMode = mode, mode === "rich" ? (ctx.output = cachedClackOutput ?? (cachedClackOutput = createClackOutput()), ctx.prompt = isTTY ? cachedClackPrompt ?? (cachedClackPrompt = createClackPrompt()) : nonInteractivePrompt, ctx.progress = cachedClackProgress ?? (cachedClackProgress = createClackProgress())) : (ctx.output = cachedPlainOutput ?? (cachedPlainOutput = createPlainOutput()), ctx.prompt = isTTY ? cachedPlainPrompt ?? (cachedPlainPrompt = createPlainPrompt()) : nonInteractivePrompt, ctx.progress = cachedPlainProgress ?? (cachedPlainProgress = createPlainProgress()));
614
+ }
615
+ async function createCliExecutionContext(options = {}) {
616
+ let ctx = await createExecutionContext(options), isTTY = detectInteractive(), initialMode = options.outputMode ?? "plain";
617
+ return applyOutputMode(ctx, initialMode, isTTY), ctx.commitOutputMode = (mode) => {
618
+ ctx.outputMode !== mode && applyOutputMode(ctx, mode, isTTY);
619
+ }, ctx;
620
+ }
621
+
622
+ export {
623
+ normalizePathWithTilde,
624
+ consoleOutput,
625
+ resolveOutput,
626
+ resolvePrompt,
627
+ createExecutionContext,
628
+ getDisplayTargetDir,
629
+ createCliExecutionContext
630
+ };
631
+ //# sourceMappingURL=chunk-BROJ6OUT.js.map