Skip to content

Commit 3aa0284

Browse files
Merge pull request #837 from appwrite/feat-deploy-init-everything
Push resources at bulk
2 parents e44eec0 + fdd0014 commit 3aa0284

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

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

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,27 @@ const awaitPools = {
230230
},
231231
}
232232

233-
const push = new Command("push")
234-
.description(commandDescriptions['push'])
235-
.configureHelp({
236-
helpWidth: process.stdout.columns || 80
237-
})
238-
.action(actionRunner(async (_options, command) => {
239-
command.help()
240-
}));
233+
const pushResources = async ({ all, yes } = {}) => {
234+
const actions = {
235+
functions: pushFunction,
236+
collections: pushCollection,
237+
buckets: pushBucket,
238+
teams: pushTeam,
239+
messages: pushMessagingTopic
240+
}
241+
242+
if (all) {
243+
Object.values(actions).forEach(action => action({ all: true, yes }));
244+
} else {
245+
const answers = await inquirer.prompt(questionsPushResources[0]);
246+
answers.resources.forEach((resource) => {
247+
const action = actions[resource];
248+
if (action !== undefined) {
249+
action({ all: true, yes });
250+
}
251+
})
252+
}
253+
};
241254

242255
const pushFunction = async ({ functionId, all, yes } = {}) => {
243256
let response = {};
@@ -987,6 +1000,12 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
9871000
}
9881001
}
9891002

1003+
const push = new Command("push")
1004+
.description(commandDescriptions['push'])
1005+
.option(`--all`, `Flag to push all resources`)
1006+
.option(`--yes`, `Flag to confirm all warnings`)
1007+
.action(actionRunner(pushResources));
1008+
9901009
push
9911010
.command("function")
9921011
.description("Push functions in the current directory.")

templates/cli/lib/questions.js.twig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,21 @@ const questionsLogin = [
277277
},
278278
];
279279

280+
const questionsPushResources = [
281+
{
282+
type: "checkbox",
283+
name: "resources",
284+
message: "Which resources would you like to push?",
285+
choices: [
286+
{ name: 'Functions', value: 'functions' },
287+
{ name: 'Collections', value: 'collections' },
288+
{ name: 'Buckets', value: 'buckets' },
289+
{ name: 'Teams', value: 'teams' },
290+
{ name: 'Topics', value: 'messages' }
291+
]
292+
}
293+
]
294+
280295
const questionsPushFunctions = [
281296
{
282297
type: "checkbox",
@@ -477,6 +492,7 @@ module.exports = {
477492
questionsLogin,
478493
questionsPullFunction,
479494
questionsPullCollection,
495+
questionsPushResources,
480496
questionsPushFunctions,
481497
questionsPushCollections,
482498
questionsPushBuckets,

0 commit comments

Comments
 (0)