@@ -11,7 +11,7 @@ const { storageListBuckets } = require("./storage");
11
11
const { localConfig } = require("../config");
12
12
const { paginate } = require("../paginate");
13
13
const { questionsPullCollection, questionsPullFunctions } = require("../questions");
14
- const { success, log, actionRunner, commandDescriptions } = require("../parser");
14
+ const { cliConfig, success, log, actionRunner, commandDescriptions } = require("../parser");
15
15
16
16
const pullProject = async () => {
17
17
try {
@@ -29,10 +29,10 @@ const pullProject = async () => {
29
29
}
30
30
}
31
31
32
- const pullFunctions = async ({ all } = {} ) => {
32
+ const pullFunctions = async () => {
33
33
const localFunctions = localConfig.getFunctions();
34
34
35
- const functions = all
35
+ const functions = cliConfig. all
36
36
? (await paginate(functionsList, { parseOutput: false }, 100, 'functions')).functions
37
37
: (await inquirer.prompt(questionsPullFunctions)).functions;
38
38
@@ -76,25 +76,18 @@ const pullFunctions = async ({ all } = {}) => {
76
76
}
77
77
}
78
78
79
- const pullCollection = async ({ all, databaseId } = {} ) => {
80
- const databaseIds = [] ;
79
+ const pullCollection = async () => {
80
+ let databases = cliConfig.ids ;
81
81
82
- if (databaseId) {
83
- databaseIds.push(databaseId);
84
- } else if (all) {
85
- let allDatabases = await databasesList({
86
- parseOutput: false
87
- })
88
-
89
- databaseIds.push(...allDatabases.databases.map((d) => d.$id));
90
- }
91
-
92
- if (databaseIds.length < = 0) {
93
- let answers = await inquirer.prompt(questionsPullCollection)
94
- databaseIds.push(...answers.databases);
82
+ if (databases.length === 0) {
83
+ if (cliConfig.all) {
84
+ databases = (await paginate(databasesList, { parseOutput: false }, 100, 'databases')).databases.map(database=>database.$id);
85
+ } else{
86
+ databases = (await inquirer.prompt(questionsPullCollection)).databases;
87
+ }
95
88
}
96
89
97
- for (const databaseId of databaseIds ) {
90
+ for (const databaseId of databases ) {
98
91
const database = await databasesGet({
99
92
databaseId,
100
93
parseOutput: false
@@ -109,17 +102,18 @@ const pullCollection = async ({ all, databaseId } = {}) => {
109
102
110
103
log(`Found ${total} collections`);
111
104
112
- collections.forEach (async collection => {
105
+ collections.map (async collection => {
113
106
log(`Fetching ${collection.name} ...`);
114
107
localConfig.addCollection({
115
108
...collection,
116
109
'$createdAt': undefined,
117
- '$updatedAt': undefined,
110
+ '$updatedAt': undefined
118
111
});
119
112
});
113
+
114
+ success();
120
115
}
121
116
122
- success();
123
117
}
124
118
125
119
const pullBucket = async () => {
@@ -176,14 +170,11 @@ pull
176
170
pull
177
171
.command("functions")
178
172
.description(`Pulling your {{ spec .title | caseUcfirst }} functions`)
179
- .option(`--all`, `Flag to pull all functions`)
180
173
.action(actionRunner(pullFunctions));
181
174
182
175
pull
183
176
.command("collections")
184
177
.description("Pulling your {{ spec .title | caseUcfirst }} collections")
185
- .option(`--databaseId <databaseId >`, `Database ID`)
186
- .option(`--all`, `Flag to pull all databases`)
187
178
.action(actionRunner(pullCollection))
188
179
189
180
pull
0 commit comments