[Request] Prompts global settings
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- node.js, typescript
- Área
- cli
Línea de trabajo
Comienza con la definición de CommonOptions en packages/prompts/src/common.ts e inspecciona cómo están conectadas las exportaciones de prompts y las opciones de salida; el issue también muestra el uso del wrapper de bin/index.ts. Se considera completado cuando el proyecto tenga una API de configuración global acordada para el formato, la indentación de la salida y, opcionalmente, los símbolos, con un comportamiento que coincida con los ejemplos solicitados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
version:
"@clack/prompts": "1.0.0-alpha.4",
Is your feature request related to a problem? Please describe.
I'd like to introduce a simple manageable way of overriding default config values (CommonOptions) for consistent formatting changes.
For example i'm not very happy with the indentation of the symbol bars, because they appear far too close to the terminal edge and I'd like to add an extra whitespace before the console lines. i.e.
# before:
┌ Unfortunately we encountered the following error:
│
■ Directory ./x does not exist. Either cd to a valid directory or correct the --path option
# after:
┌ Unfortunately we encountered the following error:
│
■ Directory ./x does not exist. Either cd to a valid directory or correct the --path option
Describe the solution you'd like
I'd like a single settings that allows for a builder-like approach to ideally re-export the individual prompts:
i.e.
const { log, intro, outro } = prompts({
output: (buffer: Uint8Array | string) => ` ${buffer}`
})
Describe alternatives you've considered
Right now I've sort of hackishly created a folder named /prompts where I'm re-exporting individual exports from @clack/prompts in a following manner:
Here's a select for example:
// output.ts
import { Writable } from "node:stream"
export const output = new Writable({
write: (chunk, encoding, callback) => {
process.stdout.write(` ${chunk}`)
callback()
},
})
And then let's say in my outro (to keep it simple):
import { outro as cOutro } from "@clack/prompts"
import { output } from "./output"
export const outro = (msg: string) => cOutro(msg, { output })
That's fairly straightforward, here's a bit more annoying example:
import { log as cLog } from "@clack/prompts"
import type { LogMessageOptions } from "@clack/prompts"
import { output } from "./output"
export const log = {
message: (message?: string | string[], opts?: LogMessageOptions) =>
cLog.message(message, { ...opts, output }),
info: (message: string, opts?: LogMessageOptions) =>
cLog.info(message, { ...opts, output }),
success: (message: string, opts?: LogMessageOptions) =>
cLog.success(message, { ...opts, output }),
step: (message: string, opts?: LogMessageOptions) =>
cLog.step(message, { ...opts, output }),
warn: (message: string, opts?: LogMessageOptions) =>
cLog.warn(message, { ...opts, output }),
warning: (message: string, opts?: LogMessageOptions) =>
cLog.warning(message, { ...opts, output }),
error: (message: string, opts?: LogMessageOptions) =>
cLog.error(message, { ...opts, output }),
} satisfies typeof cLog
Then I've introduced the following eslint rule to block direct imports from @clack/promtps (technically this step is optional, but I want to illiustrate poignantly just how cumbersome this can be to setup in a codebase that's shared across multiple people and is supposed to scale)
// eslint.config.mjs
{
// ... rest of config
{
rules: {
"@typescript-eslint/no-restricted-imports": [
"error",
{
paths: [
{
name: "@clack/prompts",
message:
"Direct imports from @clack/prompts are only allowed in src/prompts directory. Use the wrapper functions from src/prompts instead.",
},
],
},
],
},
},
{
files: ["src/prompts/**/*"],
rules: {
"@typescript-eslint/no-restricted-imports": "off",
},
}
}
And then finally - let's say in my bin/index.ts file
import { intro } from "@/prompts/intro"
intro("example")
Additional context
Now this works somewhat nicely, but even with this you quick run into issues like newlines, i.e.:
Maybe for the sake of simplicity it would be nice to expose something different like indent: number and let @clack/prompts take care of the formatting
Also it would be nice to be able to customize the bars/symbols directly from the prompts({}) config directly for advanced users
PS: Thank you very much for all the hard work you guys are putting in, really looking forward to the v1. Keep up the great work! ❤️
- Lenguaje dominante
- TypeScript
- Estrellas
- 8.1k
- Forks
- 218
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bombshell-dev/clack
-
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
bombshell-dev/clack#613 · 4 comentarios ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
bombshell-dev/clack#597 ·
-
rfc: accessible modeAbiertoenhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
bombshell-dev/clack#585 · 1 comentario · 1 reacción ·
-
[Bug] Spinner does not run `onCancel` function on `Ctrl + C`Posiblemente ocupada @cyphercodes la tomó hace 103 días. Abiertobug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
bombshell-dev/clack#573 · 1 comentario · 2 reacciones ·
-
enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
bombshell-dev/clack#565 · 1 comentario · 1 reacción ·
Todos los issues de bombshell-dev/clack
Issues similares
-
Bayern feature:Application ready web
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
digitalfabrik/entitlementcard#3176 ·
Los mantenedores suelen responder en 7 días
-
[BUG] 运行位置的分支列表不自动刷新,外部新建的分支看不到Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
NanmiCoder/cc-haha#1533 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
🐛 Bug: Calendar work items cannot be opened on mobilePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100