Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Follow these steps to get going.
1. Now on [pkg-nec/http-server](https://github.com/pkg-nec/http-server), you should see a notification about your recent changes in your fork's branch, with a green button to create a pull request. Click the button.
1. Describe your changes in detail here, following the template. Once you're satisfied, submit the form.
1. Be patient while your PR is reviewed. This can take a while. We may request changes, but don't be afraid to question them.
1. Your PR might become conflicted with the code in `master`. If this is the case, you will need to [update your PR](#up-to-date) and resolve your conflicts.
1. Your PR might become conflicted with the code in `main`. If this is the case, you will need to [update your PR](#up-to-date) and resolve your conflicts.
1. You don't need to make a new PR to any needed changes. Instead, commit on top of your changes, and push these to your fork's branch. The PR will be updated, and CI will re-run.
- **Please do not rebase and force-push**, it ruins the git history

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name: 'Dependency Review'
on:
pull_request:
branches:
- trunk
- main

# If using a dependency submission action in this workflow this permission will need to be set to:
#
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Node.js CI

on:
push:
branches: [ trunk ]
branches: [ main ]
pull_request:
branches: [ trunk ]
branches: [ main ]

permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![GitHub Workflow Status (trunk)](https://img.shields.io/github/actions/workflow/status/pkg-nec/http-server/node.js.yml?branch=trunk&style=flat-square)](https://github.com/pkg-nec/http-server/actions)
[![GitHub Workflow Status (main)](https://img.shields.io/github/actions/workflow/status/pkg-nec/http-server/node.js.yml?branch=main&style=flat-square)](https://github.com/pkg-nec/http-server/actions)
[![npm](https://img.shields.io/npm/v/@pkg-nec/http-server.svg?style=flat-square)](https://www.npmjs.com/package/@pkg-nec/http-server) [![npm downloads](https://img.shields.io/npm/dm/@pkg-nec/http-server?color=blue&label=npm%20downloads&style=flat-square)](https://www.npmjs.com/package/@pkg-nec/http-server)
[![license](https://img.shields.io/github/license/pkg-nec/http-server.svg?style=flat-square)](https://github.com/pkg-nec/http-server)

Expand All @@ -8,7 +8,7 @@

`http-server` is a simple, zero-configuration command-line static HTTP server. It is powerful enough for production usage, but it's simple and hackable enough to be used for testing, local development and learning.

![Example of running http-server](https://github.com/pkg-nec/http-server/raw/trunk/screenshots/public.png)
![Example of running http-server](https://github.com/pkg-nec/http-server/raw/main/screenshots/public.png)

## Installation:

Expand Down
213 changes: 213 additions & 0 deletions docs/superpowers/plans/2026-07-17-trunk-to-main-migration-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Trunk-to-Main Branch Migration Implementation Plan

> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Migrate the default branch of `pkg-nec/http-server` from `trunk` to `main`, update all file references, apply GitHub settings changes, and delete the `trunk` branch — with zero CI breakage at any point.

**Architecture:** File changes are committed to a new `main` branch (created from the current `trunk` tip) and pushed to origin first. GitHub repository settings are then updated in a fixed order. `trunk` is deleted last, after `main` is confirmed as default.

**Tech Stack:** git, GitHub web UI (Settings), GitHub CLI optional for verification.

## Global Constraints

- `master` branch must not be touched at any point.
- No history rewriting — no `--force` pushes.
- All file edits land in a single commit on `main` before any settings change.
- Settings must be applied in the order listed in Task 2 (dependency chain).

---

### Task 1: Update file references and push `main`

**Files:**
- Modify: `.github/workflows/node.js.yml` (lines 8, 10)
- Modify: `.github/workflows/dependency-review.yml` (line 14)
- Modify: `README.md` (lines 1, 11)
- Modify: `.github/CONTRIBUTING.md` (line 44)

**Interfaces:**
- Consumes: current `trunk` HEAD
- Produces: `origin/main` branch at the same commit tree as current `trunk` HEAD, plus one new commit with the file changes.

- [ ] **Step 1: Create `main` from `trunk`**

```bash
git checkout trunk
git checkout -b main
```

Expected: `Switched to a new branch 'main'`

- [ ] **Step 2: Edit `.github/workflows/node.js.yml`**

Open `.github/workflows/node.js.yml`. Change lines 8 and 10:

```yaml
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
```

- [ ] **Step 3: Edit `.github/workflows/dependency-review.yml`**

Open `.github/workflows/dependency-review.yml`. Change line 14:

```yaml
on:
pull_request:
branches:
- main
```

- [ ] **Step 4: Edit `README.md`**

Change line 1 (CI badge):

```markdown
[![GitHub Workflow Status (main)](https://img.shields.io/github/actions/workflow/status/pkg-nec/http-server/node.js.yml?branch=main&style=flat-square)](https://github.com/pkg-nec/http-server/actions)
```

Change line 11 (raw image URL):

```markdown
![Example of running http-server](https://github.com/pkg-nec/http-server/raw/main/screenshots/public.png)
```

- [ ] **Step 5: Edit `.github/CONTRIBUTING.md`**

Change line 44 (replace stale reference to `master` with `main`):

```markdown
1. Your PR might become conflicted with the code in `main`. If this is the case, you will need to [update your PR](#up-to-date) and resolve your conflicts.
```

- [ ] **Step 6: Verify only the expected files are changed**

```bash
git diff --name-only
```

Expected output (exactly these four files, no others):

```
.github/CONTRIBUTING.md
.github/workflows/dependency-review.yml
.github/workflows/node.js.yml
README.md
```

- [ ] **Step 7: Verify the content changes look correct**

```bash
git diff
```

Check: all four `trunk` → `main` replacements are present, no unintended lines changed.

- [ ] **Step 8: Commit**

```bash
git add .github/workflows/node.js.yml \
.github/workflows/dependency-review.yml \
README.md \
.github/CONTRIBUTING.md
git commit -m "chore: rename default branch from trunk to main"
```

Expected: `[main <sha>] chore: rename default branch from trunk to main` with `4 files changed`.

- [ ] **Step 9: Push `main` to origin**

```bash
git push origin main
```

Expected: `Branch 'main' set up to track remote branch 'main' from 'origin'.`

- [ ] **Step 10: Verify `main` exists on origin**

```bash
git branch -r | grep main
```

Expected: ` origin/main`

---

### Task 2: Apply GitHub Settings (in order)

**Files:** None — all changes are in GitHub web UI.

**Interfaces:**
- Consumes: `origin/main` from Task 1
- Produces: `main` as default branch, branch protection on `main`, npm-publish environment updated, `trunk` deleted from origin and local.

- [ ] **Step 1: Set `main` as default branch**

In GitHub: **Settings → General → Default branch**
Click the ↔ icon next to `trunk`, select `main`, click **Update**, confirm.

Verify: visiting `https://github.com/pkg-nec/http-server` shows `main` as the selected branch in the branch dropdown.

- [ ] **Step 2: Recreate branch protection rule on `main`**

In GitHub: **Settings → Branches → Branch protection rules**

First, delete the existing `trunk` rule: click **Edit** on the `trunk` rule → scroll to bottom → **Delete rule** → confirm.

Then click **Add rule** and configure:
- Branch name pattern: `main`
- ✅ Require a pull request before merging
- ✅ Require status checks to pass before merging
- Required check: `Test (20.x, ubuntu-latest)` (search and add it)
- ✅ Require branches to be up to date before merging
- ✅ Do not allow bypassing the above settings
- ✅ Restrict who can push to matching branches (if previously set — match the old rule)
- Do **not** allow force pushes
- Do **not** allow deletions

Click **Create**.

Verify: the new `main` protection rule appears in the list.

- [ ] **Step 3: Update `npm-publish` environment branch policy**

In GitHub: **Settings → Environments → npm-publish**

Under **Deployment branches and tags**, find the branch rule referencing `trunk` and update it to `main`. Save.

Verify: the deployment branch policy shows `main` (not `trunk`).

- [ ] **Step 4: Delete `trunk` from origin**

```bash
git push origin --delete trunk
```

Expected: `- [deleted] trunk`

- [ ] **Step 5: Delete local `trunk` branch**

```bash
git branch -d trunk
```

Expected: `Deleted branch trunk (was <sha>).`

- [ ] **Step 6: Final verification**

```bash
git branch -a
```

Expected: `trunk` does NOT appear in either local or remote branches. `main` and `master` are present.

```bash
git remote show origin | grep "HEAD branch"
```

Expected: `HEAD branch: main`

Check the CI badge in README renders correctly by visiting the GitHub repo page — the badge should show the `main` branch build status.
112 changes: 112 additions & 0 deletions docs/superpowers/specs/2026-07-17-trunk-to-main-migration-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Design: Migrate Default Branch from `trunk` to `main`

**Date:** 2026-07-17
**Status:** Approved

## Background

The repository was set up with `trunk` as the default branch under a Trunk-Based Development model. As an open-source project with potential multiple major versions, TBD is not the right fit. Switching to `main` as the default branch aligns with standard open-source conventions and allows long-lived support branches (e.g. `v13`, `v14`) to coexist cleanly.

`master` exists as a remnant of the upstream `http-party/http-server` fork and is left untouched.

## Approach

File references are updated first (committed to a new `main` branch pushed from `trunk`), then GitHub repository settings are updated, and finally `trunk` is deleted. This order ensures no CI breakage during the transition.

## Phase 1 — File Changes

All changes are committed on a new local `main` branch (checked out from `trunk`) and pushed to origin before any settings are touched.

### `.github/workflows/node.js.yml`

Change branch filters:

```diff
on:
push:
- branches: [ trunk ]
+ branches: [ main ]
pull_request:
- branches: [ trunk ]
+ branches: [ main ]
```

### `.github/workflows/dependency-review.yml`

Change branch filter:

```diff
on:
pull_request:
branches:
- - trunk
+ - main
```

### `README.md`

Update CI badge URL and raw image URL:

```diff
-[![GitHub Workflow Status (trunk)](https://img.shields.io/github/actions/workflow/status/pkg-nec/http-server/node.js.yml?branch=trunk&style=flat-square)](https://github.com/pkg-nec/http-server/actions)
+[![GitHub Workflow Status (main)](https://img.shields.io/github/actions/workflow/status/pkg-nec/http-server/node.js.yml?branch=main&style=flat-square)](https://github.com/pkg-nec/http-server/actions)

-![Example of running http-server](https://github.com/pkg-nec/http-server/raw/trunk/screenshots/public.png)
+![Example of running http-server](https://github.com/pkg-nec/http-server/raw/main/screenshots/public.png)
```

### `.github/CONTRIBUTING.md`

Update stale upstream reference to `master`:

```diff
-1. Your PR might become conflicted with the code in `master`. If this is the case, you will need to [update your PR](#up-to-date) and resolve your conflicts.
+1. Your PR might become conflicted with the code in `main`. If this is the case, you will need to [update your PR](#up-to-date) and resolve your conflicts.
```

### Historical plan docs (`docs/superpowers/plans/`)

Left as-is. These are past-tense archives that accurately reflect history at the time of writing. No functional impact.

## Phase 2 — Push `main` to Origin

```bash
git checkout trunk
git checkout -b main
# apply file edits above, then:
git add .github/workflows/node.js.yml \
.github/workflows/dependency-review.yml \
README.md \
.github/CONTRIBUTING.md
git commit -m "chore: rename default branch from trunk to main"
git push origin main
```

## Phase 3 — GitHub Settings (apply in order)

| Step | Location | Action |
|------|----------|--------|
| 1 | Settings → General → Default branch | Switch from `trunk` → `main` |
| 2 | Settings → Branches → Branch protection rules | Delete the `trunk` rule; create an identical rule on `main` (required status checks: `Test (20.x, ubuntu-latest)`, no force-push, no deletion) |
| 3 | Settings → Environments → `npm-publish` | Update deployment branch policy from `trunk` → `main` |
| 4 | Terminal | `git push origin --delete trunk` |
| 5 | Terminal | `git branch -d trunk` |

## What Is Not Changed

- `master` branch: left untouched (upstream fork baseline)
- `origin/master` remote tracking branch: left untouched
- Historical plan docs under `docs/superpowers/plans/`: left as-is (archives)
- `publish.yml`: no branch filter — triggered on GitHub Release publication, unaffected
- `stale.yml`: no branch filter — triggered on schedule, unaffected
- `dependabot.yml`: no branch filter — Dependabot PRs target the default branch automatically, so switching the default branch is sufficient

## Success Criteria

- `main` is the default branch on GitHub
- CI runs on push to `main` and on PRs targeting `main`
- Dependency Review runs on PRs targeting `main`
- `npm-publish` environment gate applies to `main`
- `trunk` branch is deleted from both origin and local
- README badge and image resolve correctly from `main`
- `master` branch is unchanged