github-archiver 1.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.
Files changed (43) hide show
  1. package/.claude/CLAUDE.md +248 -0
  2. package/.claude/settings.json +15 -0
  3. package/.github/dependabot.yml +76 -0
  4. package/.github/workflows/ci.yml +64 -0
  5. package/.github/workflows/release.yml +55 -0
  6. package/.releaserc.json +22 -0
  7. package/AGENTS.md +248 -0
  8. package/CHANGELOG.md +89 -0
  9. package/CONTRIBUTING.md +343 -0
  10. package/QUICKSTART.md +221 -0
  11. package/README.md +443 -0
  12. package/biome.jsonc +4 -0
  13. package/bun.lock +1380 -0
  14. package/dist/index.js +7 -0
  15. package/dist/index.js.map +7 -0
  16. package/issues.txt +1105 -0
  17. package/notes.md +0 -0
  18. package/package.json +53 -0
  19. package/scripts/build.ts +17 -0
  20. package/src/commands/archive.ts +344 -0
  21. package/src/commands/auth.ts +184 -0
  22. package/src/constants/defaults.ts +6 -0
  23. package/src/constants/messages.ts +24 -0
  24. package/src/constants/paths.ts +12 -0
  25. package/src/index.ts +44 -0
  26. package/src/services/archiver.ts +192 -0
  27. package/src/services/auth-manager.ts +79 -0
  28. package/src/services/github.ts +211 -0
  29. package/src/types/config.ts +24 -0
  30. package/src/types/error.ts +35 -0
  31. package/src/types/github.ts +34 -0
  32. package/src/types/index.ts +4 -0
  33. package/src/utils/colors.ts +79 -0
  34. package/src/utils/config.ts +95 -0
  35. package/src/utils/errors.ts +93 -0
  36. package/src/utils/formatting.ts +65 -0
  37. package/src/utils/input-handler.ts +163 -0
  38. package/src/utils/logger.ts +65 -0
  39. package/src/utils/parser.ts +125 -0
  40. package/src/utils/progress.ts +87 -0
  41. package/tests/unit/formatting.test.ts +93 -0
  42. package/tests/unit/parser.test.ts +140 -0
  43. package/tsconfig.json +36 -0
