openapi-versions 0.0.0 → 0.1.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/README.md
CHANGED
|
@@ -17,9 +17,9 @@ mise install && pnpm install
|
|
|
17
17
|
# (use --require-gate or "gate": "required" in CI): https://github.com/oasdiff/oasdiff/releases
|
|
18
18
|
pnpm codegen # check + merge + generate for playground/ and test/fixtures/ (output is gitignored)
|
|
19
19
|
pnpm typecheck # includes compile-time guarantees in test/types.check.ts
|
|
20
|
-
|
|
20
|
+
pnpm test # 41 tests: merge, since maps, oasdiff gate, compat matrix, React, loaders, major transition
|
|
21
21
|
pnpm playground:api # one client build vs backends 1.2.0 … 2.0.0
|
|
22
|
-
|
|
22
|
+
pnpm exec tsx codegen/cli.ts --check-only --config test/fixtures/broken.config.json # shows the CI gate failing
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## How it works
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# 0008. Prereleases via on-demand snapshots
|
|
2
|
+
|
|
3
|
+
- Status: accepted
|
|
4
|
+
- Date: 2026-11-02
|
|
5
|
+
|
|
6
|
+
## Context
|
|
7
|
+
|
|
8
|
+
The repo is trunk-based on `main` and releases when the Version Packages PR is merged (npm trusted publishing, no token). Consumers sometimes need unreleased changes. Changesets offers pre mode (`x.y.z-rc.n`, state in `.changeset/pre.json`) and snapshots (`x.y.z-next-<timestamp>`). Pre mode on `main` turns every Version Packages PR into a prerelease and blocks stable hotfixes; a long-lived `next` branch means two integration branches to keep in sync.
|
|
9
|
+
|
|
10
|
+
## Decision
|
|
11
|
+
|
|
12
|
+
Stay trunk-based. Prereleases are snapshots published by running the Release workflow manually (`workflow_dispatch`, `main` only) with `changeset version --snapshot next` and `changeset publish --tag next --no-git-tag`. `snapshot.useCalculatedVersion` makes the version read `0.2.0-next-…`. The job fails when no changesets are pending. The `latest` tag is never touched. No automatic snapshot on push.
|
|
13
|
+
|
|
14
|
+
## Consequences
|
|
15
|
+
|
|
16
|
+
No extra branch, no `pre.json`, stable releases are never blocked. Snapshot versions are timestamped, not a tidy `rc.1`, `rc.2` sequence, and each one stays on npm. Revisit automatic snapshots on push once a downstream app consumes `@next`, and pre mode on `main` only for a short stabilization window before a major.
|
package/docs/adr/README.md
CHANGED
|
@@ -11,3 +11,4 @@ One file per decision, `NNNN-title.md`, [MADR](https://adr.github.io/madr/) styl
|
|
|
11
11
|
| [0005](0005-patch-openapi-typescript-helpers.md) | Patch `openapi-typescript-helpers` until upstream ships the fix | accepted |
|
|
12
12
|
| [0006](0006-tooling-mise-pnpm-biome.md) | mise, pnpm, Biome, Vitest, Changesets, Renovate; no turbo yet | accepted |
|
|
13
13
|
| [0007](0007-mit-license.md) | MIT license | accepted |
|
|
14
|
+
| [0008](0008-prereleases-via-snapshots.md) | Prereleases are on-demand snapshots from `main` under the `next` tag | accepted |
|
package/docs/how-to.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# How-to
|
|
2
2
|
|
|
3
|
-
Each recipe lists the exact steps. Run `pnpm codegen`, `pnpm typecheck` and `
|
|
3
|
+
Each recipe lists the exact steps. Run `pnpm codegen`, `pnpm typecheck` and `pnpm test` after changes.
|
|
4
4
|
- [Add the spec of a new backend release](#add-the-spec-of-a-new-backend-release)
|
|
5
5
|
- [Use a feature before the backend ships it](#use-a-feature-before-the-backend-ships-it)
|
|
6
6
|
- [Gate a query, a mutation, a field](#gate-a-query-a-mutation-a-field)
|
|
@@ -146,10 +146,10 @@ oasdiff breaking specs/1.6.0.json new-spec.json --fail-on ERR
|
|
|
146
146
|
Client CI:
|
|
147
147
|
|
|
148
148
|
```bash
|
|
149
|
-
|
|
149
|
+
pnpm install --frozen-lockfile
|
|
150
150
|
pnpm codegen # fails on a breaking pair, bad config, or missing floor spec
|
|
151
151
|
git diff --exit-code src/generated # if generated code is committed
|
|
152
|
-
pnpm typecheck &&
|
|
152
|
+
pnpm typecheck && pnpm test
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
`pnpm check:breaking` runs only the gate and writes nothing.
|
package/package.json
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-versions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Multi-version OpenAPI client for the openapi-ts ecosystem: merges the minor specs of one API major, generates tolerant types with openapi-typescript, and gates features at runtime.",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"codegen:playground": "rm -rf playground/generated && tsx codegen/cli.ts --config playground/openapi-versions.config.json",
|
|
7
|
-
"codegen:test": "rm -rf test/fixtures/generated && tsx codegen/cli.ts --config test/fixtures/openapi-versions.config.json",
|
|
8
|
-
"codegen": "npm run codegen:playground && npm run codegen:test",
|
|
9
|
-
"check:breaking": "tsx codegen/cli.ts --check-only --config playground/openapi-versions.config.json",
|
|
10
|
-
"typecheck": "npm run codegen:test && npm run codegen:playground && tsc --noEmit",
|
|
11
|
-
"test": "npm run codegen:test && vitest run",
|
|
12
|
-
"playground": "npm run codegen:playground && vite --config playground/app/vite.config.ts",
|
|
13
|
-
"playground:api": "npm run codegen:playground && tsx playground/api/run.ts",
|
|
14
|
-
"build:playground": "npm run codegen:playground && vite build --config playground/app/vite.config.ts",
|
|
15
|
-
"build": "tsup",
|
|
16
|
-
"prepack": "npm run build",
|
|
17
|
-
"lint": "biome check .",
|
|
18
|
-
"format": "biome check --write .",
|
|
19
|
-
"changeset": "changeset",
|
|
20
|
-
"release": "pnpm build && changeset publish"
|
|
21
|
-
},
|
|
22
5
|
"license": "MIT",
|
|
23
6
|
"repository": {
|
|
24
7
|
"type": "git",
|
|
@@ -109,8 +92,23 @@
|
|
|
109
92
|
"optional": true
|
|
110
93
|
}
|
|
111
94
|
},
|
|
112
|
-
"packageManager": "pnpm@12.3.4",
|
|
113
95
|
"engines": {
|
|
114
96
|
"node": ">=20"
|
|
97
|
+
},
|
|
98
|
+
"scripts": {
|
|
99
|
+
"codegen:playground": "rm -rf playground/generated && tsx codegen/cli.ts --config playground/openapi-versions.config.json",
|
|
100
|
+
"codegen:test": "rm -rf test/fixtures/generated && tsx codegen/cli.ts --config test/fixtures/openapi-versions.config.json",
|
|
101
|
+
"codegen": "pnpm codegen:playground && pnpm codegen:test",
|
|
102
|
+
"check:breaking": "tsx codegen/cli.ts --check-only --config playground/openapi-versions.config.json",
|
|
103
|
+
"typecheck": "pnpm codegen:test && pnpm codegen:playground && tsc --noEmit",
|
|
104
|
+
"test": "pnpm codegen:test && vitest run",
|
|
105
|
+
"playground": "pnpm codegen:playground && vite --config playground/app/vite.config.ts",
|
|
106
|
+
"playground:api": "pnpm codegen:playground && tsx playground/api/run.ts",
|
|
107
|
+
"build:playground": "pnpm codegen:playground && vite build --config playground/app/vite.config.ts",
|
|
108
|
+
"build": "tsup",
|
|
109
|
+
"lint": "biome check .",
|
|
110
|
+
"format": "biome check --write .",
|
|
111
|
+
"changeset": "changeset",
|
|
112
|
+
"release": "pnpm build && changeset publish"
|
|
115
113
|
}
|
|
116
|
-
}
|
|
114
|
+
}
|
|
@@ -17,10 +17,10 @@ Read `docs/concepts.md` once if the vocabulary (major, minor, floor, gated) is u
|
|
|
17
17
|
```
|
|
18
18
|
The floor is the oldest minor the app supports and must have its own spec file. Ask the user for the floor if unknown (default suggestion: the oldest minor running in any environment: prod, staging, on-prem).
|
|
19
19
|
4. **Generate**: `npx openapi-versions` (or an npm script). Expect `ok v1: a -> b` lines then `gen v1: …`.
|
|
20
|
-
5. **Install**: `npm i openapi-versions openapi-fetch openapi-react-query @tanstack/react-query
|
|
20
|
+
5. **Install**: with the app's package manager (`npm i`, `pnpm add`, `yarn add`): runtime `openapi-versions openapi-fetch openapi-react-query @tanstack/react-query`, dev `openapi-typescript "typescript@<7"`; apply the `openapi-typescript-helpers` patch from `patches/` (patch-package).
|
|
21
21
|
Import everything from the generated `<outDir>/v<n>/client.ts` (`ApiVersionProvider`, `useApi`, `Feature`, `createApi`, `Paths`); the major appears only in that import path.
|
|
22
22
|
6. **Provider**: wrap the app in `QueryClientProvider` then `<ApiVersionProvider baseUrl="https://host/api/v<n>">`. The base URL must include the major prefix; `/version` is read relative to it.
|
|
23
|
-
7. **Verify**: `pnpm typecheck &&
|
|
23
|
+
7. **Verify**: `pnpm typecheck && pnpm test`; for a visual check `pnpm playground`.
|
|
24
24
|
|
|
25
25
|
## Backend prerequisites (confirm, do not assume)
|
|
26
26
|
|