huntr-cli 1.0.9
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/.env.example +7 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +43 -0
- package/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +29 -0
- package/.github/labels.json +92 -0
- package/.github/pull_request_template.md +64 -0
- package/.github/workflows/ci.yml +87 -0
- package/.github/workflows/labels.yml +27 -0
- package/.github/workflows/manual-publish.yml +105 -0
- package/.github/workflows/publish.yml +57 -0
- package/.github/workflows/release.yml +124 -0
- package/.github/workflows/security-audit.yml +44 -0
- package/.husky/pre-commit +12 -0
- package/.husky/pre-push +27 -0
- package/.lintstagedrc.json +3 -0
- package/AGENTS.md +449 -0
- package/CHANGELOG.md +38 -0
- package/CHANGES.md +259 -0
- package/LICENSE +15 -0
- package/PUBLISHING.md +191 -0
- package/README.md +385 -0
- package/ROADMAP.md +158 -0
- package/SETUP-COMPLETE.md +446 -0
- package/WORKFLOW-SUMMARY.md +368 -0
- package/completions/_huntr +168 -0
- package/completions/huntr.1 +266 -0
- package/completions/huntr.bash +91 -0
- package/dist/api/client.d.ts +14 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +74 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/personal/activities.d.ts +20 -0
- package/dist/api/personal/activities.d.ts.map +1 -0
- package/dist/api/personal/activities.js +50 -0
- package/dist/api/personal/activities.js.map +1 -0
- package/dist/api/personal/boards.d.ts +9 -0
- package/dist/api/personal/boards.d.ts.map +1 -0
- package/dist/api/personal/boards.js +16 -0
- package/dist/api/personal/boards.js.map +1 -0
- package/dist/api/personal/index.d.ts +17 -0
- package/dist/api/personal/index.d.ts.map +1 -0
- package/dist/api/personal/index.js +37 -0
- package/dist/api/personal/index.js.map +1 -0
- package/dist/api/personal/jobs.d.ts +13 -0
- package/dist/api/personal/jobs.d.ts.map +1 -0
- package/dist/api/personal/jobs.js +31 -0
- package/dist/api/personal/jobs.js.map +1 -0
- package/dist/api/personal/user.d.ts +8 -0
- package/dist/api/personal/user.d.ts.map +1 -0
- package/dist/api/personal/user.js +13 -0
- package/dist/api/personal/user.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +501 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/capture-session.d.ts +10 -0
- package/dist/commands/capture-session.d.ts.map +1 -0
- package/dist/commands/capture-session.js +478 -0
- package/dist/commands/capture-session.js.map +1 -0
- package/dist/config/clerk-session-manager.d.ts +44 -0
- package/dist/config/clerk-session-manager.d.ts.map +1 -0
- package/dist/config/clerk-session-manager.js +232 -0
- package/dist/config/clerk-session-manager.js.map +1 -0
- package/dist/config/config-manager.d.ts +15 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +51 -0
- package/dist/config/config-manager.js.map +1 -0
- package/dist/config/keychain-manager.d.ts +6 -0
- package/dist/config/keychain-manager.d.ts.map +1 -0
- package/dist/config/keychain-manager.js +37 -0
- package/dist/config/keychain-manager.js.map +1 -0
- package/dist/config/token-capture.d.ts +11 -0
- package/dist/config/token-capture.d.ts.map +1 -0
- package/dist/config/token-capture.js +252 -0
- package/dist/config/token-capture.js.map +1 -0
- package/dist/config/token-manager.d.ts +38 -0
- package/dist/config/token-manager.d.ts.map +1 -0
- package/dist/config/token-manager.js +153 -0
- package/dist/config/token-manager.js.map +1 -0
- package/dist/lib/list-options.d.ts +69 -0
- package/dist/lib/list-options.d.ts.map +1 -0
- package/dist/lib/list-options.js +299 -0
- package/dist/lib/list-options.js.map +1 -0
- package/dist/types/personal.d.ts +113 -0
- package/dist/types/personal.d.ts.map +1 -0
- package/dist/types/personal.js +4 -0
- package/dist/types/personal.js.map +1 -0
- package/docs/AUTOMATIC-PUBLISHING.md +520 -0
- package/docs/CHANGELOG-AUTOMATION.md +418 -0
- package/docs/CI-CD-SETUP.md +582 -0
- package/docs/DEV-SETUP.md +512 -0
- package/docs/ENHANCEMENT-PLAN.md +204 -0
- package/docs/ENTITY-TYPES.md +462 -0
- package/docs/GITHUB-ACTIONS-GUIDE.md +367 -0
- package/docs/NPM-PUBLISHING.md +324 -0
- package/docs/OUTPUT-EXAMPLES.md +414 -0
- package/docs/OUTPUT-FORMATS.md +299 -0
- package/docs/TESTING.md +216 -0
- package/eslint.config.js +68 -0
- package/package.json +64 -0
- package/src/api/client.ts +88 -0
- package/src/api/personal/activities.ts +66 -0
- package/src/api/personal/boards.ts +14 -0
- package/src/api/personal/index.ts +25 -0
- package/src/api/personal/jobs.ts +33 -0
- package/src/api/personal/user.ts +10 -0
- package/src/cli.ts +487 -0
- package/src/commands/capture-session.ts +582 -0
- package/src/config/clerk-session-manager.ts +263 -0
- package/src/config/config-manager.ts +56 -0
- package/src/config/keychain-manager.ts +30 -0
- package/src/config/token-capture.ts +233 -0
- package/src/config/token-manager.ts +139 -0
- package/src/lib/list-options.ts +370 -0
- package/src/types/personal.ts +114 -0
- package/tests/example.test.ts +130 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
# CI/CD Setup Guide
|
|
2
|
+
|
|
3
|
+
This document explains the complete CI/CD pipeline for huntr-cli, including pre-commit hooks, GitHub Actions workflows, and best practices.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
1. [Local Development Hooks](#local-development-hooks)
|
|
8
|
+
2. [GitHub Actions Workflows](#github-actions-workflows)
|
|
9
|
+
3. [Publishing to npm](#publishing-to-npm)
|
|
10
|
+
4. [Setting Up Secrets](#setting-up-secrets)
|
|
11
|
+
5. [Best Practices](#best-practices)
|
|
12
|
+
6. [Troubleshooting](#troubleshooting)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Local Development Hooks
|
|
17
|
+
|
|
18
|
+
### Setup (First Time)
|
|
19
|
+
|
|
20
|
+
When you clone the repo or first install dependencies, hooks are automatically set up:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install
|
|
24
|
+
# npm's "prepare" script automatically runs husky install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or manually initialize:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm run prepare
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Pre-commit Hook
|
|
34
|
+
|
|
35
|
+
**What it does:** Runs linting on only the files you're committing (via `lint-staged`)
|
|
36
|
+
|
|
37
|
+
**When it runs:** Before `git commit`
|
|
38
|
+
|
|
39
|
+
**Files checked:**
|
|
40
|
+
- All staged TypeScript files in `src/`
|
|
41
|
+
|
|
42
|
+
**What happens on failure:**
|
|
43
|
+
- ❌ Commit is blocked
|
|
44
|
+
- ESLint errors are shown
|
|
45
|
+
- You must fix errors and re-stage files
|
|
46
|
+
|
|
47
|
+
**Example:**
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
$ git add src/cli.ts
|
|
51
|
+
$ git commit -m "feat: add new feature"
|
|
52
|
+
|
|
53
|
+
🔍 Running pre-commit checks...
|
|
54
|
+
✓ src/cli.ts (eslint --fix)
|
|
55
|
+
✓ Pre-commit checks passed
|
|
56
|
+
|
|
57
|
+
[main abc1234] feat: add new feature
|
|
58
|
+
1 file changed, 10 insertions(+)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Manual linting:**
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm run lint # Check all files
|
|
65
|
+
npm run lint:fix # Auto-fix errors
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Pre-push Hook
|
|
69
|
+
|
|
70
|
+
**What it does:** Comprehensive checks before pushing to remote
|
|
71
|
+
|
|
72
|
+
**When it runs:** Before `git push` (blocks if checks fail)
|
|
73
|
+
|
|
74
|
+
**Checks performed (in order):**
|
|
75
|
+
1. TypeScript compilation (`npm run typecheck`)
|
|
76
|
+
2. Linting all source files (`npm run lint`)
|
|
77
|
+
3. Build to `dist/` (`npm run build`)
|
|
78
|
+
|
|
79
|
+
**What happens on failure:**
|
|
80
|
+
- ❌ Push is blocked
|
|
81
|
+
- Error details shown
|
|
82
|
+
- You must fix the issue before retrying push
|
|
83
|
+
|
|
84
|
+
**Example:**
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
$ git push origin feature/new-feature
|
|
88
|
+
|
|
89
|
+
🧪 Running pre-push checks...
|
|
90
|
+
📋 Typechecking...
|
|
91
|
+
✓ No TypeScript errors
|
|
92
|
+
🔍 Linting all source files...
|
|
93
|
+
✓ Lint passed
|
|
94
|
+
🔨 Building...
|
|
95
|
+
✓ Build successful
|
|
96
|
+
✓ All pre-push checks passed
|
|
97
|
+
|
|
98
|
+
Counting objects: 3, done.
|
|
99
|
+
Writing objects: 100% (3/3), 287 bytes | 287.00 KiB/s, done.
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Bypassing Hooks (Not Recommended)
|
|
103
|
+
|
|
104
|
+
**⚠️ Use only in emergencies:**
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Skip pre-commit hook only
|
|
108
|
+
git commit --no-verify
|
|
109
|
+
|
|
110
|
+
# Skip pre-push hook only
|
|
111
|
+
git push --no-verify
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Better approach:** Fix the issue instead of bypassing!
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## GitHub Actions Workflows
|
|
119
|
+
|
|
120
|
+
### CI Workflow (`.github/workflows/ci.yml`)
|
|
121
|
+
|
|
122
|
+
Runs on every push and pull request to `main` or `develop`.
|
|
123
|
+
|
|
124
|
+
**Jobs (run in parallel):**
|
|
125
|
+
|
|
126
|
+
1. **Lint** (ubuntu-latest)
|
|
127
|
+
- Installs Node 18
|
|
128
|
+
- Runs `npm run lint`
|
|
129
|
+
- Fails if lint errors found
|
|
130
|
+
|
|
131
|
+
2. **Typecheck** (ubuntu-latest)
|
|
132
|
+
- Installs Node 18
|
|
133
|
+
- Runs `npm run typecheck`
|
|
134
|
+
- Fails if TypeScript errors found
|
|
135
|
+
|
|
136
|
+
3. **Build** (ubuntu-latest)
|
|
137
|
+
- Installs Node 18
|
|
138
|
+
- Runs `npm run build`
|
|
139
|
+
- Uploads `dist/` artifacts (1 day retention)
|
|
140
|
+
|
|
141
|
+
4. **Test** (ubuntu-latest)
|
|
142
|
+
- Installs Node 18
|
|
143
|
+
- Runs `npm test`
|
|
144
|
+
|
|
145
|
+
**When it fails:**
|
|
146
|
+
- PR shows red ❌ check
|
|
147
|
+
- Cannot merge PR until all jobs pass
|
|
148
|
+
- See logs at: `Actions` tab → workflow run
|
|
149
|
+
|
|
150
|
+
**View logs:**
|
|
151
|
+
1. Go to GitHub repo
|
|
152
|
+
2. Click `Actions` tab
|
|
153
|
+
3. Click the workflow run
|
|
154
|
+
4. Click the failed job
|
|
155
|
+
5. Click the failed step for details
|
|
156
|
+
|
|
157
|
+
### Publish Workflow (`.github/workflows/publish.yml`)
|
|
158
|
+
|
|
159
|
+
Automatically publishes to npm when a GitHub Release is created.
|
|
160
|
+
|
|
161
|
+
**Trigger:** Release published (created from existing tag)
|
|
162
|
+
|
|
163
|
+
**Steps:**
|
|
164
|
+
1. Checkout code
|
|
165
|
+
2. Setup Node 18
|
|
166
|
+
3. Install dependencies
|
|
167
|
+
4. Run linting
|
|
168
|
+
5. Typecheck
|
|
169
|
+
6. Build
|
|
170
|
+
7. **Publish to npm** using `NPM_TOKEN` secret
|
|
171
|
+
8. Comment on release with success/failure
|
|
172
|
+
|
|
173
|
+
**How to trigger:**
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# 1. Create and push git tag
|
|
177
|
+
git tag v1.1.0
|
|
178
|
+
git push origin v1.1.0
|
|
179
|
+
|
|
180
|
+
# 2. Create release in GitHub UI or CLI
|
|
181
|
+
gh release create v1.1.0 --title "Version 1.1.0" --generate-notes
|
|
182
|
+
|
|
183
|
+
# OR use GitHub web UI:
|
|
184
|
+
# Go to Releases → Create new release → select tag → Publish release
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Requirements:**
|
|
188
|
+
- `NPM_TOKEN` secret configured (see [Setting Up Secrets](#setting-up-secrets))
|
|
189
|
+
- Version in `package.json` must match tag (or set manually)
|
|
190
|
+
|
|
191
|
+
### Manual Publish Workflow (`.github/workflows/manual-publish.yml`)
|
|
192
|
+
|
|
193
|
+
On-demand publishing without requiring a GitHub Release.
|
|
194
|
+
|
|
195
|
+
**Trigger:** Manual via GitHub UI (`Actions` → `Manual Publish` → `Run workflow`)
|
|
196
|
+
|
|
197
|
+
**Input:**
|
|
198
|
+
- `version` — Version to publish (e.g., `1.1.0`, `1.1.0-beta.1`)
|
|
199
|
+
- `npm_tag` — npm tag (`latest`, `beta`, `next`, `rc`)
|
|
200
|
+
|
|
201
|
+
**Steps:**
|
|
202
|
+
1. Validate version format
|
|
203
|
+
2. Update `package.json`
|
|
204
|
+
3. Lint → Typecheck → Build
|
|
205
|
+
4. Publish to npm with specified tag
|
|
206
|
+
5. Create git tag
|
|
207
|
+
6. Create GitHub Release
|
|
208
|
+
7. (Optional) Send Slack notification
|
|
209
|
+
|
|
210
|
+
**How to use:**
|
|
211
|
+
|
|
212
|
+
1. Go to GitHub repo → `Actions` tab
|
|
213
|
+
2. Click `Manual Publish` workflow
|
|
214
|
+
3. Click `Run workflow`
|
|
215
|
+
4. Fill in version (e.g., `1.1.0-beta.1`)
|
|
216
|
+
5. Select npm tag (`beta` for prereleases)
|
|
217
|
+
6. Click `Run workflow`
|
|
218
|
+
|
|
219
|
+
**Requirements:**
|
|
220
|
+
- `NPM_TOKEN` secret
|
|
221
|
+
- `SLACK_WEBHOOK_URL` secret (optional, for notifications)
|
|
222
|
+
|
|
223
|
+
### Security Audit Workflow (`.github/workflows/security-audit.yml`)
|
|
224
|
+
|
|
225
|
+
Audits dependencies for vulnerabilities daily and on-demand.
|
|
226
|
+
|
|
227
|
+
**Triggers:**
|
|
228
|
+
- Daily at midnight UTC
|
|
229
|
+
- Every push to main/develop
|
|
230
|
+
- Manual via `Actions` tab
|
|
231
|
+
|
|
232
|
+
**Steps:**
|
|
233
|
+
1. Install dependencies
|
|
234
|
+
2. Run `npm audit` (moderate severity or higher)
|
|
235
|
+
3. Upload audit report as artifact
|
|
236
|
+
|
|
237
|
+
**View audit reports:**
|
|
238
|
+
1. Go to `Actions` → `Security Audit`
|
|
239
|
+
2. Click the latest run
|
|
240
|
+
3. Download artifacts
|
|
241
|
+
|
|
242
|
+
**Audit severity levels:**
|
|
243
|
+
- `low` — Minor issues
|
|
244
|
+
- `moderate` — Consider updating
|
|
245
|
+
- `high` — Should update soon
|
|
246
|
+
- `critical` — Update immediately
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Publishing to npm
|
|
251
|
+
|
|
252
|
+
### Method 1: Automatic (GitHub Release)
|
|
253
|
+
|
|
254
|
+
Best for releases from GitHub:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# 1. Update version in package.json
|
|
258
|
+
npm version minor # 1.0.0 → 1.1.0
|
|
259
|
+
|
|
260
|
+
# 2. Push to GitHub
|
|
261
|
+
git push origin main --tags
|
|
262
|
+
|
|
263
|
+
# 3. Create release in GitHub UI or CLI
|
|
264
|
+
gh release create v1.1.0 --generate-notes
|
|
265
|
+
|
|
266
|
+
# The publish.yml workflow automatically publishes to npm
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Advantages:**
|
|
270
|
+
- Automatic
|
|
271
|
+
- Release notes auto-generated
|
|
272
|
+
- GitHub Release created automatically
|
|
273
|
+
- Professional workflow
|
|
274
|
+
|
|
275
|
+
### Method 2: Manual Dispatch
|
|
276
|
+
|
|
277
|
+
For pre-releases or emergencies:
|
|
278
|
+
|
|
279
|
+
1. Go to GitHub repo
|
|
280
|
+
2. `Actions` tab
|
|
281
|
+
3. `Manual Publish` workflow
|
|
282
|
+
4. `Run workflow`
|
|
283
|
+
5. Enter version and npm tag
|
|
284
|
+
6. Click `Run`
|
|
285
|
+
|
|
286
|
+
**Use cases:**
|
|
287
|
+
- Publishing betas/RCs
|
|
288
|
+
- Fixing version issues
|
|
289
|
+
- Publishing without Git flow
|
|
290
|
+
|
|
291
|
+
### Method 3: Local (Manual)
|
|
292
|
+
|
|
293
|
+
For testing only, not recommended for production:
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
# 1. Ensure everything is committed
|
|
297
|
+
git status
|
|
298
|
+
|
|
299
|
+
# 2. Update version
|
|
300
|
+
npm version minor
|
|
301
|
+
|
|
302
|
+
# 3. Build & publish
|
|
303
|
+
npm publish
|
|
304
|
+
|
|
305
|
+
# 4. Create git tag & push
|
|
306
|
+
git tag v1.1.0
|
|
307
|
+
git push origin main --tags
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**⚠️ Not recommended:** No automated checks, easy to forget steps
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## Setting Up Secrets
|
|
315
|
+
|
|
316
|
+
### NPM Token
|
|
317
|
+
|
|
318
|
+
Required for automated publishing:
|
|
319
|
+
|
|
320
|
+
1. Go to npmjs.com
|
|
321
|
+
2. Profile → `Access Tokens`
|
|
322
|
+
3. Generate new token (Automation level)
|
|
323
|
+
4. Copy token (long string starting with `npm_`)
|
|
324
|
+
5. GitHub repo → Settings → Secrets and variables → Actions
|
|
325
|
+
6. Create new secret: `NPM_TOKEN` = paste token
|
|
326
|
+
|
|
327
|
+
**Verify:**
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
npm whoami
|
|
331
|
+
# Should show your npm username
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Slack Webhook (Optional)
|
|
335
|
+
|
|
336
|
+
For Slack notifications on publish events:
|
|
337
|
+
|
|
338
|
+
1. Go to your Slack workspace
|
|
339
|
+
2. Create incoming webhook
|
|
340
|
+
3. Copy webhook URL
|
|
341
|
+
4. GitHub repo → Settings → Secrets → Actions
|
|
342
|
+
5. Create new secret: `SLACK_WEBHOOK_URL` = paste URL
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
## Best Practices
|
|
347
|
+
|
|
348
|
+
### 1. Always Create Feature Branches
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
# Good
|
|
352
|
+
git checkout -b feat/new-feature
|
|
353
|
+
git checkout -b fix/bug-fix
|
|
354
|
+
git checkout -b docs/update-readme
|
|
355
|
+
|
|
356
|
+
# Bad
|
|
357
|
+
git commit directly to main
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### 2. Use Conventional Commits
|
|
361
|
+
|
|
362
|
+
Following the pattern: `type: description`
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
git commit -m "feat: add field selection to list commands"
|
|
366
|
+
git commit -m "fix: pdf export format error handling"
|
|
367
|
+
git commit -m "docs: update publishing guide"
|
|
368
|
+
git commit -m "chore: update dependencies"
|
|
369
|
+
git commit -m "refactor: simplify list options parsing"
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
**Types:**
|
|
373
|
+
- `feat:` — New feature
|
|
374
|
+
- `fix:` — Bug fix
|
|
375
|
+
- `docs:` — Documentation only
|
|
376
|
+
- `chore:` — Dependencies, configs, etc.
|
|
377
|
+
- `refactor:` — Code restructuring
|
|
378
|
+
- `test:` — Test-related changes
|
|
379
|
+
- `perf:` — Performance improvements
|
|
380
|
+
|
|
381
|
+
### 3. Write Meaningful Commit Messages
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
# Good
|
|
385
|
+
git commit -m "feat: add --fields parameter for field selection
|
|
386
|
+
|
|
387
|
+
- Allows users to select specific columns in output
|
|
388
|
+
- Works with all formats: table, json, csv, pdf, excel
|
|
389
|
+
- Validates field names and provides helpful error messages
|
|
390
|
+
- Backward compatible (defaults to all fields)"
|
|
391
|
+
|
|
392
|
+
# Bad
|
|
393
|
+
git commit -m "changes"
|
|
394
|
+
git commit -m "update"
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### 4. Keep Commits Atomic
|
|
398
|
+
|
|
399
|
+
Each commit should be a logical unit:
|
|
400
|
+
|
|
401
|
+
```bash
|
|
402
|
+
# Good: separate concerns
|
|
403
|
+
git add src/lib/list-options.ts
|
|
404
|
+
git commit -m "feat: add field validation function"
|
|
405
|
+
|
|
406
|
+
git add src/cli.ts
|
|
407
|
+
git commit -m "feat: use field validation in commands"
|
|
408
|
+
|
|
409
|
+
# Bad: mixing unrelated changes
|
|
410
|
+
git add src/lib/list-options.ts src/cli.ts src/api/client.ts
|
|
411
|
+
git commit -m "various updates"
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
### 5. Push Before Merging
|
|
415
|
+
|
|
416
|
+
Always push to remote before creating PR:
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
git push origin feature/new-feature
|
|
420
|
+
# Then create PR on GitHub
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### 6. Require Passing Checks
|
|
424
|
+
|
|
425
|
+
Branch protection rules enforce workflow compliance:
|
|
426
|
+
|
|
427
|
+
**Configured (recommended):**
|
|
428
|
+
- ✅ Require CI to pass before merge
|
|
429
|
+
- ✅ Require linear history
|
|
430
|
+
- ✅ Dismiss stale PR reviews
|
|
431
|
+
|
|
432
|
+
See GitHub repo → Settings → Branches → Branch protection rules
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
436
|
+
## Troubleshooting
|
|
437
|
+
|
|
438
|
+
### Pre-commit Hook Fails
|
|
439
|
+
|
|
440
|
+
**Issue:** ESLint errors block commit
|
|
441
|
+
|
|
442
|
+
**Solution:**
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
# Auto-fix errors
|
|
446
|
+
npm run lint:fix
|
|
447
|
+
|
|
448
|
+
# Re-stage fixed files
|
|
449
|
+
git add .
|
|
450
|
+
|
|
451
|
+
# Retry commit
|
|
452
|
+
git commit -m "feat: my changes"
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
### Pre-push Hook Fails
|
|
456
|
+
|
|
457
|
+
**Issue:** TypeScript, lint, or build errors block push
|
|
458
|
+
|
|
459
|
+
**Solution:**
|
|
460
|
+
|
|
461
|
+
```bash
|
|
462
|
+
# Check what failed
|
|
463
|
+
npm run typecheck # TypeScript errors?
|
|
464
|
+
npm run lint # Linting errors?
|
|
465
|
+
npm run build # Build errors?
|
|
466
|
+
|
|
467
|
+
# Fix the issue, then retry
|
|
468
|
+
git push origin feature-branch
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Hook Not Running
|
|
472
|
+
|
|
473
|
+
**Issue:** Pre-commit/pre-push hooks not executing
|
|
474
|
+
|
|
475
|
+
**Solution:**
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
# Re-install hooks
|
|
479
|
+
npm run prepare
|
|
480
|
+
|
|
481
|
+
# Make sure hooks are executable
|
|
482
|
+
chmod +x .husky/pre-commit
|
|
483
|
+
chmod +x .husky/pre-push
|
|
484
|
+
|
|
485
|
+
# Verify installation
|
|
486
|
+
ls -la .husky/
|
|
487
|
+
# Should show pre-commit and pre-push
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### npm audit Fails on CI
|
|
491
|
+
|
|
492
|
+
**Issue:** Security vulnerabilities found
|
|
493
|
+
|
|
494
|
+
**Solution:**
|
|
495
|
+
|
|
496
|
+
```bash
|
|
497
|
+
# Check locally
|
|
498
|
+
npm audit
|
|
499
|
+
|
|
500
|
+
# Fix automatically (if available)
|
|
501
|
+
npm audit fix
|
|
502
|
+
|
|
503
|
+
# Or update specific package
|
|
504
|
+
npm update <package-name>
|
|
505
|
+
|
|
506
|
+
# Commit and push
|
|
507
|
+
git add package-lock.json
|
|
508
|
+
git commit -m "chore: fix security vulnerabilities"
|
|
509
|
+
git push
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
### Publish Fails on GitHub Actions
|
|
513
|
+
|
|
514
|
+
**Issue:** Publishing workflow error
|
|
515
|
+
|
|
516
|
+
**Check:**
|
|
517
|
+
|
|
518
|
+
1. Is `NPM_TOKEN` secret configured?
|
|
519
|
+
- Go to Settings → Secrets → Actions
|
|
520
|
+
- Verify `NPM_TOKEN` exists
|
|
521
|
+
|
|
522
|
+
2. Is the token valid?
|
|
523
|
+
```bash
|
|
524
|
+
npm whoami --token=$NPM_TOKEN
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
3. Check workflow logs for specific error:
|
|
528
|
+
- Go to `Actions` → `Publish to npm` → failed run
|
|
529
|
+
- Click job and step for details
|
|
530
|
+
|
|
531
|
+
**Common errors:**
|
|
532
|
+
- "You must be logged in" → NPM_TOKEN is missing or invalid
|
|
533
|
+
- "version not found" → package.json version doesn't match tag
|
|
534
|
+
- "already published" → version already exists on npm
|
|
535
|
+
|
|
536
|
+
### How to Manually Bypass Tests (Emergency Only)
|
|
537
|
+
|
|
538
|
+
**⚠️ Last resort only:**
|
|
539
|
+
|
|
540
|
+
```bash
|
|
541
|
+
git push --no-verify
|
|
542
|
+
# ❌ DON'T DO THIS, fix the issue instead!
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
---
|
|
546
|
+
|
|
547
|
+
## Summary
|
|
548
|
+
|
|
549
|
+
| Stage | Tool | Check | Failure Effect |
|
|
550
|
+
|-------|------|-------|-----------------|
|
|
551
|
+
| **Local commit** | husky + lint-staged | ESLint | Blocks commit |
|
|
552
|
+
| **Local push** | husky pre-push | TypeScript + ESLint + Build | Blocks push |
|
|
553
|
+
| **Remote PR** | GitHub Actions CI | Lint + TypeScript + Build + Test | Blocks merge |
|
|
554
|
+
| **Release** | GitHub Actions Publish | All checks + npm publish | Failed publish |
|
|
555
|
+
| **Daily** | GitHub Actions Security | npm audit | Warning |
|
|
556
|
+
|
|
557
|
+
## Workflow Diagram
|
|
558
|
+
|
|
559
|
+
```
|
|
560
|
+
Feature Branch
|
|
561
|
+
↓
|
|
562
|
+
Local Commit → [pre-commit hook: lint] → OK/FAIL
|
|
563
|
+
↓
|
|
564
|
+
Local Push → [pre-push hook: typecheck + lint + build] → OK/FAIL
|
|
565
|
+
↓
|
|
566
|
+
GitHub PR → [CI workflow: lint + typecheck + build + test] → OK/FAIL
|
|
567
|
+
↓
|
|
568
|
+
Merge to main
|
|
569
|
+
↓
|
|
570
|
+
Create Release
|
|
571
|
+
↓
|
|
572
|
+
[Publish workflow: publish to npm] → ✅ Live on npmjs.com
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
## Next Steps
|
|
576
|
+
|
|
577
|
+
1. **Install dependencies:** `npm install` (hooks auto-setup)
|
|
578
|
+
2. **Try committing:** Make small change, commit, watch hooks run
|
|
579
|
+
3. **Try pushing:** Make change, commit, push, watch pre-push checks
|
|
580
|
+
4. **View CI logs:** Push a PR, check GitHub Actions
|
|
581
|
+
5. **Test publish:** Use Manual Publish workflow with `beta` tag
|
|
582
|
+
6. **Create release:** Tag main, create release for auto-publish
|