@rowlabs/ev 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/dist/index.js +96 -27
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6577,6 +6577,9 @@ var init_api_client = __esm({
|
|
|
6577
6577
|
githubRepo
|
|
6578
6578
|
});
|
|
6579
6579
|
}
|
|
6580
|
+
async deleteProject(projectId) {
|
|
6581
|
+
return this.request("DELETE", `/projects/${projectId}`);
|
|
6582
|
+
}
|
|
6580
6583
|
async updateProjectName(projectId, name) {
|
|
6581
6584
|
return this.request("PATCH", `/projects/${projectId}`, {
|
|
6582
6585
|
name
|
|
@@ -7950,6 +7953,18 @@ init_auth();
|
|
|
7950
7953
|
import { Command as Command12 } from "commander";
|
|
7951
7954
|
import { execSync } from "child_process";
|
|
7952
7955
|
import chalk14 from "chalk";
|
|
7956
|
+
async function getSecretValue(projectId, appName, envName, key, isEvBackend, backendConfig) {
|
|
7957
|
+
const envId = await resolveEnvironmentId(projectId, appName, envName);
|
|
7958
|
+
const client = await createApiClient(backendConfig);
|
|
7959
|
+
const response = await client.pullSecrets(envId);
|
|
7960
|
+
const secret = response.secrets.find((s2) => s2.key === key);
|
|
7961
|
+
if (!secret) return null;
|
|
7962
|
+
if (isEvBackend) {
|
|
7963
|
+
const projectKey = await getDecryptedProjectKey(projectId);
|
|
7964
|
+
return decryptSecret(secret.encryptedValue, projectKey);
|
|
7965
|
+
}
|
|
7966
|
+
return secret.encryptedValue;
|
|
7967
|
+
}
|
|
7953
7968
|
var getCommand = new Command12("get").description("Get a single secret value").argument("<key>", "Secret key name").argument("[target]", "app:env or env").option("-c, --copy", "Copy to clipboard").action(async (key, target, options) => {
|
|
7954
7969
|
try {
|
|
7955
7970
|
const resolved = await resolveCurrentContext(target);
|
|
@@ -7957,40 +7972,94 @@ var getCommand = new Command12("get").description("Get a single secret value").a
|
|
|
7957
7972
|
console.error(chalk14.red("No ev.yaml found. Run `ev init` first."));
|
|
7958
7973
|
process.exit(1);
|
|
7959
7974
|
}
|
|
7960
|
-
const { context, backendConfig } = resolved;
|
|
7975
|
+
const { context, backendConfig, repoRoot } = resolved;
|
|
7961
7976
|
const isEvBackend = !backendConfig || backendConfig.type === "ev";
|
|
7962
|
-
const
|
|
7963
|
-
const
|
|
7964
|
-
const
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7977
|
+
const config = await loadEvConfig(process.cwd());
|
|
7978
|
+
const cwd = process.cwd();
|
|
7979
|
+
const isAtRoot = cwd === repoRoot;
|
|
7980
|
+
if (isAtRoot && !target && config?.apps && Object.keys(config.apps).length > 0) {
|
|
7981
|
+
const results = [];
|
|
7982
|
+
for (const appName of Object.keys(config.apps)) {
|
|
7983
|
+
try {
|
|
7984
|
+
const value = await getSecretValue(
|
|
7985
|
+
context.project,
|
|
7986
|
+
appName,
|
|
7987
|
+
context.env,
|
|
7988
|
+
key,
|
|
7989
|
+
isEvBackend,
|
|
7990
|
+
backendConfig
|
|
7991
|
+
);
|
|
7992
|
+
if (value !== null) {
|
|
7993
|
+
results.push({ app: appName, value });
|
|
7994
|
+
}
|
|
7995
|
+
} catch {
|
|
7996
|
+
}
|
|
7997
|
+
}
|
|
7998
|
+
if (results.length === 0) {
|
|
7999
|
+
console.error(chalk14.red(`Secret "${key}" not found in any app`));
|
|
8000
|
+
process.exit(1);
|
|
8001
|
+
}
|
|
8002
|
+
if (results.length === 1) {
|
|
8003
|
+
outputValue(results[0].value, key, options?.copy);
|
|
8004
|
+
} else {
|
|
8005
|
+
const allSame = results.every((r2) => r2.value === results[0].value);
|
|
8006
|
+
if (allSame && options?.copy) {
|
|
8007
|
+
outputValue(results[0].value, key, true);
|
|
8008
|
+
} else {
|
|
8009
|
+
console.error(chalk14.bold(`
|
|
8010
|
+
${key} found in ${results.length} apps:
|
|
8011
|
+
`));
|
|
8012
|
+
for (const { app, value } of results) {
|
|
8013
|
+
const masked = value.length <= 8 ? "****" : value.slice(0, 4) + "****" + value.slice(-4);
|
|
8014
|
+
console.error(` ${chalk14.cyan(app.padEnd(20))} ${chalk14.dim(masked)}`);
|
|
8015
|
+
}
|
|
8016
|
+
console.error();
|
|
8017
|
+
if (allSame) {
|
|
8018
|
+
console.error(chalk14.dim(" All values are identical."));
|
|
8019
|
+
outputValue(results[0].value, key, options?.copy);
|
|
8020
|
+
} else {
|
|
8021
|
+
console.error(
|
|
8022
|
+
chalk14.dim(" Values differ. Specify an app: ev get " + key + " AppName:dev")
|
|
8023
|
+
);
|
|
8024
|
+
}
|
|
8025
|
+
}
|
|
7985
8026
|
}
|
|
7986
8027
|
} else {
|
|
7987
|
-
|
|
8028
|
+
const value = await getSecretValue(
|
|
8029
|
+
context.project,
|
|
8030
|
+
context.app,
|
|
8031
|
+
context.env,
|
|
8032
|
+
key,
|
|
8033
|
+
isEvBackend,
|
|
8034
|
+
backendConfig
|
|
8035
|
+
);
|
|
8036
|
+
if (value === null) {
|
|
8037
|
+
console.error(
|
|
8038
|
+
chalk14.red(
|
|
8039
|
+
`Secret "${key}" not found in ${context.app ?? "default"}:${context.env}`
|
|
8040
|
+
)
|
|
8041
|
+
);
|
|
8042
|
+
process.exit(1);
|
|
8043
|
+
}
|
|
8044
|
+
outputValue(value, key, options?.copy);
|
|
7988
8045
|
}
|
|
7989
8046
|
} catch (err) {
|
|
7990
8047
|
console.error(chalk14.red(`Failed: ${err.message}`));
|
|
7991
8048
|
process.exit(1);
|
|
7992
8049
|
}
|
|
7993
8050
|
});
|
|
8051
|
+
function outputValue(value, key, copy) {
|
|
8052
|
+
if (copy) {
|
|
8053
|
+
try {
|
|
8054
|
+
execSync("pbcopy", { input: value });
|
|
8055
|
+
console.error(chalk14.green(`Copied ${key} to clipboard`));
|
|
8056
|
+
} catch {
|
|
8057
|
+
process.stdout.write(value);
|
|
8058
|
+
}
|
|
8059
|
+
} else {
|
|
8060
|
+
process.stdout.write(value);
|
|
8061
|
+
}
|
|
8062
|
+
}
|
|
7994
8063
|
|
|
7995
8064
|
// src/commands/backend.ts
|
|
7996
8065
|
init_config();
|
|
@@ -8862,7 +8931,7 @@ var updateCommand = new Command18("update").description("Update ev to the latest
|
|
|
8862
8931
|
const spinner = ora12("Checking for updates...").start();
|
|
8863
8932
|
try {
|
|
8864
8933
|
const latest = execSync2("npm view @rowlabs/ev version", { encoding: "utf-8" }).trim();
|
|
8865
|
-
const current = "0.4.
|
|
8934
|
+
const current = "0.4.3";
|
|
8866
8935
|
if (current === latest) {
|
|
8867
8936
|
spinner.succeed(chalk20.green(`Already on the latest version (${current})`));
|
|
8868
8937
|
return;
|
|
@@ -8955,7 +9024,7 @@ function prompt2(question) {
|
|
|
8955
9024
|
|
|
8956
9025
|
// src/index.ts
|
|
8957
9026
|
var program = new Command20();
|
|
8958
|
-
program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.4.
|
|
9027
|
+
program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.4.3");
|
|
8959
9028
|
program.addCommand(loginCommand);
|
|
8960
9029
|
program.addCommand(initCommand);
|
|
8961
9030
|
program.addCommand(pushCommand);
|