Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"imports": {
"@cfa/gitignore-parser": "jsr:@cfa/gitignore-parser@^0.1.4",
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.8",
"@deno/sandbox": "jsr:@deno/sandbox@^0.4.4",
"@deno/sandbox": "jsr:@deno/sandbox@^0.5.0",
"@std/async": "jsr:@std/async@^1.0.15",
"@std/cli": "jsr:@std/cli@1.0.22",
"@std/dotenv": "jsr:@std/dotenv@^0.225.5",
Expand Down
37 changes: 17 additions & 20 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 23 additions & 41 deletions env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Command } from "@cliffy/command";
import { parse as dotEnvParse } from "@std/dotenv";
import { getAppFromConfig, readConfig } from "./config.ts";
import { error, withApp } from "./util.ts";
import { error, tablePrinter, withApp } from "./util.ts";
import { createTrpcClient } from "./auth.ts";
import type { GlobalOptions } from "./main.ts";

Expand Down Expand Up @@ -61,51 +61,33 @@ export const envListCommand = new Command<EnvCommandContext>()
org: orgAndApp.org,
});

const processed = envVars.map((envVar) => {
const contextNames = [];

if (envVar.context_ids) {
for (const contextId of envVar.context_ids) {
contextNames.push(
contexts.find((context) => context.id === contextId)!.name,
);
}
} else {
contextNames.push("All");
}

return {
key: envVar.key,
value: envVar.value ?? "***",
contexts: contextNames.join(", "),
};
});

const contextTitle = `Contexts (${
const contextTitle = `CONTEXTS (${
contexts.map((context) => context.name).join(", ")
})`;

let keyLength = 3;
let valueLength = 5;

for (const processedElement of processed) {
keyLength = Math.max(keyLength, processedElement.key.length);
valueLength = Math.max(valueLength, processedElement.value.length);
}
tablePrinter(
["KEY", "VALUE", contextTitle],
envVars,
(envVar) => {
const contextNames = [];

if (envVar.context_ids) {
for (const contextId of envVar.context_ids) {
contextNames.push(
contexts.find((context) => context.id === contextId)!.name,
);
}
} else {
contextNames.push("All");
}

console.log(
`${"Key".padEnd(keyLength)} ${
"Value".padEnd(valueLength)
} ${contextTitle}`,
return [
envVar.key,
envVar.value ?? "***",
contextNames.join(", "),
];
},
);

for (const env of processed) {
console.log(
`${env.key.padEnd(keyLength)} ${
env.value.padEnd(valueLength)
} ${env.contexts}`,
);
}
});

export const envAddCommand = new Command<EnvCommandContext>()
Expand Down
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "./env.ts";
import { createTrpcClient, getAuth } from "./auth.ts";
import token_storage from "./token_storage.ts";
import { sandboxCommand } from "./sandbox.ts";
import { sandboxCommand } from "./sandbox/mod.ts";

const MINIMUM_DENO_VERSION = "2.4.2";
if (
Expand Down
Loading