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