gatefit 0.5.0 → 0.5.1

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 CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- All notable Gatefit changes are listed here. The version heading matches `package.json`. Tag `v0.5.0` is not cut in this change.
3
+ All notable Gatefit changes are listed here. The version heading matches `package.json`. Tag `v0.5.1` is not cut in this change.
4
+
5
+ ## [0.5.1] - 2026-10-16
6
+
7
+ ### Fixed
8
+
9
+ - `better-sqlite3` is optional and loads only when the SQLite adapter opens a database. `--version`, `--help`, and `adapter-check` run when that module is missing. A SQLite command that cannot load it prints what is missing, that the package ships prebuilds and does not compile on install, and how to reinstall the prebuild or run `npm run build-release`, then exits non-zero.
4
10
 
5
11
  ## [0.5.0] - 2026-10-16
6
12
 
package/README.md CHANGED
@@ -9,7 +9,7 @@ Fixture-first S1–S6 goldens, an `npx gatefit` CLI, and a GitHub Action. Node 2
9
9
  The CLI and GitHub Action in this repository stay free. The docs site is live. npm is live: `npx gatefit` ([gatefit](https://www.npmjs.com/package/gatefit)). Polar checkout is.
10
10
 
11
11
  - **Docs site:** live at https://gatefit.io. Cloudflare Pages project `gatefit`, hostname `gatefit-bdu.pages.dev`. From `site/`: `npm run build`, then `npx wrangler@4 pages deploy dist --project-name gatefit`. `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` come from the environment. GitHub Pages needs a public repository or a paid plan and is not the live host. `scripts/deploy-site.sh` can copy `site/dist` locally or deploy that Cloudflare target.
12
- - **npm:** live. `npx gatefit` is the last published tarball (`gatefit@0.4.0` until tag `v0.5.0`) at https://www.npmjs.com/package/gatefit. This repo is `0.5.0`. The named gate runs `npm publish --dry-run` only. A `v*` tag publishes with OIDC. See [Releasing](#releasing).
12
+ - **npm:** live. `npx gatefit` is the last published tarball (`gatefit@0.5.0` until tag `v0.5.1`) at https://www.npmjs.com/package/gatefit. This repo is `0.5.1`. The named gate runs `npm publish --dry-run` only. A `v*` tag publishes with OIDC. See [Releasing](#releasing).
13
13
  - **Polar checkout:** live. Gatefit Indie License is **$49** one-time at `https://buy.polar.sh/polar_cl_biyvx7HYtN2u19tUJCCkIuGOc98uVv7IG3gcB04eIJ0`. A plain `site` build and `scripts/deploy-site.sh` use that committed link. `PUBLIC_POLAR_CHECKOUT_URL` may override it. Any other value fails closed.
14
14
 
15
15
  ## Install / run
@@ -20,7 +20,9 @@ npx gatefit adapter-check
20
20
  npx gatefit run --suite paid_grants_access --adapter ./src/your-access-adapter.ts
21
21
  ```
22
22
 
23
- This repo is `0.5.0`. Registry: https://www.npmjs.com/package/gatefit
23
+ This repo is `0.5.1`. Registry: https://www.npmjs.com/package/gatefit
24
+
25
+ `better-sqlite3` is optional and ships prebuilds for common platforms. It does not compile during `npm install`. `--version`, `--help`, and `adapter-check` run when the native module is missing. The reference SQLite adapter loads it only when that adapter runs. If the module is missing, that command tells you to reinstall the prebuild, or to install build tools and run `npm run build-release` in the `better-sqlite3` directory, then exits non-zero.
24
26
 
25
27
  From a clone:
26
28
 
@@ -41,13 +43,13 @@ Bring your own AccessAdapter in ≤30 minutes: [docs/bring-your-adapter.md](docs
41
43
 
42
44
  ## GitHub Action
43
45
 
44
- Marketplace-ready Action lives at the repo root (`action.yml`). Tag `v0.5.0` is not cut yet. After a human pushes the annotated tag:
46
+ Marketplace-ready Action lives at the repo root (`action.yml`). Tag `v0.5.0` is released. Tag `v0.5.1` is not cut yet. After a human pushes the annotated tag:
45
47
 
46
48
  ```yaml
47
49
  - uses: actions/setup-node@v4
48
50
  with:
49
51
  node-version: "22"
50
- - uses: gatefit/gatefit@v0.5.0
52
+ - uses: gatefit/gatefit@v0.5.1
51
53
  with:
52
54
  adapter: src/your-access-adapter.ts
53
55
  ```
@@ -55,12 +57,12 @@ Marketplace-ready Action lives at the repo root (`action.yml`). Tag `v0.5.0` is
55
57
  Nested path still works:
56
58
 
57
59
  ```yaml
58
- - uses: gatefit/gatefit/.github/actions/gatefit@v0.5.0
60
+ - uses: gatefit/gatefit/.github/actions/gatefit@v0.5.1
59
61
  with:
60
62
  adapter: src/your-access-adapter.ts
61
63
  ```
62
64
 
63
- The Action wraps `gatefit run`. Adapter path is in *your* repo; goldens default to Gatefit’s S1–S6 pack. See [docs/publish.md](docs/publish.md) and the release notes [docs/release-v0.5.0.md](docs/release-v0.5.0.md).
65
+ The Action wraps `gatefit run`. Adapter path is in *your* repo; goldens default to Gatefit’s S1–S6 pack. See [docs/publish.md](docs/publish.md) and the release notes [docs/release-v0.5.1.md](docs/release-v0.5.1.md).
64
66
 
65
67
  Do not set `GATEFIT_LIVE_CLOCK` for the named gate. Do not use `sk_live`. Never treat Stripe HTTP 200 as proof of access.
66
68
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatefit",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Stripe Entitlement Edge Pack — CI that asserts the access DB survives ugly billing transitions",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,10 +46,12 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "better-sqlite3": "^13.0.3",
50
49
  "tsx": "^4.20.5",
51
50
  "yaml": "^2.8.1"
52
51
  },
52
+ "optionalDependencies": {
53
+ "better-sqlite3": "^13.0.3"
54
+ },
53
55
  "devDependencies": {
54
56
  "@types/better-sqlite3": "^9.6.0",
55
57
  "@types/node": "^22.18.0",
@@ -3,7 +3,31 @@ import type { AccessAdapter, AccessSnapshot, BillingEvent } from "../access-adap
3
3
  import { nextSnapshot } from "../access-rules.ts";
4
4
 
5
5
  const require = createRequire(import.meta.url);
6
- const Database = require("better-sqlite3") as typeof import("better-sqlite3");
6
+
7
+ function sqliteUnavailable(err: unknown): Error {
8
+ const detail = err instanceof Error ? err.message : String(err);
9
+ return new Error(
10
+ [
11
+ "gatefit: SQLite adapter cannot load better-sqlite3.",
12
+ "What is missing: the better-sqlite3 native module.",
13
+ "Why: better-sqlite3 is optional. Its package ships prebuilds for linux, darwin, and win32 (x64 and arm64) and does not compile during npm install. This process has no usable prebuild.",
14
+ "How to fix: reinstall so the prebuild is unpacked (npm install better-sqlite3, or reinstall gatefit). npm rebuild better-sqlite3 does not compile it. On a platform without a prebuild, install make and a C++ compiler (Xcode Command Line Tools on macOS, or build-essential on Linux), then in the better-sqlite3 directory run npm run build-release.",
15
+ "--version, --help, and adapter-check do not need this module.",
16
+ `Detail: ${detail}`,
17
+ ].join("\n"),
18
+ );
19
+ }
20
+
21
+ function loadDatabase(): typeof import("better-sqlite3") {
22
+ try {
23
+ const Database = require("better-sqlite3") as typeof import("better-sqlite3");
24
+ const probe = new Database(":memory:");
25
+ probe.close();
26
+ return Database;
27
+ } catch (err) {
28
+ throw sqliteUnavailable(err);
29
+ }
30
+ }
7
31
 
8
32
  type AccessRow = {
9
33
  customer_id: string;
@@ -24,6 +48,7 @@ function rowToSnapshot(row: AccessRow | undefined): AccessSnapshot {
24
48
 
25
49
  export function createAdapter(): AccessAdapter {
26
50
  const filename = process.env.GATEFIT_SQLITE_PATH ?? ":memory:";
51
+ const Database = loadDatabase();
27
52
  const db = new Database(filename);
28
53
  db.exec(`
29
54
  CREATE TABLE IF NOT EXISTS access (
package/src/cli.ts CHANGED
@@ -25,6 +25,7 @@ function usage(): string {
25
25
  " gatefit run --suite chaos --adapter <path> [--seed <value>]",
26
26
  " gatefit adapter-check",
27
27
  " gatefit live --adapter <path> [--scenario <id>]",
28
+ " gatefit --help",
28
29
  " gatefit --version",
29
30
  ].join("\n");
30
31
  }
@@ -96,11 +97,19 @@ function isVersionFlag(arg: string | undefined): boolean {
96
97
  return arg === "--version" || arg === "-v";
97
98
  }
98
99
 
100
+ function isHelpFlag(arg: string | undefined): boolean {
101
+ return arg === "--help" || arg === "-h";
102
+ }
103
+
99
104
  async function main(argv: string[]): Promise<number> {
100
105
  if (isVersionFlag(argv[0])) {
101
106
  console.log(`gatefit ${readPackageVersion()}`);
102
107
  return 0;
103
108
  }
109
+ if (isHelpFlag(argv[0])) {
110
+ console.log(usage());
111
+ return 0;
112
+ }
104
113
  const command = argv[0];
105
114
  if (command === "adapter-check") {
106
115
  return cmdAdapterCheck();