1
+ const _progress = require('cli-progress');
1
2
const inquirer = require("inquirer");
2
3
const JSONbig = require("json-bigint")({ storeAsString: false });
3
4
const { Command } = require("commander");
@@ -269,8 +270,17 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
269
270
return func;
270
271
});
271
272
273
+ const updatesBar = new _progress.MultiBar({
274
+ format: ` ${success('{status}')} | {function}({id})`,
275
+ hideCursor: true,
276
+ clearOnComplete: false,
277
+ stopOnComplete: true,
278
+ noTTYOutput: true
279
+ });
280
+ log('Deploying functions')
272
281
for (let func of functions) {
273
- log(`Deploying function ${func.name} ( ${func['$id']} )`)
282
+ const a = updatesBar.create(4, 0, { status: '', function: func.name, id: func['$id'] })
283
+ {# log(`Deploying function ${func.name} ( ${func['$id']} )`)#}
274
284
275
285
try {
276
286
response = await functionsGet({
@@ -281,7 +291,7 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
281
291
if (response.runtime !== func.runtime) {
282
292
throw new Error(`Runtime missmatch! (local=${func.runtime},remote=${response.runtime}) Please delete remote function or update your appwrite.json`);
283
293
}
284
-
294
+ a.increment({status:'Updating'})
285
295
response = await functionsUpdate({
286
296
functionId: func['$id'],
287
297
name: func.name,
@@ -298,6 +308,7 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
298
308
});
299
309
} catch (e) {
300
310
if (e.code == 404) {
311
+ a.increment({status:'Creating'})
301
312
log(`Function ${func.name} ( ${func['$id']} ) does not exist in the project. Creating ... `);
302
313
response = await functionsCreate({
303
314
functionId: func.$id || 'unique()',
@@ -353,15 +364,15 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
353
364
functionId: func['$id'],
354
365
parseOutput: false
355
366
}, 100, 'variables');
356
-
367
+
357
368
await Promise.all(variables.map(async variable => {
358
369
await functionsDeleteVariable({
359
370
functionId: func['$id'],
360
371
variableId: variable['$id'],
361
372
parseOutput: false
362
373
});
363
374
}));
364
-
375
+
365
376
let result = await awaitPools.wipeVariables(func['$id']);
366
377
if (!result) {
367
378
throw new Error("Variable deletion timed out.");
@@ -938,4 +949,4 @@ deploy
938
949
939
950
module.exports = {
940
951
deploy
941
- }
952
+ }
0 commit comments