dodopayments-cli 2.0.3 → 2.2.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.
@@ -0,0 +1,11 @@
1
+ /** @type {import("prettier").Config} */
2
+ export default {
3
+ // Enforce 2-space indentation
4
+ tabWidth: 2,
5
+
6
+ // Use single quotes
7
+ singleQuote: true,
8
+
9
+ // Always add semicolons
10
+ semi: true,
11
+ };
package/CONTRIBUTING.md CHANGED
@@ -61,17 +61,38 @@ This project and everyone participating in it is governed by our [Code of Conduc
61
61
 
62
62
  ```
63
63
  dodopayments-cli/
64
- ├── index.ts # Main CLI entrypoint
65
- ├── utils/ # Utility functions
66
- ├── dodo-webhooks/ # Webhook testing functionality
64
+ ├── src/ # All CLI source code
65
+ ├── index.ts # Main CLI entrypoint (command router)
66
+ │ │
67
+ │ ├── commands/ # Domain-based command modules
68
+ │ │ ├── addons/ # Add-on related commands
69
+ │ │ ├── checkout/ # Checkout commands
70
+ │ │ ├── customer/ # Customer management commands
71
+ │ │ ├── discount/ # Discount/coupon commands
72
+ │ │ ├── licenses/ # License management commands
73
+ │ │ ├── login/ # Authentication/login commands
74
+ │ │ ├── payment/ # Payment-related commands
75
+ │ │ ├── product/ # Product management commands
76
+ │ │ ├── refund/ # Refund commands
77
+ │ │ └── webhook/ # Webhook-related commands
78
+ │ │
79
+ │ ├── ui/ # CLI presentation layer (output/help/logo)
80
+ │ │ ├── help.ts # Help rendering
81
+ │ │ ├── index.ts # Barrel export for UI utilities
82
+ │ │ └── logo.ts # CLI logo/banner
83
+ │ │
84
+ │ └── utils/ # Shared utilities (config, client, helpers)
85
+
86
+ ├── build-binaries.ts # Script to generate distributable binaries
67
87
  ├── .github/
68
- │ ├── ISSUE_TEMPLATE/ # Issue templates
88
+ │ ├── ISSUE_TEMPLATE/
69
89
  │ ├── PULL_REQUEST_TEMPLATE.md
70
- │ └── workflows/ # CI/CD workflows
71
- ├── CONTRIBUTING.md # This file
90
+ │ └── workflows/
91
+
92
+ ├── CONTRIBUTING.md
72
93
  ├── CODE_OF_CONDUCT.md
73
94
  ├── LICENSE
74
- └── README.md
95
+ ├── README.md
75
96
  ```
76
97
 
77
98
  ## How to Contribute
package/README.md CHANGED
@@ -20,7 +20,7 @@
20
20
  <a href="#installation">Installation</a> •
21
21
  <a href="#authentication">Authentication</a> •
22
22
  <a href="#usage">Usage</a> •
23
- <a href="#webhook-testing">Webhooks</a> •
23
+ <a href="#webhooks">Webhooks</a> •
24
24
  <a href="#contributing">Contributing</a>
25
25
  </p>
26
26
 
@@ -74,6 +74,8 @@ This command will:
74
74
  3. Ask you to select the environment (**Test Mode** or **Live Mode**)
75
75
  4. Store your credentials locally to `~/.dodopayments/api-key`
76
76
 
77
+ Note: Upto 1 Test Mode & 1 Live Mode can be used at the same time
78
+
77
79
  ## Usage
78
80
 
79
81
  The general syntax is:
@@ -129,19 +131,40 @@ Manage software licenses.
129
131
  |---------|-------------|
130
132
  | `dodo licences list` | List all licenses |
131
133
 
132
- ## Webhook Testing
134
+ ### Addons
133
135
 
134
- The CLI includes a robust tool for testing webhooks by simulating events.
136
+ Manage your add-ons.
135
137
 
136
- ```bash
137
- dodo wh
138
- ```
138
+ | Command | Description |
139
+ |---------|-------------|
140
+ | `dodo addons list` | List all addons |
141
+ | `dodo addons create` | Open dashboard to create an addon |
142
+ | `dodo addons info` | View details for a specific addon |
143
+
144
+ ### Refunds
145
+
146
+ Manage your refunds.
147
+
148
+ | Command | Description |
149
+ |---------|-------------|
150
+ | `dodo refund list` | List all refunds |
151
+ | `dodo refund info` | View details for a specific refund |
152
+
153
+ ### Webhooks
154
+
155
+ Manage and test webhooks directly from the CLI.
156
+
157
+ | Command | Description |
158
+ |---------|-------------|
159
+ | `dodo wh listen` | Listen for webhooks from Dodo Payments in real time and forward them to your local dev server |
160
+ | `dodo wh trigger` | Trigger a test webhook event interactively |
161
+
162
+ > **Note:** The webhook triggering doesn't support signing requests yet. Please disable webhook signature verification while triggering. A simple way to do this is using `unsafe_unwrap()` instead of `unwrap()` in the webhook endpoint **during testing only**.
139
163
 
140
- > **Note:** The webhook testing tool doesn't support signing requests yet. Please disable webhook signature verification while testing. A simple way to do this is using `unsafe_unwrap()` instead of `unwrap()` in the webhook endpoint **during testing only**.
164
+ > **Note:** The webhook listening tool will only work with a test mode API key. If you use a live mode API key, it won't work.
141
165
 
142
166
  This interactive tool guides you through:
143
167
  1. Setting a destination **endpoint URL**
144
- 2. Configuring **Business ID**, **Product ID**, and **Metadata**
145
168
  3. Selecting a specific **Event** to trigger
146
169
 
147
170
  ### Supported Webhook Events
package/build-binaries.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { rename, rm } from "node:fs/promises";
2
+
1
3
  const targets: any = [
2
4
  "bun-darwin-x64",
3
5
  "bun-darwin-arm64",
@@ -8,15 +10,36 @@ const targets: any = [
8
10
 
9
11
  // Loop through all targets and build them
10
12
  for (const target of targets) {
11
- await Bun.build({
12
- entrypoints: ["./index.ts"],
13
- outdir: `./dist/dodopayments-cli-${target.replace('bun-', '')}`,
13
+ const targetName = target.replace('bun-', '');
14
+ const tempDir = `./dist/temp-${targetName}`;
15
+
16
+ const build = await Bun.build({
17
+ entrypoints: ["./src/index.ts"],
18
+ outdir: tempDir,
14
19
  target: "bun",
15
20
  compile: {
16
21
  // `as any` cause Bun doesn't provide type of exact platforms
17
22
  target: target as any,
18
- }
23
+ },
19
24
  });
25
+
26
+ const artifact = build.outputs[0];
27
+ if (build.success && artifact) {
28
+ const binaryPath = artifact.path;
29
+
30
+ if (binaryPath) {
31
+ let finalName = `dodo-cli-${targetName}`;
32
+ if (target.includes("windows")) {
33
+ finalName += ".exe";
34
+ }
35
+
36
+ await rename(binaryPath, `./dist/${finalName}`);
37
+ await rm(tempDir, { recursive: true, force: true });
38
+ console.log(`Successfully built ${finalName}`);
39
+ } else {
40
+ console.error(`Build successful but artifact path missing for ${target}`);
41
+ }
42
+ }
20
43
  }
21
44
 
22
45
  console.log(`Build complete! Binaries are in ./dist`);