package/QUICKSTART.md ADDED
@@ -0,0 +1,221 @@
1
+ # Quick Start Guide
2
+
3
+ Get up and running with GitHub Archiver in 5 minutes.
4
+
5
+ ## Step 1: Install
6
+
7
+ ```bash
8
+ npm install -g github-archiver
9
+ ```
10
+
11
+ Or for development:
12
+ ```bash
13
+ git clone https://github.com/mynameistito/github-archiver.git
14
+ cd github-archiver
15
+ npm install
16
+ npm run build
17
+ npm run dev -- <command>
18
+ ```
19
+
20
+ ## Step 2: Get a GitHub Token
21
+
22
+ 1. Go to https://github.com/settings/tokens/new
23
+ 2. Create a new token with `repo` scope
24
+ 3. Copy the token (you'll need it in the next step)
25
+
26
+ ## Step 3: Authenticate
27
+
28
+ ```bash
29
+ github-archiver auth login
30
+ ```
31
+
32
+ Paste your token when prompted. It's saved securely in `~/.github-archiver/config.json`.
33
+
34
+ ## Step 4: Archive Repositories
35
+
36
+ ### Option A: Interactive (Recommended)
37
+
38
+ ```bash
39
+ github-archiver archive
40
+ ```
41
+
42
+ Your default text editor opens. Enter repository URLs (one per line), save, and exit.
43
+
44
+ Supported formats:
45
+ ```
46
+ https://github.com/facebook/react
47
+ torvalds/linux
48
+ git@github.com:owner/repo.git
49
+ ```
50
+
51
+ ### Option B: From File
52
+
53
+ Create a file `repos.txt`:
54
+ ```
55
+ facebook/react
56
+ torvalds/linux
57
+ google/go
58
+ ```
59
+
60
+ Run:
61
+ ```bash
62
+ github-archiver archive --file repos.txt
63
+ ```
64
+
65
+ ### Option C: From Stdin
66
+
67
+ ```bash
68
+ cat repos.txt | github-archiver archive --stdin
69
+ ```
70
+
71
+ ## Step 5: Confirm and Watch
72
+
73
+ You'll see a preview of repositories to archive. Confirm with `y` and watch the progress:
74
+
75
+ ```
76
+ [============================ ] 5/5 (100%) - microsoft/vscode
77
+
78
+ ╔════════════════════════════════════╗
79
+ ║ Archive Operation Summary ║
80
+ ╠════════════════════════════════════╣
81
+ ║ ✅ Successful: 5 ║
82
+ ║ ⚠️ Skipped: 0 ║
83
+ ║ ❌ Failed: 0 ║
84
+ ╠════════════════════════════════════╣
85
+ ║ Total: 5 ║
86
+ ║ Duration: 1m 23s ║
87
+ ╚════════════════════════════════════╝
88
+
89
+ ✅ All repositories processed successfully!
90
+ ```
91
+
92
+ ## Common Tasks
93
+
94
+ ### Check Your Authentication
95
+
96
+ ```bash
97
+ github-archiver auth status
98
+ ```
99
+
100
+ ### Dry Run (Don't Actually Archive)
101
+
102
+ ```bash
103
+ github-archiver archive --file repos.txt --dry-run
104
+ ```
105
+
106
+ ### Speed Up Processing (More Parallel Jobs)
107
+
108
+ ```bash
109
+ github-archiver archive --file repos.txt --concurrency 10
110
+ ```
111
+
112
+ ### Skip Confirmation Prompt
113
+
114
+ ```bash
115
+ github-archiver archive --file repos.txt --force
116
+ ```
117
+
118
+ ### Verbose Output
119
+
120
+ ```bash
121
+ github-archiver archive --file repos.txt --verbose
122
+ ```
123
+
124
+ ### Logout
125
+
126
+ ```bash
127
+ github-archiver auth logout
128
+ ```
129
+
130
+ ## Troubleshooting
131
+
132
+ ### "No GitHub token found"
133
+ ```bash
134
+ github-archiver auth login
135
+ ```
136
+
137
+ ### "Permission denied"
138
+ - Make sure you're the repository owner
139
+ - Check your token has `repo` scope at https://github.com/settings/tokens
140
+
141
+ ### "Repository not found"
142
+ - Verify the repository URL is correct
143
+ - Check you have access to the repository
144
+
145
+ ### "Rate limit exceeded"
146
+ - Wait a few minutes (GitHub rate limit resets hourly)
147
+ - Use lower concurrency: `--concurrency 1`
148
+
149
+ ### Need help?
150
+ - See detailed documentation in README.md
151
+ - Check the troubleshooting section
152
+ - Open an issue at https://github.com/mynameistito/github-archiver/issues
153
+
154
+ ## What's Next?
155
+
156
+ - Read the full README.md for all options
157
+ - Check CONTRIBUTING.md to help improve the project
158
+ - Review CHANGELOG.md to see what's new
159
+ - Explore the source code in the `src/` directory
160
+
161
+ ## Examples
162
+
163
+ ### Archive all repos in a file
164
+ ```bash
165
+ github-archiver archive --file my-repos.txt --force
166
+ ```
167
+
168
+ ### Validate first without archiving
169
+ ```bash
170
+ github-archiver archive --file my-repos.txt --dry-run
171
+ ```
172
+
173
+ ### Fast mode (10 parallel jobs)
174
+ ```bash
175
+ github-archiver archive --file my-repos.txt --concurrency 10 --force
176
+ ```
177
+
178
+ ### From echo command
179
+ ```bash
180
+ echo -e "facebook/react\ntorvalds/linux\nmicrosoft/vscode" | github-archiver archive --stdin --force
181
+ ```
182
+
183
+ ## File Format Example
184
+
185
+ `repos.txt`:
186
+ ```
187
+ # Archive these repositories
188
+ https://github.com/facebook/react
189
+ https://github.com/torvalds/linux.git
190
+
191
+ # You can also use shorthand
192
+ google/go
193
+ microsoft/vscode
194
+
195
+ # SSH format works too
196
+ git@github.com:owner/private-repo.git
197
+
198
+ # Empty lines and comments are ignored
199
+ # The following has invalid format and will be skipped
200
+ this-is-invalid-!!!
201
+ ```
202
+
203
+ ## Notes
204
+
205
+ - Archived repositories are read-only
206
+ - Collaborators can still see archived repos (they just can't push)
207
+ - You can unarchive repositories anytime in GitHub
208
+ - The CLI doesn't delete repositories, only archives them
209
+ - Logs are saved to `~/.github-archiver/logs/`
210
+
211
+ ## Tips
212
+
213
+ 1. **Start small**: Test with 2-3 repositories first
214
+ 2. **Use dry-run**: Always validate with `--dry-run` if you're unsure
215
+ 3. **Save your list**: Keep your repos.txt file for reference
216
+ 4. **Check permissions**: Verify you have push access before running
217
+ 5. **Monitor progress**: Watch the progress bar and ETA
218
+
219
+ ---
220
+
221
+ Happy archiving! 🎉
package/README.md ADDED
@@ -0,0 +1,443 @@
1
+ # GitHub Archiver CLI
2
+
3
+ [![CI](https://github.com/mynameistito/github-archiver/actions/workflows/ci.yml/badge.svg)](https://github.com/mynameistito/github-archiver/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/github-archiver)](https://www.npmjs.com/package/github-archiver)
5
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
6
+
7
+ A powerful command-line tool for mass archiving GitHub repositories with parallel processing, comprehensive error handling, and user-friendly feedback.
8
+
9
+ ## Features
10
+
11
+ ✨ **Mass Archive Repositories** - Archive multiple GitHub repositories in parallel
12
+ 🔐 **Secure Authentication** - Token stored locally in `~/.github-archiver/config.json`
13
+ ⚡ **Parallel Processing** - Archive multiple repos simultaneously (configurable 1-50 concurrency)
14
+ 📋 **Multiple Input Methods** - Load repos from editor, file, or stdin
15
+ 🔍 **Validation** - Dry-run mode to validate without archiving
16
+ 📊 **Progress Tracking** - Real-time progress bars and ETA
17
+ 🛡️ **Error Recovery** - Comprehensive error handling with helpful guidance
18
+ 📝 **Detailed Logging** - Structured logging to files and console
19
+
20
+ ## Installation
21
+
22
+ ### npm
23
+
24
+ ```bash
25
+ npm install -g github-archiver
26
+ ```
27
+
28
+ ### From Source
29
+
30
+ ```bash
31
+ git clone https://github.com/mynameistito/github-archiver.git
32
+ cd github-archiver
33
+ npm install
34
+ npm run build
35
+ npm install -g .
36
+ ```
37
+
38
+ ### Development
39
+
40
+ ```bash
41
+ npm install
42
+ npm run dev -- <command>
43
+ ```
44
+
45
+ ## Quick Start
46
+
47
+ ### 1. Authenticate with GitHub
48
+
49
+ ```bash
50
+ github-archiver auth login
51
+ # Paste your GitHub Personal Access Token when prompted
52
+ ```
53
+
54
+ ### 2. Archive Repositories
55
+
56
+ ```bash
57
+ github-archiver archive
58
+ # Opens your default text editor to enter repository URLs
59
+ ```
60
+
61
+ ## Commands
62
+
63
+ ### `auth`
64
+
65
+ Manage GitHub authentication.
66
+
67
+ #### `auth login`
68
+ Authenticate with GitHub using a Personal Access Token.
69
+
70
+ ```bash
71
+ github-archiver auth login
72
+ ```
73
+
74
+ #### `auth logout`
75
+ Remove stored GitHub token.
76
+
77
+ ```bash
78
+ github-archiver auth logout
79
+ ```
80
+
81
+ #### `auth status`
82
+ Check current authentication status.
83
+
84
+ ```bash
85
+ github-archiver auth status
86
+ ```
87
+
88
+ ### `archive`
89
+
90
+ Archive multiple GitHub repositories.
91
+
92
+ ```bash
93
+ github-archiver archive [options]
94
+ ```
95
+
96
+ #### Options
97
+
98
+ | Option | Default | Description |
99
+ |--------|---------|-------------|
100
+ | `--file <path>` | - | Read repository URLs from file |
101
+ | `--stdin` | - | Read repository URLs from stdin |
102
+ | `--dry-run` | false | Validate without archiving |
103
+ | `--concurrency <n>` | 3 | Number of parallel operations (1-50) |
104
+ | `--timeout <n>` | 300 | API timeout in seconds (10-3600) |
105
+ | `--verbose` | false | Enable verbose logging |
106
+ | `--force` | false | Skip confirmation prompts |
107
+
108
+ #### Examples
109
+
110
+ **Interactive (opens editor):**
111
+ ```bash
112
+ github-archiver archive
113
+ ```
114
+
115
+ **From file:**
116
+ ```bash
117
+ github-archiver archive --file repos.txt
118
+ ```
119
+
120
+ **From stdin:**
121
+ ```bash
122
+ cat repos.txt | github-archiver archive --stdin
123
+ ```
124
+
125
+ **Dry-run (validate only):**
126
+ ```bash
127
+ github-archiver archive --file repos.txt --dry-run
128
+ ```
129
+
130
+ **Fast processing (higher concurrency):**
131
+ ```bash
132
+ github-archiver archive --file repos.txt --concurrency 10
133
+ ```
134
+
135
+ **Force without confirmation:**
136
+ ```bash
137
+ github-archiver archive --file repos.txt --force
138
+ ```
139
+
140
+ ## Input Format
141
+
142
+ Repository URLs can be specified in three formats:
143
+
144
+ ### HTTPS Format
145
+ ```
146
+ https://github.com/owner/repo
147
+ https://github.com/owner/repo.git
148
+ ```
149
+
150
+ ### SSH Format
151
+ ```
152
+ git@github.com:owner/repo.git
153
+ git@github.com:owner/repo
154
+ ```
155
+
156
+ ### Shorthand Format
157
+ ```
158
+ owner/repo
159
+ ```
160
+
161
+ ### File Example
162
+
163
+ ```
164
+ # Repositories to archive
165
+ https://github.com/facebook/react
166
+ torvalds/linux
167
+ owner/private-repo
168
+
169
+ # Comments are ignored
170
+ https://github.com/nodejs/node
171
+ ```
172
+
173
+ ## GitHub Token Requirements
174
+
175
+ You need a GitHub Personal Access Token with the following:
176
+
177
+ - **Scope**: `repo` (Full control of private repositories)
178
+ - **Minimum Permissions**: Push access to repositories you want to archive
179
+
180
+ ### How to Generate a Token
181
+
182
+ 1. Go to https://github.com/settings/tokens/new
183
+ 2. Create a new token with `repo` scope
184
+ 3. Copy the token and run `github-archiver auth login`
185
+
186
+ ## Output Example
187
+
188
+ ```
189
+ 🔐 Checking authentication...
190
+ ✅ Authenticated as: username
191
+
192
+ 📝 Getting repositories...
193
+ 📋 Will archive 5 repositories:
194
+ 1. facebook/react
195
+ 2. torvalds/linux
196
+ 3. owner/repo-1
197
+ 4. owner/repo-2
198
+ 5. owner/repo-3
199
+
200
+ Are you sure you want to archive these repositories? [y/N]: y
201
+
202
+ Starting to archive repositories... (concurrency: 3)
203
+
204
+ [======================= ] 4/5 (80%) - owner/repo-3
205
+
206
+ ╔════════════════════════════════════╗
207
+ ║ Archive Operation Summary ║
208
+ ╠════════════════════════════════════╣
209
+ ║ ✅ Successful: 5 ║
210
+ ║ ⚠️ Skipped: 0 ║
211
+ ║ ❌ Failed: 0 ║
212
+ ╠════════════════════════════════════╣
213
+ ║ Total: 5 ║
214
+ ║ Duration: 2m 45s ║
215
+ ╚════════════════════════════════════╝
216
+
217
+ ✅ All repositories processed successfully!
218
+ ```
219
+
220
+ ## Troubleshooting
221
+
222
+ ### Authentication Issues
223
+
224
+ **Error: No GitHub token found**
225
+ - Run: `github-archiver auth login`
226
+ - Ensure you have a valid Personal Access Token with `repo` scope
227
+
228
+ **Error: Invalid or expired token**
229
+ - Generate a new token at https://github.com/settings/tokens
230
+ - Run: `github-archiver auth logout` then `github-archiver auth login`
231
+
232
+ ### Permission Issues
233
+
234
+ **Error: Permission denied for owner/repo**
235
+ - Verify you are the repository owner or have push access
236
+ - Check that your token has the `repo` scope
237
+ - The repository must not be archived yet
238
+
239
+ ### Rate Limiting
240
+
241
+ **Error: GitHub API rate limit exceeded**
242
+ - Wait a few minutes (rate limit resets hourly)
243
+ - Use lower concurrency: `--concurrency 1`
244
+ - Increase timeout: `--timeout 600`
245
+
246
+ ### Network Issues
247
+
248
+ **Error: Network error or timeout**
249
+ - Check your internet connection
250
+ - GitHub API may be temporarily unavailable
251
+ - Try again in a moment
252
+ - Increase timeout: `--timeout 600`
253
+
254
+ ### Repository Not Found
255
+
256
+ **Error: Repository not found**
257
+ - Verify the repository URL is correct
258
+ - The repository may have been deleted
259
+ - Check your GitHub access to the repository
260
+
261
+ ## Configuration
262
+
263
+ Configuration is stored at:
264
+ - **Linux/macOS**: `~/.github-archiver/config.json`
265
+ - **Windows**: `%USERPROFILE%\.github-archiver\config.json`
266
+
267
+ Logs are stored at:
268
+ - **Linux/macOS**: `~/.github-archiver/logs/`
269
+ - **Windows**: `%USERPROFILE%\.github-archiver\logs\`
270
+
271
+ ## Architecture
272
+
273
+ ```
274
+ src/
275
+ ├── commands/ # CLI commands (auth, archive)
276
+ ├── services/ # GitHub API, archiving, auth management
277
+ ├── utils/ # Utilities (parsing, formatting, logging)
278
+ ├── types/ # TypeScript type definitions
279
+ └── constants/ # Configuration constants and messages
280
+
281
+ tests/
282
+ └── unit/ # Unit tests for utilities
283
+ ```
284
+
285
+ ### Core Services
286
+
287
+ - **GitHubService**: Handles GitHub API interactions with retry logic
288
+ - **Archiver**: Manages parallel repository archiving with p-queue
289
+ - **AuthManager**: Manages secure token storage
290
+ - **InputHandler**: Handles input from editor, file, or stdin
291
+ - **ProgressDisplay**: Manages progress bar and summary output
292
+
293
+ ## Development
294
+
295
+ ### Setup
296
+
297
+ ```bash
298
+ npm install
299
+ npm run typecheck
300
+ npm run test
301
+ npm run build
302
+ ```
303
+
304
+ ### Commands
305
+
306
+ | Command | Description |
307
+ |---------|-------------|
308
+ | `npm run dev -- <cmd>` | Run CLI in development mode |
309
+ | `npm run typecheck` | Check TypeScript compilation |
310
+ | `npm run test` | Run unit tests |
311
+ | `npm run build` | Build production bundle |
312
+ | `npm run lint` | Check code style |
313
+ | `npm run format` | Auto-format code |
314
+
315
+ ### Code Standards
316
+
317
+ This project uses **Ultracite**, a zero-config preset that enforces:
318
+
319
+ - Strict TypeScript with no implicit `any`
320
+ - Accessibility, performance, and security best practices
321
+ - Consistent formatting via Biome
322
+ - Comprehensive error handling
323
+
324
+ See `AGENTS.md` for detailed standards.
325
+
326
+ ### Testing
327
+
328
+ ```bash
329
+ npm run test # Run all tests
330
+ npm run test:coverage # Run with coverage report
331
+ ```
332
+
333
+ ## Release Process
334
+
335
+ This project uses **semantic-release** for automated versioning and publishing to npm.
336
+
337
+ ### How Releases Work
338
+
339
+ 1. **Commit Format**: Use [Conventional Commits](https://www.conventionalcommits.org/):
340
+ - `feat:` - New features → **minor** version bump (1.0.0 → 1.1.0)
341
+ - `fix:` - Bug fixes → **patch** version bump (1.0.0 → 1.0.1)
342
+ - `BREAKING CHANGE:` - Breaking changes → **major** version bump (1.0.0 → 2.0.0)
343
+ - `chore:`, `docs:`, `test:` - No version bump
344
+
345
+ 2. **Automatic Trigger**:
346
+ - Push to `main` branch triggers the release workflow
347
+ - Semantic release analyzes commits and determines version bump
348
+ - Package version is updated, published to npm
349
+ - GitHub release is created with changelog
350
+ - Git tag is created automatically
351
+
352
+ 3. **Trusted Publishing**:
353
+ - Uses OpenID Connect (OIDC) for secure, tokenless authentication
354
+ - No npm tokens required - eliminates security risks
355
+ - Short-lived, cryptographically-signed tokens for each publish
356
+ - Works with personal GitHub accounts
357
+
358
+ 4. **Node Version Requirements**:
359
+ - Package runs on Node 18+ (see `package.json` engines)
360
+ - Release workflow uses Node 22+ (semantic-release requirement)
361
+ - CI tests on Node 18 and 22 for maximum compatibility
362
+
363
+ 5. **Example Workflow**:
364
+ ```bash
365
+ git checkout main
366
+ git pull
367
+ # Make your commits with conventional format
368
+ git commit -m "feat: add support for custom config file"
369
+ git push
370
+ # Release happens automatically!
371
+ ```
372
+
373
+ ### Trusted Publishing Setup
374
+
375
+ This project uses npm's **Trusted Publishing** feature for secure, tokenless package publishing.
376
+
377
+ **Setup (one-time):**
378
+ 1. Go to https://www.npmjs.com/package/github-archiver/settings
379
+ 2. Under **Trusted Publisher**, click **GitHub Actions**
380
+ 3. Fill in:
381
+ - **Organization or user**: `mynameistito`
382
+ - **Repository**: `github-archiver`
383
+ - **Workflow filename**: `release.yml`
384
+ 4. Click **Set up connection**
385
+ 5. (Recommended) Enable **"Require two-factor authentication and disallow tokens"**
386
+
387
+ That's it! No tokens to manage, rotate, or worry about.</think></tool_call>
388
+
389
+ ### Commit Message Examples
390
+
391
+ ```bash
392
+ # Feature (minor version bump)
393
+ git commit -m "feat: add support for custom config file"
394
+
395
+ # Bug fix (patch version bump)
396
+ git commit -m "fix: handle empty repository list gracefully"
397
+
398
+ # Breaking change (major version bump)
399
+ git commit -m "feat!: change CLI command structure
400
+
401
+ BREAKING CHANGE: The 'auth' subcommand is now required"
402
+
403
+ # No release
404
+ git commit -m "chore: update dependencies"
405
+ git commit -m "docs: clarify installation steps"
406
+ git commit -m "test: add unit tests for parser"
407
+ ```
408
+
409
+ ### Manual Releases
410
+
411
+ If you need to publish without merging to main:
412
+ ```bash
413
+ npm run release -- --no-ci
414
+ ```
415
+
416
+ ## Contributing
417
+
418
+ Contributions are welcome! Please:
419
+
420
+ 1. Follow the code standards (run `npm run format`)
421
+ 2. Add tests for new features
422
+ 3. Ensure `npm run typecheck` and `npm run test` pass
423
+ 4. Create a pull request with a clear description
424
+
425
+ ## License
426
+
427
+ MIT - See LICENSE file for details
428
+
429
+ ## Support
430
+
431
+ Having issues? Check the [Troubleshooting](#troubleshooting) section or open an issue on GitHub.
432
+
433
+ ## Acknowledgments
434
+
435
+ - Built with TypeScript, Commander.js, Octokit, and Winston
436
+ - Uses Biome for code formatting and linting
437
+ - Inspired by the need for efficient GitHub repository management
438
+
439
+ ## Version
440
+
441
+ Current version: 1.0.0
442
+
443
+ For the latest updates and release notes, visit: https://github.com/mynameistito/github-archiver/releases
package/biome.jsonc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "extends": ["ultracite/biome/core"]
4
+ }