Skip to content

Commit e2e80e6

Browse files
committed
feat(cli): Interactive questions
1 parent 01d7bc5 commit e2e80e6

File tree

1 file changed

+85
-2
lines changed

1 file changed

+85
-2
lines changed

templates/cli/lib/questions.js.twig

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,86 @@ const questionsCreateProject = [
162162
default: "unique()"
163163
}
164164
];
165+
166+
const questionsCreateBucket = [
167+
{
168+
type: "input",
169+
name: "bucket",
170+
message: "What would you like to name your bucket?",
171+
default: "My Awesome Bucket"
172+
},
173+
{
174+
type: "input",
175+
name: "id",
176+
message: "What ID would you like to have for your bucket?",
177+
default: "unique()"
178+
},
179+
{
180+
type: "list",
181+
name: "fileSecurity",
182+
message: "Enable File-Security configuring permissions for individual file",
183+
choices: ["No", "Yes"]
184+
}
185+
];
186+
187+
const questionsCreateCollection = [
188+
{
189+
type: "list",
190+
name: "database",
191+
message: "Choose the collection database",
192+
choices: async () => {
193+
const { databases } = await paginate(databasesList, { parseOutput: false }, 100, 'databases');
194+
195+
let choices = databases.map((database, idx) => {
196+
return {
197+
name: `${database.name} (${database.$id})`,
198+
value: database.$id
199+
}
200+
})
201+
202+
if (choices.length === 0) {
203+
throw new Error("No databases found. Please create one in project console.")
204+
}
205+
206+
return choices;
207+
}
208+
},
209+
{
210+
type: "input",
211+
name: "collection",
212+
message: "What would you like to name your collection?",
213+
default: "My Awesome Collection"
214+
},
215+
{
216+
type: "input",
217+
name: "id",
218+
message: "What ID would you like to have for your collection?",
219+
default: "unique()"
220+
},
221+
{
222+
type: "list",
223+
name: "documentSecurity",
224+
message: "Enable Document-Security for configuring permissions for individual documents",
225+
choices: ["No", "Yes"]
226+
}
227+
];
228+
229+
const questionsCreateMessagingTopic = [
230+
{
231+
type: "input",
232+
name: "topic",
233+
message: "What would you like to name your messaging topic?",
234+
default: "My Awesome Topic"
235+
},
236+
{
237+
type: "input",
238+
name: "id",
239+
message: "What ID would you like to have for your messaging topic?",
240+
default: "unique()"
241+
}
242+
];
243+
244+
165245
const questionsPullProject = [
166246
...questionsProject,
167247
{
@@ -222,7 +302,7 @@ const questionsPullFunction = [
222302
id: runtime['$id'],
223303
entrypoint: getEntrypoint(runtime['$id']),
224304
ignore: getIgnores(runtime['$id']),
225-
commands : getInstallCommand(runtime['$id'])
305+
commands: getInstallCommand(runtime['$id'])
226306
},
227307
}
228308
})
@@ -431,7 +511,7 @@ const questionsListFactors = [
431511
name: `Recovery code`,
432512
value: 'recoveryCode'
433513
}
434-
].filter((ch) => factors[ch.value] === true);
514+
].filter((ch) => factors[ch.value] === true);
435515

436516
return choices;
437517
}
@@ -454,6 +534,9 @@ const questionsMfaChallenge = [
454534

455535
module.exports = {
456536
questionsCreateProject,
537+
questionsCreateBucket,
538+
questionsCreateCollection,
539+
questionsCreateMessagingTopic,
457540
questionsPullProject,
458541
questionsLogin,
459542
questionsPullFunction,

0 commit comments

Comments
 (0)