@superflag-sh/cli 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/README.md +212 -0
  2. package/package.json +47 -31
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # @superflag-sh/cli
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@superflag-sh/cli.svg)](https://www.npmjs.com/package/@superflag-sh/cli)
4
+
5
+ Command-line interface for managing [Superflag](https://superflag.sh) feature flags and remote config.
6
+
7
+ ## Quick Start
8
+
9
+ ```bash
10
+ # Install globally
11
+ npm install -g @superflag-sh/cli
12
+
13
+ # Authenticate
14
+ superflag login
15
+
16
+ # Set your default app and environment
17
+ superflag use myapp production
18
+
19
+ # Get and set flags
20
+ superflag get dark-mode
21
+ superflag set dark-mode true
22
+ ```
23
+
24
+ ## Authentication
25
+
26
+ The CLI uses browser-based OAuth authentication:
27
+
28
+ ```bash
29
+ superflag login # Opens browser to authenticate
30
+ superflag whoami # Show current user
31
+ superflag logout # Clear credentials
32
+ ```
33
+
34
+ Credentials are stored in `~/.superflag/credentials.json`.
35
+
36
+ ## Context System
37
+
38
+ Instead of passing `--app` and `--env` with every command, set a default context:
39
+
40
+ ```bash
41
+ superflag use myapp staging
42
+ ```
43
+
44
+ This saves your context to `~/.superflag/context.json`. Quick commands like `get`, `set`, and `config` will use this context automatically.
45
+
46
+ You can override context for a single command:
47
+
48
+ ```bash
49
+ superflag get feature-x --app other-app --env prod
50
+ ```
51
+
52
+ Check your current context with:
53
+
54
+ ```bash
55
+ superflag status
56
+ ```
57
+
58
+ ## Commands
59
+
60
+ ### Quick Commands
61
+
62
+ These commands use your saved context for fast flag operations:
63
+
64
+ ```bash
65
+ superflag use <app> <env> # Set default app/env context
66
+ superflag get <key> # Get a flag value
67
+ superflag set <key> <value> # Set a flag value
68
+ superflag config # Dump full config as JSON
69
+ superflag status # Show auth and context status
70
+ ```
71
+
72
+ ### Auth Commands
73
+
74
+ ```bash
75
+ superflag login # Authenticate via browser
76
+ superflag logout # Clear credentials and context
77
+ superflag whoami # Show current user email
78
+ ```
79
+
80
+ ### Apps
81
+
82
+ ```bash
83
+ superflag apps list # List all your apps
84
+ superflag apps create <name> # Create a new app
85
+ ```
86
+
87
+ ### Environments
88
+
89
+ ```bash
90
+ superflag envs list --app <name> # List environments for an app
91
+ ```
92
+
93
+ ### Flags
94
+
95
+ **List and manage flags:**
96
+
97
+ ```bash
98
+ superflag flags list --app <name> --env <slug>
99
+ superflag flags create --app <name> --env <slug> --key <key> --type <type> --value <value>
100
+ superflag flags set --app <name> --env <slug> --key <key> --value <value>
101
+ superflag flags toggle --app <name> --env <slug> --key <key>
102
+ superflag flags delete --app <name> --env <slug> --key <key>
103
+ ```
104
+
105
+ **Idempotent upsert (uses context):**
106
+
107
+ ```bash
108
+ superflag flags upsert --key new-feature --type bool --value true
109
+ superflag flags upsert --key new-feature --type bool --value true --client # Enable for client SDKs
110
+ ```
111
+
112
+ Flag types: `bool`, `string`, `number`, `json`
113
+
114
+ **Gradual rollout:**
115
+
116
+ ```bash
117
+ superflag flags rollout --key feature-x --percentage 25 # Roll out to 25%
118
+ superflag flags rollout --key feature-x --percentage 100 # Full rollout
119
+ superflag flags rollout --key feature-x --remove # Remove rollout
120
+ ```
121
+
122
+ **A/B test variants:**
123
+
124
+ ```bash
125
+ # Format: --variant "value:weight:name"
126
+ superflag flags variants --key button-color \
127
+ --variant "blue:50:control" \
128
+ --variant "green:30:variant-a" \
129
+ --variant "red:20:variant-b"
130
+
131
+ superflag flags variants --key button-color --remove # Remove variants
132
+ ```
133
+
134
+ Weights must sum to 100. Names are optional.
135
+
136
+ **Bulk operations:**
137
+
138
+ ```bash
139
+ # From file
140
+ superflag flags bulk-set --file flags.json
141
+
142
+ # From stdin
143
+ echo '{"feature-a": true, "feature-b": "new-value"}' | superflag flags bulk-set
144
+ ```
145
+
146
+ JSON format: `{"flag-key": value, ...}`
147
+
148
+ ### Keys
149
+
150
+ ```bash
151
+ superflag keys list --app <name> --env <slug>
152
+ superflag keys create --app <name> --env <slug> --type <sdk|pub>
153
+ superflag keys revoke <key-id>
154
+ ```
155
+
156
+ Key types:
157
+ - `sdk` - Server-side SDK key (full config access)
158
+ - `pub` - Client-side public key (filtered to client-enabled flags only)
159
+
160
+ ## Global Options
161
+
162
+ | Option | Description |
163
+ |--------|-------------|
164
+ | `--json` | Output as JSON |
165
+ | `--quiet`, `-q` | Suppress non-essential output |
166
+ | `--app <name>` | Override app context for this command |
167
+ | `--env <slug>` | Override env context for this command |
168
+ | `--help`, `-h` | Show help |
169
+ | `--version`, `-v` | Show version |
170
+
171
+ ## Environment Variables
172
+
173
+ | Variable | Default | Description |
174
+ |----------|---------|-------------|
175
+ | `SUPERFLAG_API_URL` | `https://superflag.sh/api/v1` | API endpoint |
176
+ | `SUPERFLAG_AUTH_URL` | `https://superflag.sh/cli-auth` | Auth endpoint |
177
+
178
+ ## Exit Codes
179
+
180
+ | Code | Meaning |
181
+ |------|---------|
182
+ | 0 | Success |
183
+ | 1 | Generic error |
184
+ | 2 | Authentication or context required |
185
+ | 3 | Resource not found |
186
+
187
+ ## Development
188
+
189
+ ```bash
190
+ # Clone and install
191
+ git clone <repo>
192
+ cd superflag-cli
193
+ bun install
194
+
195
+ # Run in development
196
+ bun run dev <command>
197
+ bun run dev use myapp staging
198
+ bun run dev get feature-x
199
+
200
+ # Build
201
+ bun run build
202
+
203
+ # Type check
204
+ bun run typecheck
205
+
206
+ # Run tests
207
+ bun test
208
+ ```
209
+
210
+ ## License
211
+
212
+ MIT
package/package.json CHANGED
@@ -1,33 +1,49 @@
1
1
  {
2
- "name": "@superflag-sh/cli",
3
- "version": "0.1.2",
4
- "description": "CLI for Superflag feature flags",
5
- "type": "module",
6
- "bin": {
7
- "superflag": "./dist/index.js"
8
- },
9
- "files": [
10
- "dist"
11
- ],
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/superflag-sh/cli"
15
- },
16
- "keywords": [
17
- "feature-flags",
18
- "cli",
19
- "superflag"
20
- ],
21
- "author": "Superflag",
22
- "license": "MIT",
23
- "devDependencies": {
24
- "@types/bun": "^1.3.5",
25
- "@types/node": "^22.0.0",
26
- "typescript": "^5.0.0"
27
- },
28
- "scripts": {
29
- "build": "rm -rf dist && bun build ./src/index.ts --outdir dist --target node --format esm && chmod +x dist/index.js",
30
- "dev": "bun run src/index.ts",
31
- "typecheck": "tsc --noEmit"
32
- }
2
+ "name": "@superflag-sh/cli",
3
+ "version": "0.1.4",
4
+ "description": "CLI for Superflag feature flags",
5
+ "type": "module",
6
+ "bin": {
7
+ "superflag": "./dist/index.js"
8
+ },
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/superflag-sh/cli"
15
+ },
16
+ "keywords": [
17
+ "feature-flags",
18
+ "cli",
19
+ "superflag"
20
+ ],
21
+ "author": "Superflag",
22
+ "license": "MIT",
23
+ "devDependencies": {
24
+ "@types/bun": "^1.3.5",
25
+ "@types/node": "^22.0.0",
26
+ "husky": "^9.1.7",
27
+ "lint-staged": "^16.2.7",
28
+ "typescript": "^5.0.0"
29
+ },
30
+ "scripts": {
31
+ "build": "rm -rf dist && bun build ./src/index.ts --outdir dist --target node --format esm && chmod +x dist/index.js",
32
+ "dev": "bun run src/index.ts",
33
+ "typecheck": "tsc --noEmit",
34
+ "test": "bun test",
35
+ "test:watch": "bun test --watch",
36
+ "prepare": "husky"
37
+ },
38
+ "dependencies": {
39
+ "@biomejs/biome": "^2.3.11"
40
+ },
41
+ "lint-staged": {
42
+ "*.{js,ts,cjs,mjs,d.cts,d.mts,jsx,tsx,json,jsonc}": [
43
+ "biome check --write --unsafe --staged --no-errors-on-unmatched"
44
+ ],
45
+ "**/*.test.ts": [
46
+ "bun test"
47
+ ]
48
+ }
33
49
  }