@rowlabs/ev 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.js +109 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6577,6 +6577,11 @@ var init_api_client = __esm({
6577
6577
  githubRepo
6578
6578
  });
6579
6579
  }
6580
+ async updateProjectName(projectId, name) {
6581
+ return this.request("PATCH", `/projects/${projectId}`, {
6582
+ name
6583
+ });
6584
+ }
6580
6585
  async listProjects() {
6581
6586
  return this.request("GET", "/projects");
6582
6587
  }
@@ -6645,6 +6650,9 @@ var init_api_client = __esm({
6645
6650
  async deleteEnvironment(appId, envId) {
6646
6651
  return this.request("DELETE", `/apps/${appId}/environments/${envId}`);
6647
6652
  }
6653
+ async deleteApp(projectId, appId) {
6654
+ return this.request("DELETE", `/projects/${projectId}/apps/${appId}`);
6655
+ }
6648
6656
  async rotateKeys(projectId, body) {
6649
6657
  return this.request("POST", `/projects/${projectId}/rotate`, body);
6650
6658
  }
@@ -6724,7 +6732,7 @@ var init_auth = __esm({
6724
6732
 
6725
6733
  // src/index.ts
6726
6734
  init_dist();
6727
- import { Command as Command19 } from "commander";
6735
+ import { Command as Command20 } from "commander";
6728
6736
 
6729
6737
  // src/commands/login.ts
6730
6738
  init_dist();
@@ -6912,11 +6920,11 @@ var initCommand = new Command2("init").description("Initialize ev in the current
6912
6920
  console.log(` ${app.name} \u2192 ${app.path}`);
6913
6921
  }
6914
6922
  const rl = await import("readline");
6915
- const readline2 = rl.createInterface({ input: process.stdin, output: process.stdout });
6923
+ const readline3 = rl.createInterface({ input: process.stdin, output: process.stdout });
6916
6924
  const answer = await new Promise((resolve) => {
6917
- readline2.question("\nAdd these as app mappings to ev.yaml? (y/N) ", resolve);
6925
+ readline3.question("\nAdd these as app mappings to ev.yaml? (y/N) ", resolve);
6918
6926
  });
6919
- readline2.close();
6927
+ readline3.close();
6920
6928
  if (answer.toLowerCase() === "y") {
6921
6929
  const appsConfig = {};
6922
6930
  for (const app of detectedApps) {
@@ -7073,6 +7081,13 @@ var pushCommand = new Command3("push").description("Push local .env files to rem
7073
7081
  const config = await loadEvConfig(process.cwd());
7074
7082
  const cwd = process.cwd();
7075
7083
  const isAtRoot = cwd === repoRoot;
7084
+ if (config?.name) {
7085
+ try {
7086
+ const client = await createApiClient(backendConfig);
7087
+ await client.updateProjectName(context.project, config.name);
7088
+ } catch {
7089
+ }
7090
+ }
7076
7091
  if (isAtRoot && config?.apps && Object.keys(config.apps).length > 0) {
7077
7092
  spinner.text = "Pushing all apps...";
7078
7093
  spinner.stop();
@@ -7567,16 +7582,16 @@ envCommand.command("create <name>").description("Create a new environment").acti
7567
7582
  });
7568
7583
  envCommand.command("delete <name>").description("Delete an environment").action(async (name) => {
7569
7584
  const rl = await import("readline");
7570
- const readline2 = rl.createInterface({ input: process.stdin, output: process.stdout });
7585
+ const readline3 = rl.createInterface({ input: process.stdin, output: process.stdout });
7571
7586
  const answer = await new Promise((resolve) => {
7572
- readline2.question(
7587
+ readline3.question(
7573
7588
  chalk10.red(
7574
7589
  `Delete environment "${name}"? This removes all secrets and releases. Type the environment name to confirm: `
7575
7590
  ),
7576
7591
  resolve
7577
7592
  );
7578
7593
  });
7579
- readline2.close();
7594
+ readline3.close();
7580
7595
  if (answer !== name) {
7581
7596
  console.log(chalk10.yellow("Cancelled."));
7582
7597
  process.exit(0);
@@ -7710,11 +7725,11 @@ accessCommand.command("grant <email>").description("Invite a user and share the
7710
7725
  });
7711
7726
  accessCommand.command("revoke <email>").description("Remove a member's access").action(async (email) => {
7712
7727
  const rl = await import("readline");
7713
- const readline2 = rl.createInterface({ input: process.stdin, output: process.stdout });
7728
+ const readline3 = rl.createInterface({ input: process.stdin, output: process.stdout });
7714
7729
  const answer = await new Promise((resolve) => {
7715
- readline2.question(chalk12.yellow(`Revoke access for ${email}? (y/N) `), resolve);
7730
+ readline3.question(chalk12.yellow(`Revoke access for ${email}? (y/N) `), resolve);
7716
7731
  });
7717
- readline2.close();
7732
+ readline3.close();
7718
7733
  if (answer.toLowerCase() !== "y") {
7719
7734
  console.log(chalk12.yellow("Cancelled."));
7720
7735
  process.exit(0);
@@ -8403,6 +8418,7 @@ _ev() {
8403
8418
  'update:Update ev to latest version'
8404
8419
  'doctor:Check setup for issues'
8405
8420
  'completions:Generate shell completions'
8421
+ 'delete:Delete an app or environment'
8406
8422
  )
8407
8423
 
8408
8424
  _arguments -C \\
@@ -8455,7 +8471,7 @@ var BASH_COMPLETION = `_ev() {
8455
8471
  cur="\${COMP_WORDS[COMP_CWORD]}"
8456
8472
  prev="\${COMP_WORDS[COMP_CWORD-1]}"
8457
8473
 
8458
- commands="login init push pull diff log get rollback env promote access backend import status scan doctor completions update"
8474
+ commands="login init push pull diff log get rollback env promote access backend import status scan doctor completions update delete"
8459
8475
 
8460
8476
  case "\${prev}" in
8461
8477
  ev)
@@ -8509,6 +8525,7 @@ complete -c ev -n '__fish_use_subcommand' -a scan -d 'Scan for env var reference
8509
8525
  complete -c ev -n '__fish_use_subcommand' -a update -d 'Update ev to latest version'
8510
8526
  complete -c ev -n '__fish_use_subcommand' -a doctor -d 'Check setup for issues'
8511
8527
  complete -c ev -n '__fish_use_subcommand' -a completions -d 'Generate shell completions'
8528
+ complete -c ev -n '__fish_use_subcommand' -a delete -d 'Delete an app or environment'
8512
8529
 
8513
8530
  # env subcommands
8514
8531
  complete -c ev -n '__fish_seen_subcommand_from env' -a create -d 'Create environment'
@@ -8845,7 +8862,7 @@ var updateCommand = new Command18("update").description("Update ev to the latest
8845
8862
  const spinner = ora12("Checking for updates...").start();
8846
8863
  try {
8847
8864
  const latest = execSync2("npm view @rowlabs/ev version", { encoding: "utf-8" }).trim();
8848
- const current = "0.4.0";
8865
+ const current = "0.4.2";
8849
8866
  if (current === latest) {
8850
8867
  spinner.succeed(chalk20.green(`Already on the latest version (${current})`));
8851
8868
  return;
@@ -8859,9 +8876,86 @@ var updateCommand = new Command18("update").description("Update ev to the latest
8859
8876
  }
8860
8877
  });
8861
8878
 
8879
+ // src/commands/delete.ts
8880
+ init_api_client();
8881
+ init_config();
8882
+ import { Command as Command19 } from "commander";
8883
+ import chalk21 from "chalk";
8884
+ import ora13 from "ora";
8885
+ import readline2 from "readline";
8886
+ var deleteCommand = new Command19("delete").description("Delete an app or environment").argument("<target>", "App name to delete, or app:env to delete a specific environment").action(async (target) => {
8887
+ try {
8888
+ const resolved = await resolveCurrentContext();
8889
+ if (!resolved) {
8890
+ console.error(chalk21.red("No ev.yaml found. Run `ev init` first."));
8891
+ process.exit(1);
8892
+ }
8893
+ const { context } = resolved;
8894
+ const client = await createApiClient();
8895
+ const project = await client.getProject(context.project);
8896
+ if (target.includes(":")) {
8897
+ const [appName, envName] = target.split(":");
8898
+ const app = project.apps.find((a2) => a2.name === appName);
8899
+ if (!app) {
8900
+ console.error(chalk21.red(`App "${appName}" not found`));
8901
+ process.exit(1);
8902
+ }
8903
+ const envs = await client.listEnvironments(app.id);
8904
+ const env = envs.find((e) => e.name === envName);
8905
+ if (!env) {
8906
+ console.error(chalk21.red(`Environment "${envName}" not found in app "${appName}"`));
8907
+ process.exit(1);
8908
+ }
8909
+ const answer = await prompt2(
8910
+ chalk21.red(`Delete environment "${appName}:${envName}"? This removes all secrets and releases. Type the environment name to confirm: `)
8911
+ );
8912
+ if (answer !== envName) {
8913
+ console.log(chalk21.yellow("Cancelled."));
8914
+ process.exit(0);
8915
+ }
8916
+ const spinner = ora13(`Deleting ${appName}:${envName}...`).start();
8917
+ await client.deleteEnvironment(app.id, env.id);
8918
+ spinner.succeed(chalk21.green(`Deleted environment "${appName}:${envName}"`));
8919
+ } else {
8920
+ const appName = target;
8921
+ const app = project.apps.find((a2) => a2.name === appName);
8922
+ if (!app) {
8923
+ console.error(chalk21.red(`App "${appName}" not found`));
8924
+ process.exit(1);
8925
+ }
8926
+ const envs = await client.listEnvironments(app.id);
8927
+ const secretCount = envs.reduce((sum, e) => sum + e.secretCount, 0);
8928
+ const answer = await prompt2(
8929
+ chalk21.red(
8930
+ `Delete app "${appName}"? This removes ${envs.length} environment${envs.length === 1 ? "" : "s"} and ${secretCount} secret${secretCount === 1 ? "" : "s"}. Type the app name to confirm: `
8931
+ )
8932
+ );
8933
+ if (answer !== appName) {
8934
+ console.log(chalk21.yellow("Cancelled."));
8935
+ process.exit(0);
8936
+ }
8937
+ const spinner = ora13(`Deleting ${appName}...`).start();
8938
+ await client.deleteApp(context.project, app.id);
8939
+ spinner.succeed(chalk21.green(`Deleted app "${appName}"`));
8940
+ }
8941
+ } catch (err) {
8942
+ console.error(chalk21.red(`Delete failed: ${err.message}`));
8943
+ process.exit(1);
8944
+ }
8945
+ });
8946
+ function prompt2(question) {
8947
+ const rl = readline2.createInterface({ input: process.stdin, output: process.stdout });
8948
+ return new Promise((resolve) => {
8949
+ rl.question(question, (answer) => {
8950
+ rl.close();
8951
+ resolve(answer.trim());
8952
+ });
8953
+ });
8954
+ }
8955
+
8862
8956
  // src/index.ts
8863
- var program = new Command19();
8864
- program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.4.0");
8957
+ var program = new Command20();
8958
+ program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.4.2");
8865
8959
  program.addCommand(loginCommand);
8866
8960
  program.addCommand(initCommand);
8867
8961
  program.addCommand(pushCommand);
@@ -8880,6 +8974,7 @@ program.addCommand(doctorCommand);
8880
8974
  program.addCommand(completionsCommand);
8881
8975
  program.addCommand(scanCommand);
8882
8976
  program.addCommand(updateCommand);
8977
+ program.addCommand(deleteCommand);
8883
8978
  async function main() {
8884
8979
  await initCrypto();
8885
8980
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowlabs/ev",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Git for env vars — sync environment variables across teams securely",
5
5
  "type": "module",
6
6
  "bin": {