github-mobile-reader 0.1.2 → 0.1.4
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.ko.md +74 -65
- package/README.md +73 -66
- package/dist/action.js +72 -188
- package/dist/cli.js +74 -189
- package/dist/index.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +85 -35
- package/dist/index.mjs +83 -35
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -44,7 +44,7 @@ data
|
|
|
44
44
|
- **GitHub Action** — 레포에 YAML 파일 하나만 추가하면 PR마다 Reader 문서가 자동 생성됩니다
|
|
45
45
|
- **파일별 분리 출력** — 변경된 JS/TS 파일마다 독립적인 섹션으로 출력
|
|
46
46
|
- **JSX/Tailwind 인식** — `.jsx`/`.tsx` 파일은 컴포넌트 트리(`🎨 JSX Structure`)와 Tailwind 클래스 diff(`💅 Style Changes`)를 별도 섹션으로 분리 출력
|
|
47
|
-
-
|
|
47
|
+
- **심볼 단위 요약** — 전체 코드 블록을 덤프하는 대신, 어떤 함수/컴포넌트가 추가·삭제·수정됐는지 목록으로 표시
|
|
48
48
|
- **보수적 설계** — 패턴이 애매할 때는 잘못된 정보를 보여주는 대신 덜 보여줍니다
|
|
49
49
|
- **보안 기본값** — 토큰은 `$GITHUB_TOKEN` 환경변수로만 읽음 — 셸 히스토리나 `ps` 목록에 노출되는 `--token` 플래그 없음
|
|
50
50
|
|
|
@@ -108,18 +108,20 @@ npx github-mobile-reader --repo owner/repo --all
|
|
|
108
108
|
|
|
109
109
|
PR마다 `reader-output/pr-<번호>.md` 파일 하나가 생성됩니다.
|
|
110
110
|
|
|
111
|
-
JSX/TSX 파일은 추가 섹션이 생성됩니다:
|
|
111
|
+
변경 요약이 없는 파일은 자동으로 생략됩니다. JSX/TSX 파일은 추가 섹션이 생성됩니다:
|
|
112
112
|
|
|
113
113
|
```
|
|
114
114
|
# 📖 PR #42 — My Feature
|
|
115
115
|
|
|
116
116
|
## 📄 `src/App.tsx`
|
|
117
117
|
|
|
118
|
-
###
|
|
118
|
+
### 변경된 함수 / 컴포넌트
|
|
119
|
+
- ✅ `parseArgs()` — added
|
|
120
|
+
- ✏️ `processPR()` — modified
|
|
121
|
+
- ❌ `oldHelper()` — removed
|
|
122
|
+
|
|
119
123
|
### 🎨 JSX Structure ← 컴포넌트 계층 구조 (JSX/TSX 전용)
|
|
120
124
|
### 💅 Style Changes ← 추가/제거된 Tailwind 클래스 (JSX/TSX 전용)
|
|
121
|
-
### ✅ Added Code
|
|
122
|
-
### ❌ Removed Code
|
|
123
125
|
```
|
|
124
126
|
|
|
125
127
|
> **참고:** `reader-output/`는 기본적으로 `.gitignore`에 포함되어 있습니다 — 생성된 파일은 로컬에만 저장되며 레포지토리에 커밋되지 않습니다.
|
|
@@ -219,9 +221,10 @@ src/languages/
|
|
|
219
221
|
|
|
220
222
|
이 라이브러리를 사용하는 가장 쉬운 방법입니다. 매 PR마다 자동으로:
|
|
221
223
|
|
|
222
|
-
1. 변경된 `.js` / `.ts` 파일의 diff를 파싱
|
|
223
|
-
2.
|
|
224
|
-
|
|
224
|
+
1. 변경된 `.js` / `.jsx` / `.ts` / `.tsx` / `.mjs` / `.cjs` 파일의 diff를 파싱
|
|
225
|
+
2. Reader Markdown 요약을 **PR 코멘트**로 게시 (파일 커밋 불필요)
|
|
226
|
+
|
|
227
|
+
> **브랜치 보호 규칙과 호환** — 워크플로우는 `pull-requests: write` 권한만 필요합니다. 커밋을 push하지 않으므로 엄격한 브랜치 보호 규칙이 설정된 레포에서도 동작합니다.
|
|
225
228
|
|
|
226
229
|
### Step 1 — 워크플로우 파일 추가
|
|
227
230
|
|
|
@@ -235,7 +238,6 @@ on:
|
|
|
235
238
|
types: [opened, synchronize, reopened]
|
|
236
239
|
|
|
237
240
|
permissions:
|
|
238
|
-
contents: write # .md 파일 커밋
|
|
239
241
|
pull-requests: write # PR 코멘트 작성
|
|
240
242
|
|
|
241
243
|
jobs:
|
|
@@ -247,44 +249,45 @@ jobs:
|
|
|
247
249
|
- name: Checkout
|
|
248
250
|
uses: actions/checkout@v4
|
|
249
251
|
with:
|
|
250
|
-
fetch-depth: 0
|
|
252
|
+
fetch-depth: 0
|
|
251
253
|
|
|
252
|
-
- name:
|
|
253
|
-
uses:
|
|
254
|
+
- name: Setup Node
|
|
255
|
+
uses: actions/setup-node@v4
|
|
254
256
|
with:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
node-version: '20'
|
|
258
|
+
|
|
259
|
+
- name: Generate Reader Markdown
|
|
260
|
+
run: npx github-mobile-reader@latest --repo ${{ github.repository }} --pr ${{ github.event.pull_request.number }} --out ./reader-output
|
|
258
261
|
env:
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
- name:
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
262
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
263
|
+
|
|
264
|
+
- name: Post PR Comment
|
|
265
|
+
uses: actions/github-script@v7
|
|
266
|
+
with:
|
|
267
|
+
script: |
|
|
268
|
+
const fs = require('fs');
|
|
269
|
+
const path = './reader-output/pr-${{ github.event.pull_request.number }}.md';
|
|
270
|
+
if (!fs.existsSync(path)) { console.log('생성된 파일 없음.'); return; }
|
|
271
|
+
const body = fs.readFileSync(path, 'utf8');
|
|
272
|
+
const comments = await github.rest.issues.listComments({
|
|
273
|
+
owner: context.repo.owner, repo: context.repo.repo,
|
|
274
|
+
issue_number: ${{ github.event.pull_request.number }},
|
|
275
|
+
});
|
|
276
|
+
const prev = comments.data.find(c =>
|
|
277
|
+
c.user.login === 'github-actions[bot]' && c.body.startsWith('# 📖 PR #')
|
|
278
|
+
);
|
|
279
|
+
if (prev) await github.rest.issues.deleteComment({
|
|
280
|
+
owner: context.repo.owner, repo: context.repo.repo, comment_id: prev.id,
|
|
281
|
+
});
|
|
282
|
+
await github.rest.issues.createComment({
|
|
283
|
+
owner: context.repo.owner, repo: context.repo.repo,
|
|
284
|
+
issue_number: ${{ github.event.pull_request.number }}, body,
|
|
285
|
+
});
|
|
272
286
|
```
|
|
273
287
|
|
|
274
288
|
### Step 2 — PR 열기
|
|
275
289
|
|
|
276
|
-
이게 전부입니다. 이후 모든 PR에
|
|
277
|
-
|
|
278
|
-
- `docs/reader/pr-<번호>.md` 파일 생성
|
|
279
|
-
- 생성된 파일 링크가 담긴 PR 코멘트 자동 게시
|
|
280
|
-
|
|
281
|
-
### Action 입력값
|
|
282
|
-
|
|
283
|
-
| 입력값 | 필수 | 기본값 | 설명 |
|
|
284
|
-
| -------------- | ---- | ------------- | ---------------------------------- |
|
|
285
|
-
| `github_token` | ✅ | — | `${{ secrets.GITHUB_TOKEN }}` 사용 |
|
|
286
|
-
| `base_branch` | ❌ | `main` | PR이 머지되는 대상 브랜치 |
|
|
287
|
-
| `output_dir` | ❌ | `docs/reader` | 생성된 `.md` 파일 저장 경로 |
|
|
290
|
+
이게 전부입니다. 이후 모든 PR에 `github-actions[bot]`이 Reader Markdown 코멘트를 자동으로 달아줍니다. 새 커밋을 push할 때마다 코멘트가 업데이트됩니다 (중복 게시 없음).
|
|
288
291
|
|
|
289
292
|
---
|
|
290
293
|
|
|
@@ -363,47 +366,53 @@ console.log(treeLines.join("\n"));
|
|
|
363
366
|
|
|
364
367
|
## 출력 형식
|
|
365
368
|
|
|
366
|
-
생성된 Reader Markdown
|
|
369
|
+
생성된 Reader Markdown 코멘트는 다음 구조로 작성됩니다:
|
|
367
370
|
|
|
368
|
-
|
|
369
|
-
# 📖
|
|
371
|
+
```markdown
|
|
372
|
+
# 📖 PR #42 — My Feature
|
|
370
373
|
|
|
371
|
-
> Generated by **github-mobile-reader**
|
|
372
374
|
> Repository: my-org/my-repo
|
|
373
|
-
> Pull Request: #42
|
|
374
375
|
> Commit: `a1b2c3d`
|
|
375
|
-
>
|
|
376
|
+
> 변경된 JS/TS 파일: 2개
|
|
376
377
|
|
|
377
378
|
---
|
|
378
379
|
|
|
379
|
-
##
|
|
380
|
+
## 📄 `src/api/users.ts`
|
|
380
381
|
|
|
381
|
-
|
|
382
|
-
getData()
|
|
383
|
-
└─ filter(callback)
|
|
384
|
-
└─ map(item → value)
|
|
385
|
-
└─ reduce(callback)
|
|
386
|
-
```
|
|
382
|
+
### 변경된 함수 / 컴포넌트
|
|
387
383
|
|
|
388
|
-
|
|
384
|
+
- ✅ `getUser()` — added
|
|
385
|
+
- ✏️ `updateUser()` — modified
|
|
386
|
+
- ❌ `legacyFetch()` — removed
|
|
389
387
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
```
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## 📄 `src/components/UserCard.tsx`
|
|
391
|
+
|
|
392
|
+
### 변경된 함수 / 컴포넌트
|
|
396
393
|
|
|
397
|
-
|
|
394
|
+
- ✏️ `UserCard()` — modified
|
|
398
395
|
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
### 🎨 JSX Structure
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
div
|
|
400
|
+
header
|
|
401
|
+
section
|
|
402
|
+
UserAvatar
|
|
403
|
+
UserName
|
|
401
404
|
```
|
|
402
405
|
|
|
406
|
+
### 💅 Style Changes
|
|
407
|
+
|
|
408
|
+
**div**
|
|
409
|
+
+ dark:bg-gray-900 rounded-xl
|
|
410
|
+
- bg-white
|
|
411
|
+
|
|
403
412
|
---
|
|
404
413
|
|
|
405
|
-
🛠 Auto-generated by github-mobile-reader.
|
|
406
|
-
|
|
414
|
+
🛠 Auto-generated by github-mobile-reader.
|
|
415
|
+
```
|
|
407
416
|
|
|
408
417
|
---
|
|
409
418
|
|
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ data
|
|
|
42
42
|
- **GitHub Action** — drop one YAML block into any repo and get auto-generated Reader docs on every PR
|
|
43
43
|
- **File-by-file output** — each changed JS/TS file gets its own independent section in the output
|
|
44
44
|
- **JSX/Tailwind aware** — `.jsx`/`.tsx` files get a component tree (`🎨 JSX Structure`) and a Tailwind class diff (`💅 Style Changes`) instead of one unreadable blob
|
|
45
|
-
- **
|
|
45
|
+
- **Symbol-level summary** — instead of dumping entire code blocks, the output lists which functions/components were added, removed, or modified
|
|
46
46
|
- **Conservative by design** — when a pattern is ambiguous, the library shows less rather than showing something wrong
|
|
47
47
|
- **Secure by default** — token is read from `$GITHUB_TOKEN` only; no flag that leaks to shell history or `ps`
|
|
48
48
|
|
|
@@ -177,18 +177,20 @@ Token: read from `$GITHUB_TOKEN` environment variable (60 req/hr unauthenticated
|
|
|
177
177
|
|
|
178
178
|
Each PR produces one file: `reader-output/pr-<number>.md`.
|
|
179
179
|
|
|
180
|
-
Inside that file, every changed JS/TS file gets its own section.
|
|
180
|
+
Inside that file, every changed JS/TS file gets its own section. Files with no detectable symbol changes are automatically skipped.
|
|
181
181
|
|
|
182
182
|
```
|
|
183
183
|
# 📖 PR #42 — My Feature
|
|
184
184
|
|
|
185
185
|
## 📄 `src/App.tsx`
|
|
186
186
|
|
|
187
|
-
###
|
|
187
|
+
### 변경된 함수 / 컴포넌트
|
|
188
|
+
- ✅ `parseArgs()` — added
|
|
189
|
+
- ✏️ `processPR()` — modified
|
|
190
|
+
- ❌ `oldHelper()` — removed
|
|
191
|
+
|
|
188
192
|
### 🎨 JSX Structure ← component hierarchy (JSX/TSX only)
|
|
189
193
|
### 💅 Style Changes ← added/removed Tailwind classes (JSX/TSX only)
|
|
190
|
-
### ✅ Added Code
|
|
191
|
-
### ❌ Removed Code
|
|
192
194
|
```
|
|
193
195
|
|
|
194
196
|
> **Note:** `reader-output/` is gitignored by default — the generated files are local only and not committed to your repository.
|
|
@@ -217,9 +219,10 @@ console.log(markdown);
|
|
|
217
219
|
|
|
218
220
|
The easiest way to use this library is as a GitHub Action. On every pull request it will:
|
|
219
221
|
|
|
220
|
-
1. Parse the diff of all changed `.js` / `.ts` files
|
|
221
|
-
2.
|
|
222
|
-
|
|
222
|
+
1. Parse the diff of all changed `.js` / `.jsx` / `.ts` / `.tsx` / `.mjs` / `.cjs` files
|
|
223
|
+
2. Post a Reader Markdown summary as a **PR comment** (no file commits required)
|
|
224
|
+
|
|
225
|
+
> **Branch protection compatible** — the workflow only needs `pull-requests: write` permission. It does not push any commits, so it works even with strict branch protection rules.
|
|
223
226
|
|
|
224
227
|
### Step 1 — Add the workflow file
|
|
225
228
|
|
|
@@ -233,8 +236,7 @@ on:
|
|
|
233
236
|
types: [opened, synchronize, reopened]
|
|
234
237
|
|
|
235
238
|
permissions:
|
|
236
|
-
|
|
237
|
-
pull-requests: write # post the PR comment
|
|
239
|
+
pull-requests: write # post PR comment
|
|
238
240
|
|
|
239
241
|
jobs:
|
|
240
242
|
generate-reader:
|
|
@@ -245,44 +247,45 @@ jobs:
|
|
|
245
247
|
- name: Checkout
|
|
246
248
|
uses: actions/checkout@v4
|
|
247
249
|
with:
|
|
248
|
-
fetch-depth: 0
|
|
250
|
+
fetch-depth: 0
|
|
249
251
|
|
|
250
|
-
- name:
|
|
251
|
-
uses:
|
|
252
|
+
- name: Setup Node
|
|
253
|
+
uses: actions/setup-node@v4
|
|
252
254
|
with:
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
255
|
+
node-version: '20'
|
|
256
|
+
|
|
257
|
+
- name: Generate Reader Markdown
|
|
258
|
+
run: npx github-mobile-reader@latest --repo ${{ github.repository }} --pr ${{ github.event.pull_request.number }} --out ./reader-output
|
|
256
259
|
env:
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
- name:
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
260
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
261
|
+
|
|
262
|
+
- name: Post PR Comment
|
|
263
|
+
uses: actions/github-script@v7
|
|
264
|
+
with:
|
|
265
|
+
script: |
|
|
266
|
+
const fs = require('fs');
|
|
267
|
+
const path = './reader-output/pr-${{ github.event.pull_request.number }}.md';
|
|
268
|
+
if (!fs.existsSync(path)) { console.log('No reader file generated.'); return; }
|
|
269
|
+
const body = fs.readFileSync(path, 'utf8');
|
|
270
|
+
const comments = await github.rest.issues.listComments({
|
|
271
|
+
owner: context.repo.owner, repo: context.repo.repo,
|
|
272
|
+
issue_number: ${{ github.event.pull_request.number }},
|
|
273
|
+
});
|
|
274
|
+
const prev = comments.data.find(c =>
|
|
275
|
+
c.user.login === 'github-actions[bot]' && c.body.startsWith('# 📖 PR #')
|
|
276
|
+
);
|
|
277
|
+
if (prev) await github.rest.issues.deleteComment({
|
|
278
|
+
owner: context.repo.owner, repo: context.repo.repo, comment_id: prev.id,
|
|
279
|
+
});
|
|
280
|
+
await github.rest.issues.createComment({
|
|
281
|
+
owner: context.repo.owner, repo: context.repo.repo,
|
|
282
|
+
issue_number: ${{ github.event.pull_request.number }}, body,
|
|
283
|
+
});
|
|
270
284
|
```
|
|
271
285
|
|
|
272
286
|
### Step 2 — Open a PR
|
|
273
287
|
|
|
274
|
-
That's it. Every subsequent PR will automatically get
|
|
275
|
-
|
|
276
|
-
- A Reader Markdown file at `docs/reader/pr-<number>.md`
|
|
277
|
-
- A comment on the PR linking to the generated file
|
|
278
|
-
|
|
279
|
-
### Action Inputs
|
|
280
|
-
|
|
281
|
-
| Input | Required | Default | Description |
|
|
282
|
-
| -------------- | -------- | ------------- | ----------------------------------- |
|
|
283
|
-
| `github_token` | ✅ | — | Use `${{ secrets.GITHUB_TOKEN }}` |
|
|
284
|
-
| `base_branch` | ❌ | `main` | The branch the PR is merging into |
|
|
285
|
-
| `output_dir` | ❌ | `docs/reader` | Directory for generated `.md` files |
|
|
288
|
+
That's it. Every subsequent PR will automatically get a Reader Markdown comment posted by `github-actions[bot]`. The comment is updated (not duplicated) on every new push.
|
|
286
289
|
|
|
287
290
|
---
|
|
288
291
|
|
|
@@ -361,49 +364,53 @@ console.log(treeLines.join("\n"));
|
|
|
361
364
|
|
|
362
365
|
## Output Format
|
|
363
366
|
|
|
364
|
-
A generated Reader Markdown
|
|
367
|
+
A generated Reader Markdown comment has the following structure:
|
|
365
368
|
|
|
366
369
|
```markdown
|
|
367
|
-
# 📖
|
|
370
|
+
# 📖 PR #42 — My Feature
|
|
368
371
|
|
|
369
|
-
> Generated by **github-mobile-reader**
|
|
370
372
|
> Repository: my-org/my-repo
|
|
371
|
-
> Pull Request: #42
|
|
372
373
|
> Commit: `a1b2c3d`
|
|
373
|
-
>
|
|
374
|
+
> 변경된 JS/TS 파일: 2개
|
|
374
375
|
|
|
375
376
|
---
|
|
376
377
|
|
|
377
|
-
##
|
|
378
|
-
```
|
|
378
|
+
## 📄 `src/api/users.ts`
|
|
379
379
|
|
|
380
|
-
|
|
381
|
-
└─ filter(callback)
|
|
382
|
-
└─ map(item → value)
|
|
383
|
-
└─ reduce(callback)
|
|
380
|
+
### 변경된 함수 / 컴포넌트
|
|
384
381
|
|
|
385
|
-
|
|
382
|
+
- ✅ `getUser()` — added
|
|
383
|
+
- ✏️ `updateUser()` — modified
|
|
384
|
+
- ❌ `legacyFetch()` — removed
|
|
386
385
|
|
|
387
|
-
|
|
386
|
+
---
|
|
388
387
|
|
|
389
|
-
|
|
390
|
-
const result = getData()
|
|
391
|
-
.filter(item => item.active)
|
|
392
|
-
.map(item => item.value)
|
|
393
|
-
.reduce((a, b) => a + b, 0)
|
|
394
|
-
````
|
|
388
|
+
## 📄 `src/components/UserCard.tsx`
|
|
395
389
|
|
|
396
|
-
|
|
390
|
+
### 변경된 함수 / 컴포넌트
|
|
397
391
|
|
|
398
|
-
|
|
399
|
-
|
|
392
|
+
- ✏️ `UserCard()` — modified
|
|
393
|
+
|
|
394
|
+
### 🎨 JSX Structure
|
|
395
|
+
|
|
396
|
+
```
|
|
397
|
+
div
|
|
398
|
+
header
|
|
399
|
+
section
|
|
400
|
+
UserAvatar
|
|
401
|
+
UserName
|
|
400
402
|
```
|
|
401
403
|
|
|
402
|
-
|
|
404
|
+
### 💅 Style Changes
|
|
403
405
|
|
|
404
|
-
|
|
406
|
+
**div**
|
|
407
|
+
+ dark:bg-gray-900 rounded-xl
|
|
408
|
+
- bg-white
|
|
405
409
|
|
|
406
|
-
|
|
410
|
+
---
|
|
411
|
+
|
|
412
|
+
🛠 Auto-generated by github-mobile-reader.
|
|
413
|
+
```
|
|
407
414
|
|
|
408
415
|
---
|
|
409
416
|
|