@@ -5,7 +5,7 @@ const { localConfig, globalConfig } = require("../config");
5
5
const { Spinner, SPINNER_ARC, SPINNER_DOTS } = require('../spinner');
6
6
const { paginate } = require('../paginate');
7
7
const { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsGetEntrypoint, questionsPushCollections, questionsConfirmPushCollections, questionsPushMessagingTopics } = require("../questions");
8
- const { actionRunner, success, log, error, commandDescriptions } = require("../parser");
8
+ const { cliConfig, actionRunner, success, log, error, commandDescriptions } = require("../parser");
9
9
const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsUpdateDeployment, functionsGetDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
10
10
const {
11
11
databasesGet,
@@ -232,7 +232,7 @@ const awaitPools = {
232
232
},
233
233
}
234
234
235
- const pushResources = async ({ all, yes } = {} ) => {
235
+ const pushResources = async () => {
236
236
const actions = {
237
237
functions: pushFunction,
238
238
collections: pushCollection,
@@ -241,27 +241,28 @@ const pushResources = async ({ all, yes } = {}) => {
241
241
messages: pushMessagingTopic
242
242
}
243
243
244
- if (all) {
245
- Object.values(actions).forEach(action => action({ all: true, yes } ));
244
+ if (cliConfig. all) {
245
+ Object.values(actions).forEach(action => action());
246
246
} else {
247
247
const answers = await inquirer.prompt(questionsPushResources[0]);
248
+
248
249
answers.resources.forEach((resource) => {
249
250
const action = actions[resource];
250
251
if (action !== undefined) {
251
- action({ all: true, yes } );
252
+ action();
252
253
}
253
254
})
254
255
}
255
256
};
256
257
257
- const pushFunction = async ({ functionId, all, yes, async } = {}) => {
258
+ const pushFunction = async ({ functionId, async } = {}) => {
258
259
let response = {};
259
260
260
261
const functionIds = [];
261
262
262
263
if (functionId) {
263
264
functionIds.push(functionId);
264
- } else if (all) {
265
+ } else if (cliConfig. all) {
265
266
const functions = localConfig.getFunctions();
266
267
if (functions.length === 0) {
267
268
throw new Error("No functions found in the current directory.");
@@ -299,7 +300,7 @@ const pushFunction = async ({ functionId, all, yes, async } = {}) => {
299
300
}
300
301
301
302
if (func.variables) {
302
- func.pushVariables = yes ;
303
+ func.pushVariables = cliConfig.force ;
303
304
304
305
try {
305
306
const { total } = await functionsListVariables({
@@ -645,12 +646,12 @@ const createAttribute = async (databaseId, collectionId, attribute) => {
645
646
}
646
647
}
647
648
648
- const pushCollection = async ({ all, yes } = {} ) => {
649
+ const pushCollection = async () => {
649
650
let response = {};
650
651
651
652
const collections = [];
652
653
653
- if (all) {
654
+ if (cliConfig. all) {
654
655
if (localConfig.getCollections().length === 0) {
655
656
throw new Error("No collections found in the current directory. Run `{{ language .params .executableName }} pull collection` to fetch all your collections.");
656
657
}
@@ -712,7 +713,7 @@ const pushCollection = async ({ all, yes } = {}) => {
712
713
713
714
log(`Collection ${collection.name} ( ${collection['$id']} ) already exists.`);
714
715
715
- if (!yes ) {
716
+ if (!cliConfig.force ) {
716
717
const answers = await inquirer.prompt(questionsPushCollections[1])
717
718
if (answers.override.toLowerCase() !== "yes") {
718
719
log(`Received "${answers.override}". Skipping ${collection.name} ( ${collection['$id']} )`);
@@ -866,13 +867,13 @@ const pushCollection = async ({ all, yes } = {}) => {
866
867
}
867
868
}
868
869
869
- const pushBucket = async ({ all, yes } = {} ) => {
870
+ const pushBucket = async () => {
870
871
let response = {};
871
872
872
873
let bucketIds = [];
873
874
const configBuckets = localConfig.getBuckets();
874
875
875
- if (all) {
876
+ if (cliConfig. all) {
876
877
if (configBuckets.length === 0) {
877
878
throw new Error("No buckets found in the current directory. Run `appwrite pull bucket` to fetch all your buckets.");
878
879
}
@@ -901,7 +902,7 @@ const pushBucket = async ({ all, yes } = {}) => {
901
902
})
902
903
log(`Bucket ${bucket.name} ( ${bucket['$id']} ) already exists.`);
903
904
904
- if (!yes ) {
905
+ if (!cliConfig.force ) {
905
906
const answers = await inquirer.prompt(questionsPushBuckets[1])
906
907
if (answers.override.toLowerCase() !== "yes") {
907
908
log(`Received "${answers.override}". Skipping ${bucket.name} ( ${bucket['$id']} )`);
@@ -953,13 +954,13 @@ const pushBucket = async ({ all, yes } = {}) => {
953
954
}
954
955
}
955
956
956
- const pushTeam = async ({ all, yes } = {} ) => {
957
+ const pushTeam = async () => {
957
958
let response = {};
958
959
959
960
let teamIds = [];
960
961
const configTeams = localConfig.getTeams();
961
962
962
- if (all) {
963
+ if (cliConfig. all) {
963
964
if (configTeams.length === 0) {
964
965
throw new Error("No teams found in the current directory. Run `appwrite pull team` to fetch all your teams.");
965
966
}
@@ -988,7 +989,7 @@ const pushTeam = async ({ all, yes } = {}) => {
988
989
})
989
990
log(`Team ${team.name} ( ${team['$id']} ) already exists.`);
990
991
991
- if (!yes ) {
992
+ if (!cliConfig.force ) {
992
993
const answers = await inquirer.prompt(questionsPushTeams[1])
993
994
if (answers.override.toLowerCase() !== "yes") {
994
995
log(`Received "${answers.override}". Skipping ${team.name} ( ${team['$id']} )`);
@@ -1023,14 +1024,14 @@ const pushTeam = async ({ all, yes } = {}) => {
1023
1024
}
1024
1025
}
1025
1026
1026
- const pushMessagingTopic = async ({ all, yes } = {} ) => {
1027
+ const pushMessagingTopic = async () => {
1027
1028
let response = {};
1028
1029
1029
1030
let topicsIds = [];
1030
1031
const configTopics = localConfig.getMessagingTopics();
1031
- let overrideExisting = yes ;
1032
+ let overrideExisting = cliConfig.force ;
1032
1033
1033
- if (all) {
1034
+ if (cliConfig. all) {
1034
1035
if (configTopics.length === 0) {
1035
1036
throw new Error("No topics found in the current directory. Run `appwrite pull topics` to pull all your messaging topics.");
1036
1037
}
@@ -1049,7 +1050,7 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
1049
1050
topics.push(...idTopic);
1050
1051
}
1051
1052
1052
- if (!yes ) {
1053
+ if (!cliConfig.force ) {
1053
1054
const answers = await inquirer.prompt(questionsPushMessagingTopics[1])
1054
1055
if (answers.override.toLowerCase() === "yes") {
1055
1056
overrideExisting = true;
@@ -1102,45 +1103,33 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
1102
1103
1103
1104
const push = new Command("push")
1104
1105
.description(commandDescriptions['push'])
1105
- .option(`--all`, `Flag to push all resources`)
1106
- .option(`--yes`, `Flag to confirm all warnings`)
1107
1106
.action(actionRunner(pushResources));
1108
1107
1109
1108
push
1110
1109
.command("function")
1111
1110
.description("Push functions in the current directory.")
1112
1111
.option(`--functionId <functionId >`, `Function ID`)
1113
- .option(`--all`, `Flag to push all functions`)
1114
- .option(`--yes`, `Flag to confirm all warnings`)
1115
1112
.option(`--async`, `Don't wait for functions deployments status`)
1116
1113
.action(actionRunner(pushFunction));
1117
1114
1118
1115
push
1119
1116
.command("collection")
1120
1117
.description("Push collections in the current project.")
1121
- .option(`--all`, `Flag to push all collections`)
1122
- .option(`--yes`, `Flag to confirm all warnings`)
1123
1118
.action(actionRunner(pushCollection));
1124
1119
1125
1120
push
1126
1121
.command("bucket")
1127
1122
.description("Push buckets in the current project.")
1128
- .option(`--all`, `Flag to push all buckets`)
1129
- .option(`--yes`, `Flag to confirm all warnings`)
1130
1123
.action(actionRunner(pushBucket));
1131
1124
1132
1125
push
1133
1126
.command("team")
1134
1127
.description("Push teams in the current project.")
1135
- .option(`--all`, `Flag to push all teams`)
1136
- .option(`--yes`, `Flag to confirm all warnings`)
1137
1128
.action(actionRunner(pushTeam));
1138
1129
1139
1130
push
1140
1131
.command("topic")
1141
1132
.description("Push messaging topics in the current project.")
1142
- .option(`--all`, `Flag to deploy all topics`)
1143
- .option(`--yes`, `Flag to confirm all warnings`)
1144
1133
.action(actionRunner(pushMessagingTopic));
1145
1134
1146
1135
module.exports = {
0 commit comments