Skip to content

Commit 028351e

Browse files
authored
feat: improve sandbox cli & add volumes management (#38)
1 parent 0715796 commit 028351e

7 files changed

Lines changed: 290 additions & 152 deletions

File tree

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"imports": {
1818
"@cfa/gitignore-parser": "jsr:@cfa/gitignore-parser@^0.1.4",
1919
"@cliffy/command": "jsr:@cliffy/command@^1.0.0-rc.8",
20-
"@deno/sandbox": "jsr:@deno/sandbox@^0.4.4",
20+
"@deno/sandbox": "jsr:@deno/sandbox@^0.5.0",
2121
"@std/async": "jsr:@std/async@^1.0.15",
2222
"@std/cli": "jsr:@std/cli@1.0.22",
2323
"@std/dotenv": "jsr:@std/dotenv@^0.225.5",

deno.lock

Lines changed: 17 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

env.ts

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Command } from "@cliffy/command";
22
import { parse as dotEnvParse } from "@std/dotenv";
33
import { getAppFromConfig, readConfig } from "./config.ts";
4-
import { error, withApp } from "./util.ts";
4+
import { error, tablePrinter, withApp } from "./util.ts";
55
import { createTrpcClient } from "./auth.ts";
66
import type { GlobalOptions } from "./main.ts";
77

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

64-
const processed = envVars.map((envVar) => {
65-
const contextNames = [];
66-
67-
if (envVar.context_ids) {
68-
for (const contextId of envVar.context_ids) {
69-
contextNames.push(
70-
contexts.find((context) => context.id === contextId)!.name,
71-
);
72-
}
73-
} else {
74-
contextNames.push("All");
75-
}
76-
77-
return {
78-
key: envVar.key,
79-
value: envVar.value ?? "***",
80-
contexts: contextNames.join(", "),
81-
};
82-
});
83-
84-
const contextTitle = `Contexts (${
64+
const contextTitle = `CONTEXTS (${
8565
contexts.map((context) => context.name).join(", ")
8666
})`;
8767

88-
let keyLength = 3;
89-
let valueLength = 5;
90-
91-
for (const processedElement of processed) {
92-
keyLength = Math.max(keyLength, processedElement.key.length);
93-
valueLength = Math.max(valueLength, processedElement.value.length);
94-
}
68+
tablePrinter(
69+
["KEY", "VALUE", contextTitle],
70+
envVars,
71+
(envVar) => {
72+
const contextNames = [];
73+
74+
if (envVar.context_ids) {
75+
for (const contextId of envVar.context_ids) {
76+
contextNames.push(
77+
contexts.find((context) => context.id === contextId)!.name,
78+
);
79+
}
80+
} else {
81+
contextNames.push("All");
82+
}
9583

96-
console.log(
97-
`${"Key".padEnd(keyLength)} ${
98-
"Value".padEnd(valueLength)
99-
} ${contextTitle}`,
84+
return [
85+
envVar.key,
86+
envVar.value ?? "***",
87+
contextNames.join(", "),
88+
];
89+
},
10090
);
101-
102-
for (const env of processed) {
103-
console.log(
104-
`${env.key.padEnd(keyLength)} ${
105-
env.value.padEnd(valueLength)
106-
} ${env.contexts}`,
107-
);
108-
}
10991
});
11092

11193
export const envAddCommand = new Command<EnvCommandContext>()

main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from "./env.ts";
1717
import { createTrpcClient, getAuth } from "./auth.ts";
1818
import token_storage from "./token_storage.ts";
19-
import { sandboxCommand } from "./sandbox.ts";
19+
import { sandboxCommand } from "./sandbox/mod.ts";
2020

2121
const MINIMUM_DENO_VERSION = "2.4.2";
2222
if (

0 commit comments

Comments
 (0)