@rowlabs/ev 0.4.2 → 0.4.4

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/dist/index.js +96 -26
  2. 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,95 @@ 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 envId = await resolveEnvironmentId(context.project, context.app, context.env);
7963
- const client = await createApiClient(backendConfig);
7964
- const response = await client.pullSecrets(envId);
7965
- const secret = response.secrets.find((s2) => s2.key === key);
7966
- if (!secret) {
7967
- console.error(
7968
- chalk14.red(`Secret "${key}" not found in ${context.app ?? "default"}:${context.env}`)
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 searches = Object.keys(config.apps).map(async (appName) => {
7982
+ try {
7983
+ const value = await getSecretValue(
7984
+ context.project,
7985
+ appName,
7986
+ context.env,
7987
+ key,
7988
+ isEvBackend,
7989
+ backendConfig
7990
+ );
7991
+ if (value !== null) return { app: appName, value };
7992
+ } catch {
7993
+ }
7994
+ return null;
7995
+ });
7996
+ const results = (await Promise.all(searches)).filter(
7997
+ (r2) => r2 !== null
7969
7998
  );
7970
- process.exit(1);
7971
- }
7972
- let value;
7973
- if (isEvBackend) {
7974
- const projectKey = await getDecryptedProjectKey(context.project);
7975
- value = decryptSecret(secret.encryptedValue, projectKey);
7976
- } else {
7977
- value = secret.encryptedValue;
7978
- }
7979
- if (options?.copy) {
7980
- try {
7981
- execSync("pbcopy", { input: value });
7982
- console.error(chalk14.green(`Copied ${key} to clipboard`));
7983
- } catch {
7984
- process.stdout.write(value);
7999
+ if (results.length === 0) {
8000
+ console.error(chalk14.red(`Secret "${key}" not found in any app`));
8001
+ process.exit(1);
8002
+ }
8003
+ if (results.length === 1) {
8004
+ outputValue(results[0].value, key, options?.copy);
8005
+ } else {
8006
+ const allSame = results.every((r2) => r2.value === results[0].value);
8007
+ if (allSame && options?.copy) {
8008
+ outputValue(results[0].value, key, true);
8009
+ } else {
8010
+ console.error(chalk14.bold(`
8011
+ ${key} found in ${results.length} apps:
8012
+ `));
8013
+ for (const { app, value } of results) {
8014
+ const masked = value.length <= 8 ? "****" : value.slice(0, 4) + "****" + value.slice(-4);
8015
+ console.error(` ${chalk14.cyan(app.padEnd(20))} ${chalk14.dim(masked)}`);
8016
+ }
8017
+ console.error();
8018
+ if (allSame) {
8019
+ console.error(chalk14.dim(" All values are identical."));
8020
+ outputValue(results[0].value, key, options?.copy);
8021
+ } else {
8022
+ console.error(
8023
+ chalk14.dim(" Values differ. Specify an app: ev get " + key + " AppName:dev")
8024
+ );
8025
+ }
8026
+ }
7985
8027
  }
7986
8028
  } else {
7987
- process.stdout.write(value);
8029
+ const value = await getSecretValue(
8030
+ context.project,
8031
+ context.app,
8032
+ context.env,
8033
+ key,
8034
+ isEvBackend,
8035
+ backendConfig
8036
+ );
8037
+ if (value === null) {
8038
+ console.error(
8039
+ chalk14.red(
8040
+ `Secret "${key}" not found in ${context.app ?? "default"}:${context.env}`
8041
+ )
8042
+ );
8043
+ process.exit(1);
8044
+ }
8045
+ outputValue(value, key, options?.copy);
7988
8046
  }
7989
8047
  } catch (err) {
7990
8048
  console.error(chalk14.red(`Failed: ${err.message}`));
7991
8049
  process.exit(1);
7992
8050
  }
7993
8051
  });
8052
+ function outputValue(value, key, copy) {
8053
+ if (copy) {
8054
+ try {
8055
+ execSync("pbcopy", { input: value });
8056
+ console.error(chalk14.green(`Copied ${key} to clipboard`));
8057
+ } catch {
8058
+ process.stdout.write(value);
8059
+ }
8060
+ } else {
8061
+ process.stdout.write(value);
8062
+ }
8063
+ }
7994
8064
 
7995
8065
  // src/commands/backend.ts
7996
8066
  init_config();
@@ -8862,7 +8932,7 @@ var updateCommand = new Command18("update").description("Update ev to the latest
8862
8932
  const spinner = ora12("Checking for updates...").start();
8863
8933
  try {
8864
8934
  const latest = execSync2("npm view @rowlabs/ev version", { encoding: "utf-8" }).trim();
8865
- const current = "0.4.2";
8935
+ const current = "0.4.4";
8866
8936
  if (current === latest) {
8867
8937
  spinner.succeed(chalk20.green(`Already on the latest version (${current})`));
8868
8938
  return;
@@ -8955,7 +9025,7 @@ function prompt2(question) {
8955
9025
 
8956
9026
  // src/index.ts
8957
9027
  var program = new Command20();
8958
- program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.4.2");
9028
+ program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.4.4");
8959
9029
  program.addCommand(loginCommand);
8960
9030
  program.addCommand(initCommand);
8961
9031
  program.addCommand(pushCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowlabs/ev",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Git for env vars — sync environment variables across teams securely",
5
5
  "type": "module",
6
6
  "bin": {