fresh-squeezy 0.1.14 → 0.1.15
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 +56 -12
- package/dist/cli.js +1496 -328
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1136 -245
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +901 -73
- package/dist/index.d.ts +901 -73
- package/dist/index.js +1106 -245
- package/dist/index.js.map +1 -1
- package/package.json +7 -10
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<a href="https://github.com/YosefHayim/fresh-squeezy">
|
|
5
|
-
<img src="public/fresh-squeezy-hero.png" alt="fresh-squeezy —
|
|
5
|
+
<img src="public/fresh-squeezy-hero.png" alt="fresh-squeezy — doctor + ops for Lemon Squeezy. Validate billing setup and run docs-backed API resource operations from CLI or TypeScript." width="640" />
|
|
6
6
|
</a>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
<strong>
|
|
10
|
+
<strong>Doctor + ops for Lemon Squeezy — catch billing misconfigs before they ship, then run docs-backed store operations from CLI or TypeScript.</strong>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
13
|
<!-- Badges. tests count is static; bump it on major test-suite changes. -->
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<img src="https://img.shields.io/node/v/fresh-squeezy?logo=node.js&logoColor=white&color=339933" alt="Node.js 20 or newer" />
|
|
20
20
|
<img src="https://img.shields.io/npm/types/fresh-squeezy?logo=typescript&logoColor=white" alt="TypeScript types included" />
|
|
21
21
|
<a href="https://packagephobia.com/result?p=fresh-squeezy"><img src="https://packagephobia.com/badge?p=fresh-squeezy" alt="install size" /></a>
|
|
22
|
-
<img src="https://img.shields.io/badge/tests-
|
|
22
|
+
<img src="https://img.shields.io/badge/tests-179%20passing-3fb950?logo=vitest&logoColor=white" alt="179 tests passing" />
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
25
|
<p align="center">
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
<a href="#what-it-catches-that-postman-and-the-official-sdk-wont">What it catches</a> ·
|
|
36
36
|
<a href="#fresh-squeezy-vs-the-alternatives">Comparison</a> ·
|
|
37
37
|
<a href="#cli">CLI</a> ·
|
|
38
|
+
<a href="#ops-docs-backed-api">Ops</a> ·
|
|
38
39
|
<a href="#library">Library</a> ·
|
|
39
40
|
<a href="#issue-codes">Issue codes</a> ·
|
|
40
41
|
<a href="#faq">FAQ</a>
|
|
@@ -42,7 +43,12 @@
|
|
|
42
43
|
|
|
43
44
|
---
|
|
44
45
|
|
|
45
|
-
**fresh-squeezy** is a CLI and TypeScript library
|
|
46
|
+
**fresh-squeezy** is a dual-mode CLI and TypeScript library for [Lemon Squeezy](https://www.lemonsqueezy.com/):
|
|
47
|
+
|
|
48
|
+
1. **Doctor / validate** — pre-flight health for stores, products, webhooks, discounts, license keys, and subscription plans. Stable [exit codes](#30-second-start), machine-readable JSON, and changelog-drift tracking the official SDK hasn't shipped yet.
|
|
49
|
+
2. **Ops** — docs-backed resource operations only (`get` / `list` / `create` / `update` / `delete` / `cancel` / `refund` / `generate-invoice` / `current-usage`). Products and variants are **read-only** on the real Lemon Squeezy API — we never invent catalog CRUD.
|
|
50
|
+
|
|
51
|
+
Node 20+. Prefer `@lemonsqueezy/lemonsqueezy.js` inside product code; use fresh-squeezy for setup, CI gates, and store ops.
|
|
46
52
|
|
|
47
53
|
## 30-second start
|
|
48
54
|
|
|
@@ -54,7 +60,7 @@ The first run adds `fresh-squeezy` to devDependencies when it is missing, then s
|
|
|
54
60
|
|
|
55
61
|
| Exit | Meaning |
|
|
56
62
|
|------|---------|
|
|
57
|
-
| `0` |
|
|
63
|
+
| `0` | Success (validators passed / op completed) |
|
|
58
64
|
| `1` | One or more validators reported `error`-level issues |
|
|
59
65
|
| `2` | Fatal (missing key, invalid flags, network failure) |
|
|
60
66
|
| `130` | User cancelled an interactive flow |
|
|
@@ -80,9 +86,10 @@ How a typical Lemon Squeezy pre-ship check compares across the tools a developer
|
|
|
80
86
|
| Changelog-drift tracking | ✅ | ❌ | ❌ | ❌ |
|
|
81
87
|
| Stable, CI-ready exit codes + JSON | ✅ | ❌ | ❌ | ⚠️ manual |
|
|
82
88
|
| One-command full sweep (`doctor`) | ✅ | ❌ | ❌ | ❌ |
|
|
89
|
+
| Docs-backed ops CLI (get/list/create/…/refund) | ✅ | ⚠️ SDK only | ⚠️ manual | ⚠️ manual |
|
|
83
90
|
| Typed API responses | ✅ | ✅ | ❌ | ⚠️ depends |
|
|
84
91
|
|
|
85
|
-
fresh-squeezy is **not** a replacement for the official SDK
|
|
92
|
+
fresh-squeezy is **not** a full replacement for the official SDK inside app code — use the SDK (or our nested client) for product runtime, and fresh-squeezy for setup, CI gates, and store ops.
|
|
86
93
|
|
|
87
94
|
## CLI
|
|
88
95
|
|
|
@@ -110,7 +117,34 @@ npx fresh-squeezy validate webhook \
|
|
|
110
117
|
|
|
111
118
|
Stores resolve in this order for every store-scoped command: explicit `--store-ids`, then `--all-stores`, then an interactive multi-select on a TTY, then a connection-only run when there's no TTY and no flag (useful as a CI smoke check). `doctor` validates connection and store access plus any explicit resource flags; add `--all-resources` to discover and validate every supported resource in the selected store(s).
|
|
112
119
|
|
|
113
|
-
|
|
120
|
+
## Ops (docs-backed API)
|
|
121
|
+
|
|
122
|
+
Only operations documented at [docs.lemonsqueezy.com/api](https://docs.lemonsqueezy.com/api). Print the matrix anytime:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npx fresh-squeezy ops --list
|
|
126
|
+
npx fresh-squeezy ops --list --json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Reads
|
|
131
|
+
npx fresh-squeezy get product --id 42 --json
|
|
132
|
+
npx fresh-squeezy list webhook --store-ids 12
|
|
133
|
+
npx fresh-squeezy list variant --parent-id 42 --json
|
|
134
|
+
|
|
135
|
+
# Writes (test mode free when args are complete; live + destructive need --yes)
|
|
136
|
+
npx fresh-squeezy create webhook --body-file webhook.json --mode test
|
|
137
|
+
npx fresh-squeezy cancel subscription --id 9 --yes
|
|
138
|
+
npx fresh-squeezy refund order --id 100 --yes --mode live
|
|
139
|
+
npx fresh-squeezy generate-invoice order --id 100 --yes
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Safety:** `delete` / `cancel` / `refund` always require `--yes` or a TTY confirm. Live-mode writes need `--yes` or TTY confirm too. Bodies are JSON:API documents via `--body` or `--body-file` (not flat flags).
|
|
143
|
+
|
|
144
|
+
**Read-only in the real API (never invent create/update/delete):** products, variants, prices, files, stores, affiliates, order-items, discount-redemptions, license-key-instances.
|
|
145
|
+
|
|
146
|
+
**→ Full command, flag, and store-resolution reference: [docs/cli-reference.md](./docs/cli-reference.md)**
|
|
147
|
+
**→ Agent skill for ops + doctor: [skills/fresh-squeezy-ops/SKILL.md](./skills/fresh-squeezy-ops/SKILL.md)**
|
|
114
148
|
|
|
115
149
|
## Library
|
|
116
150
|
|
|
@@ -119,6 +153,7 @@ import { createFreshSqueezy } from "fresh-squeezy";
|
|
|
119
153
|
|
|
120
154
|
const lemon = createFreshSqueezy(); // reads LEMON_SQUEEZY_API_KEY, LEMON_SQUEEZY_MODE
|
|
121
155
|
|
|
156
|
+
// Doctor
|
|
122
157
|
const report = await lemon.doctor({
|
|
123
158
|
storeId: 12, // library is single-store per call
|
|
124
159
|
productId: 987,
|
|
@@ -133,9 +168,14 @@ if (!report.ok) {
|
|
|
133
168
|
}
|
|
134
169
|
process.exit(1);
|
|
135
170
|
}
|
|
171
|
+
|
|
172
|
+
// Nested docs-backed ops (HTTP failures throw FreshSqueezyError)
|
|
173
|
+
const product = await lemon.products.get(42);
|
|
174
|
+
const webhooks = await lemon.webhooks.list(12);
|
|
175
|
+
await lemon.subscriptions.cancel(9);
|
|
136
176
|
```
|
|
137
177
|
|
|
138
|
-
For multi-store runs at the library layer, call `doctor()` in a loop — the CLI does exactly this. Switch on `issue.code` in CI logic; codes are stable across minor versions.
|
|
178
|
+
For multi-store doctor runs at the library layer, call `doctor()` in a loop — the CLI does exactly this. Switch on `issue.code` in CI logic; codes are stable across minor versions. Validators return `ValidationResult` and never throw for findings; resource mutations throw `FreshSqueezyError` (`code` / `status`).
|
|
139
179
|
|
|
140
180
|
Public types: [`FreshSqueezyClient`](src/createFreshSqueezy.ts), [`ValidationResult<T>`](src/core/types.ts), [`DoctorReport`](src/core/types.ts), resource attribute interfaces under [`src/resources`](src/resources), docs-generated Lemon Squeezy object types in [`src/generated/lemonSqueezyApiTypes.ts`](src/generated/lemonSqueezyApiTypes.ts), and changelog augmentation helpers in [`src/augmentations.ts`](src/augmentations.ts).
|
|
141
181
|
|
|
@@ -214,11 +254,15 @@ That's the `MODE_MISMATCH` check. fresh-squeezy compares the mode you declared (
|
|
|
214
254
|
|
|
215
255
|
### Does fresh-squeezy work in CI?
|
|
216
256
|
|
|
217
|
-
Yes. Run `npx fresh-squeezy doctor --all-stores --all-resources --json` for a machine-readable full sweep. It returns stable [exit codes](#30-second-start) (`0` pass, `1` validation errors, `2` fatal) and stable `issue.code` strings you can assert on. No TTY required — without store flags it falls back to a connection-only smoke check.
|
|
257
|
+
Yes. Run `npx fresh-squeezy doctor --all-stores --all-resources --json` for a machine-readable full sweep. It returns stable [exit codes](#30-second-start) (`0` pass, `1` validation errors, `2` fatal) and stable `issue.code` strings you can assert on. No TTY required — without store flags it falls back to a connection-only smoke check. Ops commands also accept `--json` and never hang without a TTY.
|
|
258
|
+
|
|
259
|
+
### Can I create products via the CLI?
|
|
260
|
+
|
|
261
|
+
No. Lemon Squeezy's public API does not expose product/variant create/update/delete. Run `npx fresh-squeezy ops --list` for the honest matrix.
|
|
218
262
|
|
|
219
263
|
### Is fresh-squeezy a replacement for the official Lemon Squeezy SDK?
|
|
220
264
|
|
|
221
|
-
No. The [official SDK](https://github.com/lmsqueezy/lemonsqueezy.js)
|
|
265
|
+
No. The [official SDK](https://github.com/lmsqueezy/lemonsqueezy.js) is ideal inside product code. fresh-squeezy is the dual-mode doctor + docs-backed ops layer for setup, CI, and store work. They're complementary — see the [comparison table](#fresh-squeezy-vs-the-alternatives).
|
|
222
266
|
|
|
223
267
|
### What is "changelog drift" and why should I care?
|
|
224
268
|
|
|
@@ -226,7 +270,7 @@ Lemon Squeezy ships API changes (new events, new fields, new resources) faster t
|
|
|
226
270
|
|
|
227
271
|
### Can I use fresh-squeezy as a library instead of the CLI?
|
|
228
272
|
|
|
229
|
-
Yes. `import { createFreshSqueezy } from "fresh-squeezy"` and call `doctor()
|
|
273
|
+
Yes. `import { createFreshSqueezy } from "fresh-squeezy"` and call `doctor()`, individual validators, or nested ops (`lemon.webhooks.create(…)`). Validators return typed `ValidationResult`; ops throw `FreshSqueezyError` on HTTP failure — see [Library](#library).
|
|
230
274
|
|
|
231
275
|
### Which Lemon Squeezy resources can it validate?
|
|
232
276
|
|
|
@@ -234,7 +278,7 @@ Connection/auth, stores, products (and variants), webhooks, discounts, license k
|
|
|
234
278
|
|
|
235
279
|
## Contributing
|
|
236
280
|
|
|
237
|
-
See [CONTRIBUTING.md](./CONTRIBUTING.md). Clone, `
|
|
281
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md). Clone, `pnpm install`, `pnpm test`. The project aims to stay small and boring — doctor + docs-backed ops, one HTTP layer, stable `issue.code` contract. Style: const arrows only, pure `export *` barrels — see [CODE-STYLE.md](./CODE-STYLE.md).
|
|
238
282
|
|
|
239
283
|
## Contributors
|
|
240
284
|
|