isthmus-cli 0.1.3 → 0.1.5
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.md +90 -10
- package/Skills/isthmus/SKILL.md +38 -48
- package/dist/cli/check-command.d.ts +2 -2
- package/dist/cli/check-command.js +66 -19
- package/dist/cli/check-command.js.map +1 -1
- package/dist/cli/diff-command.d.ts +5 -0
- package/dist/cli/diff-command.js +39 -0
- package/dist/cli/diff-command.js.map +1 -0
- package/dist/cli/graph-command.js +10 -14
- package/dist/cli/graph-command.js.map +1 -1
- package/dist/cli/main.js +5 -0
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/query-command.js +2 -10
- package/dist/cli/query-command.js.map +1 -1
- package/dist/cli/retentions-command.js +11 -13
- package/dist/cli/retentions-command.js.map +1 -1
- package/dist/exchange/parse.d.ts +4 -0
- package/dist/exchange/parse.js +9 -1
- package/dist/exchange/parse.js.map +1 -1
- package/dist/join/join.js +85 -2
- package/dist/join/join.js.map +1 -1
- package/dist/report/check-report.d.ts +7 -2
- package/dist/report/check-report.js +91 -36
- package/dist/report/check-report.js.map +1 -1
- package/dist/report/diff.d.ts +37 -0
- package/dist/report/diff.js +79 -0
- package/dist/report/diff.js.map +1 -0
- package/dist/report/retentions.d.ts +9 -1
- package/dist/report/retentions.js +37 -0
- package/dist/report/retentions.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -22,13 +22,14 @@ isthmus는 조사한 도구들이 언어별로 나눠 보던 이 교차 경계
|
|
|
22
22
|
|
|
23
23
|
## 상태
|
|
24
24
|
|
|
25
|
-
**0.1.
|
|
25
|
+
**0.1.5.** bridge-facts 버전 1 파서와 `check`, `query`, `graph`, `diff`,
|
|
26
26
|
cartograph용 외부 보존 근거 왕복을 구현했다. 외부 입력·혼합 target·그래프 크기와
|
|
27
|
-
Dart/Swift Phase 0 추출 경계를 fail-closed로
|
|
28
|
-
|
|
27
|
+
Dart/Swift Phase 0 추출 경계를 fail-closed로 강화했고, 조인하지 못한 사실과 근거를
|
|
28
|
+
만들지 못한 보존 대상이 조용히 사라지지 않도록 소비자 쪽에서 다시 센다. 다음 단계는
|
|
29
|
+
실제 Flutter 앱 도그푸딩과 React Native 지원이다.
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
정식 producer는 cartograph 0.5.3 이상과 dartograph 0.1.1 이상이다. 두 도구의 실제 출력과
|
|
32
|
+
공개 battery 플러그인의 Swift USR·Dart 호출 근거 왕복을 검증했다.
|
|
32
33
|
|
|
33
34
|
| 문서 | 내용 |
|
|
34
35
|
|---|---|
|
|
@@ -101,6 +102,30 @@ cartograph dead --external-retentions external-retentions.json
|
|
|
101
102
|
|
|
102
103
|
`retentions`는 핸들러의 USR을 우선 사용하고 없으면 `qualifiedName`을 남긴다. `mixed-targets` 문서는 v1에서 사실별 target을 복원할 수 없어 모든 소비 명령이 종료 코드 2로 조인을 보류한다. 먼저 생산 단계에서 target별 문서로 분리해야 한다.
|
|
103
104
|
|
|
105
|
+
cartograph는 Swift 심볼만 보존하므로 `--for cartograph`는 수신 측 Swift 문서를 최소 하나 요구하고, 없으면 빈 보존 문서 대신 종료 코드 2로 거부한다. 호출자가 있는데도 `symbol`이 없어 보존 근거로 바꿀 수 없는 Swift 핸들러가 있으면 부분 문서를 만들지 않고 같은 코드로 실패한다. 근거가 빠진 보존 파일은 소비자에게 살아 있는 핸들러를 미사용으로 보이게 하기 때문이다.
|
|
106
|
+
|
|
107
|
+
모든 소비 명령은 호출 측(dart)과 수신 측(swift) 플랫폼 문서를 최소 하나씩 요구한다. 한쪽만 있으면 한쪽 관찰을 경계 불일치로 오독하지 않고 종료 코드 2로 거부한다. 입력 실패 메시지는 원인(읽기 실패, JSON 오류, 교환 계약 위반, project 불일치, 플랫폼 구성 누락, 크기 상한)과 입력 순서, 해결 방향을 구분해 전달하며 입력 본문과 경로는 노출하지 않는다.
|
|
108
|
+
|
|
109
|
+
실제 공개 Flutter 플러그인에서 생산부터 소비까지 확인하려면 저장소 루트에서 다음 검증을
|
|
110
|
+
실행한다. 스크립트는 `plus_plugins`의 고정 커밋을 sparse checkout하고 배터리 플러그인의
|
|
111
|
+
원본 Dart·Swift 소스에서 세 메서드의 보존 근거를 확인한 뒤 임시 checkout을 지운다.
|
|
112
|
+
네트워크, Git 2.26 이상, Swift 6, cartograph 0.5.3 이상, dartograph 0.1.1 이상이
|
|
113
|
+
필요하다. isthmus는 현재 소스에서 자동으로 다시 빌드하며, 세 번째 인자로 별도 isthmus
|
|
114
|
+
JavaScript 산출물을 넘길 수도 있다.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm run build
|
|
118
|
+
node scripts/verify-public-flutter-plugin.mjs \
|
|
119
|
+
/path/to/cartograph \
|
|
120
|
+
/path/to/dartograph
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
공개 플러그인 검증은 원본 `addMethodCallDelegate` 구현에서 나온 Swift USR과 세 원본 Dart
|
|
124
|
+
호출 위치를 확인하고, cartograph `--explain`이 해당 심볼의 대표 근거를 읽는지 검증한다. 이미
|
|
125
|
+
public인 플러그인 handler의 dead 상태 전환을 억지로 만들지는 않는다. 그 전환과
|
|
126
|
+
`setMethodCallHandler` 경로는 `verify-cartograph-roundtrip.mjs`의 합성 코퍼스가 별도로
|
|
127
|
+
검증한다.
|
|
128
|
+
|
|
104
129
|
채널이나 메서드가 경계 반대편의 어느 위치와 연결되는지 조회하려면:
|
|
105
130
|
|
|
106
131
|
```bash
|
|
@@ -127,16 +152,37 @@ isthmus graph dart-bridges.json swift-bridges.json --format mermaid
|
|
|
127
152
|
- `unregistered-channel-creation` (error): 호출 측 채널 생성은 있지만 네이티브 등록이 없음
|
|
128
153
|
- `registration-without-creation` (warning): 네이티브 채널 등록은 있지만 호출 측 생성이 없음
|
|
129
154
|
- `handler-without-invocation` (warning): 네이티브 핸들러는 있지만 호출 측 사용이 없음
|
|
155
|
+
- `unhandled-invocation-unverified` (warning): 위 첫 항목과 같은 사실이지만, 수신 측이
|
|
156
|
+
핸들러를 놓쳤을 수 있다고 스스로 신고해 없는 것인지 못 본 것인지 판정할 수 없음
|
|
157
|
+
- `unregistered-channel-creation-unverified` (warning): 같은 이유로 등록 여부를 판정할 수 없음
|
|
158
|
+
|
|
159
|
+
`-unverified` 종류는 수신 측 문서의 한계에서 나온다. 예를 들어 Flutter 핸들러가
|
|
160
|
+
Objective-C로 쓰인 플러그인에서 cartograph는 `objective-c-sources:`를 신고하고 핸들러 사실을
|
|
161
|
+
내지 못한다. 이때 "핸들러 없는 호출"을 error로 단정하면 이 도구가 없애려던 오탐을 이 도구가
|
|
162
|
+
만든다. 사실과 증거는 그대로 보고하되 `--strict`를 실패시키지 않는다. 공백의 종류는 구분해서,
|
|
163
|
+
이름이 리터럴이 아닌 채널 등록은 채널 진단만 낮추고 메서드 진단은 낮추지 않는다. 호출 측
|
|
164
|
+
한계는 네이티브 코드를 가리지 않으므로 심각도에 영향을 주지 않으며, 알려지지 않은 한계
|
|
165
|
+
문구는 공백으로 해석하지 않는다.
|
|
130
166
|
|
|
131
167
|
모든 이슈는 관찰된 위치를 `evidence`로 제공한다. 동적 이름, 해석하지 못한 receiver나
|
|
132
168
|
handler 본문, USR 누락, 입력 생성 시각 차이, 혼합 target은 `limitations`에 출처와 함께
|
|
133
169
|
남긴다. 이 도구는 삭제 가능 여부를 판정하지 않는다.
|
|
134
170
|
|
|
171
|
+
`limitations`에는 생산자가 신고한 한계와 isthmus가 직접 센 한계가 함께 들어간다.
|
|
172
|
+
`tool`이 `isthmus`인 항목은 조인 단계에서 관찰한 것이다. 조인하지 못한 사실은 생산자의
|
|
173
|
+
신고나 그 개수와 무관하게 플랫폼별로 다시 센다.
|
|
174
|
+
|
|
175
|
+
- `unjoined-dynamic-channels`: 이름이 리터럴이 아닌 채널 생성·등록 사실
|
|
176
|
+
- `unjoined-dynamic-methods`: 이름이 리터럴이 아닌 호출·핸들러 사실
|
|
177
|
+
- `unjoined-unattributed-handlers`: 어느 채널에 속하는지 모르는 핸들러 사실
|
|
178
|
+
|
|
179
|
+
같은 위치의 중복 사실은 한 번만 센다. dynamic이면서 미귀속인 핸들러는 dynamic으로만 센다.
|
|
180
|
+
|
|
135
181
|
| 종료 코드 | 의미 |
|
|
136
182
|
|---|---|
|
|
137
183
|
| `0` | 실행 성공. 기본 모드에서는 이슈가 있어도 보고만 함 |
|
|
138
|
-
| `1` | `--strict`에서 error 이슈를
|
|
139
|
-
| `2` | 파일 읽기, JSON, 교환 계약, 보류된 조인 등 도구
|
|
184
|
+
| `1` | `--strict`에서 error 이슈를 발견함. `-unverified` 경고는 실패시키지 않음 |
|
|
185
|
+
| `2` | 파일 읽기, JSON, 교환 계약, project 불일치, 플랫폼 구성 누락, 보류된 조인 등 도구 실패. stderr가 원인을 구분 |
|
|
140
186
|
| `64` | 잘못된 명령·옵션·입력 개수 또는 `query`의 `notFound`·`ambiguous` |
|
|
141
187
|
|
|
142
188
|
저장소 checkout에서 개발할 때는 먼저 `npm ci`를 실행한다. 개발 검증은 타입 체크,
|
|
@@ -146,22 +192,56 @@ handler 본문, USR 누락, 입력 생성 시각 차이, 혼합 target은 `limit
|
|
|
146
192
|
npm run verify
|
|
147
193
|
```
|
|
148
194
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
195
|
+
실제 두 producer와 외부 보존 근거 왕복을 검증하려면 cartograph 0.5.3 이상,
|
|
196
|
+
dartograph 바이너리와 두 도구가 함께 분석할 fixture 루트를 넘긴다. 이 검증은 producer
|
|
197
|
+
바이너리와 컴파일러 인덱스가 필요하므로 `npm run verify`와 공개 CI에는 포함되지 않으며
|
|
198
|
+
릴리스 전에 수동으로 실행한다.
|
|
152
199
|
|
|
153
200
|
```bash
|
|
154
201
|
node scripts/verify-cartograph-roundtrip.mjs \
|
|
155
202
|
/path/to/cartograph \
|
|
203
|
+
/path/to/dartograph \
|
|
156
204
|
/path/to/FalsePositiveCorpus
|
|
157
205
|
```
|
|
158
206
|
|
|
207
|
+
## 변경 전후 비교 (0.1.4 이상)
|
|
208
|
+
|
|
209
|
+
같은 프로젝트의 변경 전후 Dart·Swift 교환 파일을 비교하려면:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
isthmus diff \
|
|
213
|
+
--before before-dart.json before-swift.json \
|
|
214
|
+
--after after-dart.json after-swift.json --strict
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
`isthmus-diff` v1은 추가·제거된 논리 메서드 연결, 새로 관찰된 불일치와 사라진 불일치,
|
|
218
|
+
양 시점의 분석 한계와 그 차이, producer 버전·생성 시각을 JSON으로 출력한다. 연결에는 호출자와
|
|
219
|
+
핸들러 위치가 포함된다. 줄 이동은 연결 변경으로 세지 않으며 rename은 추측하지 않는다.
|
|
220
|
+
같은 논리 키의 호출자·핸들러 교체나 개별 호출 위치 증감은 이번 비교 범위에 포함하지 않는다.
|
|
221
|
+
|
|
222
|
+
`--strict`는 새로 관찰된 error가 있을 때만 1이다. 기존 오류·경고·분석 한계만 있으면 0이므로
|
|
223
|
+
성공 코드가 삭제 안전성이나 완전한 분석을 뜻하지 않는다. `resolvedIssues`도 이전 불일치가
|
|
224
|
+
더 이상 관찰되지 않는다는 뜻이며, 동적 전환·추출기 변경 때문인지 한계를 함께 확인해야 한다.
|
|
225
|
+
`--strict`은 인자 위치와 무관하게 인식하며 두 번 이상 줄 수 없다.
|
|
226
|
+
|
|
227
|
+
현재 diff는 Flutter의 Dart·Swift 문서만 받는다. 각 시점에 두 플랫폼이 모두 필요하며,
|
|
228
|
+
양 시점의 `project`와 플랫폼·도구별 문서 개수가
|
|
229
|
+
같아야 한다. 한 checkout의 같은 경로에서 각 revision을 빌드해 JSON을 보관한다. 일부 파일만
|
|
230
|
+
추출한 결과와 전체 결과를 비교하지 말고 같은 분석 설정을 사용한다. 입력 파일은 합계 256개,
|
|
231
|
+
텍스트 길이 제한은 기존 CLI와 동일하다. 혼합 target이나 비교 불가능한 입력은 코드 2로 거부한다.
|
|
232
|
+
`generatedAt`은 fact 추출 시각이며 revision 순서가 아니다. 비교 방향은 `--before`와
|
|
233
|
+
`--after` 인자로 결정되므로 사용자가 올바른 revision의 파일을 지정해야 한다.
|
|
234
|
+
|
|
159
235
|
## 코딩 에이전트 skill
|
|
160
236
|
|
|
161
237
|
네이티브 브리지 핸들러를 지우거나 이름을 바꾸기 전에 `query`로 다른 언어의 호출자를
|
|
162
238
|
확인하도록 가르치는 skill 원문을 [`Skills/isthmus/SKILL.md`](Skills/isthmus/SKILL.md)에 제공한다.
|
|
163
239
|
사용하는 에이전트의 프로젝트 skill 디렉터리에 이 파일을 복사해 사용할 수 있다.
|
|
164
240
|
|
|
241
|
+
Codex는 이 checkout의 `.agents/skills/isthmus` 링크로 같은 원문을 발견한다.
|
|
242
|
+
`Skills/isthmus/SKILL.md` 한 곳만 편집하며, npm 패키지에는 이 원문이 포함된다.
|
|
243
|
+
스킬 내용 검증과 모델별 지침 조정 근거는 [에이전트 감사 기록](docs/AGENT-AUDIT.md)에 있다.
|
|
244
|
+
|
|
165
245
|
## 라이선스
|
|
166
246
|
|
|
167
247
|
[MIT](LICENSE). 상업적 사용을 포함해 영구 무료다.
|
package/Skills/isthmus/SKILL.md
CHANGED
|
@@ -1,55 +1,45 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: isthmus
|
|
3
3
|
description: >-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Trace Flutter Dart-to-Swift bridge callers, compare bridge snapshots, or produce
|
|
5
|
+
cartograph retention evidence with isthmus. Use for native MethodChannel handler
|
|
6
|
+
changes; React Native and Kotlin extraction are not supported.
|
|
6
7
|
---
|
|
7
8
|
|
|
8
9
|
# isthmus
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Obtain
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
isthmus query <channel-or-method> <
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
isthmus retentions <bridge-facts.json> <bridge-facts.json> --for cartograph \
|
|
46
|
-
> external-retentions.json &&
|
|
47
|
-
test -s external-retentions.json &&
|
|
48
|
-
cartograph dead --external-retentions external-retentions.json
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Only continue when every command exits 0. A failed or empty retentions file is not evidence
|
|
52
|
-
that a native handler is unused; remove the incomplete output and regenerate both facts files.
|
|
53
|
-
|
|
54
|
-
Do not commit generated retention files when they contain local source paths unless the
|
|
55
|
-
project has explicitly chosen to version them.
|
|
11
|
+
Use current bridge facts to answer the requested boundary question. This skill supplies
|
|
12
|
+
analysis evidence; it does not authorize source edits, deletion, publishing, or a wider audit.
|
|
13
|
+
|
|
14
|
+
## Inputs
|
|
15
|
+
|
|
16
|
+
Use `isthmus-cli` 0.1.4+ (`isthmus` binary), cartograph 0.5.3+ and dartograph 0.1.1+.
|
|
17
|
+
Obtain both Dart and Swift bridge-facts JSON with identical project roots and analysis scope.
|
|
18
|
+
Swift production requires a built compiler index; use `cartograph bridges --target flutter --format json`.
|
|
19
|
+
Do not fabricate missing facts or rewrite project identifiers just to make a join pass.
|
|
20
|
+
If inputs are missing, identify the required files and proceed with independent authorized work.
|
|
21
|
+
|
|
22
|
+
## Choose the requested operation
|
|
23
|
+
|
|
24
|
+
- Trace callers: `isthmus query <channel-or-method> <dart.json> <swift.json>`.
|
|
25
|
+
Read `usedBy`, `dependsOn`, symbol evidence, and `limitations`.
|
|
26
|
+
`ambiguous` returns qualified-name candidates; disambiguate from context or ask when necessary.
|
|
27
|
+
- Review a change: `isthmus diff --before <old-dart.json> <old-swift.json> --after <new-dart.json> <new-swift.json> --strict`.
|
|
28
|
+
Inspect added/removed logical methods, introduced/resolved issues, both sets of limitations,
|
|
29
|
+
and producer versions/timestamps. Revisions come from the caller's before/after choice.
|
|
30
|
+
Same-key endpoint changes and rename inference are outside this comparison.
|
|
31
|
+
- Supply Swift retention evidence, when requested:
|
|
32
|
+
`isthmus retentions <dart.json> <swift.json> --for cartograph`.
|
|
33
|
+
Save stdout to a new private temporary file, check successful output, then pass its path to
|
|
34
|
+
`cartograph dead --external-retentions <path>`. Clean up only artifacts created for this run.
|
|
35
|
+
|
|
36
|
+
## Interpret and finish
|
|
37
|
+
|
|
38
|
+
Code 0 means the command ran successfully, not that code is safe to delete.
|
|
39
|
+
Code 1 from check/diff strict is a finding to report; query code 64 with
|
|
40
|
+
`notFound`/`ambiguous` is a usable answer, while usage errors require corrected arguments.
|
|
41
|
+
Code 2 indicates unreadable, invalid, or deferred inputs: explain the cause category and next step.
|
|
42
|
+
Empty results, `resolvedIssues`, and missing callers can reflect dynamic names or incomplete coverage.
|
|
43
|
+
Regenerate after source changes. Report the requested finding, relevant locations/symbols and limits.
|
|
44
|
+
Respect existing user authorization; ask only when missing information changes the action.
|
|
45
|
+
Do not commit generated facts/retentions with private project information.
|
|
@@ -15,8 +15,8 @@ export interface CommandResult {
|
|
|
15
15
|
export declare function runCheckCommand(arguments_: readonly string[], readTextFile: ReadTextFile): Promise<CommandResult>;
|
|
16
16
|
/** 입력을 순서대로 읽어 파일 수·메모리 상한 안에서 교환 문서로 파싱한다. */
|
|
17
17
|
export declare function readBridgeDocuments(inputPaths: readonly string[], readTextFile: ReadTextFile): Promise<BridgeFactsDocument[]>;
|
|
18
|
-
/**
|
|
19
|
-
export declare function
|
|
18
|
+
/** 알려진 입력·조인 실패를 원인별 해결 방향을 담은 코드 2 결과로 바꾼다. */
|
|
19
|
+
export declare function inputFailureResult(error: unknown): CommandResult | undefined;
|
|
20
20
|
/** 전체 조인 보류를 깨끗한 결과와 구분하는 코드 2 결과로 바꾼다. */
|
|
21
21
|
export declare function bridgeJoinDeferredError(): CommandResult;
|
|
22
22
|
/** 내부 결함을 입력 탓으로 돌리지 않는 경로 없는 코드 2 결과다. */
|
|
@@ -30,48 +30,103 @@ export async function runCheckCommand(arguments_, readTextFile) {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
return
|
|
33
|
+
return inputFailureResult(error) ?? internalError();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
/** 입력을 순서대로 읽어 파일 수·메모리 상한 안에서 교환 문서로 파싱한다. */
|
|
37
37
|
export async function readBridgeDocuments(inputPaths, readTextFile) {
|
|
38
38
|
const documents = [];
|
|
39
39
|
let totalTextLength = 0;
|
|
40
|
-
for (const path of inputPaths) {
|
|
40
|
+
for (const [index, path] of inputPaths.entries()) {
|
|
41
|
+
const inputPosition = index + 1;
|
|
41
42
|
let text;
|
|
42
43
|
try {
|
|
43
44
|
text = await readTextFile(path);
|
|
44
45
|
}
|
|
45
46
|
catch {
|
|
46
|
-
throw new
|
|
47
|
+
throw new BridgeInputReadError(inputPosition);
|
|
47
48
|
}
|
|
48
49
|
totalTextLength += text.length;
|
|
49
50
|
if (text.length > MAX_INPUT_TEXT_LENGTH ||
|
|
50
51
|
totalTextLength > MAX_TOTAL_INPUT_TEXT_LENGTH) {
|
|
51
|
-
throw new BridgeInputLimitError();
|
|
52
|
+
throw new BridgeInputLimitError(inputPosition);
|
|
52
53
|
}
|
|
53
54
|
try {
|
|
54
55
|
documents.push(parseBridgeFactsDocument(JSON.parse(text)));
|
|
55
56
|
}
|
|
56
57
|
catch (error) {
|
|
57
|
-
if (error instanceof SyntaxError
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
if (error instanceof SyntaxError) {
|
|
59
|
+
throw new BridgeInputJsonError(inputPosition);
|
|
60
|
+
}
|
|
61
|
+
if (error instanceof BridgeFactsValidationError) {
|
|
62
|
+
throw new BridgeInputContractError(inputPosition, error.message);
|
|
60
63
|
}
|
|
61
64
|
throw error;
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
return documents;
|
|
65
68
|
}
|
|
66
|
-
/**
|
|
69
|
+
/** 실패한 입력의 1부터 시작하는 순서를 보존하는 입력 오류다. */
|
|
67
70
|
class BridgeInputError extends Error {
|
|
71
|
+
inputPosition;
|
|
72
|
+
constructor(name, inputPosition) {
|
|
73
|
+
super(`${name} at input ${inputPosition}`);
|
|
74
|
+
this.name = name;
|
|
75
|
+
this.inputPosition = inputPosition;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** 입력 파일을 읽지 못한 경우를 구분한다. */
|
|
79
|
+
class BridgeInputReadError extends BridgeInputError {
|
|
80
|
+
constructor(inputPosition) {
|
|
81
|
+
super('BridgeInputReadError', inputPosition);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/** 입력 텍스트가 JSON이 아닌 경우를 구분한다. */
|
|
85
|
+
class BridgeInputJsonError extends BridgeInputError {
|
|
86
|
+
constructor(inputPosition) {
|
|
87
|
+
super('BridgeInputJsonError', inputPosition);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** 입력 문서가 교환 계약을 어긴 경우와 그 이유를 구분한다. */
|
|
91
|
+
class BridgeInputContractError extends BridgeInputError {
|
|
92
|
+
reason;
|
|
93
|
+
constructor(inputPosition, reason) {
|
|
94
|
+
super('BridgeInputContractError', inputPosition);
|
|
95
|
+
this.reason = reason;
|
|
96
|
+
}
|
|
68
97
|
}
|
|
69
98
|
/** 입력 텍스트의 크기만 계약을 넘은 경우를 구분한다. */
|
|
70
99
|
class BridgeInputLimitError extends BridgeInputError {
|
|
100
|
+
constructor(inputPosition) {
|
|
101
|
+
super('BridgeInputLimitError', inputPosition);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** 알려진 입력·조인 실패를 원인별 해결 방향을 담은 코드 2 결과로 바꾼다. */
|
|
105
|
+
export function inputFailureResult(error) {
|
|
106
|
+
if (error instanceof BridgeInputReadError) {
|
|
107
|
+
return inputFailure(`Unable to read bridge facts input ${error.inputPosition}; `
|
|
108
|
+
+ 'check that the file exists and is readable.\n');
|
|
109
|
+
}
|
|
110
|
+
if (error instanceof BridgeInputJsonError) {
|
|
111
|
+
return inputFailure(`Bridge facts input ${error.inputPosition} is not valid JSON; `
|
|
112
|
+
+ 'regenerate it with a bridge-facts producer.\n');
|
|
113
|
+
}
|
|
114
|
+
if (error instanceof BridgeInputContractError) {
|
|
115
|
+
return inputFailure(`Bridge facts input ${error.inputPosition} violates the bridge-facts `
|
|
116
|
+
+ `contract: ${error.reason}\n`);
|
|
117
|
+
}
|
|
118
|
+
if (error instanceof BridgeInputLimitError) {
|
|
119
|
+
return inputFailure(`Bridge facts input ${error.inputPosition} exceeds the input size limits; `
|
|
120
|
+
+ 'split the extraction into smaller documents.\n');
|
|
121
|
+
}
|
|
122
|
+
if (error instanceof BridgeJoinValidationError) {
|
|
123
|
+
return inputFailure(`${error.message}\n`);
|
|
124
|
+
}
|
|
125
|
+
return undefined;
|
|
71
126
|
}
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
return
|
|
127
|
+
/** 원인 메시지만 stdout 없이 코드 2로 내보낸다. */
|
|
128
|
+
function inputFailure(standardError) {
|
|
129
|
+
return { standardOutput: '', standardError, exitCode: 2 };
|
|
75
130
|
}
|
|
76
131
|
/** 전체 조인 보류를 깨끗한 결과와 구분하는 코드 2 결과로 바꾼다. */
|
|
77
132
|
export function bridgeJoinDeferredError() {
|
|
@@ -81,14 +136,6 @@ export function bridgeJoinDeferredError() {
|
|
|
81
136
|
exitCode: 2,
|
|
82
137
|
};
|
|
83
138
|
}
|
|
84
|
-
/** 파일·JSON·계약 오류를 민감정보 없는 코드 2 결과로 바꾼다. */
|
|
85
|
-
function inputError() {
|
|
86
|
-
return {
|
|
87
|
-
standardOutput: '',
|
|
88
|
-
standardError: 'Unable to read or validate bridge facts; check the input files.\n',
|
|
89
|
-
exitCode: 2,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
139
|
/** 내부 결함을 입력 탓으로 돌리지 않는 경로 없는 코드 2 결과다. */
|
|
93
140
|
export function internalError() {
|
|
94
141
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-command.js","sourceRoot":"","sources":["../../src/cli/check-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAKjF,wCAAwC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD,wCAAwC;AACxC,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAS5D,yCAAyC;AACzC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAA6B,EAC7B,YAA0B;IAE1B,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,OAAO;QAAE,OAAO,UAAU,EAAE,CAAC;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACnF,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,UAAU,CAAC;QAAE,OAAO,UAAU,EAAE,CAAC;IACzE,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IACjD,MAAM,UAAU,GAAG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xE,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC;AAED,yCAAyC;AACzC,SAAS,UAAU;IACjB,OAAO;QACL,cAAc,EAAE,EAAE;QAClB,aAAa,EAAE,GAAG,UAAU,IAAI;QAChC,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED,2BAA2B;AAC3B,MAAM,CAAC,MAAM,UAAU,GACrB,+DAA+D;MAC7D,sBAAsB,CAAC","sourcesContent":["import {\n BridgeFactsValidationError,\n parseBridgeFactsDocument,\n type BridgeFactsDocument,\n} from '../exchange/parse.ts';\nimport {\n BridgeJoinValidationError,\n isBridgeJoinDeferred,\n joinBridgeDocuments,\n MAX_DOCUMENTS_PER_JOIN,\n} from '../join/join.ts';\nimport { createCheckReport, encodeCheckReport } from '../report/check-report.ts';\n\n/** 파일 경로를 받아 UTF-8 텍스트를 읽는 주입 경계다. */\nexport type ReadTextFile = (path: string) => Promise<string>;\n\n/** 한 입력 파일에서 허용하는 최대 UTF-16 문자열 길이다. */\nexport const MAX_INPUT_TEXT_LENGTH = 16 * 1024 * 1024;\n\n/** 한 명령에서 허용하는 전체 UTF-16 입력 문자열 길이다. */\nexport const MAX_TOTAL_INPUT_TEXT_LENGTH = 64 * 1024 * 1024;\n\n/** CLI가 프로세스 경계에 쓸 출력과 종료 코드다. */\nexport interface CommandResult {\n readonly standardOutput: string;\n readonly standardError: string;\n readonly exitCode: 0 | 1 | 2 | 64;\n}\n\n/** check 인자를 실행해 프로세스에 독립적인 결과를 반환한다. */\nexport async function runCheckCommand(\n arguments_: readonly string[],\n readTextFile: ReadTextFile,\n): Promise<CommandResult> {\n if (arguments_[0] !== 'check') return usageError();\n const options = arguments_.slice(1).filter((argument) => argument.startsWith('-'));\n if (options.some((option) => option !== '--strict')) return usageError();\n const isStrict = arguments_.includes('--strict');\n const inputPaths = arguments_.slice(1).filter((argument) => argument !== '--strict');\n if (inputPaths.length < 2 || inputPaths.length > MAX_DOCUMENTS_PER_JOIN) {\n return usageError();\n }\n try {\n const documents = await readBridgeDocuments(inputPaths, readTextFile);\n const joined = joinBridgeDocuments(documents);\n if (isBridgeJoinDeferred(joined)) return bridgeJoinDeferredError();\n const report = createCheckReport(joined);\n return {\n standardOutput: encodeCheckReport(report),\n standardError: '',\n exitCode: isStrict && report.summary.errors > 0 ? 1 : 0,\n };\n } catch (error) {\n return isExpectedInputError(error) ? inputError() : internalError();\n }\n}\n\n/** 입력을 순서대로 읽어 파일 수·메모리 상한 안에서 교환 문서로 파싱한다. */\nexport async function readBridgeDocuments(\n inputPaths: readonly string[],\n readTextFile: ReadTextFile,\n): Promise<BridgeFactsDocument[]> {\n const documents: BridgeFactsDocument[] = [];\n let totalTextLength = 0;\n for (const path of inputPaths) {\n let text: string;\n try {\n text = await readTextFile(path);\n } catch {\n throw new BridgeInputError();\n }\n totalTextLength += text.length;\n if (\n text.length > MAX_INPUT_TEXT_LENGTH ||\n totalTextLength > MAX_TOTAL_INPUT_TEXT_LENGTH\n ) {\n throw new BridgeInputLimitError();\n }\n try {\n documents.push(parseBridgeFactsDocument(JSON.parse(text)));\n } catch (error) {\n if (\n error instanceof SyntaxError ||\n error instanceof BridgeFactsValidationError\n ) {\n throw new BridgeInputError();\n }\n throw error;\n }\n }\n return documents;\n}\n\n/** 입력 텍스트가 CLI 메모리 예산을 넘었음을 나타낸다. */\nclass BridgeInputError extends Error {}\n\n/** 입력 텍스트의 크기만 계약을 넘은 경우를 구분한다. */\nclass BridgeInputLimitError extends BridgeInputError {}\n\n/** 외부 입력에서 기대하는 실패 종류인지 확인한다. */\nexport function isExpectedInputError(error: unknown): boolean {\n return error instanceof BridgeInputError || error instanceof BridgeJoinValidationError;\n}\n\n/** 전체 조인 보류를 깨끗한 결과와 구분하는 코드 2 결과로 바꾼다. */\nexport function bridgeJoinDeferredError(): CommandResult {\n return {\n standardOutput: '',\n standardError:\n 'Bridge facts could not be joined; split mixed bridge targets and retry.\\n',\n exitCode: 2,\n };\n}\n\n/** 파일·JSON·계약 오류를 민감정보 없는 코드 2 결과로 바꾼다. */\nfunction inputError(): CommandResult {\n return {\n standardOutput: '',\n standardError:\n 'Unable to read or validate bridge facts; check the input files.\\n',\n exitCode: 2,\n };\n}\n\n/** 내부 결함을 입력 탓으로 돌리지 않는 경로 없는 코드 2 결과다. */\nexport function internalError(): CommandResult {\n return {\n standardOutput: '',\n standardError: 'Internal isthmus error; retry with a current version.\\n',\n exitCode: 2,\n };\n}\n\n/** 잘못된 CLI 호출을 경로 없는 사용법과 코드 64로 바꾼다. */\nfunction usageError(): CommandResult {\n return {\n standardOutput: '',\n standardError: `${checkUsage}\\n`,\n exitCode: 64,\n };\n}\n\n/** check 명령의 한 줄 사용법이다. */\nexport const checkUsage =\n 'Usage: isthmus check <bridge-facts.json> <bridge-facts.json> '\n + '[more...] [--strict]';\n"]}
|
|
1
|
+
{"version":3,"file":"check-command.js","sourceRoot":"","sources":["../../src/cli/check-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAKjF,wCAAwC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAEtD,wCAAwC;AACxC,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAS5D,yCAAyC;AACzC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAA6B,EAC7B,YAA0B;IAE1B,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,OAAO;QAAE,OAAO,UAAU,EAAE,CAAC;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM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;IACD,IAAI,KAAK,YAAY,qBAAqB,EAAE,CAAC;QAC3C,OAAO,YAAY,CACjB,sBAAsB,KAAK,CAAC,aAAa,kCAAkC;cACzE,gDAAgD,CACnD,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,YAAY,yBAAyB,EAAE,CAAC;QAC/C,OAAO,YAAY,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,oCAAoC;AACpC,SAAS,YAAY,CAAC,aAAqB;IACzC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAC5D,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,cAAc,EAAE,EAAE;QAClB,aAAa,EACX,2EAA2E;QAC7E,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,cAAc,EAAE,EAAE;QAClB,aAAa,EAAE,yDAAyD;QACxE,QAAQ,EAAE,CAAC;KACZ,CAAC;AACJ,CAAC;AAED,yCAAyC;AACzC,SAAS,UAAU;IACjB,OAAO;QACL,cAAc,EAAE,EAAE;QAClB,aAAa,EAAE,GAAG,UAAU,IAAI;QAChC,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED,2BAA2B;AAC3B,MAAM,CAAC,MAAM,UAAU,GACrB,+DAA+D;MAC7D,sBAAsB,CAAC","sourcesContent":["import {\n BridgeFactsValidationError,\n parseBridgeFactsDocument,\n type BridgeFactsDocument,\n} from '../exchange/parse.ts';\nimport {\n BridgeJoinValidationError,\n isBridgeJoinDeferred,\n joinBridgeDocuments,\n MAX_DOCUMENTS_PER_JOIN,\n} from '../join/join.ts';\nimport { createCheckReport, encodeCheckReport } from '../report/check-report.ts';\n\n/** 파일 경로를 받아 UTF-8 텍스트를 읽는 주입 경계다. */\nexport type ReadTextFile = (path: string) => Promise<string>;\n\n/** 한 입력 파일에서 허용하는 최대 UTF-16 문자열 길이다. */\nexport const MAX_INPUT_TEXT_LENGTH = 16 * 1024 * 1024;\n\n/** 한 명령에서 허용하는 전체 UTF-16 입력 문자열 길이다. */\nexport const MAX_TOTAL_INPUT_TEXT_LENGTH = 64 * 1024 * 1024;\n\n/** CLI가 프로세스 경계에 쓸 출력과 종료 코드다. */\nexport interface CommandResult {\n readonly standardOutput: string;\n readonly standardError: string;\n readonly exitCode: 0 | 1 | 2 | 64;\n}\n\n/** check 인자를 실행해 프로세스에 독립적인 결과를 반환한다. */\nexport async function runCheckCommand(\n arguments_: readonly string[],\n readTextFile: ReadTextFile,\n): Promise<CommandResult> {\n if (arguments_[0] !== 'check') return usageError();\n const options = arguments_.slice(1).filter((argument) => argument.startsWith('-'));\n if (options.some((option) => option !== '--strict')) return usageError();\n const isStrict = arguments_.includes('--strict');\n const inputPaths = arguments_.slice(1).filter((argument) => argument !== '--strict');\n if (inputPaths.length < 2 || inputPaths.length > MAX_DOCUMENTS_PER_JOIN) {\n return usageError();\n }\n try {\n const documents = await readBridgeDocuments(inputPaths, readTextFile);\n const joined = joinBridgeDocuments(documents);\n if (isBridgeJoinDeferred(joined)) return bridgeJoinDeferredError();\n const report = createCheckReport(joined);\n return {\n standardOutput: encodeCheckReport(report),\n standardError: '',\n exitCode: isStrict && report.summary.errors > 0 ? 1 : 0,\n };\n } catch (error) {\n return inputFailureResult(error) ?? internalError();\n }\n}\n\n/** 입력을 순서대로 읽어 파일 수·메모리 상한 안에서 교환 문서로 파싱한다. */\nexport async function readBridgeDocuments(\n inputPaths: readonly string[],\n readTextFile: ReadTextFile,\n): Promise<BridgeFactsDocument[]> {\n const documents: BridgeFactsDocument[] = [];\n let totalTextLength = 0;\n for (const [index, path] of inputPaths.entries()) {\n const inputPosition = index + 1;\n let text: string;\n try {\n text = await readTextFile(path);\n } catch {\n throw new BridgeInputReadError(inputPosition);\n }\n totalTextLength += text.length;\n if (\n text.length > MAX_INPUT_TEXT_LENGTH ||\n totalTextLength > MAX_TOTAL_INPUT_TEXT_LENGTH\n ) {\n throw new BridgeInputLimitError(inputPosition);\n }\n try {\n documents.push(parseBridgeFactsDocument(JSON.parse(text)));\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new BridgeInputJsonError(inputPosition);\n }\n if (error instanceof BridgeFactsValidationError) {\n throw new BridgeInputContractError(inputPosition, error.message);\n }\n throw error;\n }\n }\n return documents;\n}\n\n/** 실패한 입력의 1부터 시작하는 순서를 보존하는 입력 오류다. */\nclass BridgeInputError extends Error {\n readonly inputPosition: number;\n\n constructor(name: string, inputPosition: number) {\n super(`${name} at input ${inputPosition}`);\n this.name = name;\n this.inputPosition = inputPosition;\n }\n}\n\n/** 입력 파일을 읽지 못한 경우를 구분한다. */\nclass BridgeInputReadError extends BridgeInputError {\n constructor(inputPosition: number) {\n super('BridgeInputReadError', inputPosition);\n }\n}\n\n/** 입력 텍스트가 JSON이 아닌 경우를 구분한다. */\nclass BridgeInputJsonError extends BridgeInputError {\n constructor(inputPosition: number) {\n super('BridgeInputJsonError', inputPosition);\n }\n}\n\n/** 입력 문서가 교환 계약을 어긴 경우와 그 이유를 구분한다. */\nclass BridgeInputContractError extends BridgeInputError {\n readonly reason: string;\n\n constructor(inputPosition: number, reason: string) {\n super('BridgeInputContractError', inputPosition);\n this.reason = reason;\n }\n}\n\n/** 입력 텍스트의 크기만 계약을 넘은 경우를 구분한다. */\nclass BridgeInputLimitError extends BridgeInputError {\n constructor(inputPosition: number) {\n super('BridgeInputLimitError', inputPosition);\n }\n}\n\n/** 알려진 입력·조인 실패를 원인별 해결 방향을 담은 코드 2 결과로 바꾼다. */\nexport function inputFailureResult(error: unknown): CommandResult | undefined {\n if (error instanceof BridgeInputReadError) {\n return inputFailure(\n `Unable to read bridge facts input ${error.inputPosition}; `\n + 'check that the file exists and is readable.\\n',\n );\n }\n if (error instanceof BridgeInputJsonError) {\n return inputFailure(\n `Bridge facts input ${error.inputPosition} is not valid JSON; `\n + 'regenerate it with a bridge-facts producer.\\n',\n );\n }\n if (error instanceof BridgeInputContractError) {\n return inputFailure(\n `Bridge facts input ${error.inputPosition} violates the bridge-facts `\n + `contract: ${error.reason}\\n`,\n );\n }\n if (error instanceof BridgeInputLimitError) {\n return inputFailure(\n `Bridge facts input ${error.inputPosition} exceeds the input size limits; `\n + 'split the extraction into smaller documents.\\n',\n );\n }\n if (error instanceof BridgeJoinValidationError) {\n return inputFailure(`${error.message}\\n`);\n }\n return undefined;\n}\n\n/** 원인 메시지만 stdout 없이 코드 2로 내보낸다. */\nfunction inputFailure(standardError: string): CommandResult {\n return { standardOutput: '', standardError, exitCode: 2 };\n}\n\n/** 전체 조인 보류를 깨끗한 결과와 구분하는 코드 2 결과로 바꾼다. */\nexport function bridgeJoinDeferredError(): CommandResult {\n return {\n standardOutput: '',\n standardError:\n 'Bridge facts could not be joined; split mixed bridge targets and retry.\\n',\n exitCode: 2,\n };\n}\n\n/** 내부 결함을 입력 탓으로 돌리지 않는 경로 없는 코드 2 결과다. */\nexport function internalError(): CommandResult {\n return {\n standardOutput: '',\n standardError: 'Internal isthmus error; retry with a current version.\\n',\n exitCode: 2,\n };\n}\n\n/** 잘못된 CLI 호출을 경로 없는 사용법과 코드 64로 바꾼다. */\nfunction usageError(): CommandResult {\n return {\n standardOutput: '',\n standardError: `${checkUsage}\\n`,\n exitCode: 64,\n };\n}\n\n/** check 명령의 한 줄 사용법이다. */\nexport const checkUsage =\n 'Usage: isthmus check <bridge-facts.json> <bridge-facts.json> '\n + '[more...] [--strict]';\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type CommandResult, type ReadTextFile } from './check-command.ts';
|
|
2
|
+
/** 전후 교환 파일을 하나의 입력 예산으로 읽어 새 경계 오류만 CI 실패로 표시한다. */
|
|
3
|
+
export declare function runDiffCommand(arguments_: readonly string[], readTextFile: ReadTextFile): Promise<CommandResult>;
|
|
4
|
+
/** 각 snapshot은 caller와 receiver 문서를 함께 제공해야 한다. */
|
|
5
|
+
export declare const diffUsage: string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MAX_DOCUMENTS_PER_JOIN } from "../join/join.js";
|
|
2
|
+
import { createBridgeDiff } from "../report/diff.js";
|
|
3
|
+
import { encodeSortedJson } from "../report/sorted-json.js";
|
|
4
|
+
import { internalError, inputFailureResult, readBridgeDocuments, } from "./check-command.js";
|
|
5
|
+
/** 전후 교환 파일을 하나의 입력 예산으로 읽어 새 경계 오류만 CI 실패로 표시한다. */
|
|
6
|
+
export async function runDiffCommand(arguments_, readTextFile) {
|
|
7
|
+
const strictFlags = arguments_.filter((argument) => argument === '--strict');
|
|
8
|
+
const args = arguments_.filter((argument) => argument !== '--strict');
|
|
9
|
+
const separator = args.indexOf('--after');
|
|
10
|
+
const beforePaths = args.slice(2, separator);
|
|
11
|
+
const afterPaths = args.slice(separator + 1);
|
|
12
|
+
const paths = [...beforePaths, ...afterPaths];
|
|
13
|
+
if (args[0] !== 'diff' ||
|
|
14
|
+
args[1] !== '--before' ||
|
|
15
|
+
strictFlags.length > 1 ||
|
|
16
|
+
separator < 4 ||
|
|
17
|
+
beforePaths.length < 2 ||
|
|
18
|
+
afterPaths.length < 2 ||
|
|
19
|
+
paths.length > MAX_DOCUMENTS_PER_JOIN ||
|
|
20
|
+
paths.some((path) => path.trim().length === 0 || path.startsWith('-'))) {
|
|
21
|
+
return { standardOutput: '', standardError: `${diffUsage}\n`, exitCode: 64 };
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const documents = await readBridgeDocuments(paths, readTextFile);
|
|
25
|
+
const report = createBridgeDiff(documents.slice(0, beforePaths.length), documents.slice(beforePaths.length));
|
|
26
|
+
return {
|
|
27
|
+
standardOutput: encodeSortedJson(report),
|
|
28
|
+
standardError: '',
|
|
29
|
+
exitCode: strictFlags.length === 1 && report.summary.introducedErrors > 0 ? 1 : 0,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return inputFailureResult(error) ?? internalError();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** 각 snapshot은 caller와 receiver 문서를 함께 제공해야 한다. */
|
|
37
|
+
export const diffUsage = 'Usage: isthmus diff --before <dart.json> <swift.json> [more...] '
|
|
38
|
+
+ '--after <dart.json> <swift.json> [more...] [--strict]';
|
|
39
|
+
//# sourceMappingURL=diff-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-command.js","sourceRoot":"","sources":["../../src/cli/diff-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC;AAE5B,qDAAqD;AACrD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAA6B,EAC7B,YAA0B;IAE1B,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC;IAC7E,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,CAAC,GAAG,WAAW,EAAE,GAAG,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GACpB,kEAAkE;MAChE,uDAAuD,CAAC","sourcesContent":["import { MAX_DOCUMENTS_PER_JOIN } from '../join/join.ts';\nimport { createBridgeDiff } from '../report/diff.ts';\nimport { encodeSortedJson } from '../report/sorted-json.ts';\nimport {\n internalError,\n inputFailureResult,\n readBridgeDocuments,\n type CommandResult,\n type ReadTextFile,\n} from './check-command.ts';\n\n/** 전후 교환 파일을 하나의 입력 예산으로 읽어 새 경계 오류만 CI 실패로 표시한다. */\nexport async function runDiffCommand(\n arguments_: readonly string[],\n readTextFile: ReadTextFile,\n): Promise<CommandResult> {\n const strictFlags = arguments_.filter((argument) => argument === '--strict');\n const args = arguments_.filter((argument) => argument !== '--strict');\n const separator = args.indexOf('--after');\n const beforePaths = args.slice(2, separator);\n const afterPaths = args.slice(separator + 1);\n const paths = [...beforePaths, ...afterPaths];\n if (\n args[0] !== 'diff' ||\n args[1] !== '--before' ||\n strictFlags.length > 1 ||\n separator < 4 ||\n beforePaths.length < 2 ||\n afterPaths.length < 2 ||\n paths.length > MAX_DOCUMENTS_PER_JOIN ||\n paths.some((path) => path.trim().length === 0 || path.startsWith('-'))\n ) {\n return { standardOutput: '', standardError: `${diffUsage}\\n`, exitCode: 64 };\n }\n try {\n const documents = await readBridgeDocuments(paths, readTextFile);\n const report = createBridgeDiff(\n documents.slice(0, beforePaths.length),\n documents.slice(beforePaths.length),\n );\n return {\n standardOutput: encodeSortedJson(report),\n standardError: '',\n exitCode: strictFlags.length === 1 && report.summary.introducedErrors > 0 ? 1 : 0,\n };\n } catch (error) {\n return inputFailureResult(error) ?? internalError();\n }\n}\n\n/** 각 snapshot은 caller와 receiver 문서를 함께 제공해야 한다. */\nexport const diffUsage =\n 'Usage: isthmus diff --before <dart.json> <swift.json> [more...] '\n + '--after <dart.json> <swift.json> [more...] [--strict]';\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isBridgeJoinDeferred, joinBridgeDocuments, MAX_DOCUMENTS_PER_JOIN, } from "../join/join.js";
|
|
2
2
|
import { BridgeGraphLimitError, BridgeGraphValidationError, createBridgeGraph, renderBridgeGraph, } from "../report/graph.js";
|
|
3
|
-
import { bridgeJoinDeferredError, internalError,
|
|
3
|
+
import { bridgeJoinDeferredError, internalError, inputFailureResult, readBridgeDocuments, } from "./check-command.js";
|
|
4
4
|
/** graph 인자를 실행해 경계 그래프와 종료 코드를 반환한다. */
|
|
5
5
|
export async function runGraphCommand(arguments_, readTextFile) {
|
|
6
6
|
const options = parseGraphArguments(arguments_);
|
|
@@ -19,11 +19,15 @@ export async function runGraphCommand(arguments_, readTextFile) {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
|
-
|
|
23
|
-
error instanceof
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
if (error instanceof BridgeGraphLimitError ||
|
|
23
|
+
error instanceof BridgeGraphValidationError) {
|
|
24
|
+
return {
|
|
25
|
+
standardOutput: '',
|
|
26
|
+
standardError: `${error.message}\n`,
|
|
27
|
+
exitCode: 2,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return inputFailureResult(error) ?? internalError();
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
/** graph의 입력 파일과 선택 출력 형식을 검증한다. */
|
|
@@ -56,14 +60,6 @@ function graphUsageError() {
|
|
|
56
60
|
exitCode: 64,
|
|
57
61
|
};
|
|
58
62
|
}
|
|
59
|
-
/** graph 입력 실패를 경로 없는 코드 2로 바꾼다. */
|
|
60
|
-
function graphInputError() {
|
|
61
|
-
return {
|
|
62
|
-
standardOutput: '',
|
|
63
|
-
standardError: 'Unable to read or validate bridge facts; check the input files.\n',
|
|
64
|
-
exitCode: 2,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
63
|
/** graph 명령의 한 줄 사용법이다. */
|
|
68
64
|
export const graphUsage = 'Usage: isthmus graph <bridge-facts.json> <bridge-facts.json> '
|
|
69
65
|
+ '[more...] [--format json|dot|mermaid]';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph-command.js","sourceRoot":"","sources":["../../src/cli/graph-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"graph-command.js","sourceRoot":"","sources":["../../src/cli/graph-command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,uBAAuB,EACvB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GAGpB,MAAM,oBAAoB,CAAC;AAE5B,yCAAyC;AACzC,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,UAA6B,EAC7B,YAA0B;IAE1B,MAAM,OAAO,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAChD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,eAAe,EAAE,CAAC;IACpD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC9E,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,oBAAoB,CAAC,MAAM,CAAC;YAAE,OAAO,uBAAuB,EAAE,CAAC;QACnE,MAAM,KAAK,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;QACxC,OAAO;YACL,cAAc,EAAE,iBAAiB,CAAC,KAAK,EAAE,OAAO,CAAC,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CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC;AAED,0BAA0B;AAC1B,SAAS,aAAa,CAAC,KAAyB;IAC9C,OAAO,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,SAAS,CAAC;AACpE,CAAC;AAED,qCAAqC;AACrC,SAAS,eAAe;IACtB,OAAO;QACL,cAAc,EAAE,EAAE;QAClB,aAAa,EAAE,GAAG,UAAU,IAAI;QAChC,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAUD,2BAA2B;AAC3B,MAAM,CAAC,MAAM,UAAU,GACrB,+DAA+D;MAC7D,uCAAuC,CAAC","sourcesContent":["import {\n isBridgeJoinDeferred,\n joinBridgeDocuments,\n MAX_DOCUMENTS_PER_JOIN,\n} from '../join/join.ts';\nimport {\n BridgeGraphLimitError,\n BridgeGraphValidationError,\n createBridgeGraph,\n renderBridgeGraph,\n} from '../report/graph.ts';\nimport {\n bridgeJoinDeferredError,\n internalError,\n inputFailureResult,\n readBridgeDocuments,\n type CommandResult,\n type ReadTextFile,\n} from './check-command.ts';\n\n/** graph 인자를 실행해 경계 그래프와 종료 코드를 반환한다. */\nexport async function runGraphCommand(\n arguments_: readonly string[],\n readTextFile: ReadTextFile,\n): Promise<CommandResult> {\n const options = parseGraphArguments(arguments_);\n if (options === undefined) return graphUsageError();\n try {\n const documents = await readBridgeDocuments(options.inputPaths, readTextFile);\n const joined = joinBridgeDocuments(documents);\n if (isBridgeJoinDeferred(joined)) return bridgeJoinDeferredError();\n const graph = createBridgeGraph(joined);\n return {\n standardOutput: renderBridgeGraph(graph, options.format),\n standardError: '',\n exitCode: 0,\n };\n } catch (error) {\n if (\n error instanceof BridgeGraphLimitError ||\n error instanceof BridgeGraphValidationError\n ) {\n return {\n standardOutput: '',\n standardError: `${error.message}\\n`,\n exitCode: 2,\n };\n }\n return inputFailureResult(error) ?? internalError();\n }\n}\n\n/** graph의 입력 파일과 선택 출력 형식을 검증한다. */\nfunction parseGraphArguments(arguments_: readonly string[]): GraphOptions | undefined {\n if (arguments_[0] !== 'graph') return undefined;\n const formatIndex = arguments_.indexOf('--format');\n const inputPaths = arguments_.slice(1, formatIndex < 0 ? undefined : formatIndex);\n if (\n inputPaths.length < 2 ||\n inputPaths.length > MAX_DOCUMENTS_PER_JOIN ||\n inputPaths.some((path) => path.startsWith('-'))\n ) {\n return undefined;\n }\n if (formatIndex < 0) return { inputPaths, format: 'json' };\n if (formatIndex !== arguments_.length - 2) return undefined;\n const format = arguments_[formatIndex + 1];\n return isGraphFormat(format) ? { inputPaths, format } : undefined;\n}\n\n/** 지원하는 그래프 형식인지 확인한다. */\nfunction isGraphFormat(value: string | undefined): value is GraphFormat {\n return value === 'json' || value === 'dot' || value === 'mermaid';\n}\n\n/** graph 사용 오류를 경로 없는 코드 64로 바꾼다. */\nfunction graphUsageError(): CommandResult {\n return {\n standardOutput: '',\n standardError: `${graphUsage}\\n`,\n exitCode: 64,\n };\n}\n\n/** 검증된 graph 명령 옵션이다. */\ninterface GraphOptions {\n readonly inputPaths: readonly string[];\n readonly format: GraphFormat;\n}\n\ntype GraphFormat = 'json' | 'dot' | 'mermaid';\n\n/** graph 명령의 한 줄 사용법이다. */\nexport const graphUsage =\n 'Usage: isthmus graph <bridge-facts.json> <bridge-facts.json> '\n + '[more...] [--format json|dot|mermaid]';\n"]}
|
package/dist/cli/main.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { readFile } from 'node:fs/promises';
|
|
3
3
|
import { checkUsage, runCheckCommand, } from "./check-command.js";
|
|
4
4
|
import { graphUsage, runGraphCommand } from "./graph-command.js";
|
|
5
|
+
import { diffUsage, runDiffCommand } from "./diff-command.js";
|
|
5
6
|
import { queryUsage, runQueryCommand } from "./query-command.js";
|
|
6
7
|
import { retentionUsage, runRetentionsCommand, } from "./retentions-command.js";
|
|
7
8
|
process.stdout.on('error', handleStreamError);
|
|
@@ -9,6 +10,7 @@ process.stderr.on('error', handleStreamError);
|
|
|
9
10
|
const commandUsages = new Map([
|
|
10
11
|
['check', checkUsage],
|
|
11
12
|
['graph', graphUsage],
|
|
13
|
+
['diff', diffUsage],
|
|
12
14
|
['query', queryUsage],
|
|
13
15
|
['retentions', retentionUsage],
|
|
14
16
|
]);
|
|
@@ -18,6 +20,7 @@ Commands:
|
|
|
18
20
|
check Report unmatched bridge calls and handlers
|
|
19
21
|
query Find both sides of a channel or method
|
|
20
22
|
graph Render matched boundary edges
|
|
23
|
+
diff Compare bridge observations before and after a change
|
|
21
24
|
retentions Produce external retention evidence
|
|
22
25
|
|
|
23
26
|
Options:
|
|
@@ -64,6 +67,8 @@ async function dispatchCommand(commandArguments) {
|
|
|
64
67
|
return runCheckCommand(commandArguments, readTextFile);
|
|
65
68
|
case 'graph':
|
|
66
69
|
return runGraphCommand(commandArguments, readTextFile);
|
|
70
|
+
case 'diff':
|
|
71
|
+
return runDiffCommand(commandArguments, readTextFile);
|
|
67
72
|
case 'query':
|
|
68
73
|
return runQueryCommand(commandArguments, readTextFile);
|
|
69
74
|
case 'retentions': {
|