[Request] Prompts global settings
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- node.js, typescript
- 領域
- cli
調査の方向性
packages/prompts/src/common.ts の CommonOptions 定義から始め、prompt の export と出力オプションがどのように接続されているかを確認してください。issue には bin/index.ts の wrapper の使用例も示されています。プロジェクトに、フォーマット、出力のインデント、そして任意でシンボルを設定するための合意済みのグローバル設定 API があり、動作が要求された例と一致すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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! ❤️
- 主要言語
- TypeScript
- スター
- 8.1k
- フォーク
- 218
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bombshell-dev/clack のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
bombshell-dev/clack#613 · コメント 4 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
bombshell-dev/clack#597 ·
-
rfc: accessible modeオープンenhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
bombshell-dev/clack#585 · コメント 1 件 · リアクション 1 件 ·
-
[Bug] Spinner does not run `onCancel` function on `Ctrl + C`対応中かも @cyphercodes が 103 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
bombshell-dev/clack#573 · コメント 1 件 · リアクション 2 件 ·
-
enhancement
難易度 3/5 1〜2日 初心者へのやさしさ 62/100
bombshell-dev/clack#565 · コメント 1 件 · リアクション 1 件 ·
bombshell-dev/clack の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
openwatersio/slackwater-database#281 ·
メンテナーはふだん 1 日以内に返信
-
accepted bug via-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
pingdotgg/t3code#18690 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Bayern feature:Application ready web
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
digitalfabrik/entitlementcard#3176 ·
メンテナーはふだん 7 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NanmiCoder/cc-haha#1533 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信