Skip to content

Commit 05df5dd

Browse files
committed
feat(cli): Interactive messaging-topic creation
1 parent 75a01c8 commit 05df5dd

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

templates/cli/lib/commands/create.js.twig

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ const { Command } = require("commander");
22
const inquirer = require("inquirer");
33
const { projectsCreate } = require("./projects");
44
const { storageCreateBucket } = require("./storage");
5+
const { messagingCreateTopic } = require("./messaging");
56
const { sdkForConsole } = require("../sdks");
67
const { localConfig } = require("../config");
7-
const { questionsCreateProject, questionsCreateBucket } = require("../questions");
8+
const { questionsCreateProject, questionsCreateBucket, questionsCreateMessagingTopic } = require("../questions");
89
const { success, error, actionRunner, commandDescriptions } = require("../parser");
910

1011
const create = new Command("create")
@@ -32,7 +33,6 @@ const createProject = async () => {
3233
success();
3334
}
3435

35-
3636
const createBucket = async () => {
3737
let response = {}
3838
const answers = await inquirer.prompt(questionsCreateBucket)
@@ -54,18 +54,37 @@ const createBucket = async () => {
5454
}
5555
};
5656

57-
const createFunction = async () => {
57+
const createCollection = async () => {
5858

5959
};
6060

61-
const createCollection = async () => {
61+
const createTopic = async () => {
62+
let response = {}
63+
const answers = await inquirer.prompt(questionsCreateMessagingTopic)
64+
if (!answers.topic || !answers.id) process.exit(1)
65+
66+
try {
67+
response = await messagingCreateTopic({
68+
topicId: answers.id,
69+
name: answers.topic,
70+
parseOutput: false
71+
})
6272

73+
{#localConfig.addMessagingTopic(response);#}
74+
success();
75+
} catch (e) {
76+
error(e.getMessage ?? 'Unknown error occurred. Please try again');
77+
}
6378
};
6479

65-
const createTopic = async () => {
80+
const createFunction = async () => {
6681

6782
};
6883

84+
85+
86+
87+
6988
create
7089
.command("project")
7190
.description("Create a new {{ spec.title|caseUcfirst }} project")

0 commit comments

Comments
 (0)