|
1 | 1 | # Versions |
2 | 2 |
|
3 | | -Product oriented code to handle versions of the Docs, such as Enterprise Cloud and Enterprise Server. |
| 3 | +The versions subject handles product versioning for GitHub Docs, including Free/Pro/Team (FPT), Enterprise Cloud (GHEC), and Enterprise Server (GHES). It provides version detection, resolution, feature flags, and version-aware content rendering. |
| 4 | + |
| 5 | +## Purpose & Scope |
| 6 | + |
| 7 | +This subject is responsible for: |
| 8 | +- Defining all available product versions (plans and releases) |
| 9 | +- Detecting current version from URL paths |
| 10 | +- Providing version-aware Liquid conditionals (e.g., `{% if ghes %}`) |
| 11 | +- Managing feature flags that vary by version |
| 12 | +- Version resolution for content applicability |
| 13 | +- Version picker UI component |
| 14 | +- Deprecation banners for old versions |
| 15 | + |
| 16 | +Related subjects: |
| 17 | +- `src/archives/` - Handles archived versions of documentation |
| 18 | +- `src/ghes-releases/` - Manages GHES release and deprecation processes |
| 19 | + |
| 20 | +## Architecture & Key Assets |
| 21 | + |
| 22 | +### Key capabilities and their locations |
| 23 | + |
| 24 | +- `lib/all-versions.ts` - `allVersions` object: Defines all version plans (fpt, ghec, ghes) with releases |
| 25 | +- `lib/enterprise-server-releases.ts` - GHES version data: supported, deprecated, latest releases |
| 26 | +- `lib/get-applicable-versions.ts` - `getApplicableVersions()`: Determines which versions apply to content based on frontmatter |
| 27 | +- `middleware/short-versions.ts` - Adds version shortcuts (e.g., `ghes`, `fpt`) to `req.context` |
| 28 | +- `middleware/features.ts` - Loads feature flags from `data/features/` and adds to context |
| 29 | +- `components/VersionPicker.tsx` - UI component for switching between versions |
| 30 | + |
| 31 | +## Setup & Usage |
| 32 | + |
| 33 | +### Version structure |
| 34 | + |
| 35 | +Versions follow the format: `plan@release` |
| 36 | +- FPT: `free-pro-team@latest` (stripped from URLs) |
| 37 | +- GHEC: `enterprise-cloud@latest` |
| 38 | +- GHES: `enterprise-server@3.11`, `enterprise-server@3.10`, etc. |
| 39 | + |
| 40 | +### Using versions in Liquid |
| 41 | + |
| 42 | +Middleware adds version shortcuts to context for use in Liquid templates: |
| 43 | + |
| 44 | +```liquid |
| 45 | +{% if fpt %} |
| 46 | +This content only appears for Free/Pro/Team. |
| 47 | +{% endif %} |
| 48 | +
|
| 49 | +{% if ghes %} |
| 50 | +This content appears for all GHES versions. |
| 51 | +{% endif %} |
| 52 | +
|
| 53 | +{% if ghes > 3.9 %} |
| 54 | +This content appears for GHES 3.10 and later. |
| 55 | +{% endif %} |
| 56 | +``` |
| 57 | + |
| 58 | +### Feature flags |
| 59 | + |
| 60 | +Feature flags in `data/features/*.yml` control content visibility: |
| 61 | + |
| 62 | +```yaml |
| 63 | +# data/features/my-feature.yml |
| 64 | +versions: |
| 65 | + fpt: '*' |
| 66 | + ghec: '*' |
| 67 | + ghes: '>= 3.10' |
| 68 | +``` |
| 69 | +
|
| 70 | +In Liquid: |
| 71 | +```liquid |
| 72 | +{% if my-feature %} |
| 73 | +This content only shows when my-feature is enabled. |
| 74 | +{% endif %} |
| 75 | +``` |
| 76 | + |
| 77 | +### Version frontmatter |
| 78 | + |
| 79 | +Content files specify applicable versions in frontmatter: |
| 80 | + |
| 81 | +```yaml |
| 82 | +versions: |
| 83 | + fpt: '*' |
| 84 | + ghec: '*' |
| 85 | + ghes: '>= 3.8' |
| 86 | +``` |
| 87 | +
|
| 88 | +### Running tests |
| 89 | +
|
| 90 | +```bash |
| 91 | +npm run test -- src/versions/tests |
| 92 | +``` |
| 93 | + |
| 94 | +## Data & External Dependencies |
| 95 | + |
| 96 | +### Data inputs |
| 97 | +- `data/features/*.yml` - Feature flag definitions |
| 98 | +- `lib/enterprise-server-releases.ts` - GHES version data |
| 99 | +- Content frontmatter - `versions` field specifies applicable versions |
| 100 | +- URL paths - Version extracted from path (e.g., `/enterprise-server@3.11/`) |
| 101 | + |
| 102 | +### Dependencies |
| 103 | +- [`@/frame`](../frame/README.md) - Path utilities for version extraction |
| 104 | +- [`@/data-directory`](../data-directory/README.md) - Loads feature flag data |
| 105 | +- [`@/archives`](../archives/README.md) - Archived version handling |
| 106 | +- [`@/ghes-releases`](../ghes-releases/README.md) - GHES release management |
| 107 | + |
| 108 | +### Data outputs |
| 109 | +- `req.context.currentVersion` - String like `enterprise-server@3.11` |
| 110 | +- `req.context.currentVersionObj` - Full version object with metadata |
| 111 | +- `req.context[shortName]` - Boolean flags: `fpt`, `ghec`, `ghes` |
| 112 | +- `req.context[featureName]` - Boolean flags for each feature |
| 113 | +- `req.context.allVersions` - All available versions |
| 114 | + |
| 115 | +## Cross-links & Ownership |
| 116 | + |
| 117 | +### Related subjects |
| 118 | +- [`src/archives`](../archives/README.md) - Handles archived/deprecated version proxying |
| 119 | +- [`src/ghes-releases`](../ghes-releases/README.md) - GHES release notes and deprecation |
| 120 | +- [`src/frame`](../frame/README.md) - Path utilities used for version detection |
| 121 | +- [`src/redirects`](../redirects/README.md) - Version-aware redirects |
| 122 | + |
| 123 | +### Ownership |
| 124 | +- Team: Docs Engineering |
| 125 | + |
| 126 | +## Current State & Next Steps |
| 127 | + |
| 128 | +### Version fallback hierarchy |
| 129 | + |
| 130 | +When no version in URL, fallback order: FPT → GHEC → GHES latest. Implemented in `lib/redirects/permalinks.ts`. |
| 131 | + |
| 132 | +### GHES versioning |
| 133 | + |
| 134 | +- Supported versions defined in `enterprise-server-releases.ts` |
| 135 | +- New GHES releases added via scripts in `src/ghes-releases/scripts/` |
| 136 | +- Deprecated versions archived via `src/archives/` |
| 137 | + |
| 138 | +### Known limitations |
| 139 | +- FPT version is stripped from URLs but exists internally |
| 140 | +- Feature flag data loaded on every request (cached per version) |
| 141 | +- Version comparison logic only supports GHES numbered releases |
| 142 | +- REST API versions handled separately via config in `src/rest/lib/config.json` |
| 143 | + |
| 144 | +### Adding a new GHES version |
| 145 | + |
| 146 | +1. Update `src/versions/lib/enterprise-server-releases.ts` |
| 147 | +2. Run GHES release scripts (see `src/ghes-releases/scripts/`) |
| 148 | +3. Update REST API config if needed |
| 149 | +4. Create release notes in `data/release-notes/` |
| 150 | + |
| 151 | +### Deprecating a GHES version |
| 152 | + |
| 153 | +1. Move version from `supported` to `deprecated` in `enterprise-server-releases.ts` |
| 154 | +2. Run archive scripts to freeze content (see `src/archives/`) |
| 155 | +3. Update redirects as needed |
4 | 156 |
|
5 | | -The directory `archives/` handles archived version of the docs. `ghes-releases/` handles version releases and deprecations processes. |
|
0 commit comments