Skip to content

Commit 937b716

Browse files
committed
revert: disable prompts for now
1 parent 4a369c7 commit 937b716

33 files changed

+678
-673
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ clean:
99
rm -rf dist
1010

1111
build-node: fmt
12-
deno --unstable run -A ./cmd/build.ts
12+
deno run -A ./cmd/build.ts
1313

1414

1515
build-bin: fmt

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ Let's create a new redis database:
102102
## Interactive
103103

104104
Let's face it, nobody can remember uuids of databases. That's why `upstash` is
105-
designed to be interactive if you omit required flags. This would cause issues
106-
in non-interactive environments such as tests in CI pipelines. Interactive
107-
propmts are disabled when the environment variable `CI` or `--non-interactive`
108-
flag is set.
105+
designed to be interactive if you omit required flags. Because this would cause
106+
issues in non-interactive environments such as tests in CI pipelines, propmts
107+
are disabled when the environment variable `CI` or `--non-interactive` flag is
108+
set.
109109

110110
For example: when you omit the `--region` flag we will ask you to select one.
111111

cmd/build.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { build, emptyDir } from "https://deno.land/x/[email protected]/mod.ts";
22

33
const packageManager = "npm";
44
const outDir = "./dist";
5-
const version = Deno.args[0];
5+
const version = Deno.args[0] ?? "development";
66

77
await emptyDir(outDir);
88

