@emeryld/manager 0.6.7 → 0.7.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.
- package/dist/helper-cli/prompts.js +38 -28
- package/dist/menu/script-helpers.js +12 -14
- package/dist/menu.js +29 -10
- package/package.json +1 -1
|
@@ -101,12 +101,12 @@ function formatInteractiveLines(state, selectedIndex, title, searchState) {
|
|
|
101
101
|
lines.push(colors.yellow('No scripts match your search.'));
|
|
102
102
|
}
|
|
103
103
|
lines.push('');
|
|
104
|
-
lines.push(colors.dim(`Use ↑/↓ (or j/k) to move, 1-${PAGE_SIZE} to run, ${PREVIOUS_KEY} prev page (when shown), ${NEXT_KEY} next page (when shown), ${BACK_KEY} back, Enter to
|
|
104
|
+
lines.push(colors.dim(`Use ↑/↓ (or j/k) to move, 1-${PAGE_SIZE} to run, ${PREVIOUS_KEY} prev page (when shown), ${NEXT_KEY} next page (when shown), ${BACK_KEY} back, Enter to run, Space to filter, Esc/Ctrl+C to exit.`));
|
|
105
105
|
if (searchState?.active) {
|
|
106
|
-
lines.push(colors.dim('Search mode: type to filter, Backspace
|
|
106
|
+
lines.push(colors.dim('Search mode: type to filter, Backspace edits the query, Esc returns to navigation, Enter runs the highlighted entry.'));
|
|
107
107
|
}
|
|
108
108
|
else {
|
|
109
|
-
lines.push(colors.dim('Press
|
|
109
|
+
lines.push(colors.dim('Press Space to start typing a filter.'));
|
|
110
110
|
}
|
|
111
111
|
return lines;
|
|
112
112
|
}
|
|
@@ -258,35 +258,21 @@ export async function promptForScript(entries, title) {
|
|
|
258
258
|
const isEscape = buffer.length === 1 && buffer[0] === 0x1b;
|
|
259
259
|
const isBackspace = buffer.length === 1 && (buffer[0] === 0x7f || buffer[0] === 0x08);
|
|
260
260
|
const isPrintable = buffer.length === 1 && buffer[0] >= 0x20 && buffer[0] <= 0x7e;
|
|
261
|
-
|
|
261
|
+
const isSpace = buffer.length === 1 && buffer[0] === 0x20;
|
|
262
|
+
if (isCtrlC) {
|
|
262
263
|
cleanup();
|
|
263
264
|
process.exit(1);
|
|
264
265
|
}
|
|
265
|
-
if (
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
commitSelection(filteredEntries[0]);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
process.stdout.write('\x07');
|
|
272
|
-
}
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
if (isBackspace) {
|
|
276
|
-
if (searchQuery.length > 0) {
|
|
277
|
-
searchQuery = searchQuery.slice(0, -1);
|
|
278
|
-
applySearch();
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
exitSearchMode();
|
|
282
|
-
}
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
if (isPrintable) {
|
|
286
|
-
searchQuery += String.fromCharCode(buffer[0]);
|
|
287
|
-
applySearch();
|
|
266
|
+
if (isEscape) {
|
|
267
|
+
if (searchActive) {
|
|
268
|
+
exitSearchMode();
|
|
288
269
|
return;
|
|
289
270
|
}
|
|
271
|
+
cleanup();
|
|
272
|
+
process.exit(1);
|
|
273
|
+
}
|
|
274
|
+
if (!searchActive && isSpace) {
|
|
275
|
+
enterSearchMode();
|
|
290
276
|
return;
|
|
291
277
|
}
|
|
292
278
|
if (isArrowUp ||
|
|
@@ -303,7 +289,29 @@ export async function promptForScript(entries, title) {
|
|
|
303
289
|
return;
|
|
304
290
|
}
|
|
305
291
|
if (isEnter) {
|
|
306
|
-
|
|
292
|
+
const option = state.options[selectedIndex];
|
|
293
|
+
if (option)
|
|
294
|
+
activateOption(option);
|
|
295
|
+
else
|
|
296
|
+
process.stdout.write('\x07');
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (searchActive) {
|
|
300
|
+
if (isBackspace) {
|
|
301
|
+
if (searchQuery.length > 0) {
|
|
302
|
+
searchQuery = searchQuery.slice(0, -1);
|
|
303
|
+
applySearch();
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
//exitSearchMode()
|
|
307
|
+
}
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
if (isPrintable) {
|
|
311
|
+
searchQuery += String.fromCharCode(buffer[0]);
|
|
312
|
+
applySearch();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
307
315
|
return;
|
|
308
316
|
}
|
|
309
317
|
if (buffer.length === 1 && buffer[0] >= 0x30 && buffer[0] <= 0x39) {
|
|
@@ -329,7 +337,9 @@ export async function promptForScript(entries, title) {
|
|
|
329
337
|
else {
|
|
330
338
|
process.stdout.write('\x07');
|
|
331
339
|
}
|
|
340
|
+
return;
|
|
332
341
|
}
|
|
342
|
+
process.stdout.write('\x07');
|
|
333
343
|
};
|
|
334
344
|
input.on('data', onData);
|
|
335
345
|
render();
|
|
@@ -191,26 +191,24 @@ export function makeBaseScriptEntries(pkg) {
|
|
|
191
191
|
const scripts = pkg.json?.scripts ?? {};
|
|
192
192
|
const dependencies = collectDependencies(pkg);
|
|
193
193
|
const marker = getPackageMarker(pkg, dependencies);
|
|
194
|
-
return BASE_SCRIPT_KEYS.
|
|
194
|
+
return BASE_SCRIPT_KEYS.reduce((entries, key) => {
|
|
195
195
|
const resolution = resolveBaseScript(pkg, key, scripts, dependencies, marker.kind);
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
const args = resolution.args;
|
|
197
|
+
if (!resolution.available || !args)
|
|
198
|
+
return entries;
|
|
199
|
+
const description = resolution.isDefault
|
|
200
|
+
? `${resolution.description} (default)`
|
|
201
|
+
: resolution.description;
|
|
202
|
+
entries.push({
|
|
202
203
|
name: key,
|
|
203
204
|
emoji: '⚡️',
|
|
204
205
|
description,
|
|
205
206
|
handler: async () => {
|
|
206
|
-
|
|
207
|
-
console.log(colors.yellow(`No ${key} command found for ${pkg.name}.`));
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
await run('pnpm', resolution.args, { cwd: pkg.path });
|
|
207
|
+
await run('pnpm', args, { cwd: pkg.path });
|
|
211
208
|
},
|
|
212
|
-
};
|
|
213
|
-
|
|
209
|
+
});
|
|
210
|
+
return entries;
|
|
211
|
+
}, []);
|
|
214
212
|
}
|
|
215
213
|
export function getPackageMarker(pkg, dependencies = collectDependencies(pkg)) {
|
|
216
214
|
const normalizedDeps = new Set([...dependencies].map((dep) => String(dep).toLowerCase().trim()));
|
package/dist/menu.js
CHANGED
|
@@ -145,17 +145,37 @@ export function buildPackageSelectionMenu(packages, onStepComplete) {
|
|
|
145
145
|
const ordered = getOrderedPackages(packages);
|
|
146
146
|
const entries = ordered.map((pkg) => {
|
|
147
147
|
const marker = getPackageMarker(pkg);
|
|
148
|
-
const
|
|
149
|
-
const
|
|
150
|
-
const
|
|
148
|
+
const primaryName = pkg.name ?? pkg.substitute ?? pkg.dirName;
|
|
149
|
+
const packageColorizer = colors[pkg.color ?? 'cyan'] ?? colors.cyan;
|
|
150
|
+
const highlightedName = packageColorizer(primaryName);
|
|
151
|
+
const tagParts = [];
|
|
152
|
+
const addTag = (value, colorizer) => {
|
|
153
|
+
if (!value)
|
|
154
|
+
return;
|
|
155
|
+
tagParts.push(colorizer(`[${value}]`));
|
|
156
|
+
};
|
|
157
|
+
const relativePath = pkg.relativeDir ?? pkg.dirName;
|
|
158
|
+
if (relativePath && relativePath !== '.') {
|
|
159
|
+
addTag(relativePath, colors.gray);
|
|
160
|
+
}
|
|
161
|
+
if (pkg.version) {
|
|
162
|
+
addTag(`v${pkg.version}`, colors.yellow);
|
|
163
|
+
}
|
|
164
|
+
if (pkg.substitute && pkg.substitute !== primaryName) {
|
|
165
|
+
const aliasTag = pkg.name ? `alias:${pkg.substitute}` : pkg.substitute;
|
|
166
|
+
addTag(aliasTag, colors.magenta);
|
|
167
|
+
}
|
|
168
|
+
if (pkg.dockerfilePath) {
|
|
169
|
+
addTag('docker', colors.green);
|
|
170
|
+
}
|
|
151
171
|
const kindLabel = formatKindLabel(marker.kind);
|
|
152
|
-
|
|
153
|
-
const
|
|
172
|
+
addTag(kindLabel, marker.kindColorize);
|
|
173
|
+
const labelWord = marker.label ? ` ${marker.colorize(marker.label)}` : '';
|
|
174
|
+
const tags = tagParts.length ? ` ${tagParts.join(' ')}` : '';
|
|
154
175
|
return {
|
|
155
|
-
name:
|
|
156
|
-
emoji:
|
|
157
|
-
description:
|
|
158
|
-
color: pkgColor,
|
|
176
|
+
name: `${highlightedName}${tags}${labelWord}`,
|
|
177
|
+
emoji: '',
|
|
178
|
+
description: pkg.json?.description ?? pkg.relativeDir ?? pkg.dirName,
|
|
159
179
|
handler: async () => {
|
|
160
180
|
const step = await runStepLoop([pkg], packages);
|
|
161
181
|
onStepComplete?.(step);
|
|
@@ -166,7 +186,6 @@ export function buildPackageSelectionMenu(packages, onStepComplete) {
|
|
|
166
186
|
return entries;
|
|
167
187
|
entries.push({
|
|
168
188
|
name: 'All packages',
|
|
169
|
-
color: 'gray',
|
|
170
189
|
emoji: globalEmoji,
|
|
171
190
|
description: 'Select all packages',
|
|
172
191
|
handler: async () => {
|