@rowlabs/ev 0.5.0 → 0.5.1

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 +24 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7573,7 +7573,7 @@ envCommand.command("create <name>").description("Create a new environment").acti
7573
7573
  async ({ context, spinner }) => {
7574
7574
  const client = await createApiClient();
7575
7575
  const project = await client.getProject(context.project);
7576
- const app = context.app ? project.apps.find((a2) => a2.name.toLowerCase() === context.app.toLowerCase()) : project.apps.find((a2) => a2.name === "default") ?? project.apps[0];
7576
+ const app = context.app ? project.apps.find((a2) => a2.name.toLowerCase() === context.app?.toLowerCase()) : project.apps.find((a2) => a2.name === "default") ?? project.apps[0];
7577
7577
  if (!app) {
7578
7578
  spinner.fail(chalk10.red("App not found"));
7579
7579
  process.exit(1);
@@ -7605,7 +7605,7 @@ envCommand.command("delete <name>").description("Delete an environment").action(
7605
7605
  async ({ context, spinner }) => {
7606
7606
  const client = await createApiClient();
7607
7607
  const project = await client.getProject(context.project);
7608
- const app = context.app ? project.apps.find((a2) => a2.name.toLowerCase() === context.app.toLowerCase()) : project.apps.find((a2) => a2.name === "default") ?? project.apps[0];
7608
+ const app = context.app ? project.apps.find((a2) => a2.name.toLowerCase() === context.app?.toLowerCase()) : project.apps.find((a2) => a2.name === "default") ?? project.apps[0];
7609
7609
  if (!app) {
7610
7610
  spinner.fail(chalk10.red("App not found"));
7611
7611
  process.exit(1);
@@ -8733,7 +8733,7 @@ async function scanDir(dir) {
8733
8733
  const varName = match[1];
8734
8734
  if (IGNORE_VARS.has(varName)) continue;
8735
8735
  if (!results.has(varName)) results.set(varName, /* @__PURE__ */ new Set());
8736
- results.get(varName).add(fullPath);
8736
+ results.get(varName)?.add(fullPath);
8737
8737
  }
8738
8738
  }
8739
8739
  }
@@ -8793,7 +8793,7 @@ function printTable(label, refs, envData, repoRoot, showFiles, localKeys) {
8793
8793
  if (!allPresent) missingCount++;
8794
8794
  console.log(row);
8795
8795
  if (showFiles) {
8796
- const files = refs.get(varName);
8796
+ const files = refs.get(varName) ?? [];
8797
8797
  for (const file of files) {
8798
8798
  const relative = file.replace(repoRoot + "/", "");
8799
8799
  console.log(chalk19.dim(` \u2192 ${relative}`));
@@ -8940,7 +8940,7 @@ var updateCommand = new Command18("update").description("Update ev to the latest
8940
8940
  const spinner = ora12("Checking for updates...").start();
8941
8941
  try {
8942
8942
  const latest = execSync2("npm view @rowlabs/ev version", { encoding: "utf-8" }).trim();
8943
- const current = "0.5.0";
8943
+ const current = "0.5.1";
8944
8944
  if (current === latest) {
8945
8945
  spinner.succeed(chalk20.green(`Already on the latest version (${current})`));
8946
8946
  return;
@@ -9045,7 +9045,8 @@ import { stat as stat3 } from "fs/promises";
9045
9045
  import { join as join10 } from "path";
9046
9046
  var isTTY = process.stdout.isTTY && !process.env.NO_COLOR;
9047
9047
  function stripAnsi(str) {
9048
- return str.replace(/\x1B\[[0-9;]*m/g, "");
9048
+ const ESC = String.fromCharCode(27);
9049
+ return str.replace(new RegExp(`${ESC}\\[[0-9;]*m`, "g"), "");
9049
9050
  }
9050
9051
  function log(msg) {
9051
9052
  console.log(isTTY ? msg : stripAnsi(msg));
@@ -9111,7 +9112,7 @@ var auditCommand = new Command20("audit").description("Check that all env vars r
9111
9112
  const results = [];
9112
9113
  if (isAtRoot && hasApps) {
9113
9114
  if (spinner) spinner.text = "Auditing all apps...";
9114
- for (const [appName, appConfig] of Object.entries(config.apps)) {
9115
+ for (const [appName, appConfig] of Object.entries(config.apps ?? {})) {
9115
9116
  const appDir = join10(repoRoot, appConfig.path);
9116
9117
  try {
9117
9118
  await stat3(appDir);
@@ -9167,12 +9168,13 @@ import { readFile as readFile7, writeFile as writeFile6, stat as stat4 } from "f
9167
9168
  import { existsSync as existsSync7 } from "fs";
9168
9169
  var isTTY2 = process.stdout.isTTY && !process.env.NO_COLOR;
9169
9170
  function stripAnsi2(str) {
9170
- return str.replace(/\x1B\[[0-9;]*m/g, "");
9171
+ const ESC = String.fromCharCode(27);
9172
+ return str.replace(new RegExp(`${ESC}\\[[0-9;]*m`, "g"), "");
9171
9173
  }
9172
9174
  function log2(msg) {
9173
9175
  console.log(isTTY2 ? msg : stripAnsi2(msg));
9174
9176
  }
9175
- async function findDeadSecrets(appName, envName, scanPath, projectId, envFiles) {
9177
+ async function findDeadSecrets(appName, envName, envDir, repoRoot, projectId, envFiles) {
9176
9178
  const client = await createApiClient();
9177
9179
  const project = await client.getProject(projectId);
9178
9180
  const serverApp = project.apps.find((a2) => a2.name.toLowerCase() === appName.toLowerCase());
@@ -9190,17 +9192,17 @@ async function findDeadSecrets(appName, envName, scanPath, projectId, envFiles)
9190
9192
  );
9191
9193
  process.exit(1);
9192
9194
  }
9193
- const refs = await scanDir(scanPath);
9195
+ const refs = await scanDir(repoRoot);
9194
9196
  const referencedKeys = new Set(refs.keys());
9195
9197
  const localKeyFiles = /* @__PURE__ */ new Map();
9196
9198
  for (const envFile of envFiles) {
9197
- const filePath = join11(scanPath, envFile);
9199
+ const filePath = join11(envDir, envFile);
9198
9200
  if (existsSync7(filePath)) {
9199
9201
  const content = await readFile7(filePath, "utf-8");
9200
9202
  const parsed = parseEnvFile(content);
9201
9203
  for (const key of Object.keys(parsed)) {
9202
9204
  if (!localKeyFiles.has(key)) localKeyFiles.set(key, []);
9203
- localKeyFiles.get(key).push(filePath);
9205
+ localKeyFiles.get(key)?.push(filePath);
9204
9206
  }
9205
9207
  }
9206
9208
  }
@@ -9262,24 +9264,18 @@ function printDeadTable(result) {
9262
9264
  }
9263
9265
  async function cleanApp(result, deadSet, envFiles, scanPath, backendConfig) {
9264
9266
  const isEvBackend = !backendConfig || backendConfig.type === "ev";
9265
- let localCleaned = 0;
9266
9267
  for (const envFile of envFiles) {
9267
9268
  const filePath = join11(scanPath, envFile);
9268
9269
  if (!existsSync7(filePath)) continue;
9269
9270
  const content = await readFile7(filePath, "utf-8");
9270
9271
  const parsed = parseEnvFile(content);
9271
- let changed = false;
9272
- for (const key of deadSet) {
9273
- if (key in parsed) {
9274
- delete parsed[key];
9275
- changed = true;
9276
- }
9272
+ const filtered = {};
9273
+ for (const [k2, v2] of Object.entries(parsed)) {
9274
+ if (!deadSet.has(k2)) filtered[k2] = v2;
9277
9275
  }
9278
- if (changed) {
9279
- await writeFile6(filePath, serializeEnv(parsed), "utf-8");
9280
- const display = envFile;
9281
- log2(isTTY2 ? ` ${chalk23.green("\u2713")} Cleaned ${display}` : ` \u2713 Cleaned ${display}`);
9282
- localCleaned++;
9276
+ if (Object.keys(filtered).length < Object.keys(parsed).length) {
9277
+ await writeFile6(filePath, serializeEnv(filtered), "utf-8");
9278
+ log2(isTTY2 ? ` ${chalk23.green("\u2713")} Cleaned ${envFile}` : ` \u2713 Cleaned ${envFile}`);
9283
9279
  }
9284
9280
  }
9285
9281
  const deadRemoteKeys = result.dead.filter((d2) => d2.inRemote).map((d2) => d2.key);
@@ -9332,7 +9328,7 @@ var cleanCommand = new Command21("clean").description("Find and remove unused se
9332
9328
  const scanPaths = /* @__PURE__ */ new Map();
9333
9329
  if (isAtRoot && hasApps) {
9334
9330
  if (spinner) spinner.text = "Scanning all apps...";
9335
- for (const [appName, appConfig] of Object.entries(config.apps)) {
9331
+ for (const [appName, appConfig] of Object.entries(config.apps ?? {})) {
9336
9332
  const appDir = join11(repoRoot, appConfig.path);
9337
9333
  try {
9338
9334
  await stat4(appDir);
@@ -9344,6 +9340,7 @@ var cleanCommand = new Command21("clean").description("Find and remove unused se
9344
9340
  appName,
9345
9341
  envName,
9346
9342
  appDir,
9343
+ repoRoot,
9347
9344
  context.project,
9348
9345
  envFiles
9349
9346
  );
@@ -9358,6 +9355,7 @@ var cleanCommand = new Command21("clean").description("Find and remove unused se
9358
9355
  appName,
9359
9356
  envName,
9360
9357
  scanPath,
9358
+ repoRoot,
9361
9359
  context.project,
9362
9360
  envFiles
9363
9361
  );
@@ -9399,7 +9397,7 @@ var cleanCommand = new Command21("clean").description("Find and remove unused se
9399
9397
 
9400
9398
  // src/index.ts
9401
9399
  var program = new Command22();
9402
- program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.5.0");
9400
+ program.name("ev").description("Git for env vars \u2014 sync environment variables across teams securely").version("0.5.1");
9403
9401
  program.addCommand(loginCommand);
9404
9402
  program.addCommand(initCommand);
9405
9403
  program.addCommand(pushCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowlabs/ev",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Git for env vars — sync environment variables across teams securely",
5
5
  "type": "module",
6
6
  "bin": {