roxify 1.5.9 → 1.5.11

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/dist/cli.js CHANGED
@@ -195,6 +195,28 @@ async function encodeCommand(args) {
195
195
  catch (e) {
196
196
  resolvedOutput = join('/', parsed.output || outputPath || outputName);
197
197
  }
198
+ // Check for empty directories *before* attempting native Rust encoder.
199
+ try {
200
+ const anyDir = inputPaths.some((p) => {
201
+ try {
202
+ return statSync(resolve(safeCwd, p)).isDirectory();
203
+ }
204
+ catch (e) {
205
+ return false;
206
+ }
207
+ });
208
+ if (anyDir) {
209
+ const { index } = await packPathsGenerator(inputPaths, undefined, () => { });
210
+ if (!index || index.length === 0) {
211
+ console.log(' ');
212
+ console.error('Error: No files found in specified input paths.');
213
+ process.exit(1);
214
+ }
215
+ }
216
+ }
217
+ catch (e) {
218
+ // ignore errors from the quick pre-check and proceed to try Rust encoding
219
+ }
198
220
  if (isRustBinaryAvailable() && !parsed.forceTs) {
199
221
  try {
200
222
  console.log(`Encoding to ${resolvedOutput} (Using native Rust encoder)\n`);
@@ -313,6 +335,11 @@ async function encodeCommand(args) {
313
335
  if (inputPaths.length > 1) {
314
336
  currentEncodeStep = 'Reading files';
315
337
  const { index, stream, totalSize } = await packPathsGenerator(inputPaths, undefined, onProgress);
338
+ if (!index || index.length === 0) {
339
+ console.log(' ');
340
+ console.error('Error: No files found in specified input paths.');
341
+ process.exit(1);
342
+ }
316
343
  inputData = stream;
317
344
  inputSizeVal = totalSize;
318
345
  displayName = parsed.outputName || 'archive';
@@ -328,6 +355,11 @@ async function encodeCommand(args) {
328
355
  if (st.isDirectory()) {
329
356
  currentEncodeStep = 'Reading files';
330
357
  const { index, stream, totalSize } = await packPathsGenerator([resolvedInput], dirname(resolvedInput), onProgress);
358
+ if (!index || index.length === 0) {
359
+ console.log(' ');
360
+ console.error(`Error: No files found in ${resolvedInput}`);
361
+ process.exit(1);
362
+ }
331
363
  inputData = stream;
332
364
  inputSizeVal = totalSize;
333
365
  displayName = parsed.outputName || basename(resolvedInput);
@@ -1,8 +1,8 @@
1
- import { arch, platform } from 'os';
2
- import { join, dirname, resolve } from 'path';
1
+ import { existsSync } from 'fs';
3
2
  import { createRequire } from 'module';
3
+ import { arch, platform } from 'os';
4
+ import { dirname, join, resolve } from 'path';
4
5
  import { fileURLToPath } from 'url';
5
- import { existsSync } from 'fs';
6
6
  function getNativeModule() {
7
7
  let moduleDir;
8
8
  let nativeRequire;
@@ -59,7 +59,9 @@ function getNativeModule() {
59
59
  // @ts-ignore
60
60
  console.debug('[native] moduleDir', moduleDir);
61
61
  let root = moduleDir && moduleDir !== '.' ? moduleDir : process.cwd();
62
- while (root.length > 1 && !existsSync(resolve(root, 'package.json')) && !existsSync(resolve(root, 'Cargo.toml'))) {
62
+ while (root.length > 1 &&
63
+ !existsSync(resolve(root, 'package.json')) &&
64
+ !existsSync(resolve(root, 'Cargo.toml'))) {
63
65
  const parent = resolve(root, '..');
64
66
  if (parent === root)
65
67
  break;
@@ -19,52 +19,29 @@ catch {
19
19
  moduleDir = process.cwd();
20
20
  }
21
21
  function findRustBinary() {
22
- const candidates = [];
23
22
  const binNames = process.platform === 'win32'
24
- ? ['roxify-cli.exe', 'roxify_cli.exe', 'roxify_native.exe']
25
- : ['roxify-cli', 'roxify_cli', 'roxify_native'];
26
- // Possible locations relative to this file (works in repo and in packaged dist)
27
- const relativeDirs = [
28
- join(__dirname, '..', '..', 'target', 'release'),
29
- join(__dirname, '..', '..', 'dist'),
30
- join(__dirname, '..'),
31
- join(__dirname, '..', '..'),
32
- ];
33
- for (const dir of relativeDirs) {
34
- for (const name of binNames) {
35
- candidates.push(join(dir, name));
23
+ ? ['roxify_native.exe', 'roxify-cli.exe', 'roxify_cli.exe']
24
+ : ['roxify_native', 'roxify-cli', 'roxify_cli'];
25
+ const baseDir = typeof moduleDir !== 'undefined' ? moduleDir : process.cwd();
26
+ // Check immediate locations (for packaged CLI)
27
+ for (const name of binNames) {
28
+ const local = join(baseDir, name);
29
+ if (existsSync(local)) {
30
+ return local;
36
31
  }
37
- }
38
- // Common global paths
39
- if (process.platform !== 'win32') {
40
- candidates.push('/usr/local/bin/roxify_native');
41
- candidates.push('/usr/bin/roxify_native');
42
- }
43
- for (const p of candidates) {
44
- try {
45
- if (existsSync(p))
46
- return p;
32
+ const parentLocal = join(baseDir, '..', name);
33
+ if (existsSync(parentLocal)) {
34
+ return parentLocal;
47
35
  }
48
- catch (e) { }
49
36
  }
50
- // Search in PATH for common binary names
51
- try {
52
- const which = process.platform === 'win32' ? 'where' : 'which';
53
- const { execSync } = require('child_process');
54
- for (const name of binNames) {
55
- try {
56
- const out = execSync(`${which} ${name}`, { encoding: 'utf-8' })
57
- .split('\n')[0]
58
- .trim();
59
- if (out && existsSync(out))
60
- return out;
61
- }
62
- catch (e) {
63
- // ignore
64
- }
37
+ // Check target/release (for development)
38
+ const targetRelease = join(baseDir, '..', '..', 'target', 'release');
39
+ for (const name of binNames) {
40
+ const targetPath = join(targetRelease, name);
41
+ if (existsSync(targetPath)) {
42
+ return targetPath;
65
43
  }
66
44
  }
67
- catch (e) { }
68
45
  return null;
69
46
  }
70
47
  export function isRustBinaryAvailable() {
@@ -73,7 +50,7 @@ export function isRustBinaryAvailable() {
73
50
  export async function encodeWithRustCLI(inputPath, outputPath, compressionLevel = 3, passphrase, encryptType = 'aes', name) {
74
51
  const cliPath = findRustBinary();
75
52
  if (!cliPath) {
76
- throw new Error('Rust CLI binary not found. Run: cargo build --release');
53
+ throw new Error('Rust CLI binary not found');
77
54
  }
78
55
  return new Promise((resolve, reject) => {
79
56
  const args = ['encode', '--level', String(compressionLevel)];
@@ -85,20 +62,14 @@ export async function encodeWithRustCLI(inputPath, outputPath, compressionLevel
85
62
  args.push('--encrypt', encryptType);
86
63
  }
87
64
  args.push(inputPath, outputPath);
88
- const proc = spawn(cliPath, args);
89
- let stderr = '';
90
- proc.stderr.on('data', (data) => {
91
- stderr += data.toString();
92
- });
93
- proc.on('error', (err) => {
94
- reject(new Error(`Failed to spawn Rust CLI: ${err.message}`));
95
- });
65
+ const proc = spawn(cliPath, args, { stdio: 'inherit' });
66
+ proc.on('error', (err) => reject(err));
96
67
  proc.on('close', (code) => {
97
68
  if (code === 0) {
98
69
  resolve();
99
70
  }
100
71
  else {
101
- reject(new Error(`Rust CLI exited with code ${code}: ${stderr}`));
72
+ reject(new Error(`Rust encoder exited with status ${code}`));
102
73
  }
103
74
  });
104
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roxify",
3
- "version": "1.5.9",
3
+ "version": "1.5.11",
4
4
  "description": "Ultra-lightweight PNG steganography with native Rust acceleration. Encode binary data into PNG images with zstd compression.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",