@revstackhq/cli 0.0.0-dev-20260226054033

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,12 @@
1
+ [?9001h[?1004h[?25l> @revstackhq/cli@0.0.0-dev-20260226054033 build C:\Users\flava\OneDrive\Desktop\Work\revstack-os\packages\cli
2
+ > tsup]0;C:\WINDOWS\system32\cmd.exe[?25hCLI Building entry: src/cli.ts
3
+ CLI Using tsconfig: tsconfig.json
4
+ CLI tsup v8.5.1
5
+ CLI Using tsup config: C:\Users\flava\OneDrive\Desktop\Work\revstack-os\packages\cli\tsup.config.ts
6
+ CLI Target: node18
7
+ CLI Cleaning output folder
8
+ ESM Build start
9
+ ESM dist\cli.js 17.97 KB
10
+ ESM dist\cli.js.map 38.83 KB
11
+ ESM ⚡️ Build success in 597ms
12
+ [?9001l[?1004l
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @revstackhq/cli
2
+
3
+ ## 0.0.0-dev-20260226054033
4
+
5
+ ### Minor Changes
6
+
7
+ - Initial release of the Revstack CLI.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Revstack Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # @revstackhq/cli
2
+
3
+ The official command-line interface for Revstack. Manages your billing configuration as code — define plans, features, and entitlements in `revstack.config.ts`, then push them to Revstack Cloud with a single command.
4
+
5
+ ## Features
6
+
7
+ - **Billing as Code:** Define your entire billing model in a type-safe TypeScript config file.
8
+ - **Zero-Build Config Loading:** Evaluates `revstack.config.ts` on the fly using `jiti` — no separate compilation step needed.
9
+ - **Diff Before Deploy:** Every `push` shows a detailed diff of what will change before anything goes live.
10
+ - **Environment Targeting:** Push and pull configs to/from different environments (`test`, `production`, etc.).
11
+ - **Interactive Authentication:** Securely store your API key locally at `~/.revstack/credentials.json`.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install -g @revstackhq/cli
17
+ ```
18
+
19
+ Or use it directly with `npx`:
20
+
21
+ ```bash
22
+ npx @revstackhq/cli init
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ### 1. Initialize a Config
28
+
29
+ Scaffold a new `revstack.config.ts` in your project root:
30
+
31
+ ```bash
32
+ revstack init
33
+ ```
34
+
35
+ This creates a starter config with example plans and features using the type-safe helpers from `@revstackhq/core`:
36
+
37
+ ```typescript
38
+ import { defineConfig, definePlan, defineFeature } from "@revstackhq/core";
39
+
40
+ const features = {
41
+ seats: defineFeature({
42
+ name: "Seats",
43
+ type: "static",
44
+ unit_type: "count",
45
+ }),
46
+ ai_tokens: defineFeature({
47
+ name: "AI Tokens",
48
+ type: "metered",
49
+ unit_type: "count",
50
+ }),
51
+ };
52
+
53
+ export default defineConfig({
54
+ features,
55
+ plans: {
56
+ default: definePlan<typeof features>({
57
+ name: "Default",
58
+ description: "Automatically created default plan for guests.",
59
+ is_default: true,
60
+ is_public: false,
61
+ type: "free",
62
+ features: {},
63
+ }),
64
+ pro: definePlan<typeof features>({
65
+ name: "Pro",
66
+ description: "For professional teams.",
67
+ is_default: false,
68
+ is_public: true,
69
+ type: "paid",
70
+ prices: [
71
+ {
72
+ amount: 2900,
73
+ currency: "USD",
74
+ billing_interval: "monthly",
75
+ trial_period_days: 14,
76
+ },
77
+ {
78
+ amount: 29000,
79
+ currency: "USD",
80
+ billing_interval: "yearly",
81
+ trial_period_days: 14,
82
+ },
83
+ ],
84
+ features: {
85
+ seats: { value_limit: 5, is_hard_limit: true },
86
+ ai_tokens: { value_limit: 1000, reset_period: "monthly" },
87
+ },
88
+ }),
89
+ },
90
+ });
91
+ ```
92
+
93
+ ### 2. Authenticate
94
+
95
+ Log in with your Revstack Secret Key (found in the [Revstack Dashboard](https://app.revstack.dev)):
96
+
97
+ ```bash
98
+ revstack login
99
+ ```
100
+
101
+ Your credentials are stored locally at `~/.revstack/credentials.json` and never leave your machine.
102
+
103
+ ### 3. Deploy
104
+
105
+ Push your config to Revstack Cloud:
106
+
107
+ ```bash
108
+ revstack push
109
+ ```
110
+
111
+ The CLI will:
112
+
113
+ 1. Parse your `revstack.config.ts`.
114
+ 2. Send it to the Revstack API to compute a diff against the current remote state.
115
+ 3. Display a color-coded summary of changes (additions, removals, updates).
116
+ 4. Ask for confirmation before applying.
117
+
118
+ ### 4. Pull Remote State
119
+
120
+ Fetch the current billing configuration from Revstack Cloud and overwrite your local `revstack.config.ts`:
121
+
122
+ ```bash
123
+ revstack pull
124
+ ```
125
+
126
+ ### 5. Log Out
127
+
128
+ Clear stored credentials:
129
+
130
+ ```bash
131
+ revstack logout
132
+ ```
133
+
134
+ ## Commands
135
+
136
+ | Command | Description |
137
+ | ----------------- | ----------------------------------------------------------- |
138
+ | `revstack init` | Scaffold a new `revstack.config.ts` |
139
+ | `revstack login` | Authenticate with your Revstack Secret Key |
140
+ | `revstack logout` | Clear stored credentials |
141
+ | `revstack push` | Diff and deploy your local config to Revstack Cloud |
142
+ | `revstack pull` | Pull remote config and overwrite local `revstack.config.ts` |
143
+
144
+ ### Global Options
145
+
146
+ | Option | Description |
147
+ | ----------- | --------------------- |
148
+ | `--version` | Print the CLI version |
149
+ | `--help` | Display help |
150
+
151
+ ### Environment Targeting
152
+
153
+ Both `push` and `pull` support the `-e, --env` flag to target a specific environment:
154
+
155
+ ```bash
156
+ # Push to production
157
+ revstack push --env production
158
+
159
+ # Pull from test (default)
160
+ revstack pull --env test
161
+ ```
162
+
163
+ ## Architecture
164
+
165
+ The CLI is intentionally a **"dumb client"**. All complex diffing, validation, and migration logic lives on the Revstack Cloud backend. The CLI's responsibilities are limited to:
166
+
167
+ 1. **Config Loading** — Evaluate `revstack.config.ts` at runtime using `jiti` and sanitize the output to plain JSON.
168
+ 2. **Authentication** — Store and retrieve the API key from `~/.revstack/credentials.json`.
169
+ 3. **Network Communication** — Send the parsed config to the Revstack API and display the results.
170
+
171
+ This keeps the CLI lightweight, fast to install, and ensures the source of truth for billing logic always lives server-side.
172
+
173
+ ## License
174
+
175
+ MIT