@@ -10,9 +10,34 @@ const { databasesGet, databasesListCollections, databasesList } = require("./dat
10
10
const { storageListBuckets } = require("./storage");
11
11
const { localConfig } = require("../config");
12
12
const { paginate } = require("../paginate");
13
- const { questionsPullCollection, questionsPullFunctions } = require("../questions");
13
+ const { questionsPullCollection, questionsPullFunctions, questionsPullResources } = require("../questions");
14
14
const { success, log, actionRunner, commandDescriptions } = require("../parser");
15
15
16
+ const pullResources = async ({ all, yes } = {}) => {
17
+ const actions = {
18
+ project: pullProject,
19
+ functions: pullFunctions,
20
+ collections: pullCollection,
21
+ buckets: pullBucket,
22
+ teams: pullTeam,
23
+ messages: pullMessagingTopic
24
+ }
25
+
26
+ if (all) {
27
+ for (let action of Object.values(actions)) {
28
+ await action({ all: true, yes });
29
+ }
30
+ } else {
31
+ const answers = await inquirer.prompt(questionsPullResources[0]);
32
+ answers.resources.forEach((resource) => {
33
+ const action = actions[resource];
34
+ if (action !== undefined) {
35
+ action({ all: true, yes });
36
+ }
37
+ })
38
+ }
39
+ };
40
+
16
41
const pullProject = async () => {
17
42
try {
18
43
let response = await projectsGet({
@@ -47,6 +72,7 @@ const pullFunctions = async ({ all } = {}) => {
47
72
} else {
48
73
func['path'] = `functions/${func['$id']}`;
49
74
localConfig.addFunction(func);
75
+ localFunctions.push(func);
50
76
}
51
77
52
78
const localFunction = localFunctions.find((localFunc) => localFunc['$id'] === func['$id']);
@@ -65,6 +91,10 @@ const pullFunctions = async ({ all } = {}) => {
65
91
parseOutput: false
66
92
})
67
93
94
+ if (!fs.existsSync(localFunction['path'])) {
95
+ fs.mkdirSync(localFunction['path'], { recursive: true });
96
+ }
97
+
68
98
tar.extract({
69
99
sync: true,
70
100
cwd: localFunction['path'],
@@ -169,6 +199,14 @@ const pull = new Command("pull")
169
199
helpWidth: process.stdout.columns || 80
170
200
});
171
201
202
+ pull
203
+ .command("all")
204
+ .description("Push all resource.")
205
+ .option(`--all`, `Flag to pull all functions`)
206
+ .option(`--yes`, `Flag to confirm all warnings`)
207
+ .action(actionRunner(pullResources));
208
+
209
+
172
210
pull
173
211
.command("project")
174
212
.description("Pulling your {{ spec .title | caseUcfirst }} project name, services and auth settings")
0 commit comments