ccperm 1.9.5 → 1.9.7
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/interactive.js +21 -7
- package/package.json +1 -1
package/dist/interactive.js
CHANGED
|
@@ -7,6 +7,21 @@ exports.startInteractive = startInteractive;
|
|
|
7
7
|
const node_readline_1 = __importDefault(require("node:readline"));
|
|
8
8
|
const colors_js_1 = require("./colors.js");
|
|
9
9
|
const explain_js_1 = require("./explain.js");
|
|
10
|
+
// Clean up messy bash permission labels for display
|
|
11
|
+
function cleanLabel(label) {
|
|
12
|
+
let s = label;
|
|
13
|
+
// Strip __NEW_LINE_hash__ prefix
|
|
14
|
+
s = s.replace(/^__NEW_LINE_[a-f0-9]+__\s*/, '');
|
|
15
|
+
// Truncate heredoc content: "python3 << 'EOF'\nimport..." → "python3 (heredoc)"
|
|
16
|
+
if (s.includes('<<'))
|
|
17
|
+
s = s.replace(/\s*<<\s*['"]?\w+['"]?.*$/, ' (heredoc)');
|
|
18
|
+
// Truncate inline scripts with \n
|
|
19
|
+
if (s.includes('\\n'))
|
|
20
|
+
s = s.replace(/\\n.*$/, '…');
|
|
21
|
+
// Strip :* and trailing * suffix
|
|
22
|
+
s = s.replace(/:\*$/, ' *');
|
|
23
|
+
return s;
|
|
24
|
+
}
|
|
10
25
|
// strip ANSI escape codes for visible length
|
|
11
26
|
function visLen(s) {
|
|
12
27
|
return s.replace(/\x1b\[[0-9;]*m/g, '').length;
|
|
@@ -183,18 +198,17 @@ function renderDetail(state, withPerms, results) {
|
|
|
183
198
|
navRows.push({ text: `${colors_js_1.YELLOW}${arrow} ${group.category}${colors_js_1.NC} ${colors_js_1.DIM}(${group.items.length})${colors_js_1.NC}`, key });
|
|
184
199
|
if (isOpen) {
|
|
185
200
|
for (const item of group.items) {
|
|
201
|
+
const clean = cleanLabel(item.name);
|
|
186
202
|
if (state.showInfo) {
|
|
187
203
|
const info = (0, explain_js_1.explain)(group.category, item.name);
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const desc = info.description ?
|
|
191
|
-
|
|
192
|
-
const name = item.name.length > maxLen ? item.name.slice(0, Math.max(8, maxLen) - 1) + '…' : item.name;
|
|
193
|
-
navRows.push({ text: ` ${dot} ${name}${desc}`, perm: item.name });
|
|
204
|
+
const nameMax = Math.min(35, w - 10);
|
|
205
|
+
const name = clean.length > nameMax ? clean.slice(0, nameMax - 1) + '…' : clean;
|
|
206
|
+
const desc = info.description ? `${colors_js_1.DIM}${info.description}${colors_js_1.NC}` : '';
|
|
207
|
+
navRows.push({ text: ` ${pad(name, nameMax)} ${desc}`, perm: item.name });
|
|
194
208
|
}
|
|
195
209
|
else {
|
|
196
210
|
const maxLen = w - 8;
|
|
197
|
-
const name =
|
|
211
|
+
const name = clean.length > maxLen ? clean.slice(0, maxLen - 1) + '…' : clean;
|
|
198
212
|
navRows.push({ text: ` ${colors_js_1.DIM}${name}${colors_js_1.NC}`, perm: item.name });
|
|
199
213
|
}
|
|
200
214
|
}
|