kfctl 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.
package/README.md ADDED
@@ -0,0 +1,322 @@
1
+ # KFC (Kubernetes Follow Colorful)
2
+
3
+ <img src="assets/logo.png" width="200" alt="KFC Logo">
4
+
5
+ A beautiful CLI tool for following Kubernetes deployment logs with rich syntax highlighting and interactive UI, built with **TypeScript + Ink**.
6
+
7
+ ![Version](https://img.shields.io/badge/version-0.1.3-blue)
8
+ ![License](https://img.shields.io/badge/license-MIT-green)
9
+ ![Node](https://img.shields.io/badge/node-%3E%3D14-brightgreen)
10
+
11
+ ---
12
+
13
+ ## ✨ Features
14
+
15
+ - 🎨 **Rich Syntax Highlighting** - JSON, strings, numbers, booleans, URLs, IPs, and more
16
+ - 🔄 **Auto-Reconnect** - Automatically reconnects when connection is lost
17
+ - 🎯 **Interactive Selection** - Beautiful Ink-powered deployment selector
18
+ - 📊 **Real-time Status** - Live connection status indicator
19
+ - 🚀 **Fast & Lightweight** - Built with TypeScript for performance
20
+ - 🎭 **React for CLI** - Powered by Ink (React for terminal)
21
+ - 🌍 **Cross-platform** - Works on Windows, macOS, and Linux
22
+ - 📦 **Zero Config** - Works out of the box with kubectl
23
+
24
+ ---
25
+
26
+ ## 🚀 Quick Start
27
+
28
+ ### Using npx (Recommended)
29
+
30
+ ```bash
31
+ npx kfctl -n production my-deployment
32
+ # or
33
+ pnpx kfctl -n production my-deployment
34
+ ```
35
+
36
+ ### Global Installation
37
+
38
+ ```bash
39
+ pnpm install -g @logan/kfc
40
+ kfctl --help
41
+ ```
42
+
43
+ ### From Source
44
+
45
+ ```bash
46
+ git clone <repository_url>
47
+ cd kfc
48
+ pnpm install
49
+ pnpm run build
50
+ pnpm link --global
51
+ kfctl --help
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 📖 Usage
57
+
58
+ ### Basic Usage
59
+
60
+ ```bash
61
+ # Follow logs for a specific deployment
62
+ kfctl my-deployment
63
+
64
+ # Specify namespace
65
+ kfctl -n production my-deployment
66
+
67
+ # Specify context and namespace
68
+ kfctl -c staging-cluster -n production my-deployment
69
+
70
+ # Custom tail lines
71
+ kfctl --tail 200 my-deployment
72
+
73
+ # Custom retry attempts
74
+ kfctl --max-retry 5 my-deployment
75
+ ```
76
+
77
+ ### Interactive Mode
78
+
79
+ ```bash
80
+ # Without deployment name, shows interactive selector
81
+ kfctl -n production
82
+
83
+ # Output:
84
+ # Select deployment:
85
+ # ❯ app-deployment
86
+ # api-deployment
87
+ # worker-deployment
88
+ ```
89
+
90
+ ---
91
+
92
+ ## 🎨 Syntax Highlighting
93
+
94
+ KFC provides rich syntax highlighting for various log formats:
95
+
96
+ ### Log Levels
97
+
98
+ - 🔴 **ERROR/FATAL** - Red bold
99
+ - 🟡 **WARN/WARNING** - Yellow
100
+ - 🟢 **INFO** - Green
101
+ - 🔵 **DEBUG** - Cyan
102
+ - ⚪ **TRACE** - White
103
+
104
+ ### Syntax Elements
105
+
106
+ - 🔵 **Timestamps** - Blue (ISO 8601)
107
+ - 🟢 **Strings** - Green (`"..."`)
108
+ - 🟣 **Numbers** - Magenta (`123`, `3.14`)
109
+ - 🟡 **Booleans** - Yellow (`true`, `false`)
110
+ - ⚫ **Null** - Gray (`null`)
111
+ - 🔵 **URLs** - Blue underlined
112
+ - 🟣 **IP Addresses** - Magenta
113
+ - 🔵 **File Paths** - Cyan
114
+
115
+ ### JSON Support
116
+
117
+ ```json
118
+ {
119
+ "timestamp": "2026-01-29T13:00:00Z", // Cyan key, Green value
120
+ "level": "INFO", // Cyan key, Green value
121
+ "user_id": 12345, // Cyan key, Magenta number
122
+ "success": true, // Cyan key, Yellow boolean
123
+ "error": null // Cyan key, Gray null
124
+ }
125
+ ```
126
+
127
+ ---
128
+
129
+ ## ⚙️ Configuration
130
+
131
+ ### Environment Variables
132
+
133
+ ```bash
134
+ export KFCTL_NAMESPACE=production # Default namespace
135
+ export KFCTL_TAIL_LINES=200 # Default tail lines
136
+ export KFCTL_MAX_RETRY=5 # Default max retry attempts
137
+ ```
138
+
139
+ ### Command Line Options
140
+
141
+ ```bash
142
+ kfctl --help
143
+
144
+ Options:
145
+ --namespace, -n Kubernetes namespace (default: default)
146
+ --context, -c Kubernetes context
147
+ --tail Number of lines to show from the end (default: 100)
148
+ --max-retry Maximum retry attempts (default: 10)
149
+ --grep, -g Filter logs by pattern (regex supported)
150
+ --after, -A Show N lines after match (default: 0)
151
+ --before, -B Show N lines before match (default: 0)
152
+ --context, -C Show N lines before and after match (default: 0)
153
+ --ignore-case, -i Case-insensitive pattern matching
154
+ --invert, -v Invert match (show non-matching lines)
155
+ --version, -v Show version
156
+ --help, -h Show help
157
+ ```
158
+
159
+ ---
160
+
161
+ ## 🛠️ Development
162
+
163
+ ### Project Structure
164
+
165
+ ```
166
+ kfc/
167
+ ├── src/
168
+ │ ├── cli.tsx # CLI entry point
169
+ │ ├── components/
170
+ │ │ ├── App.tsx # Main app component
171
+ │ │ └── LogViewer.tsx # Log viewer component
172
+ │ ├── k8s/
173
+ │ │ └── client.ts # Kubernetes client
174
+ │ └── utils/
175
+ │ └── colorize.ts # Colorization utilities
176
+ ├── dist/ # Compiled output
177
+ ├── bin/kfctl # CLI executable
178
+ ├── package.json
179
+ └── tsconfig.json
180
+ ```
181
+
182
+ ### Development Commands
183
+
184
+ ```bash
185
+ # Install dependencies
186
+ pnpm install
187
+
188
+ # Development mode (with tsx)
189
+ pnpm run dev -- -n production my-deployment
190
+
191
+ # Build
192
+ pnpm run build
193
+
194
+ # Run built version
195
+ pnpm start -- --help
196
+
197
+ # Test
198
+ pnpm test
199
+ ```
200
+
201
+ ### Tech Stack
202
+
203
+ - **TypeScript** - Type-safe JavaScript
204
+ - **Ink** - React for CLI
205
+ - **@kubernetes/client-node** - Official Kubernetes Node.js client
206
+ - **chalk** - Terminal colors
207
+ - **meow** - CLI argument parsing
208
+
209
+ ---
210
+
211
+ ## 📦 Dependencies
212
+
213
+ ### Required
214
+
215
+ - ✅ **kubectl** - Kubernetes command-line tool
216
+ - ✅ **Node.js** - v14 or higher
217
+
218
+ ### Not Required
219
+
220
+ - ❌ kubecolor (built-in syntax highlighting)
221
+ - ❌ fzf (built-in Ink selector)
222
+ - ❌ Go toolchain
223
+
224
+ ---
225
+
226
+ ## 🎯 Why TypeScript + Ink?
227
+
228
+ ### Advantages
229
+
230
+ - ✅ **Type Safety** - Full TypeScript type checking
231
+ - ✅ **React for CLI** - Build CLI with React components
232
+ - ✅ **Rich UI** - Built-in Spinner, SelectInput, and more
233
+ - ✅ **Easy Maintenance** - Familiar React development patterns
234
+ - ✅ **npx Friendly** - Run directly with `npx kfctl`
235
+ - ✅ **No Compilation Dependencies** - No need for Go toolchain
236
+
237
+ ### Comparison with Other Approaches
238
+
239
+ | Feature | zsh Script | Go CLI | TypeScript + Ink |
240
+ | -------------- | ----------------------- | ------------- | ---------------- |
241
+ | Language | Shell | Go | TypeScript |
242
+ | UI Framework | None | None | Ink (React) |
243
+ | Type Safety | ❌ | ✅ | ✅ |
244
+ | Cross-platform | ❌ | ✅ | ✅ |
245
+ | npx Support | ❌ | Needs wrapper | ✅ Native |
246
+ | Development | Simple | Traditional | React Components |
247
+ | Dependencies | kubectl, kubecolor, fzf | kubectl | kubectl, Node.js |
248
+
249
+ ---
250
+
251
+ ## 🐛 Troubleshooting
252
+
253
+ ### Deployment Not Found
254
+
255
+ ```bash
256
+ # Check if namespace is correct
257
+ kubectl get deployments -n <namespace>
258
+
259
+ # Use correct namespace
260
+ kfctl -n <namespace>
261
+ ```
262
+
263
+ ### Cannot Connect to Kubernetes
264
+
265
+ ```bash
266
+ # Check kubectl configuration
267
+ kubectl config current-context
268
+ kubectl get pods
269
+
270
+ # Specify context
271
+ kfctl -c <context> -n <namespace>
272
+ ```
273
+
274
+ ### Node.js Version Too Old
275
+
276
+ ```bash
277
+ # Check Node.js version
278
+ node --version
279
+
280
+ # Requires v14 or higher
281
+ # Use nvm to upgrade
282
+ nvm install 18
283
+ nvm use 18
284
+ ```
285
+
286
+ ---
287
+
288
+ ## 📚 Documentation
289
+
290
+ - [README_TS.md](README_TS.md) - Detailed TypeScript version documentation
291
+ - [COLOR_OUTPUT.md](COLOR_OUTPUT.md) - Color output features
292
+ - [KUBERNETES_SETUP.md](KUBERNETES_SETUP.md) - Kubernetes environment setup
293
+
294
+ ---
295
+
296
+ ## 📝 License
297
+
298
+ MIT
299
+
300
+ ---
301
+
302
+ ## 🙏 Acknowledgments
303
+
304
+ - [Ink](https://github.com/vadimdemedes/ink) - React for CLI
305
+ - [kubectl](https://kubernetes.io/docs/reference/kubectl/) - Kubernetes CLI
306
+ - [@kubernetes/client-node](https://github.com/kubernetes-client/javascript) - Kubernetes Node.js client
307
+ - [chalk](https://github.com/chalk/chalk) - Terminal colors
308
+
309
+ ---
310
+
311
+ ## 🎊 Get Started
312
+
313
+ ```bash
314
+ # Try it now!
315
+ npx kfctl -n kube-system coredns
316
+
317
+ # Or install globally
318
+ pnpm install -g @logan/kfc
319
+ kfctl --help
320
+ ```
321
+
322
+ **Enjoy beautiful Kubernetes logs!** 🚀✨
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env node
2
+ import React from 'react';
3
+ import { render } from 'ink';
4
+ import meow from 'meow';
5
+ import App from './components/App.js';
6
+ const cli = meow(`
7
+ Usage
8
+ $ kfctl [deployment-name]
9
+
10
+ Options
11
+ --namespace, -n Kubernetes namespace (default: default)
12
+ --context, -c Kubernetes context
13
+ --tail Number of lines to show from the end (default: 100)
14
+ --max-retry Maximum retry attempts (default: 10)
15
+ --timeout Connection timeout in seconds (default: 10)
16
+ --grep, -g Filter logs by pattern (regex supported)
17
+ --after, -A Show N lines after match (default: 0)
18
+ --before, -B Show N lines before match (default: 0)
19
+ --context, -C Show N lines before and after match (default: 0)
20
+ --ignore-case, -i Case-insensitive pattern matching
21
+ --invert, -v Invert match (show non-matching lines)
22
+ --version Show version
23
+ --help, -h Show help
24
+
25
+ Examples
26
+ $ kfctl my-deployment
27
+ $ kfctl -n production my-deployment
28
+ $ kfctl -c staging-cluster -n production my-deployment
29
+ $ kfctl --tail 200 my-deployment
30
+ $ kfctl --grep "ERROR" my-deployment
31
+ $ kfctl -g "user.*login" -A 3 -B 2 my-deployment
32
+ $ kfctl -g "payment" -C 5 my-deployment
33
+ $ kfctl -g "success" -i my-deployment
34
+ `, {
35
+ importMeta: import.meta,
36
+ flags: {
37
+ namespace: {
38
+ type: 'string',
39
+ shortFlag: 'n',
40
+ default: process.env.KFCTL_NAMESPACE || 'default',
41
+ },
42
+ context: {
43
+ type: 'string',
44
+ shortFlag: 'c',
45
+ },
46
+ tail: {
47
+ type: 'number',
48
+ default: parseInt(process.env.KFCTL_TAIL_LINES || '100'),
49
+ },
50
+ maxRetry: {
51
+ type: 'number',
52
+ default: parseInt(process.env.KFCTL_MAX_RETRY || '10'),
53
+ },
54
+ timeout: {
55
+ type: 'number',
56
+ default: parseInt(process.env.KFCTL_TIMEOUT || '10'),
57
+ },
58
+ grep: {
59
+ type: 'string',
60
+ shortFlag: 'g',
61
+ },
62
+ after: {
63
+ type: 'number',
64
+ shortFlag: 'A',
65
+ default: 0,
66
+ },
67
+ before: {
68
+ type: 'number',
69
+ shortFlag: 'B',
70
+ default: 0,
71
+ },
72
+ contextLines: {
73
+ type: 'number',
74
+ shortFlag: 'C',
75
+ default: 0,
76
+ },
77
+ ignoreCase: {
78
+ type: 'boolean',
79
+ shortFlag: 'i',
80
+ default: false,
81
+ },
82
+ invert: {
83
+ type: 'boolean',
84
+ shortFlag: 'v',
85
+ default: false,
86
+ },
87
+ version: {
88
+ type: 'boolean',
89
+ },
90
+ },
91
+ });
92
+ const app = render(React.createElement(App, { deploymentName: cli.input[0], namespace: cli.flags.namespace, context: cli.flags.context, tail: cli.flags.tail, maxRetry: cli.flags.maxRetry, timeout: cli.flags.timeout, grepPattern: cli.flags.grep, grepAfter: cli.flags.after, grepBefore: cli.flags.before, grepContext: cli.flags.contextLines, grepIgnoreCase: cli.flags.ignoreCase, grepInvert: cli.flags.invert }));
93
+ await app.waitUntilExit();
94
+ process.exit(0);
95
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,GAAG,MAAM,qBAAqB,CAAC;AAEtC,MAAM,GAAG,GAAG,IAAI,CACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BA,EACA;IACC,UAAU,EAAE,MAAM,CAAC,IAAI;IACvB,KAAK,EAAE;QACN,SAAS,EAAE;YACV,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,GAAG;YACd,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,SAAS;SACjD;QACD,OAAO,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,GAAG;SACd;QACD,IAAI,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,KAAK,CAAC;SACxD;QACD,QAAQ,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC;SACtD;QACD,OAAO,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,IAAI,CAAC;SACpD;QACD,IAAI,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,SAAS,EAAE,GAAG;SACd;QACD,KAAK,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,SA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0,0 +1,17 @@
1
+ import React from 'react';
2
+ interface AppProps {
3
+ deploymentName?: string;
4
+ namespace: string;
5
+ context?: string;
6
+ tail: number;
7
+ maxRetry: number;
8
+ timeout: number;
9
+ grepPattern?: string;
10
+ grepAfter?: number;
11
+ grepBefore?: number;
12
+ grepContext?: number;
13
+ grepIgnoreCase?: boolean;
14
+ grepInvert?: boolean;
15
+ }
16
+ export default function App({ deploymentName: initialDeployment, namespace: initialNamespace, context: initialContext, tail, maxRetry, timeout, grepPattern, grepAfter, grepBefore, grepContext, grepIgnoreCase, grepInvert, }: AppProps): React.JSX.Element | null;
17
+ export {};