@@ -17,8 +17,13 @@ await build({
1717
outDir,
1818
shims: {
1919
deno: true,
20-
crypto: true,
21-
undici: true,
20+
// undici: true,
21+
custom: [
22+
{
23+
package: { name: "node-fetch", version: "latest" },
24+
globalNames: [{ name: "fetch", exportName: "default" }],
25+
},
26+
],
2227
},
2328

2429
scriptModule: false,

src/commands/auth/login.ts

+18-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { cliffy } from "../../deps.ts";
21
import { Command } from "../../util/command.ts";
32
import { DEFAULT_CONFIG_PATH, loadConfig } from "../../config.ts";
43
export const loginCmd = new Command()
@@ -8,42 +7,42 @@ export const loginCmd = new Command()
87
This will store your email and api key in ${DEFAULT_CONFIG_PATH}.
98
you can override this with "--config=/path/to/.upstash.json"`,
109
)
11-
.arguments("[email]")
10+
.option("-e, --email=<string>", "The email you use in upstash console")
1211
.option(
13-
"-k, --apiKey=<string>",
12+
"-k, --api-key=<string>",
1413
"Management api apiKey from https://console.upstash.com/account/api",
1514
)
16-
.action(async (options, email): Promise<void> => {
15+
.action((options): void => {
1716
const config = loadConfig(options.config);
1817
if (config) {
1918
throw new Error(
2019
`You are already logged in, please log out first or delete ${options.config}`,
2120
);
2221
}
23-
22+
let email = options.upstashEmail;
2423
if (!email) {
2524
email = options.upstashEmail;
2625
}
27-
if (!email) {
28-
if (options.ci) {
29-
throw new cliffy.ValidationError("email");
30-
}
31-
email = await cliffy.Input.prompt("Enter your email");
32-
}
26+
// if (!email) {
27+
// if (options.ci) {
28+
// throw new cliffy.ValidationError("email");
29+
// }
30+
// email = await cliffy.Input.prompt("Enter your email");
31+
// }
3332

3433
let apiKey = options.upstashToken;
3534

3635
if (!apiKey) {
3736
apiKey = options.apiKey;
3837
}
39-
if (!apiKey) {
40-
if (options.ci) {
41-
throw new cliffy.ValidationError("apiKey");
42-
}
43-
apiKey = await cliffy.Secret.prompt(
44-
"Enter your apiKey from https://console.upstash.com/account/api",
45-
);
46-
}
38+
// if (!apiKey) {
39+
// if (options.ci) {
40+
// throw new cliffy.ValidationError("apiKey");
41+
// }
42+
// apiKey = await cliffy.Secret.prompt(
43+
// "Enter your apiKey from https://console.upstash.com/account/api"
44+
// );
45+
// }
4746

4847
Deno.writeTextFileSync(options.config, JSON.stringify({ email, apiKey }));
4948
});

src/commands/kafka/cluster/create.ts

+16-14
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ enum Region {
1111
export const createCmd = new Command()
1212
.name("create")
1313
.description("Create a new kafka cluster")
14-
.option("-n --name <string>", "Name of the cluster")
14+
.option("-n --name <string>", "Name of the cluster", { required: true })
1515
.type("region", new cliffy.EnumType(Region))
16-
.option("-r --region <string:region>", "Region of the database")
16+
.option("-r --region <string:region>", "Region of the database", {
17+
required: true,
18+
})
1719
.option(
1820
"--multizone-replication [boolean]",
1921
"Set true to enable multizone-replication",
@@ -33,18 +35,18 @@ export const createCmd = new Command()
3335
options.name = await cliffy.Input.prompt("Set a name for your cluster");
3436
}
3537

36-
if (!options.region) {
37-
if (options.ci) {
38-
throw new cliffy.ValidationError("region");
39-
}
40-
options.region = (await cliffy.Select.prompt({
41-
message: "Select a region",
42-
options: Object.entries(Region).map(([name, value]) => ({
43-
name,
44-
value,
45-
})),
46-
})) as Region;
47-
}
38+
// if (!options.region) {
39+
// if (options.ci) {
40+
// throw new cliffy.ValidationError("region");
41+
// }
42+
// options.region = (await cliffy.Select.prompt({
43+
// message: "Select a region",
44+
// options: Object.entries(Region).map(([name, value]) => ({
45+
// name,
46+
// value,
47+
// })),
48+
// })) as Region;
49+
// }
4850
const body: Record<string, string | number | boolean | undefined> = {
4951
name: options.name,
5052
region: options.region,

src/commands/kafka/cluster/delete.ts

+23-20
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,36 @@ import { cliffy } from "../../../deps.ts";
22
import { Command } from "../../../util/command.ts";
33
import { parseAuth } from "../../../util/auth.ts";
44
import { http } from "../../../util/http.ts";
5-
import type { Cluster } from "./types.ts";
5+
// import type { Cluster } from "./types.ts";
66

77
export const deleteCmd = new Command()
88
.name("delete")
99
.description("delete a cluster")
10-
.option("--id=<string>", "The id of your cluster")
11-
.example("Delete", `upstash kafka cluster delete ${crypto.randomUUID()}`)
10+
.option("--id=<string>", "The id of your cluster", { required: true })
11+
.example(
12+
"Delete",
13+
`upstash kafka cluster delete f860e7e2-27b8-4166-90d5-ea41e90b4809`,
14+
)
1215
.action(async (options): Promise<void> => {
1316
const authorization = await parseAuth(options);
1417

15-
if (!options.id) {
16-
if (options.ci) {
17-
throw new cliffy.ValidationError("id");
18-
}
19-
const clusters = await http.request<Cluster[]>({
20-
method: "GET",
21-
authorization,
22-
path: ["v2", "kafka", "clusters"],
23-
});
24-
options.id = await cliffy.Select.prompt({
25-
message: "Select a cluster",
26-
options: clusters.map(({ name, cluster_id }) => ({
27-
name: name,
28-
value: cluster_id,
29-
})),
30-
});
31-
}
18+
// if (!options.id) {
19+
// if (options.ci) {
20+
// throw new cliffy.ValidationError("id");
21+
// }
22+
// const clusters = await http.request<Cluster[]>({
23+
// method: "GET",
24+
// authorization,
25+
// path: ["v2", "kafka", "clusters"],
26+
// });
27+
// options.id = await cliffy.Select.prompt({
28+
// message: "Select a cluster",
29+
// options: clusters.map(({ name, cluster_id }) => ({
30+
// name: name,
31+
// value: cluster_id,
32+
// })),
33+
// });
34+
// }
3235

3336
await http.request<Response>({
3437
method: "DELETE",

src/commands/kafka/cluster/get.ts

+19-19
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ import type { Cluster } from "./types.ts";
77
export const getCmd = new Command()
88
.name("get")
99
.description("get information about a kafka clusters")
10-
.option("--id=<string>", "The id of your cluster")
11-
.example("Get", `upstash kafka cluster ${crypto.randomUUID}`)
10+
.option("--id=<string>", "The id of your cluster", { required: true })
11+
.example("Get", `upstash kafka cluster f860e7e2-27b8-4166-90d5-ea41e90b4809`)
1212
.action(async (options): Promise<void> => {
1313
const authorization = await parseAuth(options);
1414

15-
if (!options.id) {
16-
if (options.ci) {
17-
throw new cliffy.ValidationError("id");
18-
}
19-
const clusters = await http.request<Cluster[]>({
20-
method: "GET",
21-
authorization,
22-
path: ["v2", "kafka", "clusters"],
23-
});
24-
options.id = await cliffy.Select.prompt({
25-
message: "Select a cluster",
26-
options: clusters.map(({ name, cluster_id }) => ({
27-
name: name,
28-
value: cluster_id,
29-
})),
30-
});
31-
}
15+
// if (!options.id) {
16+
// if (options.ci) {
17+
// throw new cliffy.ValidationError("id");
18+
// }
19+
// const clusters = await http.request<Cluster[]>({
20+
// method: "GET",
21+
// authorization,
22+
// path: ["v2", "kafka", "clusters"],
23+
// });
24+
// options.id = await cliffy.Select.prompt({
25+
// message: "Select a cluster",
26+
// options: clusters.map(({ name, cluster_id }) => ({
27+
// name: name,
28+
// value: cluster_id,
29+
// })),
30+
// });
31+
// }
3232

3333
const cluster = await http.request<Cluster[]>({
3434
method: "GET",

src/commands/kafka/cluster/rename.ts

+26-26
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@ import { cliffy } from "../../../deps.ts";
22
import { Command } from "../../../util/command.ts";
33
import { parseAuth } from "../../../util/auth.ts";
44
import { http } from "../../../util/http.ts";
5-
import type { Cluster } from "./types.ts";
5+
// import type { Cluster } from "./types.ts";
66

77
export const renameCmd = new Command()
88
.name("rename")
99
.description("Rename a kafka cluster")
10-
.option("--id=<string>", "The id of your cluster")
11-
.option("--name=<string>", "The name of your cluster")
10+
.option("--id=<string>", "The id of your cluster", { required: true })
11+
.option("--name=<string>", "The name of your cluster", { required: true })
1212
.example(
1313
"Rename",
14-
`upstash kafka cluster rename ${crypto.randomUUID()} new-name`,
14+
`upstash kafka cluster rename f860e7e2-27b8-4166-90d5-ea41e90b4809 new-name`,
1515
)
1616
.action(async (options): Promise<void> => {
1717
const authorization = await parseAuth(options);
1818

19-
if (!options.id) {
20-
if (options.ci) {
21-
throw new cliffy.ValidationError("id");
22-
}
23-
const clusters = await http.request<Cluster[]>({
24-
method: "GET",
25-
authorization,
26-
path: ["v2", "kafka", "clusters"],
27-
});
28-
options.id = await cliffy.Select.prompt({
29-
message: "Select a cluster to rename",
30-
options: clusters.map((c) => ({
31-
name: c.name,
32-
value: c.cluster_id,
33-
})),
34-
});
35-
}
19+
// if (!options.id) {
20+
// if (options.ci) {
21+
// throw new cliffy.ValidationError("id");
22+
// }
23+
// const clusters = await http.request<Cluster[]>({
24+
// method: "GET",
25+
// authorization,
26+
// path: ["v2", "kafka", "clusters"],
27+
// });
28+
// options.id = await cliffy.Select.prompt({
29+
// message: "Select a cluster to rename",
30+
// options: clusters.map((c) => ({
31+
// name: c.name,
32+
// value: c.cluster_id,
33+
// })),
34+
// });
35+
// }
3636

37-
if (!options.name) {
38-
options.name = await cliffy.Input.prompt({
39-
message: "Choose a new name",
40-
});
41-
}
37+
// if (!options.name) {
38+
// options.name = await cliffy.Input.prompt({
39+
// message: "Choose a new name",
40+
// });
41+
// }
4242
const db = await http.request<Response>({
4343
method: "POST",
4444
authorization,

src/commands/kafka/cluster/reset_password.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@ import { cliffy } from "../../../deps.ts";
22
import { Command } from "../../../util/command.ts";
33
import { parseAuth } from "../../../util/auth.ts";
44
import { http } from "../../../util/http.ts";
5-
import type { Cluster } from "./types.ts";
5+
// import type { Cluster } from "./types.ts";
66
export const resetPasswordCmd = new Command()
77
.name("reset-password")
88
.description("reset the password of a kafka cluster")
9-
.option("--id=<string>", "The id of your cluster")
9+
.option("--id=<string>", "The id of your cluster", { required: true })
1010
.example(
1111
"Reset",
12-
`upstash kafka cluster reset-password ${crypto.randomUUID()}`,
12+
`upstash kafka cluster reset-password f860e7e2-27b8-4166-90d5-ea41e90b4809`,
1313
)
1414
.action(async (options): Promise<void> => {
1515
const authorization = await parseAuth(options);
1616

17-
if (!options.id) {
18-
if (options.ci) {
19-
throw new cliffy.ValidationError("id");
20-
}
21-
const clusters = await http.request<Cluster[]>({
22-
method: "GET",
23-
authorization,
24-
path: ["v2", "kafka", "clusters"],
25-
});
26-
options.id = await cliffy.Select.prompt({
27-
message: "Select a cluster",
28-
options: clusters.map((c) => ({
29-
name: c.name,
30-
value: c.cluster_id,
31-
})),
32-
});
33-
}
17+
// if (!options.id) {
18+
// if (options.ci) {
19+
// throw new cliffy.ValidationError("id");
20+
// }
21+
// const clusters = await http.request<Cluster[]>({
22+
// method: "GET",
23+
// authorization,
24+
// path: ["v2", "kafka", "clusters"],
25+
// });
26+
// options.id = await cliffy.Select.prompt({
27+
// message: "Select a cluster",
28+
// options: clusters.map((c) => ({
29+
// name: c.name,
30+
// value: c.cluster_id,
31+
// })),
32+
// });
33+
// }
3434

3535
const db = await http.request<Response>({
3636
method: "POST",

0 commit comments

Comments
 (0)