pixelkit-cli 0.0.0-stage → 1.0.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.
Files changed (96) hide show
  1. package/CONTRIBUTING.md +395 -0
  2. package/LICENSE +21 -0
  3. package/README.md +323 -2
  4. package/dist/cli/arguments.d.ts +10 -0
  5. package/dist/cli/arguments.d.ts.map +1 -0
  6. package/dist/cli/arguments.js +44 -0
  7. package/dist/cli/arguments.js.map +1 -0
  8. package/dist/cli/commands.d.ts +6 -0
  9. package/dist/cli/commands.d.ts.map +1 -0
  10. package/dist/cli/commands.js +103 -0
  11. package/dist/cli/commands.js.map +1 -0
  12. package/dist/cli/index.d.ts +3 -0
  13. package/dist/cli/index.d.ts.map +1 -0
  14. package/dist/cli/index.js +50 -0
  15. package/dist/cli/index.js.map +1 -0
  16. package/dist/commands/png.d.ts +3 -0
  17. package/dist/commands/png.d.ts.map +1 -0
  18. package/dist/commands/png.js +100 -0
  19. package/dist/commands/png.js.map +1 -0
  20. package/dist/commands/webp.d.ts +3 -0
  21. package/dist/commands/webp.d.ts.map +1 -0
  22. package/dist/commands/webp.js +100 -0
  23. package/dist/commands/webp.js.map +1 -0
  24. package/dist/converters/png/index.d.ts +4 -0
  25. package/dist/converters/png/index.d.ts.map +1 -0
  26. package/dist/converters/png/index.js +23 -0
  27. package/dist/converters/png/index.js.map +1 -0
  28. package/dist/converters/png/options.d.ts +8 -0
  29. package/dist/converters/png/options.d.ts.map +1 -0
  30. package/dist/converters/png/options.js +6 -0
  31. package/dist/converters/png/options.js.map +1 -0
  32. package/dist/converters/registry.d.ts +5 -0
  33. package/dist/converters/registry.d.ts.map +1 -0
  34. package/dist/converters/registry.js +48 -0
  35. package/dist/converters/registry.js.map +1 -0
  36. package/dist/converters/types.d.ts +12 -0
  37. package/dist/converters/types.d.ts.map +1 -0
  38. package/dist/converters/types.js +2 -0
  39. package/dist/converters/types.js.map +1 -0
  40. package/dist/converters/webp/index.d.ts +4 -0
  41. package/dist/converters/webp/index.d.ts.map +1 -0
  42. package/dist/converters/webp/index.js +23 -0
  43. package/dist/converters/webp/index.js.map +1 -0
  44. package/dist/converters/webp/options.d.ts +9 -0
  45. package/dist/converters/webp/options.d.ts.map +1 -0
  46. package/dist/converters/webp/options.js +8 -0
  47. package/dist/converters/webp/options.js.map +1 -0
  48. package/dist/core/converter.d.ts +16 -0
  49. package/dist/core/converter.d.ts.map +1 -0
  50. package/dist/core/converter.js +50 -0
  51. package/dist/core/converter.js.map +1 -0
  52. package/dist/core/file-validator.d.ts +12 -0
  53. package/dist/core/file-validator.d.ts.map +1 -0
  54. package/dist/core/file-validator.js +29 -0
  55. package/dist/core/file-validator.js.map +1 -0
  56. package/dist/core/output-manager.d.ts +9 -0
  57. package/dist/core/output-manager.d.ts.map +1 -0
  58. package/dist/core/output-manager.js +27 -0
  59. package/dist/core/output-manager.js.map +1 -0
  60. package/dist/core/path-resolver.d.ts +6 -0
  61. package/dist/core/path-resolver.d.ts.map +1 -0
  62. package/dist/core/path-resolver.js +26 -0
  63. package/dist/core/path-resolver.js.map +1 -0
  64. package/dist/core/scanner.d.ts +9 -0
  65. package/dist/core/scanner.d.ts.map +1 -0
  66. package/dist/core/scanner.js +45 -0
  67. package/dist/core/scanner.js.map +1 -0
  68. package/dist/ui/image-selector.d.ts +3 -0
  69. package/dist/ui/image-selector.d.ts.map +1 -0
  70. package/dist/ui/image-selector.js +30 -0
  71. package/dist/ui/image-selector.js.map +1 -0
  72. package/dist/ui/messages.d.ts +8 -0
  73. package/dist/ui/messages.d.ts.map +1 -0
  74. package/dist/ui/messages.js +23 -0
  75. package/dist/ui/messages.js.map +1 -0
  76. package/dist/ui/progress.d.ts +3 -0
  77. package/dist/ui/progress.d.ts.map +1 -0
  78. package/dist/ui/progress.js +23 -0
  79. package/dist/ui/progress.js.map +1 -0
  80. package/dist/ui/spinner.d.ts +10 -0
  81. package/dist/ui/spinner.d.ts.map +1 -0
  82. package/dist/ui/spinner.js +35 -0
  83. package/dist/ui/spinner.js.map +1 -0
  84. package/dist/utils/constants.d.ts +19 -0
  85. package/dist/utils/constants.d.ts.map +1 -0
  86. package/dist/utils/constants.js +31 -0
  87. package/dist/utils/constants.js.map +1 -0
  88. package/dist/utils/errors.d.ts +10 -0
  89. package/dist/utils/errors.d.ts.map +1 -0
  90. package/dist/utils/errors.js +27 -0
  91. package/dist/utils/errors.js.map +1 -0
  92. package/dist/utils/logger.d.ts +10 -0
  93. package/dist/utils/logger.d.ts.map +1 -0
  94. package/dist/utils/logger.js +30 -0
  95. package/dist/utils/logger.js.map +1 -0
  96. package/package.json +69 -4
