@tenderprompt/cli 0.1.0

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.
package/bin/tender.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { runTenderCli } from "../dist/index.js";
4
+
5
+ function shouldReadEntrypointStdin(args) {
6
+ return (
7
+ args[0] === "artifacts" &&
8
+ args[1] === "git" &&
9
+ args[2] === "credential"
10
+ );
11
+ }
12
+
13
+ async function readEntrypointStdin() {
14
+ if (process.stdin.isTTY) {
15
+ return undefined;
16
+ }
17
+ const chunks = [];
18
+ for await (const chunk of process.stdin) {
19
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
20
+ }
21
+ return Buffer.concat(chunks).toString("utf8");
22
+ }
23
+
24
+ const args = process.argv.slice(2);
25
+ const exitCode = await runTenderCli(
26
+ args,
27
+ undefined,
28
+ shouldReadEntrypointStdin(args) ? { stdin: await readEntrypointStdin() } : undefined
29
+ );
30
+ process.exit(exitCode);
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ type TenderCliIo = {
3
+ stdout: (message: string) => void;
4
+ stderr: (message: string) => void;
5
+ };
6
+ type TenderCliRuntime = {
7
+ fetcher?: typeof fetch;
8
+ env?: Record<string, string | undefined>;
9
+ sleeper?: (milliseconds: number) => Promise<void>;
10
+ now?: () => number;
11
+ stdin?: string;
12
+ commandRunner?: (command: string, args: string[], options: {
13
+ cwd: string;
14
+ }) => Promise<TenderCommandResult>;
15
+ };
16
+ type TenderCommandResult = {
17
+ exitCode: number;
18
+ stdout: string;
19
+ stderr: string;
20
+ };
21
+ export declare function runTenderCli(args: string[], io?: TenderCliIo, runtime?: TenderCliRuntime): Promise<number>;
22
+ export {};