@jondot/dotvault 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.
Files changed (2) hide show
  1. package/bin/dotvault +61 -0
  2. package/package.json +14 -0
package/bin/dotvault ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const os = require("os");
6
+ const path = require("path");
7
+
8
+ function getBinaryPath() {
9
+ if (process.env.DOTVAULT_BINARY) {
10
+ return process.env.DOTVAULT_BINARY;
11
+ }
12
+
13
+ const platform = process.platform;
14
+ const arch = os.arch();
15
+
16
+ const PLATFORMS = {
17
+ "darwin-arm64": "@jondot/dotvault-cli-darwin-arm64",
18
+ "linux-x64": "@jondot/dotvault-cli-linux-x64",
19
+ "linux-arm64": "@jondot/dotvault-cli-linux-arm64",
20
+ };
21
+
22
+ const key = `${platform}-${arch}`;
23
+ const pkg = PLATFORMS[key];
24
+
25
+ if (!pkg) {
26
+ console.error(
27
+ `Unsupported platform: ${platform}-${arch}. ` +
28
+ `Supported: ${Object.keys(PLATFORMS).join(", ")}`
29
+ );
30
+ process.exit(1);
31
+ }
32
+
33
+ const binaryName = "dv";
34
+
35
+ try {
36
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
37
+ return path.join(pkgDir, binaryName);
38
+ } catch {
39
+ console.error(
40
+ `Could not find the dotvault binary for ${platform}-${arch}.\n` +
41
+ `The package ${pkg} does not appear to be installed.\n` +
42
+ `Try reinstalling: npm i -g @jondot/dotvault`
43
+ );
44
+ process.exit(1);
45
+ }
46
+ }
47
+
48
+ const binary = getBinaryPath();
49
+
50
+ try {
51
+ fs.chmodSync(binary, 0o755);
52
+ } catch {}
53
+
54
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
55
+
56
+ if (result.error) {
57
+ console.error(`Failed to execute dotvault: ${result.error.message}`);
58
+ process.exit(1);
59
+ }
60
+
61
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@jondot/dotvault",
3
+ "version": "0.1.0",
4
+ "description": "Resolve secrets from pluggable backends into your dev environment",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "dv": "bin/dotvault"
8
+ },
9
+ "optionalDependencies": {
10
+ "@jondot/dotvault-cli-darwin-arm64": "0.1.0",
11
+ "@jondot/dotvault-cli-linux-x64": "0.1.0",
12
+ "@jondot/dotvault-cli-linux-arm64": "0.1.0"
13
+ }
14
+ }