@keywaysh/cli 0.0.1 → 0.0.2
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 +296 -11
- package/dist/cli.js +1316 -123
- package/package.json +20 -12
package/README.md
CHANGED
|
@@ -1,29 +1,203 @@
|
|
|
1
1
|
# Keyway CLI
|
|
2
2
|
|
|
3
|
-
>
|
|
3
|
+
> GitHub-native secrets manager for dev teams
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://www.npmjs.com/package/@keywaysh/cli)
|
|
4
7
|
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
7
10
|
```bash
|
|
8
|
-
|
|
11
|
+
pnpm add -g @keywaysh/cli
|
|
9
12
|
```
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
Or use without installing:
|
|
15
|
+
|
|
12
16
|
```bash
|
|
13
|
-
|
|
17
|
+
npx @keywaysh/cli init
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# 0. Authenticate once (browser/device flow)
|
|
24
|
+
keyway login
|
|
25
|
+
|
|
26
|
+
# 1. Initialize a vault for your repository
|
|
14
27
|
keyway init
|
|
15
28
|
|
|
16
|
-
#
|
|
17
|
-
|
|
29
|
+
# 2. Prepare your env file with secrets (e.g., .env or .env.staging)
|
|
30
|
+
|
|
31
|
+
# 3. Push secrets to the vault
|
|
32
|
+
keyway push --file .env
|
|
33
|
+
|
|
34
|
+
# 4. On another machine, pull secrets
|
|
35
|
+
keyway pull --file .env
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Commands
|
|
39
|
+
|
|
40
|
+
### `keyway login`
|
|
41
|
+
|
|
42
|
+
Authenticate with GitHub through the Keyway OAuth/device flow and cache a session locally.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
keyway login
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If you forget to log in, `init`, `push`, and `pull` will prompt you to authenticate (skip with `--no-login-prompt` in CI).
|
|
49
|
+
|
|
50
|
+
Fine-grained PAT alternative:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
keyway login --token
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
This opens GitHub to create a repo-scoped fine-grained PAT (metadata: read-only, no account permissions). Paste the `github_pat_...` token when prompted; the CLI validates and stores it.
|
|
57
|
+
|
|
58
|
+
### `keyway init`
|
|
59
|
+
|
|
60
|
+
Initialize a vault for the current repository.
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
keyway init
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Requirements:**
|
|
67
|
+
- Must be in a git repository
|
|
68
|
+
- Repository must have a GitHub remote
|
|
69
|
+
- Authenticated via `keyway login` (or provide `GITHUB_TOKEN`)
|
|
70
|
+
|
|
71
|
+
### `keyway push`
|
|
72
|
+
|
|
73
|
+
Upload secrets from a local env file to the vault.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Push env file to development environment (default)
|
|
77
|
+
keyway push --file .env
|
|
78
|
+
|
|
79
|
+
# Push to a specific environment
|
|
80
|
+
keyway push --env production
|
|
81
|
+
|
|
82
|
+
# Push a different file
|
|
83
|
+
keyway push --file .env.staging --env staging
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Options:**
|
|
87
|
+
- `-e, --env <environment>` - Environment name (default: "development")
|
|
88
|
+
- `-f, --file <file>` - File to push (default file used if not provided)
|
|
89
|
+
|
|
90
|
+
### `keyway pull`
|
|
18
91
|
|
|
19
|
-
|
|
20
|
-
keyway list
|
|
92
|
+
Download secrets from the vault to a local env file.
|
|
21
93
|
|
|
22
|
-
|
|
23
|
-
|
|
94
|
+
```bash
|
|
95
|
+
# Pull development environment to your env file (default path if omitted)
|
|
96
|
+
keyway pull --file .env
|
|
97
|
+
|
|
98
|
+
# Pull from a specific environment
|
|
99
|
+
keyway pull --env production
|
|
100
|
+
|
|
101
|
+
# Pull to a different file
|
|
102
|
+
keyway pull --file .env.local --env development
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Options:**
|
|
106
|
+
- `-e, --env <environment>` - Environment name (default: "development")
|
|
107
|
+
- `-f, --file <file>` - File to write to (default file used if not provided)
|
|
108
|
+
|
|
109
|
+
### `keyway doctor`
|
|
110
|
+
|
|
111
|
+
Run comprehensive environment diagnostics.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Run all checks
|
|
115
|
+
keyway doctor
|
|
116
|
+
|
|
117
|
+
# Output as JSON (for CI/CD)
|
|
118
|
+
keyway doctor --json
|
|
119
|
+
|
|
120
|
+
# Strict mode (treat warnings as failures)
|
|
121
|
+
keyway doctor --strict
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Checks performed:**
|
|
125
|
+
- ✅ Node.js version (≥18.0.0 required)
|
|
126
|
+
- ✅ Git installation and repository status
|
|
127
|
+
- ✅ Network connectivity to API
|
|
128
|
+
- ✅ File system write permissions
|
|
129
|
+
- ✅ .gitignore configuration for environment files
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
### GitHub Token
|
|
134
|
+
|
|
135
|
+
Keyway prefers the OAuth/device flow:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
keyway login
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This opens a browser (or gives you a code/URL) and stores a Keyway token in `~/.config/keyway/config.json`.
|
|
142
|
+
|
|
143
|
+
If you cannot use the login flow, set a GitHub token manually:
|
|
144
|
+
|
|
145
|
+
**Option 1: Environment Variable**
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
export GITHUB_TOKEN=your_github_personal_access_token
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Option 2: Git Config**
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
git config --global github.token your_github_personal_access_token
|
|
24
155
|
```
|
|
25
156
|
|
|
157
|
+
**Creating a GitHub Token:**
|
|
158
|
+
|
|
159
|
+
1. Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
|
|
160
|
+
2. Click "Generate new token"
|
|
161
|
+
3. Select scopes: `repo` (Full control of private repositories)
|
|
162
|
+
4. Generate and copy the token
|
|
163
|
+
|
|
164
|
+
### API URL
|
|
165
|
+
|
|
166
|
+
By default, Keyway uses the production API at `https://keyway-backend-production.up.railway.app`. To point to another API:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
export KEYWAY_API_URL=http://localhost:3000
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Analytics
|
|
173
|
+
|
|
174
|
+
Keyway uses PostHog for privacy-first analytics. To configure:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
export KEYWAY_POSTHOG_KEY=your_posthog_key
|
|
178
|
+
export KEYWAY_POSTHOG_HOST=https://app.posthog.com
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Disable telemetry:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
export KEYWAY_DISABLE_TELEMETRY=1
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The CLI ships with built-in analytics defaults; use the env vars above to override for development.
|
|
188
|
+
|
|
189
|
+
**Privacy:** No secret names or values are ever sent to analytics.
|
|
190
|
+
|
|
191
|
+
## How It Works
|
|
192
|
+
|
|
193
|
+
1. **Authentication**: Uses your GitHub token to verify identity
|
|
194
|
+
2. **Authorization**: Checks if you're a collaborator/admin on the repository
|
|
195
|
+
3. **Encryption**: All secrets are encrypted server-side with AES-256-GCM
|
|
196
|
+
4. **Storage**: Encrypted secrets stored in PostgreSQL
|
|
197
|
+
5. **Retrieval**: Secrets are decrypted and returned only to authorized users
|
|
198
|
+
|
|
26
199
|
## Development
|
|
200
|
+
|
|
27
201
|
```bash
|
|
28
202
|
# Install dependencies
|
|
29
203
|
npm install
|
|
@@ -34,9 +208,120 @@ npm run dev
|
|
|
34
208
|
# Build
|
|
35
209
|
npm run build
|
|
36
210
|
|
|
211
|
+
# Watch mode
|
|
212
|
+
npm run build:watch
|
|
213
|
+
|
|
214
|
+
# Run tests
|
|
215
|
+
npm test
|
|
216
|
+
|
|
37
217
|
# Test locally
|
|
38
218
|
npm link
|
|
219
|
+
keyway --version
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Architecture
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
src/
|
|
226
|
+
├── cli.tsx # Main CLI entry point with commander
|
|
227
|
+
├── types.ts # TypeScript types and interfaces
|
|
228
|
+
├── ui/ # Ink React components
|
|
229
|
+
│ ├── Banner.tsx # Startup banner with gradient
|
|
230
|
+
│ └── Spinner.tsx # Loading spinner component
|
|
231
|
+
├── cmds/ # Command implementations
|
|
232
|
+
│ ├── init.ts # Initialize vault
|
|
233
|
+
│ ├── push.ts # Push secrets
|
|
234
|
+
│ ├── pull.ts # Pull secrets
|
|
235
|
+
│ └── doctor.tsx # Environment diagnostics
|
|
236
|
+
├── utils/ # Utility functions
|
|
237
|
+
│ ├── analytics.ts # PostHog integration
|
|
238
|
+
│ ├── api.ts # API client
|
|
239
|
+
│ └── git.ts # Git helpers
|
|
240
|
+
└── core/ # Core business logic
|
|
241
|
+
└── doctor.ts # Doctor checks implementations
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Privacy & Security
|
|
245
|
+
|
|
246
|
+
### Analytics Safety
|
|
247
|
+
|
|
248
|
+
**NEVER tracked:**
|
|
249
|
+
- Secret names (e.g., `API_KEY`, `DATABASE_URL`)
|
|
250
|
+
- Secret values
|
|
251
|
+
- Environment variable content
|
|
252
|
+
- Access tokens
|
|
253
|
+
- File contents
|
|
254
|
+
|
|
255
|
+
**Only tracked:**
|
|
256
|
+
- Command usage (init, push, pull)
|
|
257
|
+
- Repository names (public info)
|
|
258
|
+
- Environment names (e.g., "production")
|
|
259
|
+
- Number of variables (count only)
|
|
260
|
+
- Error messages (sanitized)
|
|
261
|
+
- Machine-specific anonymous ID
|
|
262
|
+
|
|
263
|
+
### Distinct ID
|
|
264
|
+
|
|
265
|
+
Each machine has a unique, anonymous identifier stored in `~/.config/keyway/id.json`. This ID is randomly generated and contains no personally identifiable information.
|
|
266
|
+
|
|
267
|
+
## Troubleshooting
|
|
268
|
+
|
|
269
|
+
### "Not in a git repository"
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Initialize git and add a remote
|
|
273
|
+
git init
|
|
274
|
+
git remote add origin git@github.com:your-org/your-repo.git
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### "GitHub token not found"
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
# Set your GitHub token
|
|
281
|
+
export GITHUB_TOKEN=your_token
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### "Vault not found"
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Initialize the vault first
|
|
288
|
+
keyway init
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### "You do not have access to this repository"
|
|
292
|
+
|
|
293
|
+
Make sure you're a collaborator or admin on the GitHub repository.
|
|
294
|
+
|
|
295
|
+
### Disabling the Banner
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Via command line flag
|
|
299
|
+
keyway --no-banner doctor
|
|
300
|
+
|
|
301
|
+
# Via environment variable
|
|
302
|
+
export KEYWAY_NO_BANNER=1
|
|
303
|
+
keyway doctor
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Publishing to npm
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# Update version
|
|
310
|
+
npm version patch # or minor, or major
|
|
311
|
+
|
|
312
|
+
# Build
|
|
313
|
+
npm run build
|
|
314
|
+
|
|
315
|
+
# Publish
|
|
316
|
+
npm publish
|
|
39
317
|
```
|
|
40
318
|
|
|
41
319
|
## License
|
|
42
|
-
|
|
320
|
+
|
|
321
|
+
MIT © Nicolas Ritouet
|
|
322
|
+
|
|
323
|
+
## Support
|
|
324
|
+
|
|
325
|
+
- **Issues**: https://github.com/keywaysh/cli/issues
|
|
326
|
+
- **Email**: unlock@keyway.sh
|
|
327
|
+
- **Website**: https://keyway.sh
|