package/README.md CHANGED
@@ -1,3 +1,324 @@
1
- # Temporary Holding Version
1
+ 🚀 PixelKit CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A modular command-line image conversion toolkit built for developers.
4
+
5
+ <p align="center">
6
+ <img src="https://readme-typing-svg.demolab.com?font=Fira+Code&weight=500&size=20&pause=1000&color=38BDF8&center=true&vCenter=true&width=650&lines=Convert+images+with+simple+commands.;PNG+to+WebP+%7C+WebP+to+PNG;Fast+image+conversion+from+your+terminal.;Built+with+TypeScript+%26+Sharp." alt="PixelKit CLI animated typing" />
7
+ </p><p align="center">
8
+ <img src="https://img.shields.io/badge/Node.js-20%2B-339933?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js 20+" />
9
+ <img src="https://img.shields.io/badge/TypeScript-5.9-3178C6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript" />
10
+ <img src="https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge" alt="MIT License" />
11
+ </p><p align="center">
12
+ <b>One toolkit. Multiple image converters. Zero complicated workflows.</b>
13
+ </p>---
14
+
15
+ ✨ Overview
16
+
17
+ PixelKit CLI is an open-source command-line image conversion toolkit designed to simplify image format conversion directly from your terminal.
18
+
19
+ Instead of opening image editors or manually converting files one by one, PixelKit lets you convert images using simple commands.
20
+
21
+ Navigate to your assets directory, run a converter, select your images, and let PixelKit handle the conversion.
22
+
23
+ Why PixelKit?
24
+
25
+ - ⚡ Simple terminal-based image conversion.
26
+ - 🎯 Interactive image selection using arrow keys and Space.
27
+ - 📁 Convert images from any specified directory.
28
+ - 🖼️ Convert individual image files directly.
29
+ - 🔄 Preserve original files.
30
+ - 🌈 Preserve transparency when converting transparent PNG images to WebP.
31
+ - 🧩 Modular architecture designed for future converters.
32
+ - 💻 Developer-friendly command-line interface.
33
+
34
+ 🛠️ Available Converters
35
+
36
+ Command| Conversion| Availability
37
+ "webpkit"| Supported image formats → WebP| Available
38
+ "pngkit"| Supported image formats → PNG| Available
39
+
40
+ ---
41
+
42
+ 📦 Installation
43
+
44
+ You can install PixelKit CLI globally using npm or run it through npx without a permanent global installation.
45
+
46
+ Option 1: Install globally with npm
47
+
48
+ npm install -g pixelkit-cli
49
+
50
+ After installation, use the commands from any directory:
51
+
52
+ pixelkit-cli --help
53
+ webpkit
54
+ pngkit
55
+
56
+ Option 2: Use with npx
57
+
58
+ Don't want to install PixelKit globally?
59
+
60
+ You can use "npx" to execute the package directly.
61
+
62
+ Display help:
63
+
64
+ npx --yes pixelkit-cli --help
65
+
66
+ List available converters:
67
+
68
+ npx --yes pixelkit-cli --list
69
+
70
+ Display version:
71
+
72
+ npx --yes pixelkit-cli --version
73
+
74
+ Display project information:
75
+
76
+ npx --yes pixelkit-cli --info
77
+
78
+ Run the WebP converter:
79
+
80
+ npx --yes --package=pixelkit-cli webpkit
81
+
82
+ Run the PNG converter:
83
+
84
+ npx --yes --package=pixelkit-cli pngkit
85
+
86
+ Use npx with a specific path:
87
+
88
+ npx --yes --package=pixelkit-cli webpkit ./my-app/public
89
+
90
+ npx --yes --package=pixelkit-cli pngkit ./my-app/public
91
+
92
+ «npx downloads and executes the package when needed. Global installation is recommended if you use PixelKit regularly.»
93
+
94
+ ---
95
+
96
+ 🚀 Quick Start
97
+
98
+ 1. Convert images in the current directory
99
+
100
+ Navigate to your assets directory:
101
+
102
+ cd my-app/public
103
+
104
+ Run:
105
+
106
+ webpkit
107
+
108
+ PixelKit scans the current directory and displays supported images in an interactive selector.
109
+
110
+ 2. Convert images from another directory
111
+
112
+ You don't need to navigate into the target directory.
113
+
114
+ webpkit ./my-app/public
115
+
116
+ 3. Convert a single image
117
+
118
+ webpkit ./my-app/public/logo.png
119
+
120
+ A single image path starts direct conversion without opening the interactive selector.
121
+
122
+ 4. Convert WebP images to PNG
123
+
124
+ pngkit
125
+
126
+ Or specify a directory:
127
+
128
+ pngkit ./my-app/public
129
+
130
+ Convert one image:
131
+
132
+ pngkit ./my-app/public/logo.webp
133
+
134
+ ---
135
+
136
+ 🎮 Interactive Image Selection
137
+
138
+ PixelKit includes an interactive terminal image selector.
139
+
140
+ Key| Action
141
+ ↑ / ↓| Navigate through images
142
+ Space| Select or deselect an image
143
+ Enter| Confirm selection and start conversion
144
+
145
+ Select exactly the images you want to convert.
146
+
147
+ ⚙️ Global CLI Options
148
+
149
+ PixelKit provides global commands for accessing help and project information.
150
+
151
+ pixelkit-cli --help
152
+
153
+ Command| Description
154
+ "pixelkit-cli --help"| Display CLI usage instructions
155
+ "pixelkit-cli --list"| List available converters
156
+ "pixelkit-cli --version"| Display installed version
157
+ "pixelkit-cli --info"| Display project information
158
+
159
+ Short options:
160
+
161
+ pixelkit-cli -h
162
+ pixelkit-cli -l
163
+ pixelkit-cli -v
164
+
165
+ ---
166
+
167
+ 🖼️ Image Conversion Features
168
+
169
+ WebP Conversion
170
+
171
+ Convert supported image formats into optimized WebP images.
172
+
173
+ webpkit ./assets
174
+
175
+ Example:
176
+
177
+ logo.png → logo.webp
178
+ banner.jpg → banner.webp
179
+
180
+ PNG Conversion
181
+
182
+ Convert supported image formats into PNG images.
183
+
184
+ pngkit ./assets
185
+
186
+ Example:
187
+
188
+ logo.webp → logo.png
189
+ photo.jpg → photo.png
190
+
191
+ Transparency Preservation
192
+
193
+ PixelKit preserves transparency when converting transparent PNG images into WebP.
194
+
195
+ This allows transparent logos, icons and other graphics to retain their alpha channel.
196
+
197
+ Original File Protection
198
+
199
+ PixelKit generates converted images alongside the original files.
200
+
201
+ assets/
202
+ ├── logo.png
203
+ └── logo.webp
204
+
205
+ Original files are not intentionally replaced during conversion.
206
+
207
+ Existing output files are protected against accidental overwriting.
208
+
209
+ Directory Scanning
210
+
211
+ PixelKit scans the specified directory without recursively scanning its subdirectories.
212
+
213
+ Already-existing files in the target output format are excluded from the conversion list.
214
+
215
+ ---
216
+
217
+ 🧰 Technology Stack
218
+
219
+ PixelKit is built using a modern Node.js and TypeScript toolchain.
220
+
221
+ Technology| Purpose
222
+ Node.js| Runtime environment
223
+ TypeScript| Type-safe application development
224
+ Sharp| Image processing and conversion
225
+ @inquirer/prompts| Interactive terminal selection
226
+ Chalk| Terminal colors and styling
227
+ pnpm| Package management
228
+ Node.js Test Runner| Automated testing
229
+ tsx| TypeScript development execution
230
+ Prettier| Code formatting
231
+
232
+ 🧪 Testing
233
+
234
+ PixelKit uses the Node.js test runner with TypeScript execution through "tsx".
235
+
236
+ Current automated test coverage includes:
237
+
238
+ - CLI command handling
239
+ - PNG to WebP conversion
240
+ - WebP to PNG conversion
241
+ - Unsupported image validation
242
+ - PNG transparency preservation
243
+ - Existing output protection
244
+ - Invalid image handling
245
+ - Directory scanning
246
+ - Path resolution
247
+ - Image filtering
248
+
249
+ Run tests:
250
+
251
+ pnpm test
252
+
253
+ Run TypeScript checks:
254
+
255
+ pnpm typecheck
256
+
257
+ Build the project:
258
+
259
+ pnpm build
260
+
261
+ Run complete verification:
262
+
263
+ pnpm check
264
+
265
+ 🗺️ Roadmap
266
+
267
+ PixelKit is designed to grow into a modular image conversion toolkit.
268
+
269
+ - [x] TypeScript CLI foundation
270
+ - [x] Global CLI command registration
271
+ - [x] Interactive image selector
272
+ - [x] WebP converter
273
+ - [x] PNG converter
274
+ - [x] Direct file conversion
275
+ - [x] Directory-based conversion
276
+ - [x] Transparency preservation for PNG to WebP
277
+ - [x] Existing output protection
278
+ - [x] Automated tests
279
+ - [x] Modular converter registry
280
+ - [ ] AVIF converter
281
+ - [ ] JPEG converter
282
+ - [ ] GIF converter
283
+ - [ ] Batch conversion improvements
284
+ - [ ] Advanced conversion options
285
+ - [ ] Conversion quality configuration
286
+
287
+ 🤝 Contributing
288
+
289
+ Contributions, bug reports and feature suggestions are welcome!
290
+
291
+ If you want to contribute to PixelKit, please read "CONTRIBUTING.md" (CONTRIBUTING.md) before submitting changes.
292
+
293
+ 📄 License
294
+
295
+ PixelKit CLI is open-source software licensed under the "MIT License" (LICENSE).
296
+
297
+ Copyright © 2026 Rahul Savnani.
298
+
299
+ 👨‍💻 Author
300
+
301
+ Rahul Savnani
302
+
303
+ Independent developer building practical developer tools with modern technologies.
304
+
305
+ - GitHub: "@rsavnani18" (https://github.com/rsavnani18)
306
+ - Website: "rahulsavnani.vercel.app" (https://rahulsavnani.vercel.app)
307
+
308
+ ⭐ Support the Project
309
+
310
+ If PixelKit CLI is useful to you:
311
+
312
+ - Give the repository a ⭐ star.
313
+ - Report bugs and suggest improvements.
314
+ - Share it with other developers.
315
+ - Contribute new converters and features.
316
+
317
+ ---
318
+
319
+ <p align="center">
320
+ <b>Built for developers. Powered by PixelKit.</b>
321
+ </p><p align="center">
322
+ <img src="https://img.shields.io/badge/Made%20with-TypeScript-3178C6?style=flat-square&logo=typescript&logoColor=white" alt="Made with TypeScript" />
323
+ <img src="https://img.shields.io/badge/Open%20Source-MIT-green?style=flat-square" alt="Open Source MIT" />
324
+ </p>
@@ -0,0 +1,10 @@
1
+ export type InputType = "directory" | "file";
2
+ export interface ParsedInput {
3
+ type: InputType;
4
+ path: string;
5
+ }
6
+ export interface ParsedArguments {
7
+ input: ParsedInput;
8
+ }
9
+ export declare function parseArguments(args: string[]): ParsedArguments;
10
+ //# sourceMappingURL=arguments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arguments.d.ts","sourceRoot":"","sources":["../../src/cli/arguments.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,WAAW,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,eAAe,CAoD9D"}
@@ -0,0 +1,44 @@
1
+ import { existsSync, statSync } from "node:fs";
2
+ import path from "node:path";
3
+ export function parseArguments(args) {
4
+ // Remove the argument separator sometimes forwarded by package managers.
5
+ const cleanArgs = args.filter((arg) => arg !== "--");
6
+ if (cleanArgs.length === 0) {
7
+ return {
8
+ input: {
9
+ type: "directory",
10
+ path: process.cwd()
11
+ }
12
+ };
13
+ }
14
+ if (cleanArgs.length > 1) {
15
+ throw new Error("Only one directory or image path can be provided.");
16
+ }
17
+ const providedPath = cleanArgs[0];
18
+ if (!providedPath) {
19
+ throw new Error("Please provide a valid path.");
20
+ }
21
+ const absolutePath = path.resolve(process.cwd(), providedPath);
22
+ if (!existsSync(absolutePath)) {
23
+ throw new Error(`Path does not exist: ${providedPath}`);
24
+ }
25
+ const stats = statSync(absolutePath);
26
+ if (stats.isDirectory()) {
27
+ return {
28
+ input: {
29
+ type: "directory",
30
+ path: absolutePath
31
+ }
32
+ };
33
+ }
34
+ if (stats.isFile()) {
35
+ return {
36
+ input: {
37
+ type: "file",
38
+ path: absolutePath
39
+ }
40
+ };
41
+ }
42
+ throw new Error(`Unsupported path type: ${providedPath}`);
43
+ }
44
+ //# sourceMappingURL=arguments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arguments.js","sourceRoot":"","sources":["../../src/cli/arguments.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,IAAI,MAAM,WAAW,CAAC;AAa7B,MAAM,UAAU,cAAc,CAAC,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5D,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function showHelp(): void;
2
+ export declare function showConverterList(): void;
3
+ export declare function showVersion(): void;
4
+ export declare function showInfo(): void;
5
+ export declare function handleGlobalCommand(args: string[]): boolean;
6
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AA8BA,wBAAgB,QAAQ,IAAI,IAAI,CA+B/B;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAcxC;AAED,wBAAgB,WAAW,IAAI,IAAI,CAMlC;AAED,wBAAgB,QAAQ,IAAI,IAAI,CAoB/B;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAoC3D"}
@@ -0,0 +1,103 @@
1
+ import { readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import chalk from "chalk";
4
+ import { getAllConverters } from "../converters/registry.js";
5
+ import { APP_NAME, PACKAGE_NAME } from "../utils/constants.js";
6
+ function getPackageInfo() {
7
+ const packagePath = new URL("../../package.json", import.meta.url);
8
+ return JSON.parse(readFileSync(packagePath, "utf8"));
9
+ }
10
+ export function showHelp() {
11
+ console.log(`
12
+ ${chalk.bold.cyan("PIXELKIT CLI")}
13
+ ${chalk.gray("Modern image conversion toolkit for developers")}
14
+
15
+ ${chalk.bold("USAGE")}
16
+ pixelkit-cli [options]
17
+ webpkit [path]
18
+ pngkit [path]
19
+
20
+ ${chalk.bold("GLOBAL OPTIONS")}
21
+ ${chalk.green("--help, -h")} Display CLI help
22
+ ${chalk.green("--list, -l")} List available converters
23
+ ${chalk.green("--version, -v")} Display installed version
24
+ ${chalk.green("--info")} Display project information
25
+
26
+ ${chalk.bold("CONVERTER COMMANDS")}
27
+ ${chalk.yellow("webpkit [path]")} Convert images to WebP
28
+ ${chalk.yellow("pngkit [path]")} Convert images to PNG
29
+
30
+ ${chalk.bold("EXAMPLES")}
31
+ webpkit
32
+ webpkit ./my-app/public
33
+ webpkit ./my-app/public/logo.png
34
+
35
+ pngkit
36
+ pngkit ./my-app/public
37
+ pngkit ./my-app/public/logo.webp
38
+
39
+ ${chalk.cyan("Use pixelkit-cli --list to see available converters.")}
40
+ `);
41
+ }
42
+ export function showConverterList() {
43
+ console.log(`\n${chalk.bold.cyan("AVAILABLE CONVERTERS")}\n`);
44
+ for (const converter of getAllConverters()) {
45
+ console.log(` ${chalk.yellow(converter.command)}`);
46
+ console.log(` ${chalk.gray(converter.description)}`);
47
+ console.log(` Output: ${chalk.green(converter.outputFormat.toUpperCase())}\n`);
48
+ }
49
+ }
50
+ export function showVersion() {
51
+ const packageInfo = getPackageInfo();
52
+ console.log(`${chalk.bold.cyan(APP_NAME)} ${chalk.green(`v${packageInfo.version}`)}`);
53
+ }
54
+ export function showInfo() {
55
+ const packageInfo = getPackageInfo();
56
+ console.log(`
57
+ ${chalk.bold.cyan(APP_NAME)}
58
+ ${chalk.gray(packageInfo.description)}
59
+
60
+ ${chalk.bold("PROJECT INFORMATION")}
61
+ Package: ${chalk.green(packageInfo.name || PACKAGE_NAME)}
62
+ Version: ${chalk.green(packageInfo.version)}
63
+ Author: ${packageInfo.author}
64
+ License: ${packageInfo.license}
65
+
66
+ ${chalk.bold("PROJECT LINKS")}
67
+ GitHub: ${packageInfo.repository?.url ?? "Not configured"}
68
+ Homepage: ${packageInfo.homepage ?? "Not configured"}
69
+ npm: https://www.npmjs.com/package/${packageInfo.name}
70
+
71
+ ${chalk.cyan("Built for developers, powered by PixelKit.")}
72
+ `);
73
+ }
74
+ export function handleGlobalCommand(args) {
75
+ const cleanArgs = args.filter((arg) => arg !== "--");
76
+ if (cleanArgs.length === 0) {
77
+ return false;
78
+ }
79
+ if (cleanArgs.length > 1) {
80
+ return false;
81
+ }
82
+ const command = cleanArgs[0];
83
+ switch (command) {
84
+ case "--help":
85
+ case "-h":
86
+ showHelp();
87
+ return true;
88
+ case "--list":
89
+ case "-l":
90
+ showConverterList();
91
+ return true;
92
+ case "--version":
93
+ case "-v":
94
+ showVersion();
95
+ return true;
96
+ case "--info":
97
+ showInfo();
98
+ return true;
99
+ default:
100
+ return false;
101
+ }
102
+ }
103
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EACL,QAAQ,EACR,YAAY,EACb,MAAM,uBAAuB,CAAC;AAc/B,SAAS,cAAc;IACrB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnE,OAAO,IAAI,CAAC,KAAK,CACf,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CACnB,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO,CAAC,GAAG,CAAC;EACZ,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;EAC/B,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC;;EAE5D,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC;;;;;EAKnB,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC;IAC1B,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;IACzB,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC;IACzB,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC;IAC5B,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;;EAEvB,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC;IAC9B,KAAK,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAC9B,KAAK,CAAC,MAAM,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 -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import { pathToFileURL } from "node:url";
4
+ import chalk from "chalk";
5
+ import { handleGlobalCommand, showHelp } from "./commands.js";
6
+ async function main() {
7
+ const args = process.argv.slice(2);
8
+ // Detect the executable name used by the user.
9
+ const executableName = path
10
+ .basename(process.argv[1] ?? "")
11
+ .replace(/\.(js|ts|mjs|cjs)$/i, "")
12
+ .toLowerCase();
13
+ let converterCommand;
14
+ if (executableName === "webpkit" || executableName === "pngkit") {
15
+ converterCommand = executableName;
16
+ }
17
+ else if (args[0] === "webpkit" || args[0] === "pngkit") {
18
+ // Also supports: pixelkit-cli webpkit ./images
19
+ converterCommand = args[0];
20
+ process.argv.splice(2, 1);
21
+ }
22
+ // Run the selected converter.
23
+ if (converterCommand) {
24
+ if (converterCommand === "webpkit") {
25
+ await import("../commands/webp.js");
26
+ }
27
+ else {
28
+ await import("../commands/png.js");
29
+ }
30
+ return;
31
+ }
32
+ // Handle global CLI options.
33
+ if (handleGlobalCommand(args)) {
34
+ return;
35
+ }
36
+ if (args.length === 0) {
37
+ showHelp();
38
+ return;
39
+ }
40
+ console.error(chalk.red(`Unknown command or option: ${args[0]}`));
41
+ console.log(chalk.gray("Run pixelkit-cli --help for usage information."));
42
+ process.exitCode = 1;
43
+ }
44
+ main().catch((error) => {
45
+ console.error(chalk.red(error instanceof Error
46
+ ? error.message
47
+ : "An unexpected error occurred."));
48
+ process.exitCode = 1;
49
+ });
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,MAAM,OAAO,C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CAAC,8BAA8B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CACnD,CAAC;IAEF,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAC7D,CAAC;IAEF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;IAC9B,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CACP,KAAK,YAAY,KAAK;QACpB,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,+BAA+B,CACpC,CACF,CAAC;IAEF,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=png.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"png.d.ts","sourceRoot":"","sources":["../../src/commands/png.ts"],"names":[],"mappings":""}
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+ import path from "node:path";
3
+ import chalk from "chalk";
4
+ import { parseArguments } from "../cli/arguments.js";
5
+ import { scanImages } from "../core/scanner.js";
6
+ import { validateImage, validateImages } from "../core/file-validator.js";
7
+ import { convertToPng } from "../converters/png/index.js";
8
+ import { getConverter } from "../converters/registry.js";
9
+ import { selectImages } from "../ui/image-selector.js";
10
+ import { renderProgress } from "../ui/progress.js";
11
+ import { success, error, warning, heading, info } from "../ui/messages.js";
12
+ async function main() {
13
+ try {
14
+ const parsed = parseArguments(process.argv.slice(2));
15
+ const input = parsed.input;
16
+ const converter = getConverter("png");
17
+ heading("PIXELKIT PNG CONVERTER");
18
+ let files;
19
+ // Single image mode
20
+ if (input.type === "file") {
21
+ const extension = path.extname(input.path).toLowerCase();
22
+ if (!converter.supportedExtensions.includes(extension)) {
23
+ throw new Error(`Unsupported image format: ${extension}`);
24
+ }
25
+ const validation = await validateImage({
26
+ name: path.basename(input.path),
27
+ path: input.path,
28
+ extension,
29
+ size: 0
30
+ });
31
+ if (!validation.valid) {
32
+ throw new Error(`Invalid image: ${validation.error ?? "Unable to read image"}`);
33
+ }
34
+ files = [validation.file];
35
+ info("Single image detected. Starting direct conversion.");
36
+ }
37
+ else {
38
+ // Directory mode
39
+ const scannedImages = await scanImages(input.path, "png");
40
+ if (scannedImages.length === 0) {
41
+ warning("No supported images found in this directory.");
42
+ return;
43
+ }
44
+ info(`${scannedImages.length} image(s) found.`);
45
+ const validationResults = await validateImages(scannedImages);
46
+ const validImages = validationResults
47
+ .filter((result) => result.valid)
48
+ .map((result) => result.file);
49
+ const invalidCount = scannedImages.length - validImages.length;
50
+ if (invalidCount > 0) {
51
+ warning(`${invalidCount} invalid image(s) skipped.`);
52
+ }
53
+ if (validImages.length === 0) {
54
+ warning("No valid images available for conversion.");
55
+ return;
56
+ }
57
+ files = await selectImages(validImages);
58
+ if (files.length === 0) {
59
+ warning("No images selected. Conversion cancelled.");
60
+ return;
61
+ }
62
+ }
63
+ // Conversion
64
+ heading("CONVERSION STARTED");
65
+ let successful = 0;
66
+ let failed = 0;
67
+ for (let index = 0; index < files.length; index++) {
68
+ const file = files[index];
69
+ const result = await convertToPng(file.path);
70
+ if (result.success) {
71
+ successful++;
72
+ success(`${file.name} → ${path.basename(result.outputPath)}`);
73
+ }
74
+ else {
75
+ failed++;
76
+ error(`${file.name}: ${result.error ?? "Conversion failed"}`);
77
+ }
78
+ renderProgress(index + 1, files.length, "Converting");
79
+ }
80
+ // Summary
81
+ heading("CONVERSION SUMMARY");
82
+ success(`Successful: ${successful}`);
83
+ if (failed > 0) {
84
+ error(`Failed: ${failed}`);
85
+ }
86
+ info(`Total selected: ${files.length}`);
87
+ console.log(chalk.green("\nPNG conversion process completed!\n"));
88
+ if (failed > 0) {
89
+ process.exitCode = 1;
90
+ }
91
+ }
92
+ catch (err) {
93
+ error(err instanceof Error
94
+ ? err.message
95
+ : "An unexpected error occurred.");
96
+ process.exitCode = 1;
97
+ }
98
+ }
99
+ void main();
100
+ //# sourceMappingURL=png.js.map