@@ -2,10 +2,10 @@ const chalk = require('chalk');
2
2
const inquirer = require("inquirer");
3
3
const JSONbig = require("json-bigint")({ storeAsString: false });
4
4
const { Command } = require("commander");
5
- const { localConfig, globalConfig, KeysAttributes, KeysFunction, whitelistKeys, KeysTopics, KeysStorage, KeysTeams, } = require("../config");
5
+ const { localConfig, globalConfig, KeysAttributes, KeysFunction, whitelistKeys, KeysTopics, KeysStorage, KeysTeams, KeysCollection } = require("../config");
6
6
const { Spinner, SPINNER_ARC, SPINNER_DOTS } = require('../spinner');
7
7
const { paginate } = require('../paginate');
8
- const { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsGetEntrypoint, questionsPushCollections, questionPushChanges, questionPushChangesConfirmation , questionsPushMessagingTopics, questionsPushResources } = require("../questions");
8
+ const { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsGetEntrypoint, questionsPushCollections, questionPushChanges, questionPushChangesFix , questionsPushMessagingTopics, questionsPushResources } = require("../questions");
9
9
const { cliConfig, actionRunner, success, warn, log, hint, error, commandDescriptions, drawTable } = require("../parser");
10
10
const { proxyListRules } = require('./proxy');
11
11
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsGetDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
@@ -341,42 +341,50 @@ const awaitPools = {
341
341
}
342
342
343
343
const getConfirmation = async () => {
344
- if (!cliConfig.force) {
345
- async function fixConfirmation() {
346
- const answers = await inquirer.prompt(questionPushChangesConfirmation);
347
- if (answers.changes !== 'YES' && answers.changes !== 'NO') {
348
- return await fixConfirmation();
349
- }
350
-
351
- return answers.changes;
352
- }
344
+ if (cliConfig.force) {
345
+ return true;
346
+ }
353
347
354
- let answers = await inquirer.prompt(questionPushChanges);
348
+ async function fixConfirmation() {
349
+ const answers = await inquirer.prompt(questionPushChangesFix);
355
350
if (answers.changes !== 'YES' && answers.changes !== 'NO') {
356
- answers.changes = await fixConfirmation();
351
+ return await fixConfirmation();
357
352
}
358
353
359
- if (answers.changes === 'YES') {
360
- return true;
361
- }
354
+ return answers.changes;
355
+ }
356
+
357
+ let answers = await inquirer.prompt(questionPushChanges);
358
+
359
+ if (answers.changes !== 'YES' && answers.changes !== 'NO') {
360
+ answers.changes = await fixConfirmation();
361
+ }
362
362
363
- warn('Skipping push action. Changes were not applied.');
364
- return false ;
363
+ if (answers.changes === 'YES') {
364
+ return true ;
365
365
}
366
366
367
- return true;
367
+ warn('Skipping push action. Changes were not applied.');
368
+ return false;
369
+
368
370
};
369
371
370
- const approveChanges = async (resource, resourceGetFunction, keys, resourceName, resourcePlural, skipKeys = []) => {
372
+ const approveChanges = async (resource, resourceGetFunction, keys, resourceName, resourcePlural, skipKeys = [], secondId = '', secondResourceName = '' ) => {
371
373
log('Checking for changes ...');
372
374
const changes = [];
373
375
374
376
await Promise.all(resource.map(async (localResource) => {
375
377
try {
376
- const remoteResource = await resourceGetFunction( {
378
+ const options = {
377
379
[resourceName]: localResource['$id'],
378
380
parseOutput: false,
379
- });
381
+ };
382
+
383
+ if (secondId !== '' && secondResourceName !== '') {
384
+ options[secondResourceName] = localResource[secondId]
385
+ }
386
+
387
+ const remoteResource = await resourceGetFunction(options);
380
388
381
389
for (let [key, value] of Object.entries(whitelistKeys(remoteResource, keys))) {
382
390
if (skipKeys.includes(key)) {
@@ -1310,8 +1318,6 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
1310
1318
1311
1319
const databases = Array.from(new Set(collections.map(collection => collection['databaseId'])));
1312
1320
1313
- log('Checking for changes ...');
1314
-
1315
1321
// Parallel db actions
1316
1322
await Promise.all(databases.map(async (databaseId) => {
1317
1323
const localDatabase = localConfig.getDatabase(databaseId);
@@ -1342,6 +1348,10 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
1342
1348
}
1343
1349
}));
1344
1350
1351
+
1352
+ if (!(await approveChanges(collections, databasesGetCollection, KeysCollection, 'collectionId', 'collections', ['attributes', 'indexes'], 'databaseId', 'databaseId',))) {
1353
+ return;
1354
+ }
1345
1355
// Parallel collection actions
1346
1356
await Promise.all(collections.map(async (collection) => {
1347
1357
try {
0 commit comments