@pixzle/cli 0.0.1

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,268 @@
1
+ # @pixzle/cli
2
+
3
+ CLI implementation of image fragmentation and restoration using the `@pixzle/node` library.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @pixzle/cli
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ The CLI provides two main commands: `shuffle` and `restore`.
14
+
15
+ ### Global Help
16
+
17
+ ```bash
18
+ pixzle --help
19
+ ```
20
+
21
+ ```
22
+ Usage: pixzle [options] [command]
23
+
24
+ CLI tool for image fragmentation and restoration
25
+
26
+ Options:
27
+ -V, --version output the version number
28
+ -h, --help display help for command
29
+
30
+ Commands:
31
+ shuffle [options] <images...> Fragment images
32
+ restore [options] <fragments...> Restore fragmented images
33
+ help [command] display help for command
34
+ ```
35
+
36
+ ### Shuffle Command
37
+
38
+ Fragment images into multiple pieces.
39
+
40
+ ```bash
41
+ pixzle shuffle <images...> -o <output_directory> [options]
42
+ ```
43
+
44
+ #### Options
45
+
46
+ | Option | Description | Required | Default |
47
+ |--------|-------------|----------|---------|
48
+ | `-o, --output <dir>` | Output directory for fragments and manifest | ✅ | - |
49
+ | `-b, --block-size <size>` | Pixel block size (positive integer) | ❌ | 10 |
50
+ | `-p, --prefix <prefix>` | Prefix for fragment files | ❌ | "fragment" |
51
+ | `-s, --seed <seed>` | Random seed (integer) | ❌ | auto-generated |
52
+ | `--preserve-name` | Preserve original file names | ❌ | false |
53
+ | `--cross-image-shuffle` | Shuffle blocks across all images instead of within each image independently | ❌ | false (per-image shuffle by default) |
54
+
55
+ #### Examples
56
+
57
+ **Basic fragmentation:**
58
+ ```bash
59
+ pixzle shuffle image1.jpg image2.png -o ./fragments
60
+ ```
61
+
62
+ **Custom configuration:**
63
+ ```bash
64
+ pixzle shuffle *.jpg -o ./output -b 20 -p "my_fragment" --preserve-name
65
+ ```
66
+
67
+ **With seed for reproducible results:**
68
+ ```bash
69
+ pixzle shuffle image.png -o ./output -s 12345
70
+ ```
71
+
72
+ **Cross-image shuffle (shuffle blocks across all images):**
73
+ ```bash
74
+ pixzle shuffle image1.png image2.png image3.png -o ./output --cross-image-shuffle
75
+ ```
76
+
77
+ #### Output Structure
78
+
79
+ After fragmentation, the output directory will contain:
80
+ ```
81
+ output/
82
+ ├── manifest.json # Metadata for restoration
83
+ ├── fragment_0000.png # Fragment files
84
+ ├── fragment_0001.png
85
+ └── ...
86
+ ```
87
+
88
+ ### Restore Command
89
+
90
+ Restore fragmented images using the manifest file.
91
+
92
+ ```bash
93
+ pixzle restore <fragments...> -m <manifest_path> -o <output_directory> [options]
94
+ ```
95
+
96
+ #### Options
97
+
98
+ | Option | Description | Required |
99
+ |--------|-------------|----------|
100
+ | `-m, --manifest <path>` | Path to the manifest.json file | ✅ |
101
+ | `-o, --output <dir>` | Output directory for restored images | ✅ |
102
+
103
+ #### Examples
104
+
105
+ **Basic restoration:**
106
+ ```bash
107
+ pixzle restore ./fragments/*.png -m ./fragments/manifest.json -o ./restored
108
+ ```
109
+
110
+ **Specific fragments:**
111
+ ```bash
112
+ pixzle restore fragment_0000.png fragment_0001.png fragment_0002.png -m manifest.json -o ./output
113
+ ```
114
+
115
+ ## Error Handling
116
+
117
+ The CLI provides clear error messages for common issues:
118
+
119
+ - **File not found**: When input images or manifest don't exist
120
+ - **Invalid options**: When required options are missing or invalid
121
+ - **Restoration errors**: When fragments are corrupted or manifest doesn't match
122
+ - **Permission errors**: When output directory cannot be created
123
+
124
+ ## Examples Workflow
125
+
126
+ ### Complete Workflow Example
127
+
128
+ 1. **Prepare images:**
129
+ ```bash
130
+ ls images/
131
+ # photo1.jpg photo2.png document.pdf
132
+ ```
133
+
134
+ 2. **Fragment images:**
135
+ ```bash
136
+ pixzle shuffle images/photo1.jpg images/photo2.png -o ./backup --preserve-name
137
+ ```
138
+ ```
139
+ 🔀 Starting image fragmentation...
140
+ ✅ Images fragmented successfully to: /path/to/backup
141
+ ```
142
+
143
+ 3. **Check output:**
144
+ ```bash
145
+ ls backup/
146
+ # manifest.json fragment_0000.png fragment_0001.png fragment_0002.png fragment_0003.png
147
+ ```
148
+
149
+ 4. **Restore images:**
150
+ ```bash
151
+ pixzle restore backup/*.png -m backup/manifest.json -o ./restored
152
+ ```
153
+ ```
154
+ 🔀 Starting image restoration...
155
+ ✅ Images restored successfully to: /path/to/restored
156
+ ```
157
+
158
+ 5. **Verify restoration:**
159
+ ```bash
160
+ ls restored/
161
+ # photo1.jpg photo2.png
162
+ ```
163
+
164
+ ### Advanced Configuration Example
165
+
166
+ For custom fragmentation:
167
+
168
+ ```bash
169
+ # Fragment with custom settings
170
+ pixzle shuffle sensitive/*.jpg \
171
+ -o ./vault \
172
+ -b 5 \
173
+ -p "secure_chunk" \
174
+ -s 42 \
175
+ --preserve-name
176
+
177
+ # The output will use smaller blocks (5x5 pixels) and custom naming
178
+ ```
179
+
180
+ ## Integration with Scripts
181
+
182
+ ### Bash Script Example
183
+
184
+ ```bash
185
+ #!/bin/bash
186
+
187
+ # Backup script
188
+ IMAGES_DIR="./photos"
189
+ BACKUP_DIR="./backup"
190
+
191
+ # Create backup
192
+ echo "Creating backup..."
193
+ pixzle shuffle "$IMAGES_DIR"/*.{jpg,png} \
194
+ -o "$BACKUP_DIR" \
195
+ --preserve-name
196
+
197
+ if [ $? -eq 0 ]; then
198
+ echo "✅ Backup completed successfully"
199
+ # Optionally remove original files or move them
200
+ else
201
+ echo "❌ Backup failed"
202
+ exit 1
203
+ fi
204
+ ```
205
+
206
+ ### Recovery Script Example
207
+
208
+ ```bash
209
+ #!/bin/bash
210
+
211
+ # Recovery script
212
+ BACKUP_DIR="./backup"
213
+ RESTORE_DIR="./recovered_photos"
214
+
215
+ # Restore from backup
216
+ echo "Restoring from backup..."
217
+ pixzle restore "$BACKUP_DIR"/fragment_*.png \
218
+ -m "$BACKUP_DIR/manifest.json" \
219
+ -o "$RESTORE_DIR"
220
+
221
+ if [ $? -eq 0 ]; then
222
+ echo "✅ Recovery completed successfully"
223
+ else
224
+ echo "❌ Recovery failed"
225
+ exit 1
226
+ fi
227
+ ```
228
+
229
+ ## Development
230
+
231
+ ### Building from Source
232
+
233
+ ```bash
234
+ # Clone the repository
235
+ git clone https://github.com/tuki0918/pixzle.git
236
+ cd pixzle
237
+
238
+ # Install dependencies
239
+ npm install
240
+
241
+ # Build the CLI
242
+ npm run build
243
+
244
+ # Test the CLI
245
+ cd packages/cli
246
+ npm test
247
+ ```
248
+
249
+ ### Running in Development Mode
250
+
251
+ ```bash
252
+ cd packages/cli
253
+ npm run dev -- shuffle --help
254
+ ```
255
+
256
+ ## Related Packages
257
+
258
+ - [`@pixzle/core`](../core) - Core fragmentation logic
259
+ - [`@pixzle/node`](../node) - Node.js implementation
260
+ - [`@pixzle/browser`](../browser) - Browser implementation (coming soon)
261
+
262
+ ## License
263
+
264
+ See the [LICENSE](../../LICENSE) file in the root directory.
265
+
266
+ ## Support
267
+
268
+ For issues and questions, please visit the [GitHub repository](https://github.com/tuki0918/pixzle/issues).
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,24 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { registerRestoreCommand } from "./commands/restore";
4
+ import { registerShuffleCommand } from "./commands/shuffle";
5
+ const program = new Command();
6
+ program
7
+ .name("pixzle")
8
+ .description("CLI tool for image fragmentation and restoration")
9
+ .version("0.8.1");
10
+ // Register commands
11
+ registerShuffleCommand(program);
12
+ registerRestoreCommand(program);
13
+ // Error handling
14
+ program.on("command:*", () => {
15
+ console.error("Invalid command. See --help for available commands.");
16
+ process.exit(1);
17
+ });
18
+ // Parse arguments
19
+ program.parse(process.argv);
20
+ // Show help if no command provided
21
+ if (process.argv.length <= 2) {
22
+ program.help();
23
+ }
24
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,kDAAkD,CAAC;KAC/D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,oBAAoB;AACpB,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAChC,sBAAsB,CAAC,OAAO,CAAC,CAAC;AAEhC,iBAAiB;AACjB,OAAO,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,kBAAkB;AAClB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,mCAAmC;AACnC,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Command } from "commander";
2
+ /**
3
+ * Configures and registers the restore command
4
+ * @param program Commander program instance
5
+ */
6
+ export declare function registerRestoreCommand(program: Command): void;
@@ -0,0 +1,39 @@
1
+ import Pixzle from "@pixzle/node";
2
+ import { validateImagePaths, validateManifestPath, validateOutputDirectory, } from "../validators";
3
+ /**
4
+ * Configures and registers the restore command
5
+ * @param program Commander program instance
6
+ */
7
+ export function registerRestoreCommand(program) {
8
+ program
9
+ .command("restore")
10
+ .description("Restore fragmented images")
11
+ .argument("<fragments...>", "Fragment file paths")
12
+ .requiredOption("-m, --manifest <path>", "Manifest file path")
13
+ .requiredOption("-o, --output <dir>", "Output directory")
14
+ .action(handleRestoreCommand);
15
+ }
16
+ /**
17
+ * Handles the restore command execution
18
+ * @param fragments Array of fragment file paths
19
+ * @param options Command options
20
+ */
21
+ async function handleRestoreCommand(fragments, options) {
22
+ try {
23
+ console.log("🔀 Starting image restoration...");
24
+ const imagePaths = validateImagePaths(fragments);
25
+ const manifestPath = validateManifestPath(options.manifest);
26
+ const outputDir = validateOutputDirectory(options.output);
27
+ await Pixzle.restore({
28
+ imagePaths,
29
+ manifestPath,
30
+ outputDir,
31
+ });
32
+ console.log(`✅ Images restored successfully to: ${outputDir}`);
33
+ }
34
+ catch (error) {
35
+ console.error(`❌ Restoration failed: ${error instanceof Error ? error.message : String(error)}`);
36
+ process.exit(1);
37
+ }
38
+ }
39
+ //# sourceMappingURL=restore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restore.js","sourceRoot":"","sources":["../../src/commands/restore.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,cAAc,CAAC;AAGlC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,2BAA2B,CAAC;SACxC,QAAQ,CAAC,gBAAgB,EAAE,qBAAqB,CAAC;SACjD,cAAc,CAAC,uBAAuB,EAAE,oBAAoB,CAAC;SAC7D,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,CAAC;SACxD,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,oBAAoB,CACjC,SAAmB,EACnB,OAAuB;IAEvB,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QAEhD,MAAM,UAAU,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5D,MAAM,SAAS,GAAG,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE1D,MAAM,MAAM,CAAC,OAAO,CAAC;YACnB,UAAU;YACV,YAAY;YACZ,SAAS;SACV,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,yBAAyB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAClF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { Command } from "commander";
2
+ /**
3
+ * Configures and registers the shuffle command
4
+ * @param program Commander program instance
5
+ */
6
+ export declare function registerShuffleCommand(program: Command): void;
@@ -0,0 +1,65 @@
1
+ import Pixzle from "@pixzle/node";
2
+ import { validateImagePaths, validateOutputDirectory } from "../validators";
3
+ /**
4
+ * Configures and registers the shuffle command
5
+ * @param program Commander program instance
6
+ */
7
+ export function registerShuffleCommand(program) {
8
+ program
9
+ .command("shuffle")
10
+ .description("Fragment images")
11
+ .argument("<images...>", "Input image file paths")
12
+ .requiredOption("-o, --output <dir>", "Output directory")
13
+ .option("-b, --block-size <size>", "Pixel block size", (value) => {
14
+ const num = Number.parseInt(value, 10);
15
+ if (Number.isNaN(num) || num <= 0) {
16
+ throw new Error("Block size must be a positive integer");
17
+ }
18
+ return num;
19
+ })
20
+ .option("-p, --prefix <prefix>", "Prefix for fragment files")
21
+ .option("-s, --seed <seed>", "Random seed", (value) => {
22
+ const num = Number.parseInt(value, 10);
23
+ if (Number.isNaN(num)) {
24
+ throw new Error("Seed must be an integer");
25
+ }
26
+ return num;
27
+ })
28
+ .option("--preserve-name", "Preserve original file names")
29
+ .option("--cross-image-shuffle", "Shuffle blocks across all images instead of within each image independently")
30
+ .action(handleShuffleCommand);
31
+ }
32
+ /**
33
+ * Handles the shuffle command execution
34
+ * @param images Array of image file paths
35
+ * @param options Command options
36
+ */
37
+ async function handleShuffleCommand(images, options) {
38
+ try {
39
+ console.log("🔀 Starting image fragmentation...");
40
+ const imagePaths = validateImagePaths(images);
41
+ const outputDir = validateOutputDirectory(options.output);
42
+ const config = {};
43
+ if (options.blockSize !== undefined)
44
+ config.blockSize = options.blockSize;
45
+ if (options.prefix !== undefined)
46
+ config.prefix = options.prefix;
47
+ if (options.seed !== undefined)
48
+ config.seed = options.seed;
49
+ if (options.preserveName)
50
+ config.preserveName = true;
51
+ if (options.crossImageShuffle)
52
+ config.crossImageShuffle = true;
53
+ await Pixzle.shuffle({
54
+ imagePaths,
55
+ outputDir,
56
+ config: Object.keys(config).length > 0 ? config : undefined,
57
+ });
58
+ console.log(`✅ Images fragmented successfully to: ${outputDir}`);
59
+ }
60
+ catch (error) {
61
+ console.error(`❌ Fragmentation failed: ${error instanceof Error ? error.message : String(error)}`);
62
+ process.exit(1);
63
+ }
64
+ }
65
+ //# sourceMappingURL=shuffle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shuffle.js","sourceRoot":"","sources":["../../src/commands/shuffle.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,cAAc,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,iBAAiB,CAAC;SAC9B,QAAQ,CAAC,aAAa,EAAE,wBAAwB,CAAC;SACjD,cAAc,CAA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AAS,GAAG,OAAO,CAAC,SAAS,CAAC;QAC1E,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QACjE,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC3D,IAAI,OAAO,CAAC,YAAY;YAAE,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;QACrD,IAAI,OAAO,CAAC,iBAAiB;YAAE,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAE/D,MAAM,MAAM,CAAC,OAAO,CAAC;YACnB,UAAU;YACV,SAAS;YACT,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;SAC5D,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,wCAAwC,SAAS,EAAE,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,2BAA2B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACpF,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as Pixzle } from "@pixzle/node";
2
+ export type { FragmentationConfig } from "@pixzle/core";
3
+ export type { RestoreOptions, ShuffleOptions } from "./types";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ // Export CLI functionality for programmatic usage if needed
2
+ export { default as Pixzle } from "@pixzle/node";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface ShuffleOptions {
2
+ output: string;
3
+ blockSize?: number;
4
+ prefix?: string;
5
+ seed?: number;
6
+ preserveName?: boolean;
7
+ crossImageShuffle?: boolean;
8
+ }
9
+ export interface RestoreOptions {
10
+ manifest: string;
11
+ output: string;
12
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Validates an array of image file paths
3
+ * @param paths Array of file paths to validate
4
+ * @returns Array of resolved absolute paths
5
+ */
6
+ export declare function validateImagePaths(paths: string[]): string[];
7
+ /**
8
+ * Validates output directory path
9
+ * @param outputPath Output directory path
10
+ * @returns Resolved absolute path
11
+ */
12
+ export declare function validateOutputDirectory(outputPath: string): string;
13
+ /**
14
+ * Validates manifest file path
15
+ * @param manifestPath Path to manifest file
16
+ * @returns Resolved absolute path
17
+ */
18
+ export declare function validateManifestPath(manifestPath: string): string;
@@ -0,0 +1,56 @@
1
+ import { existsSync, lstatSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ /**
4
+ * Validates an array of image file paths
5
+ * @param paths Array of file paths to validate
6
+ * @returns Array of resolved absolute paths
7
+ */
8
+ export function validateImagePaths(paths) {
9
+ const resolvedPaths = [];
10
+ for (const path of paths) {
11
+ const resolvedPath = resolve(path);
12
+ if (!existsSync(resolvedPath)) {
13
+ console.error(`Error: File not found: ${path}`);
14
+ process.exit(1);
15
+ }
16
+ if (!lstatSync(resolvedPath).isFile()) {
17
+ console.error(`Error: Not a file: ${path}`);
18
+ process.exit(1);
19
+ }
20
+ resolvedPaths.push(resolvedPath);
21
+ }
22
+ return resolvedPaths;
23
+ }
24
+ /**
25
+ * Validates output directory path
26
+ * @param outputPath Output directory path
27
+ * @returns Resolved absolute path
28
+ */
29
+ export function validateOutputDirectory(outputPath) {
30
+ const resolvedPath = resolve(outputPath);
31
+ // Create parent directory if it doesn't exist
32
+ const parentDir = dirname(resolvedPath);
33
+ if (!existsSync(parentDir)) {
34
+ console.error(`Error: Parent directory does not exist: ${parentDir}`);
35
+ process.exit(1);
36
+ }
37
+ return resolvedPath;
38
+ }
39
+ /**
40
+ * Validates manifest file path
41
+ * @param manifestPath Path to manifest file
42
+ * @returns Resolved absolute path
43
+ */
44
+ export function validateManifestPath(manifestPath) {
45
+ const resolvedPath = resolve(manifestPath);
46
+ if (!existsSync(resolvedPath)) {
47
+ console.error(`Error: Manifest file not found: ${manifestPath}`);
48
+ process.exit(1);
49
+ }
50
+ if (!lstatSync(resolvedPath).isFile()) {
51
+ console.error(`Error: Manifest path is not a file: ${manifestPath}`);
52
+ process.exit(1);
53
+ }
54
+ return resolvedPath;
55
+ }
56
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAe;IAChD,MAAM,aAAa,GAAa,EAAE,CAAC;IAEnC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAEnC,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,OAAO,CAAC,KAAK,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAC;YAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,SAAS,CAAC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+ "version": "0.0.1",
4
+ "description": "CLI implementation of image fragmentation and restoration (RESERVED)",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "pixzle": "./dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc -p tsconfig.build.json",
15
+ "build:check": "tsc -p tsconfig.build.json --noEmit",
16
+ "test": "vitest",
17
+ "dev": "tsx src/cli.ts"
18
+ },
19
+ "keywords": [],
20
+ "author": "tuki0918",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/tuki0918/pixzle.git",
24
+ "directory": "packages/cli"
25
+ },
26
+ "license": "MIT",
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "dependencies": {
31
+ "@pixzle/core": "file:../core",
32
+ "@pixzle/node": "file:../node",
33
+ "commander": "^12.1.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^22.10.1",
37
+ "tsx": "^4.20.5",
38
+ "typescript": "^5.7.2",
39
+ "vitest": "^3.1.4"
40
+ }
41
+ }