@@ -68,8 +68,9 @@ const { checkDeployConditions } = require('../utils');
68
68
const STEP_SIZE = 100; // Resources
69
69
const POLL_DEBOUNCE = 2000; // Milliseconds
70
70
const POLL_MAX_DEBOUNCE = 1800; // Times of POLL_DEBOUNCE (1 hour)
71
+ const POLL_DEFAULT_VALUE = 30;
71
72
72
- let pollMaxDebounces = 30 ;
73
+ let pollMaxDebounces = POLL_DEFAULT_VALUE ;
73
74
74
75
const changeableKeys = ['status', 'required', 'xdefault', 'elements', 'min', 'max', 'default', 'error'];
75
76
@@ -90,11 +91,13 @@ const awaitPools = {
90
91
return true;
91
92
}
92
93
93
- let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
94
- if (steps > 1 && iteration === 1) {
95
- pollMaxDebounces *= steps;
94
+ if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
95
+ let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
96
+ if (steps > 1 && iteration === 1) {
97
+ pollMaxDebounces *= steps;
96
98
97
- log('Found a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
99
+ log('Found a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
100
+ }
98
101
}
99
102
100
103
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
@@ -121,11 +124,13 @@ const awaitPools = {
121
124
return true;
122
125
}
123
126
124
- let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
125
- if (steps > 1 && iteration === 1) {
126
- pollMaxDebounces *= steps;
127
+ if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
128
+ let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
129
+ if (steps > 1 && iteration === 1) {
130
+ pollMaxDebounces *= steps;
127
131
128
- log('Found a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
132
+ log('Found a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
133
+ }
129
134
}
130
135
131
136
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
@@ -151,11 +156,13 @@ const awaitPools = {
151
156
return true;
152
157
}
153
158
154
- let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
155
- if (steps > 1 && iteration === 1) {
156
- pollMaxDebounces *= steps;
159
+ if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
160
+ let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
161
+ if (steps > 1 && iteration === 1) {
162
+ pollMaxDebounces *= steps;
157
163
158
- log('Found a large number of variables, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
164
+ log('Found a large number of variables, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
165
+ }
159
166
}
160
167
161
168
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
@@ -170,11 +177,13 @@ const awaitPools = {
170
177
return false;
171
178
}
172
179
173
- let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
174
- if (steps > 1 && iteration === 1) {
175
- pollMaxDebounces *= steps;
180
+ if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
181
+ let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
182
+ if (steps > 1 && iteration === 1) {
183
+ pollMaxDebounces *= steps;
176
184
177
- log('Found a large number of attributes to be deleted. Increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
185
+ log('Found a large number of attributes to be deleted. Increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
186
+ }
178
187
}
179
188
180
189
const { attributes } = await paginate(databasesListAttributes, {
@@ -203,11 +212,13 @@ const awaitPools = {
203
212
return false;
204
213
}
205
214
206
- let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
207
- if (steps > 1 && iteration === 1) {
208
- pollMaxDebounces *= steps;
215
+ if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
216
+ let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
217
+ if (steps > 1 && iteration === 1) {
218
+ pollMaxDebounces *= steps;
209
219
210
- log('Creating a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
220
+ log('Creating a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
221
+ }
211
222
}
212
223
213
224
const { attributes } = await paginate(databasesListAttributes, {
@@ -248,11 +259,13 @@ const awaitPools = {
248
259
return false;
249
260
}
250
261
251
- let steps = Math.max(1, Math.ceil(indexKeys.length / STEP_SIZE));
252
- if (steps > 1 && iteration === 1) {
253
- pollMaxDebounces *= steps;
262
+ if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
263
+ let steps = Math.max(1, Math.ceil(indexKeys.length / STEP_SIZE));
264
+ if (steps > 1 && iteration === 1) {
265
+ pollMaxDebounces *= steps;
254
266
255
- log('Creating a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
267
+ log('Creating a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
268
+ }
256
269
}
257
270
258
271
const { indexes } = await paginate(databasesListIndexes, {
@@ -648,7 +661,7 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection)
648
661
649
662
if (changes.length > 0) {
650
663
changedAttributes = changes.map((change) => change.attribute);
651
- await Promise.all(changedAttributes.map((changed) => updateAttribute(collection['databaseId'],collection['$id'], changed)));
664
+ await Promise.all(changedAttributes.map((changed) => updateAttribute(collection['databaseId'], collection['$id'], changed)));
652
665
}
653
666
654
667
const deletingAttributes = deleting.map((change) => change.attribute);
@@ -1024,9 +1037,9 @@ const pushFunction = async ({ functionId, async, returnOnZero } = { returnOnZero
1024
1037
});
1025
1038
1026
1039
if (!async) {
1027
- if(successfullyPushed === 0) {
1040
+ if (successfullyPushed === 0) {
1028
1041
error('No functions were pushed.');
1029
- } else if(successfullyDeployed != successfullyPushed) {
1042
+ } else if (successfullyDeployed != successfullyPushed) {
1030
1043
warn(`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} functions`)
1031
1044
} else {
1032
1045
success(`Successfully pushed ${successfullyPushed} functions.`);
@@ -1036,9 +1049,13 @@ const pushFunction = async ({ functionId, async, returnOnZero } = { returnOnZero
1036
1049
}
1037
1050
}
1038
1051
1039
- const pushCollection = async ({ returnOnZero } = { returnOnZero: false }) => {
1052
+ const pushCollection = async ({ returnOnZero, debounce } = { returnOnZero: false }) => {
1040
1053
const collections = [];
1041
1054
1055
+ if (debounce) {
1056
+ pollMaxDebounces = debounce;
1057
+ }
1058
+
1042
1059
if (cliConfig.all) {
1043
1060
checkDeployConditions(localConfig);
1044
1061
if (localConfig.getCollections().length === 0) {
@@ -1410,6 +1427,7 @@ push
1410
1427
.command("collection")
1411
1428
.alias("collections")
1412
1429
.description("Push collections in the current project.")
1430
+ .option(`-d, --debounce <maxDebounces >`, `Max number of debounces, default: 30.`)
1413
1431
.action(actionRunner(pushCollection));
1414
1432
1415
1433
push
0 commit comments