uilint 0.2.48 → 0.2.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{init-ui-RQKFF33G.js → chunk-4PRDR64J.js} +1882 -3547
- package/dist/chunk-4PRDR64J.js.map +1 -0
- package/dist/{chunk-5536ROOI.js → chunk-MSOAR5VP.js} +3 -3
- package/dist/{chunk-5536ROOI.js.map → chunk-MSOAR5VP.js.map} +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/dist/init-ui-GKA2KU3I.js +1691 -0
- package/dist/init-ui-GKA2KU3I.js.map +1 -0
- package/dist/remove-ui-ZODRMK5G.js +601 -0
- package/dist/remove-ui-ZODRMK5G.js.map +1 -0
- package/package.json +5 -5
- package/dist/init-ui-RQKFF33G.js.map +0 -1
|
@@ -0,0 +1,601 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
Spinner,
|
|
4
|
+
analyze,
|
|
5
|
+
execute,
|
|
6
|
+
getAllInstallers
|
|
7
|
+
} from "./chunk-4PRDR64J.js";
|
|
8
|
+
import "./chunk-MSOAR5VP.js";
|
|
9
|
+
import "./chunk-VSBVUS56.js";
|
|
10
|
+
import "./chunk-ZDSDZNIB.js";
|
|
11
|
+
import {
|
|
12
|
+
pc
|
|
13
|
+
} from "./chunk-CZNPG4UI.js";
|
|
14
|
+
import "./chunk-JPE27ROY.js";
|
|
15
|
+
|
|
16
|
+
// src/commands/remove-ui.tsx
|
|
17
|
+
import { render } from "ink";
|
|
18
|
+
|
|
19
|
+
// src/commands/remove/components/RemoveApp.tsx
|
|
20
|
+
import { useState, useEffect } from "react";
|
|
21
|
+
import { Box, Text, useApp, useInput } from "ink";
|
|
22
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
|
+
function getProjectsWithInstalls(project) {
|
|
24
|
+
const installers = getAllInstallers();
|
|
25
|
+
const projects = [];
|
|
26
|
+
const seenPaths = /* @__PURE__ */ new Set();
|
|
27
|
+
for (const installer of installers) {
|
|
28
|
+
if (!installer.isApplicable(project)) continue;
|
|
29
|
+
const targets = installer.getTargets(project);
|
|
30
|
+
for (const target of targets) {
|
|
31
|
+
if (!target.isInstalled) continue;
|
|
32
|
+
let projectPath = target.path;
|
|
33
|
+
let type = "global";
|
|
34
|
+
let hint = "Other";
|
|
35
|
+
if (installer.id === "next") {
|
|
36
|
+
type = "nextjs";
|
|
37
|
+
hint = "Next.js App Router";
|
|
38
|
+
} else if (installer.id === "vite") {
|
|
39
|
+
type = "vite";
|
|
40
|
+
hint = "Vite + React";
|
|
41
|
+
} else if (installer.id === "eslint") {
|
|
42
|
+
type = "eslint";
|
|
43
|
+
hint = "ESLint";
|
|
44
|
+
} else if (installer.id === "genstyleguide" || installer.id === "skill") {
|
|
45
|
+
projectPath = project.workspaceRoot;
|
|
46
|
+
type = "global";
|
|
47
|
+
hint = "Global";
|
|
48
|
+
}
|
|
49
|
+
if (seenPaths.has(projectPath)) {
|
|
50
|
+
const existing = projects.find((p) => p.path === projectPath);
|
|
51
|
+
if (existing) {
|
|
52
|
+
existing.installedCount++;
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
seenPaths.add(projectPath);
|
|
57
|
+
const relativePath = projectPath.replace(project.workspaceRoot + "/", "");
|
|
58
|
+
projects.push({
|
|
59
|
+
id: `${type}:${projectPath}`,
|
|
60
|
+
name: relativePath || ".",
|
|
61
|
+
path: projectPath,
|
|
62
|
+
type,
|
|
63
|
+
hint,
|
|
64
|
+
installedCount: 1
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return projects;
|
|
69
|
+
}
|
|
70
|
+
function getInstalledItemsForProject(project, selectedProject) {
|
|
71
|
+
const installers = getAllInstallers();
|
|
72
|
+
const items = [];
|
|
73
|
+
for (const installer of installers) {
|
|
74
|
+
if (!installer.isApplicable(project)) continue;
|
|
75
|
+
const targets = installer.getTargets(project);
|
|
76
|
+
for (const target of targets) {
|
|
77
|
+
if (!target.isInstalled) continue;
|
|
78
|
+
if (selectedProject) {
|
|
79
|
+
if (installer.id === "genstyleguide" || installer.id === "skill") {
|
|
80
|
+
if (selectedProject.type !== "global") continue;
|
|
81
|
+
} else {
|
|
82
|
+
if (target.path !== selectedProject.path) continue;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
items.push({
|
|
86
|
+
id: `${installer.id}:${target.id}`,
|
|
87
|
+
installerId: installer.id,
|
|
88
|
+
installer,
|
|
89
|
+
label: installer.name,
|
|
90
|
+
hint: target.hint,
|
|
91
|
+
target
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return items;
|
|
96
|
+
}
|
|
97
|
+
function Header({ subtitle }) {
|
|
98
|
+
return /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsxs(Box, { children: [
|
|
99
|
+
/* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: "\u25C6 UILint" }),
|
|
100
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: " v0.5.0" }),
|
|
101
|
+
subtitle && /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
102
|
+
" \xB7 ",
|
|
103
|
+
subtitle
|
|
104
|
+
] })
|
|
105
|
+
] }) });
|
|
106
|
+
}
|
|
107
|
+
function FrameworkBadge({ type }) {
|
|
108
|
+
switch (type) {
|
|
109
|
+
case "nextjs":
|
|
110
|
+
return /* @__PURE__ */ jsx(Text, { color: "white", backgroundColor: "black", children: " Next.js " });
|
|
111
|
+
case "vite":
|
|
112
|
+
return /* @__PURE__ */ jsx(Text, { color: "black", backgroundColor: "yellow", children: " Vite " });
|
|
113
|
+
case "eslint":
|
|
114
|
+
return /* @__PURE__ */ jsx(Text, { color: "white", backgroundColor: "blue", children: " ESLint " });
|
|
115
|
+
case "global":
|
|
116
|
+
return /* @__PURE__ */ jsx(Text, { color: "white", backgroundColor: "magenta", children: " Global " });
|
|
117
|
+
default:
|
|
118
|
+
return /* @__PURE__ */ jsx(Text, { dimColor: true, children: "Other" });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function ProjectSelector({
|
|
122
|
+
projects,
|
|
123
|
+
cursor,
|
|
124
|
+
onSelect,
|
|
125
|
+
onCancel
|
|
126
|
+
}) {
|
|
127
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
128
|
+
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { bold: true, children: "Select a project to remove components from:" }) }),
|
|
129
|
+
projects.map((project, index) => {
|
|
130
|
+
const isCursor = index === cursor;
|
|
131
|
+
return /* @__PURE__ */ jsxs(Box, { paddingLeft: 1, children: [
|
|
132
|
+
/* @__PURE__ */ jsx(Text, { color: isCursor ? "cyan" : void 0, children: isCursor ? "\u203A " : " " }),
|
|
133
|
+
/* @__PURE__ */ jsx(Box, { width: 12, children: /* @__PURE__ */ jsx(FrameworkBadge, { type: project.type }) }),
|
|
134
|
+
/* @__PURE__ */ jsx(Box, { width: 30, children: /* @__PURE__ */ jsx(Text, { color: isCursor ? "cyan" : void 0, bold: isCursor, children: project.name }) }),
|
|
135
|
+
/* @__PURE__ */ jsxs(Text, { color: "green", dimColor: true, children: [
|
|
136
|
+
project.installedCount,
|
|
137
|
+
" installed"
|
|
138
|
+
] })
|
|
139
|
+
] }, project.id);
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, borderStyle: "single", borderColor: "gray", paddingX: 1, children: /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
142
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u2191\u2193" }),
|
|
143
|
+
" navigate",
|
|
144
|
+
" ",
|
|
145
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "enter" }),
|
|
146
|
+
" select",
|
|
147
|
+
" ",
|
|
148
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "q" }),
|
|
149
|
+
" quit"
|
|
150
|
+
] }) })
|
|
151
|
+
] });
|
|
152
|
+
}
|
|
153
|
+
function SelectionItem({
|
|
154
|
+
item,
|
|
155
|
+
isSelected,
|
|
156
|
+
isCursor
|
|
157
|
+
}) {
|
|
158
|
+
return /* @__PURE__ */ jsxs(Box, { paddingLeft: 2, children: [
|
|
159
|
+
/* @__PURE__ */ jsx(Text, { color: isCursor ? "cyan" : void 0, children: isCursor ? "\u203A " : " " }),
|
|
160
|
+
/* @__PURE__ */ jsx(Box, { width: 2, children: /* @__PURE__ */ jsx(Text, { color: isSelected ? "red" : "gray", children: isSelected ? "\u2717" : "\u25CB" }) }),
|
|
161
|
+
/* @__PURE__ */ jsx(Box, { width: 28, children: /* @__PURE__ */ jsx(
|
|
162
|
+
Text,
|
|
163
|
+
{
|
|
164
|
+
color: isSelected ? "red" : isCursor ? "cyan" : void 0,
|
|
165
|
+
children: item.label
|
|
166
|
+
}
|
|
167
|
+
) }),
|
|
168
|
+
/* @__PURE__ */ jsx(Box, { width: 20, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: item.hint || "" }) }),
|
|
169
|
+
/* @__PURE__ */ jsx(Text, { color: "green", dimColor: true, children: "installed" })
|
|
170
|
+
] });
|
|
171
|
+
}
|
|
172
|
+
function SelectionList({
|
|
173
|
+
items,
|
|
174
|
+
selectedIds,
|
|
175
|
+
cursor,
|
|
176
|
+
selectedProject,
|
|
177
|
+
canGoBack,
|
|
178
|
+
onBack
|
|
179
|
+
}) {
|
|
180
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
181
|
+
selectedProject && /* @__PURE__ */ jsxs(Box, { marginBottom: 1, children: [
|
|
182
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "Project: " }),
|
|
183
|
+
/* @__PURE__ */ jsx(Text, { bold: true, color: "cyan", children: selectedProject.name }),
|
|
184
|
+
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
185
|
+
" (",
|
|
186
|
+
selectedProject.hint,
|
|
187
|
+
")"
|
|
188
|
+
] })
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { children: "Select components to remove:" }) }),
|
|
191
|
+
items.map((item, index) => /* @__PURE__ */ jsx(
|
|
192
|
+
SelectionItem,
|
|
193
|
+
{
|
|
194
|
+
item,
|
|
195
|
+
isSelected: selectedIds.has(item.id),
|
|
196
|
+
isCursor: index === cursor
|
|
197
|
+
},
|
|
198
|
+
item.id
|
|
199
|
+
)),
|
|
200
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, borderStyle: "single", borderColor: "gray", paddingX: 1, children: /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
201
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u2191\u2193" }),
|
|
202
|
+
" navigate",
|
|
203
|
+
" ",
|
|
204
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "space" }),
|
|
205
|
+
" toggle",
|
|
206
|
+
" ",
|
|
207
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "a" }),
|
|
208
|
+
" all",
|
|
209
|
+
" ",
|
|
210
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "n" }),
|
|
211
|
+
" none",
|
|
212
|
+
" ",
|
|
213
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "enter" }),
|
|
214
|
+
" remove",
|
|
215
|
+
" ",
|
|
216
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "q" }),
|
|
217
|
+
" quit"
|
|
218
|
+
] }) }),
|
|
219
|
+
canGoBack && /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
220
|
+
"Press ",
|
|
221
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "b" }),
|
|
222
|
+
" or ",
|
|
223
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "\u2190" }),
|
|
224
|
+
" to select a different project"
|
|
225
|
+
] }) }),
|
|
226
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsxs(Text, { children: [
|
|
227
|
+
/* @__PURE__ */ jsx(Text, { color: "red", children: selectedIds.size }),
|
|
228
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: " to remove" })
|
|
229
|
+
] }) })
|
|
230
|
+
] });
|
|
231
|
+
}
|
|
232
|
+
function Confirmation({
|
|
233
|
+
items,
|
|
234
|
+
selectedIds,
|
|
235
|
+
dryRun,
|
|
236
|
+
onConfirm,
|
|
237
|
+
onBack
|
|
238
|
+
}) {
|
|
239
|
+
const selectedItems = items.filter((item) => selectedIds.has(item.id));
|
|
240
|
+
useInput((input, key) => {
|
|
241
|
+
if (input === "y" || key.return) {
|
|
242
|
+
onConfirm();
|
|
243
|
+
} else if (input === "n" || key.escape || input === "b") {
|
|
244
|
+
onBack();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
248
|
+
/* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { bold: true, children: [
|
|
249
|
+
dryRun ? "Preview: Would remove" : "Confirm removal of",
|
|
250
|
+
" ",
|
|
251
|
+
selectedItems.length,
|
|
252
|
+
" component(s):"
|
|
253
|
+
] }) }),
|
|
254
|
+
selectedItems.map((item) => /* @__PURE__ */ jsxs(Box, { paddingLeft: 2, children: [
|
|
255
|
+
/* @__PURE__ */ jsx(Text, { color: "red", children: "\u2717 " }),
|
|
256
|
+
/* @__PURE__ */ jsx(Text, { children: item.label }),
|
|
257
|
+
item.hint && /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
258
|
+
" (",
|
|
259
|
+
item.hint,
|
|
260
|
+
")"
|
|
261
|
+
] })
|
|
262
|
+
] }, item.id)),
|
|
263
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: dryRun ? /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
264
|
+
"Dry run mode - no changes will be made.",
|
|
265
|
+
" ",
|
|
266
|
+
"Press ",
|
|
267
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "enter" }),
|
|
268
|
+
" to see details or ",
|
|
269
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "b" }),
|
|
270
|
+
" to go back."
|
|
271
|
+
] }) : /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
272
|
+
"Press ",
|
|
273
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "y" }),
|
|
274
|
+
" or ",
|
|
275
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "enter" }),
|
|
276
|
+
" to confirm, ",
|
|
277
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "n" }),
|
|
278
|
+
" or ",
|
|
279
|
+
/* @__PURE__ */ jsx(Text, { color: "cyan", children: "b" }),
|
|
280
|
+
" to go back."
|
|
281
|
+
] }) })
|
|
282
|
+
] });
|
|
283
|
+
}
|
|
284
|
+
function RemoveApp({
|
|
285
|
+
projectPromise,
|
|
286
|
+
skipConfirmation = false,
|
|
287
|
+
dryRun = false,
|
|
288
|
+
onComplete,
|
|
289
|
+
onError
|
|
290
|
+
}) {
|
|
291
|
+
const { exit } = useApp();
|
|
292
|
+
const [phase, setPhase] = useState("loading");
|
|
293
|
+
const [project, setProject] = useState(null);
|
|
294
|
+
const [projectsWithInstalls, setProjectsWithInstalls] = useState([]);
|
|
295
|
+
const [selectedProject, setSelectedProject] = useState(null);
|
|
296
|
+
const [items, setItems] = useState([]);
|
|
297
|
+
const [selectedIds, setSelectedIds] = useState(/* @__PURE__ */ new Set());
|
|
298
|
+
const [cursor, setCursor] = useState(0);
|
|
299
|
+
const [projectCursor, setProjectCursor] = useState(0);
|
|
300
|
+
const [error, setError] = useState(null);
|
|
301
|
+
useEffect(() => {
|
|
302
|
+
if (phase !== "loading") return;
|
|
303
|
+
projectPromise.then((proj) => {
|
|
304
|
+
setProject(proj);
|
|
305
|
+
const projects = getProjectsWithInstalls(proj);
|
|
306
|
+
setProjectsWithInstalls(projects);
|
|
307
|
+
if (projects.length === 0) {
|
|
308
|
+
setError(new Error("No UILint components are installed in this project."));
|
|
309
|
+
setPhase("error");
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (projects.length === 1) {
|
|
313
|
+
const singleProject = projects[0];
|
|
314
|
+
setSelectedProject(singleProject);
|
|
315
|
+
const installedItems = getInstalledItemsForProject(proj, singleProject);
|
|
316
|
+
setItems(installedItems);
|
|
317
|
+
setPhase("select");
|
|
318
|
+
} else {
|
|
319
|
+
setPhase("select-project");
|
|
320
|
+
}
|
|
321
|
+
}).catch((err) => {
|
|
322
|
+
setError(err);
|
|
323
|
+
setPhase("error");
|
|
324
|
+
onError?.(err);
|
|
325
|
+
});
|
|
326
|
+
}, [phase, projectPromise, onError]);
|
|
327
|
+
useInput((input, key) => {
|
|
328
|
+
if (phase === "select-project") {
|
|
329
|
+
if (key.upArrow) {
|
|
330
|
+
setProjectCursor((prev) => prev > 0 ? prev - 1 : projectsWithInstalls.length - 1);
|
|
331
|
+
} else if (key.downArrow) {
|
|
332
|
+
setProjectCursor((prev) => prev < projectsWithInstalls.length - 1 ? prev + 1 : 0);
|
|
333
|
+
} else if (key.return) {
|
|
334
|
+
const selected = projectsWithInstalls[projectCursor];
|
|
335
|
+
if (selected && project) {
|
|
336
|
+
setSelectedProject(selected);
|
|
337
|
+
const installedItems = getInstalledItemsForProject(project, selected);
|
|
338
|
+
setItems(installedItems);
|
|
339
|
+
setCursor(0);
|
|
340
|
+
setSelectedIds(/* @__PURE__ */ new Set());
|
|
341
|
+
setPhase("select");
|
|
342
|
+
}
|
|
343
|
+
} else if (input === "q" || key.escape) {
|
|
344
|
+
exit();
|
|
345
|
+
}
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (phase !== "select") return;
|
|
349
|
+
if (key.upArrow) {
|
|
350
|
+
setCursor((prev) => prev > 0 ? prev - 1 : items.length - 1);
|
|
351
|
+
} else if (key.downArrow) {
|
|
352
|
+
setCursor((prev) => prev < items.length - 1 ? prev + 1 : 0);
|
|
353
|
+
} else if (input === " ") {
|
|
354
|
+
const item = items[cursor];
|
|
355
|
+
if (item) {
|
|
356
|
+
setSelectedIds((prev) => {
|
|
357
|
+
const next = new Set(prev);
|
|
358
|
+
if (next.has(item.id)) {
|
|
359
|
+
next.delete(item.id);
|
|
360
|
+
} else {
|
|
361
|
+
next.add(item.id);
|
|
362
|
+
}
|
|
363
|
+
return next;
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
} else if (input === "a") {
|
|
367
|
+
setSelectedIds(new Set(items.map((item) => item.id)));
|
|
368
|
+
} else if (input === "n") {
|
|
369
|
+
setSelectedIds(/* @__PURE__ */ new Set());
|
|
370
|
+
} else if (key.return) {
|
|
371
|
+
if (selectedIds.size === 0) {
|
|
372
|
+
exit();
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
if (skipConfirmation) {
|
|
376
|
+
finishSelection();
|
|
377
|
+
} else {
|
|
378
|
+
setPhase("confirm");
|
|
379
|
+
}
|
|
380
|
+
} else if ((input === "b" || key.leftArrow) && projectsWithInstalls.length > 1) {
|
|
381
|
+
setSelectedProject(null);
|
|
382
|
+
setPhase("select-project");
|
|
383
|
+
} else if (input === "q" || key.escape) {
|
|
384
|
+
exit();
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
const finishSelection = () => {
|
|
388
|
+
if (!project) return;
|
|
389
|
+
const selections = [];
|
|
390
|
+
const installerMap = /* @__PURE__ */ new Map();
|
|
391
|
+
for (const item of items) {
|
|
392
|
+
if (!selectedIds.has(item.id)) continue;
|
|
393
|
+
const existing = installerMap.get(item.installerId);
|
|
394
|
+
if (existing) {
|
|
395
|
+
existing.targets.push(item.target);
|
|
396
|
+
} else {
|
|
397
|
+
installerMap.set(item.installerId, {
|
|
398
|
+
installer: item.installer,
|
|
399
|
+
targets: [item.target]
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
for (const [, { installer, targets }] of installerMap) {
|
|
404
|
+
selections.push({
|
|
405
|
+
installer,
|
|
406
|
+
targets,
|
|
407
|
+
selected: true
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
onComplete(selections);
|
|
411
|
+
};
|
|
412
|
+
if (phase === "loading") {
|
|
413
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
414
|
+
/* @__PURE__ */ jsx(Header, { subtitle: "Remove" }),
|
|
415
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
416
|
+
/* @__PURE__ */ jsx(Spinner, {}),
|
|
417
|
+
/* @__PURE__ */ jsx(Text, { children: " Scanning project..." })
|
|
418
|
+
] })
|
|
419
|
+
] });
|
|
420
|
+
}
|
|
421
|
+
if (phase === "error") {
|
|
422
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
423
|
+
/* @__PURE__ */ jsx(Header, {}),
|
|
424
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
425
|
+
/* @__PURE__ */ jsx(Text, { color: "red", children: "\u2717 " }),
|
|
426
|
+
/* @__PURE__ */ jsx(Text, { color: "red", children: error?.message || "An unknown error occurred" })
|
|
427
|
+
] })
|
|
428
|
+
] });
|
|
429
|
+
}
|
|
430
|
+
if (phase === "select-project") {
|
|
431
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
432
|
+
/* @__PURE__ */ jsx(Header, { subtitle: "Remove" }),
|
|
433
|
+
/* @__PURE__ */ jsx(
|
|
434
|
+
ProjectSelector,
|
|
435
|
+
{
|
|
436
|
+
projects: projectsWithInstalls,
|
|
437
|
+
cursor: projectCursor,
|
|
438
|
+
onSelect: (selected) => {
|
|
439
|
+
if (project) {
|
|
440
|
+
setSelectedProject(selected);
|
|
441
|
+
const installedItems = getInstalledItemsForProject(project, selected);
|
|
442
|
+
setItems(installedItems);
|
|
443
|
+
setCursor(0);
|
|
444
|
+
setSelectedIds(/* @__PURE__ */ new Set());
|
|
445
|
+
setPhase("select");
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
onCancel: () => exit()
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
] });
|
|
452
|
+
}
|
|
453
|
+
if (phase === "select") {
|
|
454
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
455
|
+
/* @__PURE__ */ jsx(Header, { subtitle: "Remove" }),
|
|
456
|
+
/* @__PURE__ */ jsx(
|
|
457
|
+
SelectionList,
|
|
458
|
+
{
|
|
459
|
+
items,
|
|
460
|
+
selectedIds,
|
|
461
|
+
cursor,
|
|
462
|
+
selectedProject,
|
|
463
|
+
canGoBack: projectsWithInstalls.length > 1,
|
|
464
|
+
onBack: () => {
|
|
465
|
+
setSelectedProject(null);
|
|
466
|
+
setPhase("select-project");
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
] });
|
|
471
|
+
}
|
|
472
|
+
if (phase === "confirm") {
|
|
473
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
474
|
+
/* @__PURE__ */ jsx(Header, { subtitle: "Remove" }),
|
|
475
|
+
/* @__PURE__ */ jsx(
|
|
476
|
+
Confirmation,
|
|
477
|
+
{
|
|
478
|
+
items,
|
|
479
|
+
selectedIds,
|
|
480
|
+
dryRun,
|
|
481
|
+
onConfirm: finishSelection,
|
|
482
|
+
onBack: () => setPhase("select")
|
|
483
|
+
}
|
|
484
|
+
)
|
|
485
|
+
] });
|
|
486
|
+
}
|
|
487
|
+
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
|
|
488
|
+
/* @__PURE__ */ jsx(Header, {}),
|
|
489
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: "Loading..." })
|
|
490
|
+
] });
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
// src/commands/remove-ui.tsx
|
|
494
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
495
|
+
function limitList(items, max) {
|
|
496
|
+
if (items.length <= max) return items;
|
|
497
|
+
return [...items.slice(0, max), pc.dim(`\u2026and ${items.length - max} more`)];
|
|
498
|
+
}
|
|
499
|
+
function printRemoveReport(result) {
|
|
500
|
+
const failedActions = result.actionsPerformed.filter((r) => !r.success);
|
|
501
|
+
const okActions = result.actionsPerformed.filter((r) => r.success);
|
|
502
|
+
if (result.success) {
|
|
503
|
+
console.log(`
|
|
504
|
+
${pc.green("\u2713")} Removal completed successfully`);
|
|
505
|
+
} else {
|
|
506
|
+
console.log(`
|
|
507
|
+
${pc.yellow("\u26A0")} Removal completed with errors`);
|
|
508
|
+
}
|
|
509
|
+
const { summary } = result;
|
|
510
|
+
const modified = summary.filesModified;
|
|
511
|
+
const deleted = summary.filesDeleted;
|
|
512
|
+
if (modified.length + deleted.length > 0) {
|
|
513
|
+
console.log(`
|
|
514
|
+
${pc.bold("Files:")}`);
|
|
515
|
+
for (const p of limitList(modified, 20))
|
|
516
|
+
console.log(`- ${pc.yellow("~")} ${p}`);
|
|
517
|
+
for (const p of limitList(deleted, 20))
|
|
518
|
+
console.log(`- ${pc.red("-")} ${p}`);
|
|
519
|
+
}
|
|
520
|
+
if (failedActions.length > 0) {
|
|
521
|
+
console.log(`
|
|
522
|
+
${pc.bold(pc.red("Failures:"))}`);
|
|
523
|
+
for (const a of failedActions) {
|
|
524
|
+
const action = a.action;
|
|
525
|
+
const type = String(action.type || "unknown");
|
|
526
|
+
const pathish = typeof action.path === "string" && action.path || typeof action.projectPath === "string" && action.projectPath || typeof action.packagePath === "string" && action.packagePath || "";
|
|
527
|
+
console.error(`- ${type}${pathish ? ` (${pathish})` : ""}`);
|
|
528
|
+
if (a.error) console.error(` ${a.error}`);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
console.log(
|
|
532
|
+
pc.dim(
|
|
533
|
+
`
|
|
534
|
+
Summary: ${okActions.length} action(s) ok, ${failedActions.length} failed`
|
|
535
|
+
)
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
function buildRemovalPlan(selections, project) {
|
|
539
|
+
const actions = [];
|
|
540
|
+
for (const selection of selections) {
|
|
541
|
+
if (!selection.selected || selection.targets.length === 0) continue;
|
|
542
|
+
const { installer, targets } = selection;
|
|
543
|
+
if (installer.planRemove) {
|
|
544
|
+
const removePlan = installer.planRemove(targets, project);
|
|
545
|
+
actions.push(...removePlan.actions);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return actions;
|
|
549
|
+
}
|
|
550
|
+
function isInteractiveTerminal() {
|
|
551
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
552
|
+
}
|
|
553
|
+
async function removeUI(options = {}) {
|
|
554
|
+
const projectPath = process.cwd();
|
|
555
|
+
if (!isInteractiveTerminal()) {
|
|
556
|
+
console.error("\n\u2717 Interactive mode requires a TTY terminal.");
|
|
557
|
+
console.error("Run uilint remove in an interactive terminal.\n");
|
|
558
|
+
process.exit(1);
|
|
559
|
+
}
|
|
560
|
+
const projectPromise = analyze(projectPath);
|
|
561
|
+
const { waitUntilExit } = render(
|
|
562
|
+
/* @__PURE__ */ jsx2(
|
|
563
|
+
RemoveApp,
|
|
564
|
+
{
|
|
565
|
+
projectPromise,
|
|
566
|
+
skipConfirmation: options.yes,
|
|
567
|
+
dryRun: options.dryRun,
|
|
568
|
+
onComplete: async (selections) => {
|
|
569
|
+
const project = await projectPromise;
|
|
570
|
+
if (selections.length === 0) {
|
|
571
|
+
console.log("\nNo components selected for removal");
|
|
572
|
+
process.exit(0);
|
|
573
|
+
}
|
|
574
|
+
const actions = buildRemovalPlan(selections, project);
|
|
575
|
+
if (actions.length === 0) {
|
|
576
|
+
console.log("\nNo removal actions to perform");
|
|
577
|
+
process.exit(0);
|
|
578
|
+
}
|
|
579
|
+
const result = await execute(
|
|
580
|
+
{ actions, dependencies: [] },
|
|
581
|
+
{
|
|
582
|
+
dryRun: options.dryRun,
|
|
583
|
+
projectPath: project.projectPath
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
printRemoveReport(result);
|
|
587
|
+
process.exit(result.success ? 0 : 1);
|
|
588
|
+
},
|
|
589
|
+
onError: (error) => {
|
|
590
|
+
console.error("\n\u2717 Error:", error.message);
|
|
591
|
+
process.exit(1);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
)
|
|
595
|
+
);
|
|
596
|
+
await waitUntilExit();
|
|
597
|
+
}
|
|
598
|
+
export {
|
|
599
|
+
removeUI
|
|
600
|
+
};
|
|
601
|
+
//# sourceMappingURL=remove-ui-ZODRMK5G.js.map
|