envlock-core 0.6.1 → 0.6.2
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/index.js +21 -29
- package/dist/index.cjs +30 -28
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -28
- package/package.json +4 -1
package/dist/cli/index.js
CHANGED
|
@@ -60,51 +60,43 @@ ${installHint}`);
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// src/invoke.ts
|
|
63
|
-
function runWithSecrets(options) {
|
|
63
|
+
async function runWithSecrets(options) {
|
|
64
64
|
const { envFile, environment, onePasswordEnvId, command, args } = options;
|
|
65
|
-
checkBinary(
|
|
66
|
-
"dotenvx",
|
|
67
|
-
"Install dotenvx: npm install -g @dotenvx/dotenvx\nOr add it as a dev dependency."
|
|
68
|
-
);
|
|
69
65
|
const privateKeyVar = `DOTENV_PRIVATE_KEY_${environment.toUpperCase()}`;
|
|
70
66
|
const keyAlreadyInjected = !!process.env[privateKeyVar];
|
|
71
|
-
|
|
72
|
-
if (keyAlreadyInjected) {
|
|
73
|
-
log.debug(`Spawning: dotenvx run -f ${envFile} -- ${command} ${args.join(" ")}`);
|
|
74
|
-
result = spawnSync(
|
|
75
|
-
"dotenvx",
|
|
76
|
-
["run", "-f", envFile, "--", command, ...args],
|
|
77
|
-
{ stdio: "inherit" }
|
|
78
|
-
);
|
|
79
|
-
if (result.error) {
|
|
80
|
-
throw new Error(`[envlock] Failed to spawn 'dotenvx': ${result.error.message}`);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
67
|
+
if (!keyAlreadyInjected) {
|
|
83
68
|
checkBinary(
|
|
84
69
|
"op",
|
|
85
70
|
"Install 1Password CLI: brew install --cask 1password-cli@beta\nThen sign in: op signin"
|
|
86
71
|
);
|
|
87
|
-
log.debug(`
|
|
88
|
-
|
|
72
|
+
log.debug(`Re-invoking via: op run --environment ${onePasswordEnvId}`);
|
|
73
|
+
const result2 = spawnSync(
|
|
89
74
|
"op",
|
|
90
75
|
[
|
|
91
76
|
"run",
|
|
92
77
|
"--environment",
|
|
93
78
|
onePasswordEnvId,
|
|
94
79
|
"--",
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"--",
|
|
100
|
-
command,
|
|
101
|
-
...args
|
|
80
|
+
process.execPath,
|
|
81
|
+
...process.execArgv,
|
|
82
|
+
process.argv[1],
|
|
83
|
+
...process.argv.slice(2)
|
|
102
84
|
],
|
|
103
85
|
{ stdio: "inherit" }
|
|
104
86
|
);
|
|
105
|
-
if (
|
|
106
|
-
throw new Error(`[envlock] Failed to spawn 'op': ${
|
|
87
|
+
if (result2.error) {
|
|
88
|
+
throw new Error(`[envlock] Failed to spawn 'op': ${result2.error.message}`);
|
|
107
89
|
}
|
|
90
|
+
process.exit(result2.status ?? 1);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
log.debug(`Decrypting ${envFile} via dotenvx`);
|
|
94
|
+
const { config } = await import("@dotenvx/dotenvx");
|
|
95
|
+
config({ path: envFile });
|
|
96
|
+
log.debug(`Spawning: ${command} ${args.join(" ")}`);
|
|
97
|
+
const result = spawnSync(command, args, { stdio: "inherit" });
|
|
98
|
+
if (result.error) {
|
|
99
|
+
throw new Error(`[envlock] Failed to spawn '${command}': ${result.error.message}`);
|
|
108
100
|
}
|
|
109
101
|
process.exit(result.status ?? 1);
|
|
110
102
|
}
|
|
@@ -239,7 +231,7 @@ async function run(argv, cwd = process.cwd()) {
|
|
|
239
231
|
log.debug(`Environment: ${environment}`);
|
|
240
232
|
log.debug(`Env file: ${envFile}`);
|
|
241
233
|
log.debug(`Command: ${command} ${args.join(" ")}`);
|
|
242
|
-
runWithSecrets({ envFile, environment, onePasswordEnvId, command, args });
|
|
234
|
+
await runWithSecrets({ envFile, environment, onePasswordEnvId, command, args });
|
|
243
235
|
}
|
|
244
236
|
var _resolvedArgv1 = (() => {
|
|
245
237
|
try {
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -81,51 +91,43 @@ ${installHint}`);
|
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
// src/invoke.ts
|
|
84
|
-
function runWithSecrets(options) {
|
|
94
|
+
async function runWithSecrets(options) {
|
|
85
95
|
const { envFile, environment, onePasswordEnvId, command, args } = options;
|
|
86
|
-
checkBinary(
|
|
87
|
-
"dotenvx",
|
|
88
|
-
"Install dotenvx: npm install -g @dotenvx/dotenvx\nOr add it as a dev dependency."
|
|
89
|
-
);
|
|
90
96
|
const privateKeyVar = `DOTENV_PRIVATE_KEY_${environment.toUpperCase()}`;
|
|
91
97
|
const keyAlreadyInjected = !!process.env[privateKeyVar];
|
|
92
|
-
|
|
93
|
-
if (keyAlreadyInjected) {
|
|
94
|
-
log.debug(`Spawning: dotenvx run -f ${envFile} -- ${command} ${args.join(" ")}`);
|
|
95
|
-
result = (0, import_node_child_process2.spawnSync)(
|
|
96
|
-
"dotenvx",
|
|
97
|
-
["run", "-f", envFile, "--", command, ...args],
|
|
98
|
-
{ stdio: "inherit" }
|
|
99
|
-
);
|
|
100
|
-
if (result.error) {
|
|
101
|
-
throw new Error(`[envlock] Failed to spawn 'dotenvx': ${result.error.message}`);
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
98
|
+
if (!keyAlreadyInjected) {
|
|
104
99
|
checkBinary(
|
|
105
100
|
"op",
|
|
106
101
|
"Install 1Password CLI: brew install --cask 1password-cli@beta\nThen sign in: op signin"
|
|
107
102
|
);
|
|
108
|
-
log.debug(`
|
|
109
|
-
|
|
103
|
+
log.debug(`Re-invoking via: op run --environment ${onePasswordEnvId}`);
|
|
104
|
+
const result2 = (0, import_node_child_process2.spawnSync)(
|
|
110
105
|
"op",
|
|
111
106
|
[
|
|
112
107
|
"run",
|
|
113
108
|
"--environment",
|
|
114
109
|
onePasswordEnvId,
|
|
115
110
|
"--",
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"--",
|
|
121
|
-
command,
|
|
122
|
-
...args
|
|
111
|
+
process.execPath,
|
|
112
|
+
...process.execArgv,
|
|
113
|
+
process.argv[1],
|
|
114
|
+
...process.argv.slice(2)
|
|
123
115
|
],
|
|
124
116
|
{ stdio: "inherit" }
|
|
125
117
|
);
|
|
126
|
-
if (
|
|
127
|
-
throw new Error(`[envlock] Failed to spawn 'op': ${
|
|
118
|
+
if (result2.error) {
|
|
119
|
+
throw new Error(`[envlock] Failed to spawn 'op': ${result2.error.message}`);
|
|
128
120
|
}
|
|
121
|
+
process.exit(result2.status ?? 1);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
log.debug(`Decrypting ${envFile} via dotenvx`);
|
|
125
|
+
const { config } = await import("@dotenvx/dotenvx");
|
|
126
|
+
config({ path: envFile });
|
|
127
|
+
log.debug(`Spawning: ${command} ${args.join(" ")}`);
|
|
128
|
+
const result = (0, import_node_child_process2.spawnSync)(command, args, { stdio: "inherit" });
|
|
129
|
+
if (result.error) {
|
|
130
|
+
throw new Error(`[envlock] Failed to spawn '${command}': ${result.error.message}`);
|
|
129
131
|
}
|
|
130
132
|
process.exit(result.status ?? 1);
|
|
131
133
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -25,7 +25,7 @@ interface RunWithSecretsOptions {
|
|
|
25
25
|
command: string;
|
|
26
26
|
args: string[];
|
|
27
27
|
}
|
|
28
|
-
declare function runWithSecrets(options: RunWithSecretsOptions): void
|
|
28
|
+
declare function runWithSecrets(options: RunWithSecretsOptions): Promise<void>;
|
|
29
29
|
|
|
30
30
|
declare function hasBinary(name: string): boolean;
|
|
31
31
|
declare function checkBinary(name: string, installHint: string): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ interface RunWithSecretsOptions {
|
|
|
25
25
|
command: string;
|
|
26
26
|
args: string[];
|
|
27
27
|
}
|
|
28
|
-
declare function runWithSecrets(options: RunWithSecretsOptions): void
|
|
28
|
+
declare function runWithSecrets(options: RunWithSecretsOptions): Promise<void>;
|
|
29
29
|
|
|
30
30
|
declare function hasBinary(name: string): boolean;
|
|
31
31
|
declare function checkBinary(name: string, installHint: string): void;
|
package/dist/index.js
CHANGED
|
@@ -47,51 +47,43 @@ ${installHint}`);
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// src/invoke.ts
|
|
50
|
-
function runWithSecrets(options) {
|
|
50
|
+
async function runWithSecrets(options) {
|
|
51
51
|
const { envFile, environment, onePasswordEnvId, command, args } = options;
|
|
52
|
-
checkBinary(
|
|
53
|
-
"dotenvx",
|
|
54
|
-
"Install dotenvx: npm install -g @dotenvx/dotenvx\nOr add it as a dev dependency."
|
|
55
|
-
);
|
|
56
52
|
const privateKeyVar = `DOTENV_PRIVATE_KEY_${environment.toUpperCase()}`;
|
|
57
53
|
const keyAlreadyInjected = !!process.env[privateKeyVar];
|
|
58
|
-
|
|
59
|
-
if (keyAlreadyInjected) {
|
|
60
|
-
log.debug(`Spawning: dotenvx run -f ${envFile} -- ${command} ${args.join(" ")}`);
|
|
61
|
-
result = spawnSync(
|
|
62
|
-
"dotenvx",
|
|
63
|
-
["run", "-f", envFile, "--", command, ...args],
|
|
64
|
-
{ stdio: "inherit" }
|
|
65
|
-
);
|
|
66
|
-
if (result.error) {
|
|
67
|
-
throw new Error(`[envlock] Failed to spawn 'dotenvx': ${result.error.message}`);
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
54
|
+
if (!keyAlreadyInjected) {
|
|
70
55
|
checkBinary(
|
|
71
56
|
"op",
|
|
72
57
|
"Install 1Password CLI: brew install --cask 1password-cli@beta\nThen sign in: op signin"
|
|
73
58
|
);
|
|
74
|
-
log.debug(`
|
|
75
|
-
|
|
59
|
+
log.debug(`Re-invoking via: op run --environment ${onePasswordEnvId}`);
|
|
60
|
+
const result2 = spawnSync(
|
|
76
61
|
"op",
|
|
77
62
|
[
|
|
78
63
|
"run",
|
|
79
64
|
"--environment",
|
|
80
65
|
onePasswordEnvId,
|
|
81
66
|
"--",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"--",
|
|
87
|
-
command,
|
|
88
|
-
...args
|
|
67
|
+
process.execPath,
|
|
68
|
+
...process.execArgv,
|
|
69
|
+
process.argv[1],
|
|
70
|
+
...process.argv.slice(2)
|
|
89
71
|
],
|
|
90
72
|
{ stdio: "inherit" }
|
|
91
73
|
);
|
|
92
|
-
if (
|
|
93
|
-
throw new Error(`[envlock] Failed to spawn 'op': ${
|
|
74
|
+
if (result2.error) {
|
|
75
|
+
throw new Error(`[envlock] Failed to spawn 'op': ${result2.error.message}`);
|
|
94
76
|
}
|
|
77
|
+
process.exit(result2.status ?? 1);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
log.debug(`Decrypting ${envFile} via dotenvx`);
|
|
81
|
+
const { config } = await import("@dotenvx/dotenvx");
|
|
82
|
+
config({ path: envFile });
|
|
83
|
+
log.debug(`Spawning: ${command} ${args.join(" ")}`);
|
|
84
|
+
const result = spawnSync(command, args, { stdio: "inherit" });
|
|
85
|
+
if (result.error) {
|
|
86
|
+
throw new Error(`[envlock] Failed to spawn '${command}': ${result.error.message}`);
|
|
95
87
|
}
|
|
96
88
|
process.exit(result.status ?? 1);
|
|
97
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envlock-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core 1Password + dotenvx secret injection logic for envlock",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"test": "vitest run",
|
|
38
38
|
"test:watch": "vitest"
|
|
39
39
|
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@dotenvx/dotenvx": "^1.59.1"
|
|
42
|
+
},
|
|
40
43
|
"devDependencies": {
|
|
41
44
|
"@types/node": "^20.14.10",
|
|
42
45
|
"tsup": "^8.0.0",
|