@side-quest/kit 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ Initial release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Nathan Vale
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,399 @@
1
+ # bun-typescript-starter
2
+
3
+ Modern TypeScript starter template with enterprise-grade tooling.
4
+
5
+ ## Features
6
+
7
+ - **Bun** - Fast all-in-one JavaScript runtime and toolkit
8
+ - **TypeScript 5.9+** - Strict mode, ESM only
9
+ - **Biome** - Lightning-fast linting and formatting (replaces ESLint + Prettier)
10
+ - **Vitest** - Fast unit testing with native Bun support
11
+ - **Changesets** - Automated versioning and changelog generation
12
+ - **GitHub Actions** - Comprehensive CI/CD with OIDC npm publishing
13
+ - **Conventional Commits** - Enforced via commitlint + Husky
14
+
15
+ ## Quick Start
16
+
17
+ ### Prerequisites
18
+
19
+ - [Bun](https://bun.sh) installed (`curl -fsSL https://bun.sh/install | bash`)
20
+ - [GitHub CLI](https://cli.github.com) installed and authenticated (`gh auth login`)
21
+ - [npm account](https://www.npmjs.com) with a granular access token (see [NPM Token Setup](#npm-token-setup))
22
+
23
+ ### Option A: GitHub CLI (Recommended)
24
+
25
+ Create a new repo from this template and set it up in one command:
26
+
27
+ ```bash
28
+ # Create repo from template
29
+ gh repo create myusername/my-lib --template nathanvale/bun-typescript-starter --public --clone
30
+
31
+ # Run setup (interactive)
32
+ cd my-lib
33
+ bun run setup
34
+ ```
35
+
36
+ ### Option B: CLI Mode (Non-Interactive)
37
+
38
+ For automated/scripted setups, pass all arguments via CLI flags:
39
+
40
+ ```bash
41
+ # Create repo from template
42
+ gh repo create myusername/my-lib --template nathanvale/bun-typescript-starter --public --clone
43
+ cd my-lib
44
+
45
+ # Run setup with all arguments (no prompts)
46
+ bun run setup -- \
47
+ --name "@myusername/my-lib" \
48
+ --description "My awesome library" \
49
+ --author "Your Name" \
50
+ --yes
51
+ ```
52
+
53
+ ### Option C: degit
54
+
55
+ ```bash
56
+ npx degit nathanvale/bun-typescript-starter my-lib
57
+ cd my-lib
58
+ bun run setup
59
+ ```
60
+
61
+ ## Setup Script
62
+
63
+ The setup script configures your project and optionally creates the GitHub repository with all settings pre-configured.
64
+
65
+ ### Interactive Mode
66
+
67
+ ```bash
68
+ bun run setup
69
+ ```
70
+
71
+ Prompts for:
72
+ - Package name (e.g., `@myusername/my-lib` or `my-lib`)
73
+ - Repository name
74
+ - GitHub username/org
75
+ - Project description
76
+ - Author name
77
+
78
+ ### CLI Mode
79
+
80
+ ```bash
81
+ bun run setup -- [options]
82
+ ```
83
+
84
+ | Flag | Short | Description |
85
+ |------|-------|-------------|
86
+ | `--name` | `-n` | Package name (e.g., `@myusername/my-lib`) |
87
+ | `--repo` | `-r` | Repository name (defaults to package name) |
88
+ | `--user` | `-u` | GitHub username/org (auto-detected from `gh`) |
89
+ | `--description` | `-d` | Project description |
90
+ | `--author` | `-a` | Author name |
91
+ | `--yes` | `-y` | Skip confirmation prompts (auto-yes) |
92
+ | `--no-github` | | Skip GitHub repo creation/configuration |
93
+ | `--help` | `-h` | Show help |
94
+
95
+ ### What Setup Does
96
+
97
+ 1. **Configures files** - Replaces placeholders in `package.json` and `.changeset/config.json`
98
+ 2. **Installs dependencies** - Runs `bun install`
99
+ 3. **Creates initial commit** - Commits all configured files
100
+ 4. **Creates GitHub repo** (if it doesn't exist) - Uses `gh repo create`
101
+ 5. **Configures GitHub settings**:
102
+ - Enables workflow permissions for PR creation
103
+ - Sets squash-only merging
104
+ - Enables auto-delete branches
105
+ - Enables auto-merge
106
+ - Configures branch protection rules
107
+
108
+ ## Complete Setup Guide
109
+
110
+ This guide walks through the full process of creating a new package and publishing it to npm.
111
+
112
+ ### Step 1: Create Repository
113
+
114
+ ```bash
115
+ # Create and clone from template
116
+ gh repo create myusername/my-lib --template nathanvale/bun-typescript-starter --public --clone
117
+ cd my-lib
118
+ ```
119
+
120
+ ### Step 2: Run Setup
121
+
122
+ ```bash
123
+ # Interactive mode
124
+ bun run setup
125
+
126
+ # Or non-interactive mode
127
+ bun run setup -- \
128
+ --name "@myusername/my-lib" \
129
+ --description "My awesome library" \
130
+ --author "Your Name" \
131
+ --yes
132
+ ```
133
+
134
+ ### Step 3: Install Changeset Bot
135
+
136
+ Install the [Changeset Bot](https://github.com/apps/changeset-bot) GitHub App on your repo. It comments on every PR with changeset status so you know at a glance whether version bumps are queued.
137
+
138
+ 1. Visit https://github.com/apps/changeset-bot
139
+ 2. Click **Install** and select your repository
140
+ 3. Grant the requested permissions (pull request read/write, contents read-only)
141
+
142
+ > The bot works alongside the `autogenerate-changeset.yml` workflow — the bot comments instantly, and the workflow auto-generates a changeset file if one is missing.
143
+
144
+ ### Step 4: Configure NPM Token
145
+
146
+ Before publishing, you need to add your npm token to GitHub secrets.
147
+
148
+ #### Create npm Granular Access Token
149
+
150
+ 1. Go to [npmjs.com](https://www.npmjs.com) → Access Tokens → Generate New Token → **Granular Access Token**
151
+
152
+ 2. Configure the token:
153
+ - **Token name:** `github-actions-publish` (or any name)
154
+ - **Expiration:** 90 days (maximum for granular tokens)
155
+ - **Packages and scopes:** Select "All packages" for new packages, or specific packages for existing ones
156
+ - **Permissions:** Read and write
157
+ - **IMPORTANT:** Check **"Bypass two-factor authentication for automation"**
158
+
159
+ > Without "Bypass 2FA", CI/CD publishing will fail with "Access token expired or revoked"
160
+
161
+ 3. Copy the token (starts with `npm_`)
162
+
163
+ #### Add Token to GitHub Secrets
164
+
165
+ ```bash
166
+ # If you have NPM_TOKEN in your environment
167
+ echo "$NPM_TOKEN" | gh secret set NPM_TOKEN --repo myusername/my-lib
168
+
169
+ # Or set it interactively
170
+ gh secret set NPM_TOKEN --repo myusername/my-lib
171
+ # Paste your token when prompted
172
+ ```
173
+
174
+ ### Step 5: Create Initial Release
175
+
176
+ Create a changeset describing your initial release:
177
+
178
+ ```bash
179
+ # Create a feature branch
180
+ git checkout -b feat/initial-release
181
+
182
+ # Create changeset file
183
+ mkdir -p .changeset
184
+ cat > .changeset/initial-release.md << 'EOF'
185
+ ---
186
+ "@myusername/my-lib": minor
187
+ ---
188
+
189
+ Initial release
190
+ EOF
191
+
192
+ # Commit and push
193
+ git add .changeset/initial-release.md
194
+ git commit -m "chore: add changeset for initial release"
195
+ git push -u origin feat/initial-release
196
+
197
+ # Create PR
198
+ gh pr create --title "chore: add changeset for initial release" --body "Initial release"
199
+ ```
200
+
201
+ ### Step 6: Merge and Publish
202
+
203
+ 1. **Wait for CI checks** to pass on your PR
204
+ 2. **Merge the PR** - This triggers the changesets workflow
205
+ 3. **A "Version Packages" PR** will be automatically created
206
+ 4. **Merge the Version PR** - This triggers the publish workflow
207
+ 5. **Package is published to npm!**
208
+
209
+ ```bash
210
+ # Check your package
211
+ npm view @myusername/my-lib
212
+ ```
213
+
214
+ ### Step 7: Configure OIDC Trusted Publishing (Optional)
215
+
216
+ After the first publish, you can enable token-free publishing via OIDC:
217
+
218
+ 1. Go to [npmjs.com](https://www.npmjs.com) → Your Package → Settings → Publishing Access
219
+ 2. Click "Add Trusted Publisher"
220
+ 3. Configure:
221
+ - **Owner:** Your GitHub username/org
222
+ - **Repository:** Your repo name
223
+ - **Workflow file:** `publish.yml`
224
+ 4. Save changes
225
+ 5. Optionally remove the `NPM_TOKEN` secret from GitHub
226
+
227
+ Now future releases will publish automatically without any tokens!
228
+
229
+ ## NPM Token Setup
230
+
231
+ ### Why Granular Tokens?
232
+
233
+ As of December 2024, npm has revoked all classic tokens. You must use **granular access tokens** for CI/CD publishing.
234
+
235
+ ### Token Requirements
236
+
237
+ | Setting | Value | Why |
238
+ |---------|-------|-----|
239
+ | Type | Granular Access Token | Classic tokens no longer work |
240
+ | Packages | All packages (for new) or specific | Allows publishing |
241
+ | Permissions | Read and write | Required to publish |
242
+ | **Bypass 2FA** | **Checked** | **Required for CI/CD** |
243
+
244
+ ### Common Errors
245
+
246
+ | Error | Cause | Fix |
247
+ |-------|-------|-----|
248
+ | "Access token expired or revoked" | Token doesn't have "Bypass 2FA" | Create new token with 2FA bypass |
249
+ | "E404 Not Found" | Token doesn't have publish permissions | Check token has read/write access |
250
+ | "E403 Forbidden" | Package scope mismatch | Ensure token covers your package scope |
251
+
252
+ ## What's Included
253
+
254
+ ### CI/CD Workflows
255
+
256
+ | Workflow | Trigger | Purpose |
257
+ |----------|---------|---------|
258
+ | `pr-quality.yml` | PR | Lint, Typecheck, Test with coverage |
259
+ | `publish.yml` | Push to main | Auto-publish via Changesets |
260
+ | `autogenerate-changeset.yml` | PR | Auto-generate changeset if missing |
261
+ | `commitlint.yml` | PR | Enforce conventional commits |
262
+ | `pr-title.yml` | PR | Validate PR title format |
263
+ | `security.yml` | Push/Schedule | CodeQL + Trivy scanning |
264
+ | `dependency-review.yml` | PR | Supply chain security |
265
+ | `dependabot-auto-merge.yml` | Dependabot PR | Auto-merge patch updates |
266
+
267
+ ### GitHub Apps
268
+
269
+ | App | Purpose |
270
+ |-----|---------|
271
+ | [Changeset Bot](https://github.com/apps/changeset-bot) | PR comments with changeset status |
272
+
273
+ ### Scripts
274
+
275
+ ```bash
276
+ # Development
277
+ bun dev # Watch mode
278
+ bun run build # Build for production
279
+ bun run clean # Remove dist/
280
+
281
+ # Quality
282
+ bun run check # Biome lint + format (write)
283
+ bun run lint # Lint only
284
+ bun run format # Format only
285
+ bun run typecheck # TypeScript type check
286
+ bun run validate # Full quality check (lint + types + build + test)
287
+
288
+ # Testing
289
+ bun test # Run tests
290
+ bun test --watch # Watch mode
291
+ bun run coverage # With coverage report
292
+
293
+ # Publishing
294
+ bun run version:gen # Create changeset interactively
295
+ bun run release # Publish to npm (CI handles this)
296
+ ```
297
+
298
+ ## Project Structure
299
+
300
+ ```
301
+ ├── .github/
302
+ │ ├── workflows/ # CI/CD workflows
303
+ │ ├── actions/ # Reusable composite actions
304
+ │ └── scripts/ # CI helper scripts
305
+ ├── .husky/ # Git hooks
306
+ ├── .changeset/ # Changeset config
307
+ ├── src/
308
+ │ └── index.ts # Main entry point
309
+ ├── tests/
310
+ │ └── index.test.ts # Example test
311
+ ├── biome.json # Biome config
312
+ ├── tsconfig.json # TypeScript config
313
+ ├── bunup.config.ts # Build config
314
+ └── package.json
315
+ ```
316
+
317
+ ## Configuration
318
+
319
+ ### Biome
320
+
321
+ Configured in `biome.json`:
322
+ - Tab indentation
323
+ - 80 character line width
324
+ - Single quotes
325
+ - Organize imports on save
326
+
327
+ ### TypeScript
328
+
329
+ - Strict mode enabled
330
+ - ESM output
331
+ - Source maps and declarations
332
+
333
+ ### Changesets
334
+
335
+ - GitHub changelog format
336
+ - Public npm access
337
+ - Provenance enabled
338
+
339
+ ## Branch Protection
340
+
341
+ The setup script automatically configures branch protection for `main`:
342
+
343
+ - Require pull request before merging
344
+ - Require status checks to pass ("All checks passed")
345
+ - Require linear history
346
+ - No force pushes
347
+ - No deletions
348
+
349
+ If you need to manually configure it:
350
+
351
+ 1. Go to Settings → Branches → Add rule
352
+ 2. Branch name pattern: `main`
353
+ 3. Enable the settings above
354
+
355
+ ## Troubleshooting
356
+
357
+ ### Setup script hangs
358
+
359
+ If running in a non-TTY environment (like some CI systems), use CLI flags:
360
+
361
+ ```bash
362
+ bun run setup -- --name "my-lib" --description "desc" --author "name" --yes
363
+ ```
364
+
365
+ ### CI can't create PRs
366
+
367
+ The setup script enables this automatically. If you need to do it manually:
368
+
369
+ ```bash
370
+ gh api repos/OWNER/REPO/actions/permissions/workflow \
371
+ --method PUT \
372
+ -f default_workflow_permissions=write \
373
+ -F can_approve_pull_request_reviews=true
374
+ ```
375
+
376
+ ### Version PR checks don't run
377
+
378
+ Bot-created PRs don't trigger workflows. Push an empty commit:
379
+
380
+ ```bash
381
+ git fetch origin
382
+ git checkout changeset-release/main
383
+ git commit --allow-empty -m "chore: trigger CI"
384
+ git push
385
+ ```
386
+
387
+ ### npm publish fails with 404
388
+
389
+ 1. Ensure your npm token has "Bypass 2FA" checked
390
+ 2. Ensure token has "Read and write" permissions
391
+ 3. Ensure token covers "All packages" (for new packages)
392
+
393
+ ## License
394
+
395
+ MIT
396
+
397
+ ---
398
+
399
+ Built with [bun-typescript-starter](https://github.com/nathanvale/bun-typescript-starter)