@@ -3,7 +3,7 @@ const JSONbig = require("json-bigint")({ storeAsString: false });
3
3
const { Command } = require("commander");
4
4
const { localConfig } = require("../config");
5
5
const { paginate } = require('../paginate');
6
- const { questionsDeployBuckets, questionsDeployTeams, questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections, questionsConfirmDeployCollections } = require("../questions");
6
+ const { questionsDeployResources, questionsDeployBuckets, questionsDeployTeams, questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections, questionsConfirmDeployCollections } = require("../questions");
7
7
const { actionRunner, success, log, error, commandDescriptions } = require("../parser");
8
8
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsUpdateDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
9
9
const {
@@ -227,14 +227,27 @@ const awaitPools = {
227
227
},
228
228
}
229
229
230
- const deploy = new Command("deploy")
231
- .description(commandDescriptions['deploy'])
232
- .configureHelp({
233
- helpWidth: process.stdout.columns || 80
234
- })
235
- .action(actionRunner(async (_options, command) => {
236
- command.help()
237
- }));
230
+ const deployResources = async ({ all, yes } = {}) => {
231
+ const actions = {
232
+ functions: deployFunction,
233
+ collections: deployCollection,
234
+ buckets: deployBucket,
235
+ teams: deployTeam,
236
+ messages: new Function()
237
+ }
238
+
239
+ if (all) {
240
+ Object.values(actions).forEach(action => action({ all: true, yes }));
241
+ } else {
242
+ const answers = await inquirer.prompt(questionsDeployResources[0]);
243
+ answers.resources.forEach((resource) => {
244
+ const action = actions[resource];
245
+ if (action !== undefined) {
246
+ action({ all: true, yes });
247
+ }
248
+ })
249
+ }
250
+ };
238
251
239
252
const deployFunction = async ({ functionId, all, yes } = {}) => {
240
253
let response = {};
@@ -353,15 +366,15 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
353
366
functionId: func['$id'],
354
367
parseOutput: false
355
368
}, 100, 'variables');
356
-
369
+
357
370
await Promise.all(variables.map(async variable => {
358
371
await functionsDeleteVariable({
359
372
functionId: func['$id'],
360
373
variableId: variable['$id'],
361
374
parseOutput: false
362
375
});
363
376
}));
364
-
377
+
365
378
let result = await awaitPools.wipeVariables(func['$id']);
366
379
if (!result) {
367
380
throw new Error("Variable deletion timed out.");
@@ -906,6 +919,11 @@ const deployTeam = async ({ all, yes } = {}) => {
906
919
}
907
920
}
908
921
}
922
+ const deploy = new Command("deploy")
923
+ .description(commandDescriptions['deploy'])
924
+ .option(`--all`, `Flag to deploy all resources`)
925
+ .option(`--yes`, `Flag to confirm all warnings`)
926
+ .action(actionRunner(deployResources));
909
927
910
928
deploy
911
929
.command("function")
@@ -938,4 +956,4 @@ deploy
938
956
939
957
module.exports = {
940
958
deploy
941
- }
959
+ }
0 commit comments