@@ -5,9 +5,8 @@ const { Command } = require("commander");
5
5
const { localConfig, globalConfig } = 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, questionsConfirmPushCollections, questionsPushMessagingTopics } = require("../questions");
9
- const { actionRunner, success, log, error, commandDescriptions, drawTable } = require("../parser");
10
- const { cliConfig, actionRunner, success, log, error, commandDescriptions } = require("../parser");
8
+ const { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsGetEntrypoint, questionsPushCollections, questionsConfirmPushCollections, questionsPushMessagingTopics, questionsPushResources } = require("../questions");
9
+ const { cliConfig, actionRunner, success, log, error, commandDescriptions, drawTable } = require("../parser");
11
10
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsUpdateDeployment, functionsGetDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
12
11
const {
13
12
databasesGet,
@@ -29,7 +28,6 @@ const {
29
28
databasesDeleteAttribute,
30
29
databasesListAttributes,
31
30
databasesListIndexes,
32
- databasesDeleteIndex,
33
31
databasesUpdateCollection
34
32
} = require("./databases");
35
33
const {
@@ -376,7 +374,7 @@ const pushFunction = async ({ functionId, async } = {}) => {
376
374
if (functions.length === 0) {
377
375
throw new Error("No functions found in the current directory.");
378
376
}
379
- functionIds.push(...functions.map((func, idx ) => {
377
+ functionIds.push(...functions.map((func) => {
380
378
return func.$id;
381
379
}));
382
380
}
@@ -480,7 +478,7 @@ const pushFunction = async ({ functionId, async } = {}) => {
480
478
});
481
479
} catch (e) {
482
480
483
- if (e.code == 404) {
481
+ if (Number( e.code) = == 404) {
484
482
functionExists = false;
485
483
} else {
486
484
updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' });
@@ -835,15 +833,19 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection)
835
833
if (changing.length === 0) {
836
834
return changedAttributes;
837
835
}
838
- log('There are pending changes in your collection deployment');
836
+
837
+ log(!cliConfig.force ? 'There are pending changes in your collection deployment' : 'List of applied changes');
838
+
839
839
drawTable(changing.map((change) => {
840
840
return { Key: change.key, Action: change.action, Reason: change.reason, };
841
841
}));
842
842
843
- const answers = await inquirer.prompt(questionsPushCollections[1]);
843
+ if (!cliConfig.force) {
844
+ const answers = await inquirer.prompt(questionsPushCollections[1]);
844
845
845
- if (answers.changes.toLowerCase() !== 'yes') {
846
- return changedAttributes;
846
+ if (answers.changes.toLowerCase() !== 'yes') {
847
+ return changedAttributes;
848
+ }
847
849
}
848
850
849
851
if (conflicts.length > 0) {
@@ -888,6 +890,7 @@ const pushCollection = async () => {
888
890
})
889
891
}
890
892
const databases = Array.from(new Set(collections.map(collection => collection['databaseId'])));
893
+ log('Checking for databases and collection changes');
891
894
892
895
// Parallel db actions
893
896
await Promise.all(databases.map(async (databaseId) => {
@@ -926,15 +929,13 @@ const pushCollection = async () => {
926
929
databaseId: collection['databaseId'],
927
930
collectionId: collection['$id'],
928
931
parseOutput: false,
929
- });
930
932
});
931
933
932
934
if (remoteCollection.name !== collection.name) {
933
935
await databasesUpdateCollection({
934
936
databaseId: collection['databaseId'],
935
937
collectionId: collection['$id'],
936
938
name: collection.name,
937
- name: collection.name,
938
939
parseOutput: false
939
940
})
940
941
@@ -944,7 +945,7 @@ const pushCollection = async () => {
944
945
945
946
collection.isExisted = true;
946
947
} catch (e) {
947
- if (e.code == 404) {
948
+ if (Number( e.code) = == 404) {
948
949
log(`Collection ${collection.name} does not exist in the project. Creating ... `);
949
950
await databasesCreateCollection({
950
951
databaseId: collection['databaseId'],
@@ -1092,7 +1093,6 @@ const pushBucket = async () => {
1092
1093
enabled: bucket.enabled,
1093
1094
maximumFileSize: bucket.maximumFileSize,
1094
1095
allowedFileExtensions: bucket.allowedFileExtensions,
1095
- compression: bucket.compression,
1096
1096
encryption: bucket.encryption,
1097
1097
antivirus: bucket.antivirus,
1098
1098
compression: bucket.compression,
@@ -1101,7 +1101,7 @@ const pushBucket = async () => {
1101
1101
1102
1102
success(`Pushed ${bucket.name} ( ${bucket['$id']} )`);
1103
1103
} catch (e) {
1104
- if (e.code == 404) {
1104
+ if (Number( e.code) = == 404) {
1105
1105
log(`Bucket ${bucket.name} does not exist in the project. Creating ... `);
1106
1106
1107
1107
response = await storageCreateBucket({
@@ -1172,15 +1172,15 @@ const pushTeam = async () => {
1172
1172
1173
1173
log(`Updating team ...`)
1174
1174
1175
- await teamsUpdate ({
1175
+ await teamsUpdateName ({
1176
1176
teamId: team['$id'],
1177
1177
name: team.name,
1178
1178
parseOutput: false
1179
1179
});
1180
1180
1181
1181
success(`Pushed ${team.name} ( ${team['$id']} )`);
1182
1182
} catch (e) {
1183
- if (e.code == 404) {
1183
+ if (Number( e.code) = == 404) {
1184
1184
log(`Team ${team.name} does not exist in the project. Creating ... `);
1185
1185
1186
1186
response = await teamsCreate({
@@ -1257,7 +1257,7 @@ const pushMessagingTopic = async () => {
1257
1257
1258
1258
success(`Pushed ${topic.name} ( ${topic['$id']} )`);
1259
1259
} catch (e) {
1260
- if (e.code == 404) {
1260
+ if (Number( e.code) = == 404) {
1261
1261
log(`Topic ${topic.name} does not exist in the project. Creating ... `);
1262
1262
1263
1263
response = await messagingCreateTopic({
0 commit comments