1
1
const { Command } = require("commander");
2
2
const inquirer = require("inquirer");
3
3
const { projectsCreate } = require("./projects");
4
+ const { storageCreateBucket } = require("./storage");
4
5
const { sdkForConsole } = require("../sdks");
5
6
const { localConfig } = require("../config");
6
- const { questionsCreateProject } = require("../questions");
7
- const { success, actionRunner, commandDescriptions } = require("../parser");
7
+ const { questionsCreateProject, questionsCreateBucket } = require("../questions");
8
+ const { success, error, actionRunner, commandDescriptions } = require("../parser");
8
9
9
10
const create = new Command("create")
10
11
.description(commandDescriptions['create'])
@@ -31,11 +32,65 @@ const createProject = async () => {
31
32
success();
32
33
}
33
34
35
+
36
+ const createBucket = async () => {
37
+ let response = {}
38
+ const answers = await inquirer.prompt(questionsCreateBucket)
39
+ if (!answers.bucket || !answers.id || !answers.fileSecurity) process.exit(1)
40
+
41
+ try {
42
+ response = await storageCreateBucket({
43
+ bucketId: answers.id,
44
+ name: answers.bucket,
45
+ fileSecurity: answers.fileSecurity.toLowerCase() === 'yes',
46
+ enabled: true,
47
+ parseOutput: false
48
+ })
49
+
50
+ localConfig.addBucket(response);
51
+ success();
52
+ } catch (e) {
53
+ error(e.getMessage ?? 'Unknown error occurred. Please try again');
54
+ }
55
+ };
56
+
57
+ const createFunction = async () => {
58
+
59
+ };
60
+
61
+ const createCollection = async () => {
62
+
63
+ };
64
+
65
+ const createTopic = async () => {
66
+
67
+ };
68
+
34
69
create
35
70
.command("project")
36
71
.description("Create a new {{ spec .title | caseUcfirst }} project")
37
72
.action(actionRunner(createProject));
38
73
74
+ create
75
+ .command("function")
76
+ .description("Create a new {{ spec .title | caseUcfirst }} function")
77
+ .action(actionRunner(createFunction));
78
+
79
+ create
80
+ .command("bucket")
81
+ .description("Create a new {{ spec .title | caseUcfirst }} bucket")
82
+ .action(actionRunner(createBucket));
83
+
84
+ create
85
+ .command("collection")
86
+ .description("Create a new {{ spec .title | caseUcfirst }} collection")
87
+ .action(actionRunner(createCollection));
88
+
89
+ create
90
+ .command("topic")
91
+ .description("Create a new {{ spec .title | caseUcfirst }} topic")
92
+ .action(actionRunner(createTopic));
93
+
39
94
module.exports = {
40
95
create,
41
96
};
0 commit comments