difit 4.0.7 → 5.0.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/README.ja.md +1 -2
- package/README.ko.md +1 -2
- package/README.md +6 -2
- package/README.zh.md +1 -2
- package/dist/cli/index.js +0 -35
- package/dist/cli/index.test.js +0 -264
- package/dist/cli/utils.d.ts +0 -2
- package/dist/cli/utils.js +1 -18
- package/dist/cli/utils.test.js +0 -16
- package/dist/client/assets/{arc-DX2p9X2Y.js → arc-DbOd2jxV.js} +1 -1
- package/dist/client/assets/architecture-YZFGNWBL-0n2ZLuLj.js +1 -0
- package/dist/client/assets/{architectureDiagram-Q4EWVU46-FixTWViB.js → architectureDiagram-Q4EWVU46-BFXI_tUS.js} +1 -1
- package/dist/client/assets/{blockDiagram-DXYQGD6D-CUAMgGr9.js → blockDiagram-DXYQGD6D-BOEZDsFe.js} +1 -1
- package/dist/client/assets/{c4Diagram-AHTNJAMY-BM_HNNZe.js → c4Diagram-AHTNJAMY-BdIoPSTS.js} +1 -1
- package/dist/client/assets/channel-DPag0OPA.js +1 -0
- package/dist/client/assets/{chunk-2KRD3SAO-DeT59g2K.js → chunk-2KRD3SAO-BaHSMZbk.js} +1 -1
- package/dist/client/assets/{chunk-336JU56O-CaGvJA86.js → chunk-336JU56O-BGfMTguc.js} +2 -2
- package/dist/client/assets/chunk-426QAEUC-Ct2OJ1s3.js +1 -0
- package/dist/client/assets/{chunk-4BX2VUAB-D9mNDl5f.js → chunk-4BX2VUAB-CNkIhTNe.js} +1 -1
- package/dist/client/assets/{chunk-4TB4RGXK-Df3b4HEG.js → chunk-4TB4RGXK-wFMAN-Ug.js} +1 -1
- package/dist/client/assets/{chunk-55IACEB6-dCWLe_n4.js → chunk-55IACEB6-J_10GkPG.js} +1 -1
- package/dist/client/assets/{chunk-5FUZZQ4R-EScvXcSN.js → chunk-5FUZZQ4R-0NY9W0kL.js} +1 -1
- package/dist/client/assets/{chunk-5PVQY5BW-ail-oj89.js → chunk-5PVQY5BW-nUEO-vub.js} +1 -1
- package/dist/client/assets/{chunk-67CJDMHE-CHeCIL1u.js → chunk-67CJDMHE-CpK_DCjw.js} +1 -1
- package/dist/client/assets/{chunk-7N4EOEYR-P0tNRVMZ.js → chunk-7N4EOEYR-CJfX2SRB.js} +1 -1
- package/dist/client/assets/{chunk-AA7GKIK3-DloBHWSo.js → chunk-AA7GKIK3-DGHjDQX4.js} +1 -1
- package/dist/client/assets/{chunk-BSJP7CBP-CGLThsR8.js → chunk-BSJP7CBP-DiXS795w.js} +1 -1
- package/dist/client/assets/{chunk-CIAEETIT-rCt2IEMp.js → chunk-CIAEETIT-DaOGL_z8.js} +1 -1
- package/dist/client/assets/{chunk-EDXVE4YY-DIJEIKIq.js → chunk-EDXVE4YY-EPdmphYw.js} +1 -1
- package/dist/client/assets/{chunk-ENJZ2VHE-CdrdxFfV.js → chunk-ENJZ2VHE-9x7-Qpzy.js} +1 -1
- package/dist/client/assets/{chunk-FMBD7UC4-BH_GgR9u.js → chunk-FMBD7UC4-Dgx4um1Q.js} +1 -1
- package/dist/client/assets/{chunk-FOC6F5B3-D71VljSN.js → chunk-FOC6F5B3-BaVe0aqm.js} +1 -1
- package/dist/client/assets/{chunk-ICPOFSXX-2vcQKuhB.js → chunk-ICPOFSXX-C9l3r2YR.js} +1 -1
- package/dist/client/assets/{chunk-K5T4RW27-BWIFd7pZ.js → chunk-K5T4RW27-Bv0dnd8C.js} +1 -1
- package/dist/client/assets/{chunk-KGLVRYIC-Ck8I8tdt.js → chunk-KGLVRYIC-BdTDi9hU.js} +1 -1
- package/dist/client/assets/{chunk-LIHQZDEY-Cc7TtI-w.js → chunk-LIHQZDEY-BEYvjNoB.js} +1 -1
- package/dist/client/assets/{chunk-ORNJ4GCN-BMSqiphc.js → chunk-ORNJ4GCN-CHeeoEx_.js} +1 -1
- package/dist/client/assets/{chunk-OYMX7WX6-B5faFb53.js → chunk-OYMX7WX6-Bapbqtyc.js} +1 -1
- package/dist/client/assets/chunk-QZHKN3VN-CNqVW4m2.js +1 -0
- package/dist/client/assets/{chunk-U2HBQHQK-BILTfRyq.js → chunk-U2HBQHQK-CpVfEbNc.js} +1 -1
- package/dist/client/assets/{chunk-X2U36JSP-D4-56gWx.js → chunk-X2U36JSP-BAcfna0L.js} +1 -1
- package/dist/client/assets/{chunk-XPW4576I-SxB401Zg.js → chunk-XPW4576I-D0wrDPCQ.js} +1 -1
- package/dist/client/assets/{chunk-YZCP3GAM-CWXUVxFj.js → chunk-YZCP3GAM-D_AeoI3D.js} +1 -1
- package/dist/client/assets/{chunk-ZZ45TVLE-CXjZua4f.js → chunk-ZZ45TVLE-CwpZ5yb7.js} +1 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-aX3PLX0y.js +1 -0
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-CshAcrwe.js +1 -0
- package/dist/client/assets/clone-J5cJUwR3.js +1 -0
- package/dist/client/assets/{cose-bilkent-S5V4N54A-YToNpueF.js → cose-bilkent-S5V4N54A-DJvkrscF.js} +1 -1
- package/dist/client/assets/{dagre-tvaMpP4D.js → dagre-BADyoi72.js} +1 -1
- package/dist/client/assets/{dagre-KV5264BT-QFYoTa0z.js → dagre-KV5264BT-BDTirpEd.js} +1 -1
- package/dist/client/assets/{diagram-5BDNPKRD-DM0NNmEN.js → diagram-5BDNPKRD-CJSn8eie.js} +1 -1
- package/dist/client/assets/{diagram-G4DWMVQ6-TiLkMmwt.js → diagram-G4DWMVQ6-COzN0wAe.js} +1 -1
- package/dist/client/assets/{diagram-MMDJMWI5-DM1ykqrB.js → diagram-MMDJMWI5-Bau__Yfk.js} +1 -1
- package/dist/client/assets/{diagram-TYMM5635-BEOLX1wr.js → diagram-TYMM5635-DKIgp_-m.js} +1 -1
- package/dist/client/assets/{dist-CCBhd9az.js → dist-CL_sSZWx.js} +1 -1
- package/dist/client/assets/{erDiagram-SMLLAGMA-DZcjZq6z.js → erDiagram-SMLLAGMA-Iw0m0edr.js} +1 -1
- package/dist/client/assets/{flowDiagram-DWJPFMVM-B1AVT9es.js → flowDiagram-DWJPFMVM-CtXQs1rX.js} +1 -1
- package/dist/client/assets/{ganttDiagram-T4ZO3ILL-BCEXws9V.js → ganttDiagram-T4ZO3ILL-B0341I_2.js} +1 -1
- package/dist/client/assets/gitGraph-7Q5UKJZL-NWgYXB7y.js +1 -0
- package/dist/client/assets/{gitGraphDiagram-UUTBAWPF-CVznBDOl.js → gitGraphDiagram-UUTBAWPF-Yv3oicIa.js} +1 -1
- package/dist/client/assets/{graphlib-C4fWcyt1.js → graphlib-BLiSTux3.js} +1 -1
- package/dist/client/assets/{index-6LShOAAb.js → index-C2jd9xpN.js} +6 -6
- package/dist/client/assets/{index-C16wNcPQ.css → index-v-PY_jQI.css} +1 -1
- package/dist/client/assets/info-OMHHGYJF-Bvc7BWzq.js +1 -0
- package/dist/client/assets/{infoDiagram-42DDH7IO-D8Oxr-KJ.js → infoDiagram-42DDH7IO-Cfjrwz2v.js} +1 -1
- package/dist/client/assets/{ishikawaDiagram-UXIWVN3A-BE9KniVE.js → ishikawaDiagram-UXIWVN3A-Cc-jozqB.js} +1 -1
- package/dist/client/assets/{journeyDiagram-VCZTEJTY-B3lGcz06.js → journeyDiagram-VCZTEJTY-Bjx1sC-s.js} +1 -1
- package/dist/client/assets/{kanban-definition-6JOO6SKY-Bs1QdB0j.js → kanban-definition-6JOO6SKY-CIkJYslO.js} +1 -1
- package/dist/client/assets/{line-CO4-KhEq.js → line-yxqmb99x.js} +1 -1
- package/dist/client/assets/{linear-CnaJKs0I.js → linear-DCAQGlgU.js} +1 -1
- package/dist/client/assets/{mermaid-parser.core-CravK6bS.js → mermaid-parser.core-B5ufZrv2.js} +2 -2
- package/dist/client/assets/{mermaid.core-DTh9KJvF.js → mermaid.core-BFOnV1aK.js} +3 -3
- package/dist/client/assets/{mindmap-definition-QFDTVHPH-D2xU2hfX.js → mindmap-definition-QFDTVHPH-CPflWkUN.js} +1 -1
- package/dist/client/assets/packet-4T2RLAQJ-DNpLsp8v.js +1 -0
- package/dist/client/assets/pie-ZZUOXDRM-D8uToFEL.js +1 -0
- package/dist/client/assets/{pieDiagram-DEJITSTG-CRX6y4IQ.js → pieDiagram-DEJITSTG-Dl3gScVb.js} +1 -1
- package/dist/client/assets/{quadrantDiagram-34T5L4WZ-K2HFp8O8.js → quadrantDiagram-34T5L4WZ-38YyGeXU.js} +1 -1
- package/dist/client/assets/radar-PYXPWWZC-VrpLp1jL.js +1 -0
- package/dist/client/assets/{requirementDiagram-MS252O5E-C-8AW0uI.js → requirementDiagram-MS252O5E-CZW6zJs_.js} +1 -1
- package/dist/client/assets/{sankeyDiagram-XADWPNL6-Bv-_ZFS5.js → sankeyDiagram-XADWPNL6-D4r0GNlW.js} +1 -1
- package/dist/client/assets/{sequenceDiagram-FGHM5R23-Bk4QYIPk.js → sequenceDiagram-FGHM5R23-2xItvAxs.js} +1 -1
- package/dist/client/assets/{src-XMuEuFcU.js → src-YK4ClFOB.js} +1 -1
- package/dist/client/assets/{stateDiagram-FHFEXIEX-CI1G7zGC.js → stateDiagram-FHFEXIEX-lBViG7kM.js} +1 -1
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-BcU-AM4S.js +1 -0
- package/dist/client/assets/{timeline-definition-GMOUNBTQ-CnXv8xHg.js → timeline-definition-GMOUNBTQ-DmlaOXs4.js} +1 -1
- package/dist/client/assets/treeView-SZITEDCU-B1qc9ijP.js +1 -0
- package/dist/client/assets/treemap-W4RFUUIX-Dl7yWWae.js +1 -0
- package/dist/client/assets/{vennDiagram-DHZGUBPP-M5x471Ar.js → vennDiagram-DHZGUBPP-BOLv0A8q.js} +1 -1
- package/dist/client/assets/wardley-RL74JXVD-CEXd-1Ht.js +1 -0
- package/dist/client/assets/{wardleyDiagram-NUSXRM2D-BG99uPNN.js → wardleyDiagram-NUSXRM2D-B5lHUuTU.js} +1 -1
- package/dist/client/assets/{xychartDiagram-5P7HB3ND-DO7Upr9G.js → xychartDiagram-5P7HB3ND-D8nLdJo8.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/types/diff.d.ts +0 -10
- package/dist/utils/commentFormatting.test.js +0 -52
- package/package.json +4 -5
- package/dist/cli/tuiDeprecation.d.ts +0 -3
- package/dist/cli/tuiDeprecation.js +0 -16
- package/dist/cli/tuiDeprecation.test.d.ts +0 -1
- package/dist/cli/tuiDeprecation.test.js +0 -16
- package/dist/client/assets/architecture-YZFGNWBL-2zVtKbnG.js +0 -1
- package/dist/client/assets/channel-B_ddQhpW.js +0 -1
- package/dist/client/assets/chunk-426QAEUC-CMTCMPn4.js +0 -1
- package/dist/client/assets/chunk-QZHKN3VN-B-G9G-FB.js +0 -1
- package/dist/client/assets/classDiagram-6PBFFD2Q-DnUQ2iGN.js +0 -1
- package/dist/client/assets/classDiagram-v2-HSJHXN6E-Dwp5vuOB.js +0 -1
- package/dist/client/assets/clone-aWrl-obY.js +0 -1
- package/dist/client/assets/gitGraph-7Q5UKJZL-BE3Mcr-v.js +0 -1
- package/dist/client/assets/info-OMHHGYJF-CBpXVhw-.js +0 -1
- package/dist/client/assets/packet-4T2RLAQJ-abaJ3V5T.js +0 -1
- package/dist/client/assets/pie-ZZUOXDRM-B12dpA7V.js +0 -1
- package/dist/client/assets/radar-PYXPWWZC-BbBaJJN8.js +0 -1
- package/dist/client/assets/stateDiagram-v2-QKLJ7IA2-DQ0U-oto.js +0 -1
- package/dist/client/assets/treeView-SZITEDCU-CM0rCBUc.js +0 -1
- package/dist/client/assets/treemap-W4RFUUIX-CXoNE_rL.js +0 -1
- package/dist/client/assets/wardley-RL74JXVD-B_EtnvOk.js +0 -1
- package/dist/server/git-diff-tui.d.ts +0 -2
- package/dist/server/git-diff-tui.js +0 -100
- package/dist/server/git-diff-tui.test.d.ts +0 -1
- package/dist/server/git-diff-tui.test.js +0 -76
- package/dist/tui/App.d.ts +0 -10
- package/dist/tui/App.js +0 -92
- package/dist/tui/components/DiffViewer.d.ts +0 -8
- package/dist/tui/components/DiffViewer.js +0 -88
- package/dist/tui/components/FileList.d.ts +0 -8
- package/dist/tui/components/FileList.js +0 -48
- package/dist/tui/components/SideBySideDiffViewer.d.ts +0 -9
- package/dist/tui/components/SideBySideDiffViewer.js +0 -240
- package/dist/tui/components/StatusBar.d.ts +0 -8
- package/dist/tui/components/StatusBar.js +0 -19
- package/dist/tui/utils/parseDiff.d.ts +0 -2
- package/dist/tui/utils/parseDiff.js +0 -67
- package/dist/utils/createId.test.d.ts +0 -1
- package/dist/utils/createId.test.js +0 -48
package/README.ja.md
CHANGED
|
@@ -131,7 +131,7 @@ git diff --cached | difit -
|
|
|
131
131
|
標準入力モードは、意図を優先して次のルールで選択されます。
|
|
132
132
|
|
|
133
133
|
- `-` を指定した場合は常に標準入力モード
|
|
134
|
-
- positional 引数(`<target>` / `[compare-with]
|
|
134
|
+
- positional 引数(`<target>` / `[compare-with]`)または `--pr` がある場合は Git/PR モードとして扱い、標準入力を自動読み取りしない
|
|
135
135
|
- 明示モード指定がない場合のみ、stdin が pipe/file/socket のときに自動で標準入力モードになる
|
|
136
136
|
|
|
137
137
|
## ⚙️ CLIオプション
|
|
@@ -147,7 +147,6 @@ git diff --cached | difit -
|
|
|
147
147
|
| `--host` | 127.0.0.1 | サーバーをバインドするホストアドレス(外部からアクセスしたい場合は0.0.0.0を指定) |
|
|
148
148
|
| `--no-open` | false | ブラウザを自動的に開かない |
|
|
149
149
|
| `--mode` | split | 表示モード。`unified`または`split` |
|
|
150
|
-
| `--tui` (deprecated) | false | WebUIの代わりにターミナルUIを使用 |
|
|
151
150
|
| `--clean` | false | 起動時に既存コメントと閲覧済みファイルをすべてクリア |
|
|
152
151
|
| `--include-untracked` | false | diffにuntrackedファイルを自動的に含める(`.`または`working`のみ有効) |
|
|
153
152
|
| `--keep-alive` | false | ブラウザ切断後もサーバーを終了せず起動したままにする(Ctrl+Cで手動停止) |
|
package/README.ko.md
CHANGED
|
@@ -131,7 +131,7 @@ git diff --cached | difit -
|
|
|
131
131
|
표준 입력 모드는 의도 우선 규칙으로 선택됩니다:
|
|
132
132
|
|
|
133
133
|
- `-`를 지정하면 표준 입력 모드가 명시적으로 활성화됩니다
|
|
134
|
-
- positional 인수(`<target>` / `[compare-with]`)
|
|
134
|
+
- positional 인수(`<target>` / `[compare-with]`) 또는 `--pr`이 지정되면 Git/PR 모드로 처리하고 stdin 자동 읽기를 하지 않습니다
|
|
135
135
|
- 명시적 모드 지정이 없고 stdin이 pipe/file/socket 인 경우에만 자동으로 표준 입력 모드가 됩니다
|
|
136
136
|
|
|
137
137
|
## ⚙️ CLI 옵션
|
|
@@ -147,7 +147,6 @@ git diff --cached | difit -
|
|
|
147
147
|
| `--host` | 127.0.0.1 | 서버를 바인딩할 호스트 주소 (외부 액세스는 0.0.0.0 사용) |
|
|
148
148
|
| `--no-open` | false | 브라우저를 자동으로 열지 않음 |
|
|
149
149
|
| `--mode` | split | 표시 모드: `unified` 또는 `split` |
|
|
150
|
-
| `--tui` (deprecated) | false | WebUI 대신 터미널 UI 모드 사용 |
|
|
151
150
|
| `--clean` | false | 시작 시 모든 기존 코멘트와 열람된 파일 표시 초기화 |
|
|
152
151
|
| `--include-untracked` | false | diff에 untracked 파일 자동 포함 (`.` 또는 `working`에서만 유효) |
|
|
153
152
|
| `--keep-alive` | false | 브라우저 연결이 끊겨도 서버 유지 (Ctrl+C로 수동 종료) |
|
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
<img src="public/logo.png" alt="difit" width="260">
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/difit"><img src="https://img.shields.io/npm/v/difit.svg" alt="npm version"></a>
|
|
7
|
+
<a href="https://github.com/yoshiko-pg/difit/actions/workflows/pr.yml"><img src="https://github.com/yoshiko-pg/difit/actions/workflows/pr.yml/badge.svg" alt="CI"></a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
5
10
|
<p align="center">
|
|
6
11
|
English | <a href="./README.ja.md">日本語</a> | <a href="./README.zh.md">简体中文</a> | <a href="./README.ko.md">한국어</a>
|
|
7
12
|
</p>
|
|
@@ -131,7 +136,7 @@ git diff --cached | difit -
|
|
|
131
136
|
Stdin mode is selected with intent-first rules:
|
|
132
137
|
|
|
133
138
|
- `-` explicitly enables stdin mode
|
|
134
|
-
- If positional arguments (`<target>` / `[compare-with]`)
|
|
139
|
+
- If positional arguments (`<target>` / `[compare-with]`) or `--pr` are provided, difit treats the command as Git/PR mode and does not auto-read stdin
|
|
135
140
|
- Auto stdin detection applies only when no explicit mode is selected and stdin is a pipe/file/socket
|
|
136
141
|
|
|
137
142
|
## ⚙️ CLI Options
|
|
@@ -147,7 +152,6 @@ Stdin mode is selected with intent-first rules:
|
|
|
147
152
|
| `--host` | 127.0.0.1 | Host address to bind server to (use 0.0.0.0 for external access) |
|
|
148
153
|
| `--no-open` | false | Don't automatically open browser |
|
|
149
154
|
| `--mode` | split | Display mode: `unified` or `split` |
|
|
150
|
-
| `--tui` (deprecated) | false | Use terminal UI mode instead of WebUI |
|
|
151
155
|
| `--clean` | false | Clear all existing comments and viewed files on startup |
|
|
152
156
|
| `--include-untracked` | false | Automatically include untracked files in diff (only with `.` or `working`) |
|
|
153
157
|
| `--keep-alive` | false | Keep server running after browser disconnects (stop manually with Ctrl+C) |
|
package/README.zh.md
CHANGED
|
@@ -131,7 +131,7 @@ git diff --cached | difit -
|
|
|
131
131
|
标准输入模式按“意图优先”规则选择:
|
|
132
132
|
|
|
133
133
|
- `-` 会显式启用标准输入模式
|
|
134
|
-
- 当提供 positional 参数(`<target>` / `[compare-with]
|
|
134
|
+
- 当提供 positional 参数(`<target>` / `[compare-with]`)或 `--pr` 时,difit 会按 Git/PR 模式处理,不会自动读取 stdin
|
|
135
135
|
- 只有在未显式选择模式且 stdin 为 pipe/file/socket 时,才会自动进入标准输入模式
|
|
136
136
|
|
|
137
137
|
## ⚙️ CLI 选项
|
|
@@ -147,7 +147,6 @@ git diff --cached | difit -
|
|
|
147
147
|
| `--host` | 127.0.0.1 | 绑定服务器的主机地址(使用 0.0.0.0 进行外部访问) |
|
|
148
148
|
| `--no-open` | false | 不自动打开浏览器 |
|
|
149
149
|
| `--mode` | split | 显示模式:`unified` 或 `split` |
|
|
150
|
-
| `--tui` (deprecated) | false | 使用终端 UI 模式而不是 WebUI |
|
|
151
150
|
| `--clean` | false | 启动时清除所有现有评论和已查看的文件 |
|
|
152
151
|
| `--include-untracked` | false | 自动将 untracked 文件包含在 diff 中(仅在 `.` 或 `working` 时有效) |
|
|
153
152
|
| `--keep-alive` | false | 浏览器断开后保持服务器运行(使用 Ctrl+C 手动停止) |
|
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from 'child_process';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
-
import React from 'react';
|
|
5
4
|
import { simpleGit } from 'simple-git';
|
|
6
5
|
import pkg from '../../package.json' with { type: 'json' };
|
|
7
6
|
import { startServer } from '../server/server.js';
|
|
@@ -11,7 +10,6 @@ import { DEFAULT_DIFF_VIEW_MODE, normalizeDiffViewMode } from '../utils/diffMode
|
|
|
11
10
|
import { shouldReadStdin, findUntrackedFiles, markFilesIntentToAdd, promptUser, parseCommentOptions, validateDiffArguments, getGitRoot, readStdin, } from './utils.js';
|
|
12
11
|
import { createCommentCommand } from './comment.js';
|
|
13
12
|
import { getPrPatch, getPrCommentImports } from './github.js';
|
|
14
|
-
import { warnAboutTuiDeprecation } from './tuiDeprecation.js';
|
|
15
13
|
function isSpecialArg(arg) {
|
|
16
14
|
return arg === 'working' || arg === 'staged' || arg === '.';
|
|
17
15
|
}
|
|
@@ -131,7 +129,6 @@ program
|
|
|
131
129
|
.option('--no-open', 'do not automatically open browser')
|
|
132
130
|
.option('--mode <mode>', 'diff mode (split or unified)', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
133
131
|
.option('--comment <json>', 'inject initial review comments (repeatable, accepts a JSON object or array)', (value, previous) => [...previous, value], [])
|
|
134
|
-
.option('--tui', 'use terminal UI instead of web interface')
|
|
135
132
|
.option('--pr <url>', 'GitHub PR URL to review (e.g., https://github.com/owner/repo/pull/123)')
|
|
136
133
|
.option('--clean', 'start with a clean slate by clearing all existing comments')
|
|
137
134
|
.option('--include-untracked', 'automatically include untracked files in diff')
|
|
@@ -177,10 +174,6 @@ program
|
|
|
177
174
|
console.error('Error: --merge-base option cannot be used with --pr');
|
|
178
175
|
process.exit(1);
|
|
179
176
|
}
|
|
180
|
-
if (options.tui) {
|
|
181
|
-
console.error('Error: --pr option cannot be used with --tui');
|
|
182
|
-
process.exit(1);
|
|
183
|
-
}
|
|
184
177
|
if (options.context !== undefined) {
|
|
185
178
|
console.error('Error: --context option cannot be used with --pr');
|
|
186
179
|
process.exit(1);
|
|
@@ -207,7 +200,6 @@ program
|
|
|
207
200
|
commitish,
|
|
208
201
|
hasPositionalArgs: program.args.length > 0,
|
|
209
202
|
hasPrOption: false,
|
|
210
|
-
hasTuiOption: Boolean(options.tui),
|
|
211
203
|
});
|
|
212
204
|
if (readFromStdin) {
|
|
213
205
|
if (options.context !== undefined) {
|
|
@@ -273,33 +265,6 @@ program
|
|
|
273
265
|
await handleUntrackedFiles(git, options.includeUntracked);
|
|
274
266
|
}
|
|
275
267
|
}
|
|
276
|
-
if (options.tui) {
|
|
277
|
-
if (backgroundMode) {
|
|
278
|
-
console.error('Error: --background option cannot be used with --tui');
|
|
279
|
-
process.exit(1);
|
|
280
|
-
}
|
|
281
|
-
if (commentImports.length > 0) {
|
|
282
|
-
console.error('Error: --comment option cannot be used with --tui');
|
|
283
|
-
process.exit(1);
|
|
284
|
-
}
|
|
285
|
-
// Check if we're in a TTY environment
|
|
286
|
-
if (!process.stdin.isTTY) {
|
|
287
|
-
console.error('Error: TUI mode requires an interactive terminal (TTY).');
|
|
288
|
-
console.error('Try running the command directly in your terminal without piping.');
|
|
289
|
-
process.exit(1);
|
|
290
|
-
}
|
|
291
|
-
await warnAboutTuiDeprecation();
|
|
292
|
-
// Dynamic import for TUI mode
|
|
293
|
-
const { render } = await import('ink');
|
|
294
|
-
const { default: TuiApp } = await import('../tui/App.js');
|
|
295
|
-
render(React.createElement(TuiApp, {
|
|
296
|
-
selection,
|
|
297
|
-
mode: options.mode,
|
|
298
|
-
repoPath,
|
|
299
|
-
contextLines: options.context,
|
|
300
|
-
}));
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
268
|
const validation = validateDiffArguments(selection.targetCommitish, compareWith);
|
|
304
269
|
if (!validation.valid) {
|
|
305
270
|
console.error(`Error: ${validation.error}`);
|
package/dist/cli/index.test.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
4
3
|
import { DiffMode } from '../types/watch.js';
|
|
5
4
|
import { DEFAULT_DIFF_VIEW_MODE, normalizeDiffViewMode } from '../utils/diffMode.js';
|
|
@@ -130,7 +129,6 @@ describe('CLI index.ts', () => {
|
|
|
130
129
|
.option('--no-open', 'no-open')
|
|
131
130
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
132
131
|
.option('--merge-base', 'merge-base')
|
|
133
|
-
.option('--tui', 'tui')
|
|
134
132
|
.option('--pr <url>', 'pr')
|
|
135
133
|
.action(async (commitish, _compareWith, options) => {
|
|
136
134
|
// Simulate the logic from index.ts
|
|
@@ -237,7 +235,6 @@ describe('CLI index.ts', () => {
|
|
|
237
235
|
.option('--host <host>', 'host', '')
|
|
238
236
|
.option('--no-open', 'no-open')
|
|
239
237
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
240
|
-
.option('--tui', 'tui')
|
|
241
238
|
.option('--pr <url>', 'pr')
|
|
242
239
|
.option('--merge-base', 'merge-base')
|
|
243
240
|
.option('--clean', 'start with a clean slate by clearing all existing comments')
|
|
@@ -330,13 +327,11 @@ describe('CLI index.ts', () => {
|
|
|
330
327
|
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
331
328
|
.argument('[compare-with]', 'compare-with')
|
|
332
329
|
.option('--context <lines>', 'context', parseInt)
|
|
333
|
-
.option('--tui', 'tui')
|
|
334
330
|
.action(async (commitish, _compareWith, options) => {
|
|
335
331
|
const readFromStdin = shouldReadStdin({
|
|
336
332
|
commitish,
|
|
337
333
|
hasPositionalArgs: program.args.length > 0,
|
|
338
334
|
hasPrOption: false,
|
|
339
|
-
hasTuiOption: Boolean(options.tui),
|
|
340
335
|
});
|
|
341
336
|
if (readFromStdin && options.context !== undefined) {
|
|
342
337
|
console.error('Error: --context option cannot be used with stdin diff');
|
|
@@ -385,13 +380,11 @@ describe('CLI index.ts', () => {
|
|
|
385
380
|
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
386
381
|
.argument('[compare-with]', 'compare-with')
|
|
387
382
|
.option('--merge-base', 'merge-base')
|
|
388
|
-
.option('--tui', 'tui')
|
|
389
383
|
.action(async (commitish, _compareWith, options) => {
|
|
390
384
|
const readFromStdin = shouldReadStdin({
|
|
391
385
|
commitish,
|
|
392
386
|
hasPositionalArgs: program.args.length > 0,
|
|
393
387
|
hasPrOption: false,
|
|
394
|
-
hasTuiOption: Boolean(options.tui),
|
|
395
388
|
});
|
|
396
389
|
if (readFromStdin && options.mergeBase) {
|
|
397
390
|
console.error('Error: --merge-base option cannot be used with stdin diff');
|
|
@@ -488,7 +481,6 @@ describe('CLI index.ts', () => {
|
|
|
488
481
|
.option('--host <host>', 'host', '')
|
|
489
482
|
.option('--no-open', 'no-open')
|
|
490
483
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
491
|
-
.option('--tui', 'tui')
|
|
492
484
|
.option('--pr <url>', 'pr')
|
|
493
485
|
.action(async (commitish, _compareWith, options) => {
|
|
494
486
|
if (commitish === 'working' || commitish === '.') {
|
|
@@ -518,7 +510,6 @@ describe('CLI index.ts', () => {
|
|
|
518
510
|
.option('--host <host>', 'host', '')
|
|
519
511
|
.option('--no-open', 'no-open')
|
|
520
512
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
521
|
-
.option('--tui', 'tui')
|
|
522
513
|
.option('--pr <url>', 'pr')
|
|
523
514
|
.action(async (commitish, _compareWith, options) => {
|
|
524
515
|
if (commitish === 'working' || commitish === '.') {
|
|
@@ -548,7 +539,6 @@ describe('CLI index.ts', () => {
|
|
|
548
539
|
.option('--host <host>', 'host', '')
|
|
549
540
|
.option('--no-open', 'no-open')
|
|
550
541
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
551
|
-
.option('--tui', 'tui')
|
|
552
542
|
.option('--pr <url>', 'pr')
|
|
553
543
|
.option('--include-untracked', 'include untracked')
|
|
554
544
|
.action(async (commitish, _compareWith, options) => {
|
|
@@ -583,7 +573,6 @@ describe('CLI index.ts', () => {
|
|
|
583
573
|
.option('--host <host>', 'host', '')
|
|
584
574
|
.option('--no-open', 'no-open')
|
|
585
575
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
586
|
-
.option('--tui', 'tui')
|
|
587
576
|
.option('--pr <url>', 'pr')
|
|
588
577
|
.option('--include-untracked', 'include untracked')
|
|
589
578
|
.action(async (commitish, _compareWith, options) => {
|
|
@@ -645,7 +634,6 @@ describe('CLI index.ts', () => {
|
|
|
645
634
|
.option('--host <host>', 'host', '')
|
|
646
635
|
.option('--no-open', 'no-open')
|
|
647
636
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
648
|
-
.option('--tui', 'tui')
|
|
649
637
|
.option('--pr <url>', 'pr')
|
|
650
638
|
.action(async (commitish, _compareWith, options) => {
|
|
651
639
|
const manualCommentImports = actualParseCommentOptions(options.comment);
|
|
@@ -711,7 +699,6 @@ describe('CLI index.ts', () => {
|
|
|
711
699
|
.option('--host <host>', 'host', '')
|
|
712
700
|
.option('--no-open', 'no-open')
|
|
713
701
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
714
|
-
.option('--tui', 'tui')
|
|
715
702
|
.option('--pr <url>', 'pr')
|
|
716
703
|
.action(async (commitish, _compareWith, options) => {
|
|
717
704
|
const manualCommentImports = actualParseCommentOptions(options.comment);
|
|
@@ -757,7 +744,6 @@ describe('CLI index.ts', () => {
|
|
|
757
744
|
.option('--host <host>', 'host', '')
|
|
758
745
|
.option('--no-open', 'no-open')
|
|
759
746
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
760
|
-
.option('--tui', 'tui')
|
|
761
747
|
.option('--pr <url>', 'pr')
|
|
762
748
|
.action(async (commitish, _compareWith, options) => {
|
|
763
749
|
if (options.pr) {
|
|
@@ -773,35 +759,6 @@ describe('CLI index.ts', () => {
|
|
|
773
759
|
expect(console.error).toHaveBeenCalledWith('Error: --pr option cannot be used with positional arguments');
|
|
774
760
|
expect(process.exit).toHaveBeenCalledWith(1);
|
|
775
761
|
});
|
|
776
|
-
it('rejects PR option with --tui', async () => {
|
|
777
|
-
const prUrl = 'https://github.com/owner/repo/pull/123';
|
|
778
|
-
const program = new Command();
|
|
779
|
-
program
|
|
780
|
-
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
781
|
-
.argument('[compare-with]', 'compare-with')
|
|
782
|
-
.option('--port <port>', 'port', parseInt)
|
|
783
|
-
.option('--host <host>', 'host', '')
|
|
784
|
-
.option('--no-open', 'no-open')
|
|
785
|
-
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
786
|
-
.option('--tui', 'tui')
|
|
787
|
-
.option('--pr <url>', 'pr')
|
|
788
|
-
.action(async (commitish, _compareWith, options) => {
|
|
789
|
-
if (options.pr) {
|
|
790
|
-
if (commitish !== 'HEAD' || _compareWith) {
|
|
791
|
-
console.error('Error: --pr option cannot be used with positional arguments');
|
|
792
|
-
process.exit(1);
|
|
793
|
-
}
|
|
794
|
-
if (options.tui) {
|
|
795
|
-
console.error('Error: --pr option cannot be used with --tui');
|
|
796
|
-
process.exit(1);
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
await program.parseAsync(['--pr', prUrl, '--tui'], { from: 'user' });
|
|
801
|
-
expect(console.error).toHaveBeenCalledWith('Error: --pr option cannot be used with --tui');
|
|
802
|
-
expect(process.exit).toHaveBeenCalledWith(1);
|
|
803
|
-
expect(mockStartServer).not.toHaveBeenCalled();
|
|
804
|
-
});
|
|
805
762
|
});
|
|
806
763
|
describe('--comment option', () => {
|
|
807
764
|
it('passes parsed comment imports to startServer', async () => {
|
|
@@ -849,27 +806,6 @@ describe('CLI index.ts', () => {
|
|
|
849
806
|
],
|
|
850
807
|
});
|
|
851
808
|
});
|
|
852
|
-
it('rejects --comment with --tui', async () => {
|
|
853
|
-
const program = new Command();
|
|
854
|
-
program
|
|
855
|
-
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
856
|
-
.option('--comment <json>', 'comment', (value, previous) => [...previous, value], [])
|
|
857
|
-
.option('--tui', 'tui')
|
|
858
|
-
.action(async (_commitish, options) => {
|
|
859
|
-
const commentImports = actualParseCommentOptions(options.comment);
|
|
860
|
-
if (options.tui && commentImports.length > 0) {
|
|
861
|
-
console.error('Error: --comment option cannot be used with --tui');
|
|
862
|
-
process.exit(1);
|
|
863
|
-
}
|
|
864
|
-
});
|
|
865
|
-
await program.parseAsync([
|
|
866
|
-
'--tui',
|
|
867
|
-
'--comment',
|
|
868
|
-
'{"type":"thread","filePath":"src/example.ts","position":{"side":"new","line":10},"body":"Imported comment"}',
|
|
869
|
-
], { from: 'user' });
|
|
870
|
-
expect(console.error).toHaveBeenCalledWith('Error: --comment option cannot be used with --tui');
|
|
871
|
-
expect(process.exit).toHaveBeenCalledWith(1);
|
|
872
|
-
});
|
|
873
809
|
it('reports invalid comment json before starting the server', async () => {
|
|
874
810
|
const program = new Command();
|
|
875
811
|
program
|
|
@@ -906,7 +842,6 @@ describe('CLI index.ts', () => {
|
|
|
906
842
|
.option('--host <host>', 'host', '')
|
|
907
843
|
.option('--no-open', 'no-open')
|
|
908
844
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
909
|
-
.option('--tui', 'tui')
|
|
910
845
|
.option('--pr <url>', 'pr')
|
|
911
846
|
.option('--clean', 'start with a clean slate by clearing all existing comments')
|
|
912
847
|
.action(async (commitish, _compareWith, options) => {
|
|
@@ -945,7 +880,6 @@ describe('CLI index.ts', () => {
|
|
|
945
880
|
.option('--host <host>', 'host', '')
|
|
946
881
|
.option('--no-open', 'no-open')
|
|
947
882
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
948
|
-
.option('--tui', 'tui')
|
|
949
883
|
.option('--pr <url>', 'pr')
|
|
950
884
|
.option('--clean', 'start with a clean slate by clearing all existing comments')
|
|
951
885
|
.action(async (commitish, _compareWith, options) => {
|
|
@@ -986,7 +920,6 @@ describe('CLI index.ts', () => {
|
|
|
986
920
|
.option('--host <host>', 'host', '')
|
|
987
921
|
.option('--no-open', 'no-open')
|
|
988
922
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
989
|
-
.option('--tui', 'tui')
|
|
990
923
|
.option('--pr <url>', 'pr')
|
|
991
924
|
.option('--clean', 'start with a clean slate by clearing all existing comments')
|
|
992
925
|
.option('--keep-alive', 'keep server running even after browser disconnects')
|
|
@@ -1027,7 +960,6 @@ describe('CLI index.ts', () => {
|
|
|
1027
960
|
.option('--host <host>', 'host', '')
|
|
1028
961
|
.option('--no-open', 'no-open')
|
|
1029
962
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1030
|
-
.option('--tui', 'tui')
|
|
1031
963
|
.option('--pr <url>', 'pr')
|
|
1032
964
|
.option('--clean', 'start with a clean slate by clearing all existing comments')
|
|
1033
965
|
.option('--keep-alive', 'keep server running even after browser disconnects')
|
|
@@ -1070,7 +1002,6 @@ describe('CLI index.ts', () => {
|
|
|
1070
1002
|
.option('--host <host>', 'host', '')
|
|
1071
1003
|
.option('--no-open', 'no-open')
|
|
1072
1004
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1073
|
-
.option('--tui', 'tui')
|
|
1074
1005
|
.option('--pr <url>', 'pr')
|
|
1075
1006
|
.action(async (commitish, _compareWith, options) => {
|
|
1076
1007
|
const { url, isEmpty } = await startServer({
|
|
@@ -1112,7 +1043,6 @@ describe('CLI index.ts', () => {
|
|
|
1112
1043
|
.option('--host <host>', 'host', '')
|
|
1113
1044
|
.option('--no-open', 'no-open')
|
|
1114
1045
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1115
|
-
.option('--tui', 'tui')
|
|
1116
1046
|
.option('--pr <url>', 'pr')
|
|
1117
1047
|
.action(async (commitish, _compareWith, options) => {
|
|
1118
1048
|
const { url, isEmpty } = await startServer({
|
|
@@ -1145,7 +1075,6 @@ describe('CLI index.ts', () => {
|
|
|
1145
1075
|
.option('--host <host>', 'host', '')
|
|
1146
1076
|
.option('--no-open', 'no-open')
|
|
1147
1077
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1148
|
-
.option('--tui', 'tui')
|
|
1149
1078
|
.option('--pr <url>', 'pr')
|
|
1150
1079
|
.action(async (commitish, _compareWith, options) => {
|
|
1151
1080
|
await startServer({
|
|
@@ -1171,7 +1100,6 @@ describe('CLI index.ts', () => {
|
|
|
1171
1100
|
.option('--host <host>', 'host', '')
|
|
1172
1101
|
.option('--no-open', 'no-open')
|
|
1173
1102
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1174
|
-
.option('--tui', 'tui')
|
|
1175
1103
|
.option('--pr <url>', 'pr')
|
|
1176
1104
|
.action(async (commitish, _compareWith, options) => {
|
|
1177
1105
|
await startServer({
|
|
@@ -1188,195 +1116,6 @@ describe('CLI index.ts', () => {
|
|
|
1188
1116
|
}));
|
|
1189
1117
|
});
|
|
1190
1118
|
});
|
|
1191
|
-
describe('TUI mode', () => {
|
|
1192
|
-
let mockRender;
|
|
1193
|
-
let mockTuiApp;
|
|
1194
|
-
const expectRenderedTuiProps = (props) => {
|
|
1195
|
-
expect(mockRender).toHaveBeenCalledTimes(1);
|
|
1196
|
-
expect(mockRender).toHaveBeenCalledWith({
|
|
1197
|
-
component: mockTuiApp,
|
|
1198
|
-
props,
|
|
1199
|
-
});
|
|
1200
|
-
};
|
|
1201
|
-
beforeEach(() => {
|
|
1202
|
-
mockRender = vi.fn();
|
|
1203
|
-
mockTuiApp = vi.fn();
|
|
1204
|
-
// Mock React.createElement for testing
|
|
1205
|
-
vi.spyOn(React, 'createElement').mockImplementation((component, props) => ({ component, props }));
|
|
1206
|
-
// Mock process.stdin.isTTY
|
|
1207
|
-
Object.defineProperty(process.stdin, 'isTTY', {
|
|
1208
|
-
value: true,
|
|
1209
|
-
configurable: true,
|
|
1210
|
-
});
|
|
1211
|
-
});
|
|
1212
|
-
afterEach(() => {
|
|
1213
|
-
vi.restoreAllMocks();
|
|
1214
|
-
});
|
|
1215
|
-
it('passes arguments to TUI app correctly', async () => {
|
|
1216
|
-
mockFindUntrackedFiles.mockResolvedValue([]);
|
|
1217
|
-
const program = new Command();
|
|
1218
|
-
program
|
|
1219
|
-
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
1220
|
-
.argument('[compare-with]', 'compare-with')
|
|
1221
|
-
.option('--port <port>', 'port', parseInt)
|
|
1222
|
-
.option('--host <host>', 'host', '')
|
|
1223
|
-
.option('--no-open', 'no-open')
|
|
1224
|
-
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1225
|
-
.option('--tui', 'tui')
|
|
1226
|
-
.option('--pr <url>', 'pr')
|
|
1227
|
-
.action(async (commitish, _compareWith, options) => {
|
|
1228
|
-
if (options.tui) {
|
|
1229
|
-
if (!process.stdin.isTTY) {
|
|
1230
|
-
console.error('Error: TUI mode requires an interactive terminal (TTY).');
|
|
1231
|
-
process.exit(1);
|
|
1232
|
-
}
|
|
1233
|
-
const render = mockRender;
|
|
1234
|
-
const TuiApp = mockTuiApp;
|
|
1235
|
-
render(React.createElement(TuiApp, {
|
|
1236
|
-
selection: { targetCommitish: commitish, baseCommitish: commitish + '^' },
|
|
1237
|
-
mode: options.mode,
|
|
1238
|
-
}));
|
|
1239
|
-
}
|
|
1240
|
-
});
|
|
1241
|
-
await program.parseAsync(['main', '--tui'], { from: 'user' });
|
|
1242
|
-
expectRenderedTuiProps({
|
|
1243
|
-
selection: { targetCommitish: 'main', baseCommitish: 'main^' },
|
|
1244
|
-
mode: 'split',
|
|
1245
|
-
});
|
|
1246
|
-
});
|
|
1247
|
-
it('passes context option to TUI app', async () => {
|
|
1248
|
-
mockFindUntrackedFiles.mockResolvedValue([]);
|
|
1249
|
-
const program = new Command();
|
|
1250
|
-
program
|
|
1251
|
-
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
1252
|
-
.argument('[compare-with]', 'compare-with')
|
|
1253
|
-
.option('--port <port>', 'port', parseInt)
|
|
1254
|
-
.option('--host <host>', 'host', '')
|
|
1255
|
-
.option('--no-open', 'no-open')
|
|
1256
|
-
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1257
|
-
.option('--context <lines>', 'context', parseInt)
|
|
1258
|
-
.option('--tui', 'tui')
|
|
1259
|
-
.option('--pr <url>', 'pr')
|
|
1260
|
-
.action(async (commitish, _compareWith, options) => {
|
|
1261
|
-
if (options.tui) {
|
|
1262
|
-
const render = mockRender;
|
|
1263
|
-
const TuiApp = mockTuiApp;
|
|
1264
|
-
render(React.createElement(TuiApp, {
|
|
1265
|
-
selection: { targetCommitish: commitish, baseCommitish: commitish + '^' },
|
|
1266
|
-
mode: options.mode,
|
|
1267
|
-
contextLines: options.context,
|
|
1268
|
-
}));
|
|
1269
|
-
}
|
|
1270
|
-
});
|
|
1271
|
-
await program.parseAsync(['--tui', '--context', '2'], { from: 'user' });
|
|
1272
|
-
expectRenderedTuiProps({
|
|
1273
|
-
selection: { targetCommitish: 'HEAD', baseCommitish: 'HEAD^' },
|
|
1274
|
-
mode: 'split',
|
|
1275
|
-
contextLines: 2,
|
|
1276
|
-
});
|
|
1277
|
-
});
|
|
1278
|
-
it('passes mode option to TUI app', async () => {
|
|
1279
|
-
mockFindUntrackedFiles.mockResolvedValue([]);
|
|
1280
|
-
const program = new Command();
|
|
1281
|
-
program
|
|
1282
|
-
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
1283
|
-
.argument('[compare-with]', 'compare-with')
|
|
1284
|
-
.option('--port <port>', 'port', parseInt)
|
|
1285
|
-
.option('--host <host>', 'host', '')
|
|
1286
|
-
.option('--no-open', 'no-open')
|
|
1287
|
-
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1288
|
-
.option('--tui', 'tui')
|
|
1289
|
-
.option('--pr <url>', 'pr')
|
|
1290
|
-
.action(async (commitish, _compareWith, options) => {
|
|
1291
|
-
if (options.tui) {
|
|
1292
|
-
if (!process.stdin.isTTY) {
|
|
1293
|
-
console.error('Error: TUI mode requires an interactive terminal (TTY).');
|
|
1294
|
-
process.exit(1);
|
|
1295
|
-
}
|
|
1296
|
-
const render = mockRender;
|
|
1297
|
-
const TuiApp = mockTuiApp;
|
|
1298
|
-
render(React.createElement(TuiApp, {
|
|
1299
|
-
selection: { targetCommitish: commitish, baseCommitish: commitish + '^' },
|
|
1300
|
-
mode: options.mode,
|
|
1301
|
-
}));
|
|
1302
|
-
}
|
|
1303
|
-
});
|
|
1304
|
-
await program.parseAsync(['--tui', '--mode', 'unified'], { from: 'user' });
|
|
1305
|
-
expectRenderedTuiProps({
|
|
1306
|
-
selection: { targetCommitish: 'HEAD', baseCommitish: 'HEAD^' },
|
|
1307
|
-
mode: 'unified',
|
|
1308
|
-
});
|
|
1309
|
-
});
|
|
1310
|
-
it('handles special arguments with TUI mode', async () => {
|
|
1311
|
-
mockFindUntrackedFiles.mockResolvedValue([]);
|
|
1312
|
-
const program = new Command();
|
|
1313
|
-
program
|
|
1314
|
-
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
1315
|
-
.argument('[compare-with]', 'compare-with')
|
|
1316
|
-
.option('--port <port>', 'port', parseInt)
|
|
1317
|
-
.option('--host <host>', 'host', '')
|
|
1318
|
-
.option('--no-open', 'no-open')
|
|
1319
|
-
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1320
|
-
.option('--tui', 'tui')
|
|
1321
|
-
.option('--pr <url>', 'pr')
|
|
1322
|
-
.action(async (commitish, _compareWith, options) => {
|
|
1323
|
-
if (options.tui) {
|
|
1324
|
-
const render = mockRender;
|
|
1325
|
-
const TuiApp = mockTuiApp;
|
|
1326
|
-
let targetCommitish = commitish;
|
|
1327
|
-
let baseCommitish;
|
|
1328
|
-
if (commitish === 'working') {
|
|
1329
|
-
baseCommitish = 'staged';
|
|
1330
|
-
}
|
|
1331
|
-
else if (commitish === 'staged' || commitish === '.') {
|
|
1332
|
-
baseCommitish = 'HEAD';
|
|
1333
|
-
}
|
|
1334
|
-
else {
|
|
1335
|
-
baseCommitish = commitish + '^';
|
|
1336
|
-
}
|
|
1337
|
-
render(React.createElement(TuiApp, {
|
|
1338
|
-
selection: { targetCommitish, baseCommitish },
|
|
1339
|
-
mode: options.mode,
|
|
1340
|
-
}));
|
|
1341
|
-
}
|
|
1342
|
-
});
|
|
1343
|
-
await program.parseAsync(['working', '--tui', '--mode', 'unified'], { from: 'user' });
|
|
1344
|
-
expectRenderedTuiProps({
|
|
1345
|
-
selection: { targetCommitish: 'working', baseCommitish: 'staged' },
|
|
1346
|
-
mode: 'unified',
|
|
1347
|
-
});
|
|
1348
|
-
});
|
|
1349
|
-
it('rejects TUI mode in non-TTY environment', async () => {
|
|
1350
|
-
// Mock non-TTY environment
|
|
1351
|
-
Object.defineProperty(process.stdin, 'isTTY', {
|
|
1352
|
-
value: false,
|
|
1353
|
-
configurable: true,
|
|
1354
|
-
});
|
|
1355
|
-
const program = new Command();
|
|
1356
|
-
program
|
|
1357
|
-
.argument('[commit-ish]', 'commit-ish', 'HEAD')
|
|
1358
|
-
.argument('[compare-with]', 'compare-with')
|
|
1359
|
-
.option('--port <port>', 'port', parseInt)
|
|
1360
|
-
.option('--host <host>', 'host', '')
|
|
1361
|
-
.option('--no-open', 'no-open')
|
|
1362
|
-
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1363
|
-
.option('--tui', 'tui')
|
|
1364
|
-
.option('--pr <url>', 'pr')
|
|
1365
|
-
.action(async (_commitish, _compareWith, options) => {
|
|
1366
|
-
if (options.tui) {
|
|
1367
|
-
if (!process.stdin.isTTY) {
|
|
1368
|
-
console.error('Error: TUI mode requires an interactive terminal (TTY).');
|
|
1369
|
-
console.error('Try running the command directly in your terminal without piping.');
|
|
1370
|
-
process.exit(1);
|
|
1371
|
-
}
|
|
1372
|
-
}
|
|
1373
|
-
});
|
|
1374
|
-
await program.parseAsync(['--tui'], { from: 'user' });
|
|
1375
|
-
expect(console.error).toHaveBeenCalledWith('Error: TUI mode requires an interactive terminal (TTY).');
|
|
1376
|
-
expect(console.error).toHaveBeenCalledWith('Try running the command directly in your terminal without piping.');
|
|
1377
|
-
expect(process.exit).toHaveBeenCalledWith(1);
|
|
1378
|
-
});
|
|
1379
|
-
});
|
|
1380
1119
|
describe('Diff mode determination', () => {
|
|
1381
1120
|
const testCases = [
|
|
1382
1121
|
{
|
|
@@ -1421,7 +1160,6 @@ describe('CLI index.ts', () => {
|
|
|
1421
1160
|
.option('--host <host>', 'host', '')
|
|
1422
1161
|
.option('--no-open', 'no-open')
|
|
1423
1162
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1424
|
-
.option('--tui', 'tui')
|
|
1425
1163
|
.option('--pr <url>', 'pr')
|
|
1426
1164
|
.action(async (commitish, compareWith, options) => {
|
|
1427
1165
|
// Simulate determineDiffMode function behavior
|
|
@@ -1469,7 +1207,6 @@ describe('CLI index.ts', () => {
|
|
|
1469
1207
|
.option('--host <host>', 'host', '')
|
|
1470
1208
|
.option('--no-open', 'no-open')
|
|
1471
1209
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1472
|
-
.option('--tui', 'tui')
|
|
1473
1210
|
.option('--pr <url>', 'pr')
|
|
1474
1211
|
.action(async (commitish, compareWith, options) => {
|
|
1475
1212
|
// Simulate determineDiffMode function behavior
|
|
@@ -1517,7 +1254,6 @@ describe('CLI index.ts', () => {
|
|
|
1517
1254
|
.option('--host <host>', 'host', '')
|
|
1518
1255
|
.option('--no-open', 'no-open')
|
|
1519
1256
|
.option('--mode <mode>', 'mode', normalizeDiffViewMode, DEFAULT_DIFF_VIEW_MODE)
|
|
1520
|
-
.option('--tui', 'tui')
|
|
1521
1257
|
.option('--pr <url>', 'pr')
|
|
1522
1258
|
.action(async (commitish, compareWith, options) => {
|
|
1523
1259
|
// Simulate determineDiffMode function behavior with the fix
|
package/dist/cli/utils.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ interface ShouldReadStdinOptions {
|
|
|
8
8
|
commitish: string;
|
|
9
9
|
hasPositionalArgs: boolean;
|
|
10
10
|
hasPrOption: boolean;
|
|
11
|
-
hasTuiOption: boolean;
|
|
12
11
|
stdinSource?: StdinSource;
|
|
13
12
|
}
|
|
14
13
|
export declare function shouldReadStdin(options: ShouldReadStdinOptions): boolean;
|
|
@@ -24,6 +23,5 @@ export declare function validateDiffArguments(targetCommitish: string, baseCommi
|
|
|
24
23
|
export declare function findUntrackedFiles(git: SimpleGit): Promise<string[]>;
|
|
25
24
|
export declare function markFilesIntentToAdd(git: SimpleGit, files: string[]): Promise<void>;
|
|
26
25
|
export declare function promptUser(message: string): Promise<boolean>;
|
|
27
|
-
export declare function waitForEnter(message: string): Promise<void>;
|
|
28
26
|
export declare function readStdin(): Promise<string>;
|
|
29
27
|
export {};
|