@dotenc/cli 0.4.2 → 0.4.3
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 +3 -3
- package/dist/cli.js +32 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
## 30-Second Example
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
dotenc init
|
|
13
|
-
dotenc env edit alice
|
|
14
|
-
dotenc dev npm start
|
|
12
|
+
dotenc init # pick your SSH key, choose a name
|
|
13
|
+
dotenc env edit alice # add your personal secrets
|
|
14
|
+
dotenc dev npm start # run with your encrypted env
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
Encrypted `.env.alice.enc` committed.
|
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@ var package_default;
|
|
|
7
7
|
var init_package = __esm(() => {
|
|
8
8
|
package_default = {
|
|
9
9
|
name: "@dotenc/cli",
|
|
10
|
-
version: "0.4.
|
|
10
|
+
version: "0.4.3",
|
|
11
11
|
description: "🔐 Git-native encrypted environments powered by your SSH keys",
|
|
12
12
|
author: "Ivan Filho <i@ivanfilho.com>",
|
|
13
13
|
license: "MIT",
|
|
@@ -1037,9 +1037,9 @@ var init_config = __esm(() => {
|
|
|
1037
1037
|
});
|
|
1038
1038
|
|
|
1039
1039
|
// src/helpers/getCurrentKeyName.ts
|
|
1040
|
-
var getCurrentKeyName = async () => {
|
|
1041
|
-
const { keys: privateKeys } = await getPrivateKeys();
|
|
1042
|
-
const publicKeys = await getPublicKeys();
|
|
1040
|
+
var getCurrentKeyName = async (deps = { getPrivateKeys, getPublicKeys }) => {
|
|
1041
|
+
const { keys: privateKeys } = await deps.getPrivateKeys();
|
|
1042
|
+
const publicKeys = await deps.getPublicKeys();
|
|
1043
1043
|
const privateFingerprints = new Set(privateKeys.map((k) => k.fingerprint));
|
|
1044
1044
|
const match = publicKeys.find((pub) => privateFingerprints.has(pub.fingerprint));
|
|
1045
1045
|
return match?.name;
|
|
@@ -1131,13 +1131,18 @@ var init_run = __esm(() => {
|
|
|
1131
1131
|
|
|
1132
1132
|
// src/commands/dev.ts
|
|
1133
1133
|
import chalk8 from "chalk";
|
|
1134
|
-
var devCommand = async (command, args
|
|
1135
|
-
|
|
1134
|
+
var devCommand = async (command, args, deps = {
|
|
1135
|
+
getCurrentKeyName,
|
|
1136
|
+
runCommand,
|
|
1137
|
+
logError: (message) => console.error(message),
|
|
1138
|
+
exit: (code) => process.exit(code)
|
|
1139
|
+
}) => {
|
|
1140
|
+
const keyName = await deps.getCurrentKeyName();
|
|
1136
1141
|
if (!keyName) {
|
|
1137
|
-
|
|
1138
|
-
|
|
1142
|
+
deps.logError(`${chalk8.red("Error:")} could not resolve your identity. Run ${chalk8.gray("dotenc init")} first.`);
|
|
1143
|
+
deps.exit(1);
|
|
1139
1144
|
}
|
|
1140
|
-
await runCommand(command, args, { env: `development,${keyName}` });
|
|
1145
|
+
await deps.runCommand(command, args, { env: `development,${keyName}` });
|
|
1141
1146
|
};
|
|
1142
1147
|
var init_dev = __esm(() => {
|
|
1143
1148
|
init_getCurrentKeyName();
|
|
@@ -1282,8 +1287,8 @@ var init_createHash = () => {};
|
|
|
1282
1287
|
|
|
1283
1288
|
// src/helpers/getDefaultEditor.ts
|
|
1284
1289
|
import { execSync } from "node:child_process";
|
|
1285
|
-
var getDefaultEditor = async () => {
|
|
1286
|
-
const config = await getHomeConfig();
|
|
1290
|
+
var defaultGetDefaultEditorDeps, getDefaultEditor = async (deps = defaultGetDefaultEditorDeps) => {
|
|
1291
|
+
const config = await deps.getHomeConfig();
|
|
1287
1292
|
if (config.editor) {
|
|
1288
1293
|
return config.editor;
|
|
1289
1294
|
}
|
|
@@ -1293,21 +1298,32 @@ var getDefaultEditor = async () => {
|
|
|
1293
1298
|
if (process.env.VISUAL) {
|
|
1294
1299
|
return process.env.VISUAL;
|
|
1295
1300
|
}
|
|
1296
|
-
const platform =
|
|
1301
|
+
const platform = deps.platform;
|
|
1297
1302
|
if (platform === "win32") {
|
|
1298
1303
|
return "notepad";
|
|
1299
1304
|
}
|
|
1300
1305
|
const editors = ["nano", "vim", "vi"];
|
|
1301
1306
|
for (const editor of editors) {
|
|
1302
|
-
|
|
1303
|
-
execSync(`command -v ${editor}`, { stdio: "ignore" });
|
|
1307
|
+
if (deps.commandExists(editor)) {
|
|
1304
1308
|
return editor;
|
|
1305
|
-
}
|
|
1309
|
+
}
|
|
1306
1310
|
}
|
|
1307
1311
|
throw new Error('No text editor found. Please set the EDITOR environment variable, configure an editor using "dotenc config editor <command>", or install a text editor (e.g., nano, vim, or notepad).');
|
|
1308
1312
|
};
|
|
1309
1313
|
var init_getDefaultEditor = __esm(() => {
|
|
1310
1314
|
init_homeConfig();
|
|
1315
|
+
defaultGetDefaultEditorDeps = {
|
|
1316
|
+
getHomeConfig,
|
|
1317
|
+
commandExists: (command) => {
|
|
1318
|
+
try {
|
|
1319
|
+
execSync(`command -v ${command}`, { stdio: "ignore" });
|
|
1320
|
+
return true;
|
|
1321
|
+
} catch {
|
|
1322
|
+
return false;
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
platform: process.platform
|
|
1326
|
+
};
|
|
1311
1327
|
});
|
|
1312
1328
|
|
|
1313
1329
|
// src/commands/env/edit.ts
|
|
@@ -2056,7 +2072,7 @@ var init_program = __esm(() => {
|
|
|
2056
2072
|
auth.command("revoke").argument("[environment]", "the environment to revoke access from").argument("[publicKey]", "the name of the public key to revoke access from the environment").description("revoke access from an environment").action(revokeCommand);
|
|
2057
2073
|
auth.command("list").argument("[environment]", "the environment to list access for").description("list keys with access to an environment").action(authListCommand);
|
|
2058
2074
|
program.command("run").argument("<command>", "the command to run").argument("[args...]", "the arguments to pass to the command").addOption(new Option("-e, --env <env1>[,env2[,...]]", "the environments to run the command in")).description("run a command in an environment").action(runCommand);
|
|
2059
|
-
program.command("dev").argument("<command>", "the command to run").argument("[args...]", "the arguments to pass to the command").description("shortcut for 'run -e development,<yourname> <command>'").action(devCommand);
|
|
2075
|
+
program.command("dev").argument("<command>", "the command to run").argument("[args...]", "the arguments to pass to the command").description("shortcut for 'run -e development,<yourname> <command>'").action((command, args) => devCommand(command, args));
|
|
2060
2076
|
key = program.command("key").description("manage keys");
|
|
2061
2077
|
key.command("add").argument("[name]", "the name of the public key in the project").addOption(new Option("--from-ssh <path>", "add a public key derived from an SSH key file")).addOption(new Option("-f, --from-file <file>", "add the key from a PEM file")).addOption(new Option("-s, --from-string <string>", "add a public key from a string")).description("add a public key to the project").action(keyAddCommand);
|
|
2062
2078
|
key.command("list").description("list all public keys in the project").action(keyListCommand);
|