@@ -188,46 +188,6 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
188
188
throw new Error(`Runtime missmatch! (local=${func.runtime},remote=${response.runtime}) Please delete remote function or update your appwrite.json`);
189
189
}
190
190
191
- if(func.variables) {
192
- // Delete existing variables
193
-
194
- // TODO: Pagination?
195
- const { variables: remoteVariables } = await functionsListVariables({
196
- functionId: func['$id'],
197
- queries: [ 'limit(100)' ],
198
- parseOutput: false
199
- });
200
-
201
- if(remoteVariables.length > 0) {
202
- if(!yes) {
203
- const variableAnswers = await inquirer.prompt(questionsDeployFunctions[1])
204
-
205
- if (variableAnswers.override !== "YES") {
206
- log(`Received "${variableAnswers.override}". Skipping ${func.name} ( ${func['$id']} )`);
207
- continue;
208
- }
209
- }
210
-
211
- await Promise.all(remoteVariables.map(async remoteVariable => {
212
- await functionsDeleteVariable({
213
- functionId: func['$id'],
214
- variableId: remoteVariable['$id'],
215
- parseOutput: false
216
- });
217
- }));
218
- }
219
-
220
- // Deploy local variables
221
- await Promise.all(Object.keys(func.variables).map(async localVariableKey => {
222
- await functionsCreateVariable({
223
- functionId: func['$id'],
224
- key: localVariableKey,
225
- value: func.variables[localVariableKey],
226
- parseOutput: false
227
- });
228
- }));
229
- }
230
-
231
191
response = await functionsUpdate({
232
192
functionId: func['$id'],
233
193
name: func.name,
@@ -264,6 +224,47 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
264
224
}
265
225
}
266
226
227
+ // Create function variables
228
+ if(func.variables) {
229
+ // Delete existing variables
230
+
231
+ // TODO: Pagination?
232
+ const { variables: remoteVariables } = await functionsListVariables({
233
+ functionId: func['$id'],
234
+ queries: [ 'limit(100)' ],
235
+ parseOutput: false
236
+ });
237
+
238
+ if(remoteVariables.length > 0) {
239
+ if(!yes) {
240
+ const variableAnswers = await inquirer.prompt(questionsDeployFunctions[1])
241
+
242
+ if (variableAnswers.override !== "YES") {
243
+ log(`Received "${variableAnswers.override}". Skipping ${func.name} ( ${func['$id']} )`);
244
+ continue;
245
+ }
246
+ }
247
+
248
+ await Promise.all(remoteVariables.map(async remoteVariable => {
249
+ await functionsDeleteVariable({
250
+ functionId: func['$id'],
251
+ variableId: remoteVariable['$id'],
252
+ parseOutput: false
253
+ });
254
+ }));
255
+ }
256
+
257
+ // Deploy local variables
258
+ await Promise.all(Object.keys(func.variables).map(async localVariableKey => {
259
+ await functionsCreateVariable({
260
+ functionId: func['$id'],
261
+ key: localVariableKey,
262
+ value: func.variables[localVariableKey],
263
+ parseOutput: false
264
+ });
265
+ }));
266
+ }
267
+
267
268
// Create tag
268
269
if (!func.entrypoint) {
269
270
answers = await inquirer.prompt(questionsGetEntrypoint)
0 commit comments