@oalacea/shadow-secret 0.2.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/bin/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Binary Directory
2
+
3
+ This directory contains the compiled Rust binaries for different platforms.
4
+
5
+ ## CI/CD Injection
6
+
7
+ The binaries are **NOT** committed to this repository. They are injected during the CI/CD pipeline before publishing to NPM.
8
+
9
+ ## Build Process
10
+
11
+ 1. **Compile Rust binary:**
12
+ ```bash
13
+ cd packages/core
14
+ cargo build --release
15
+ ```
16
+
17
+ 2. **Copy to bin directory:**
18
+ - Windows: `target/release/shadow-secret.exe` → `packages/cli-npm/bin/shadow-secret.exe`
19
+ - Unix: `target/release/shadow-secret` → `packages/cli-npm/bin/shadow-secret`
20
+
21
+ 3. **Publish to NPM:**
22
+ ```bash
23
+ cd packages/cli-npm
24
+ npm publish
25
+ ```
26
+
27
+ ## Development
28
+
29
+ For local development during active development:
30
+
31
+ ```bash
32
+ # Build the binary
33
+ cd packages/core
34
+ cargo build --release
35
+
36
+ # Copy to bin directory (manual for development)
37
+ cp target/release/shadow-secret.exe ../cli-npm/bin/ # Windows
38
+ cp target/release/shadow-secret ../cli-npm/bin/ # Unix
39
+
40
+ # Test the NPM wrapper
41
+ cd ../cli-npm
42
+ npm link
43
+ shadow-secret --version
44
+ ```
45
+
46
+ ## Platform Support
47
+
48
+ - ✅ Windows (x64): `shadow-secret.exe`
49
+ - ✅ Linux (x64): `shadow-secret`
50
+ - ✅ macOS (x64/ARM64): `shadow-secret`
package/lib/bridge.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Shadow Secret NPM Bridge
5
+ *
6
+ * This script acts as a bridge between NPM and the native Rust binary.
7
+ * It detects the platform and spawns the correct binary with proper
8
+ * terminal inheritance for an seamless user experience.
9
+ *
10
+ * Platform support:
11
+ * - Windows (x64): shadow-secret.exe
12
+ * - Linux (x64): shadow-secret (TODO: Add via CI/CD)
13
+ * - macOS (x64/ARM64): shadow-secret (TODO: Add via CI/CD)
14
+ */
15
+
16
+ const { spawn } = require('child_process');
17
+ const path = require('path');
18
+ const fs = require('fs');
19
+
20
+ // Platform detection
21
+ const platform = process.platform;
22
+ const isWindows = platform === 'win32';
23
+
24
+ // Binary name based on platform
25
+ // Note: For now, only Windows binary is included
26
+ // Linux and macOS will be added in future releases via CI/CD
27
+ const binaryName = isWindows ? 'shadow-secret.exe' : 'shadow-secret';
28
+
29
+ // Resolve binary path relative to this script
30
+ const binDir = path.resolve(__dirname, '..', 'bin');
31
+ const binaryPath = path.join(binDir, binaryName);
32
+
33
+ /**
34
+ * Check if the binary exists
35
+ */
36
+ function binaryExists() {
37
+ return fs.existsSync(binaryPath);
38
+ }
39
+
40
+ /**
41
+ * Spawn the native binary with inherited stdio
42
+ */
43
+ function spawnBinary() {
44
+ // Check if binary exists
45
+ if (!binaryExists()) {
46
+ console.error(`❌ Error: Binary not found at ${binaryPath}`);
47
+ console.error('');
48
+ console.error('The native Rust binary is not installed.');
49
+ console.error('');
50
+ console.error('If you are developing this package:');
51
+ console.error(' 1. Build the binary: cd packages/core && cargo build --release');
52
+ console.error(` 2. Copy the binary to: ${binaryPath}`);
53
+ console.error('');
54
+ console.error('If you are a user:');
55
+ console.error(' Please reinstall this package: npm install -g shadow-secret');
56
+ console.error('');
57
+ console.error('For more information, visit: https://github.com/Pamacea/shadow-secret');
58
+ process.exit(1);
59
+ }
60
+
61
+ // Get arguments (skip first two: node executable and this script)
62
+ const args = process.argv.slice(2);
63
+
64
+ // Spawn the binary with inherited stdio for seamless terminal integration
65
+ const child = spawn(binaryPath, args, {
66
+ stdio: 'inherit',
67
+ env: process.env
68
+ });
69
+
70
+ // Forward exit code
71
+ child.on('close', (code) => {
72
+ process.exit(code ?? 0);
73
+ });
74
+
75
+ // Forward errors
76
+ child.on('error', (err) => {
77
+ console.error(`❌ Failed to start binary: ${err.message}`);
78
+ process.exit(1);
79
+ });
80
+ }
81
+
82
+ // Execute
83
+ spawnBinary();
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@oalacea/shadow-secret",
3
+ "version": "0.2.1",
4
+ "description": "Secure secret management for modern development workflows",
5
+ "bin": {
6
+ "shadow-secret": "lib/bridge.js"
7
+ },
8
+ "scripts": {
9
+ "test": "node lib/bridge.js --version"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ "lib",
14
+ "package.json"
15
+ ],
16
+ "keywords": [
17
+ "secrets",
18
+ "sops",
19
+ "security",
20
+ "age",
21
+ "encryption",
22
+ "cli",
23
+ "rust"
24
+ ],
25
+ "author": "Yanis <yanis@example.com>",
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/Pamacea/shadow-secret"
30
+ },
31
+ "homepage": "https://github.com/Pamacea/shadow-secret#readme"
32
+ }