appwrite-cli 6.0.0-rc.6 → 6.0.0-rc.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +3 -3
  2. package/docs/examples/functions/create.md +1 -0
  3. package/docs/examples/functions/{download-deployment.md → get-deployment-download.md} +1 -1
  4. package/docs/examples/functions/get-template.md +2 -0
  5. package/docs/examples/functions/list-specifications.md +1 -0
  6. package/docs/examples/functions/list-templates.md +5 -0
  7. package/docs/examples/functions/update.md +1 -0
  8. package/index.js +4 -3
  9. package/install.ps1 +2 -2
  10. package/install.sh +1 -1
  11. package/lib/client.js +3 -3
  12. package/lib/commands/account.js +1 -49
  13. package/lib/commands/assistant.js +1 -2
  14. package/lib/commands/avatars.js +1 -8
  15. package/lib/commands/console.js +1 -2
  16. package/lib/commands/databases.js +1 -49
  17. package/lib/commands/functions.js +182 -45
  18. package/lib/commands/generic.js +11 -11
  19. package/lib/commands/graphql.js +1 -3
  20. package/lib/commands/health.js +1 -24
  21. package/lib/commands/init.js +14 -24
  22. package/lib/commands/locale.js +1 -9
  23. package/lib/commands/messaging.js +1 -47
  24. package/lib/commands/migrations.js +1 -17
  25. package/lib/commands/project.js +1 -7
  26. package/lib/commands/projects.js +1 -46
  27. package/lib/commands/proxy.js +1 -6
  28. package/lib/commands/pull.js +81 -41
  29. package/lib/commands/push.js +134 -60
  30. package/lib/commands/run.js +10 -12
  31. package/lib/commands/storage.js +1 -16
  32. package/lib/commands/teams.js +1 -15
  33. package/lib/commands/users.js +1 -44
  34. package/lib/commands/vcs.js +1 -11
  35. package/lib/config.js +28 -8
  36. package/lib/emulation/docker.js +1 -3
  37. package/lib/paginate.js +3 -1
  38. package/lib/parser.js +12 -15
  39. package/lib/questions.js +16 -31
  40. package/package.json +2 -2
  41. package/scoop/appwrite.json +3 -3
@@ -35,7 +35,7 @@ function convertReadStreamToReadableStream(readStream) {
35
35
  });
36
36
  }
37
37
 
38
- const health = new Command("health").description(commandDescriptions['health']).configureHelp({
38
+ const health = new Command("health").description(commandDescriptions['health'] ?? '').configureHelp({
39
39
  helpWidth: process.stdout.columns || 80
40
40
  })
41
41
 
@@ -63,7 +63,6 @@ const healthGet = async ({parseOutput = true, overrideForCli = false, sdk = unde
63
63
 
64
64
  if (parseOutput) {
65
65
  parse(response)
66
- success()
67
66
  }
68
67
 
69
68
  return response;
@@ -94,7 +93,6 @@ const healthGetAntivirus = async ({parseOutput = true, overrideForCli = false, s
94
93
 
95
94
  if (parseOutput) {
96
95
  parse(response)
97
- success()
98
96
  }
99
97
 
100
98
  return response;
@@ -125,7 +123,6 @@ const healthGetCache = async ({parseOutput = true, overrideForCli = false, sdk =
125
123
 
126
124
  if (parseOutput) {
127
125
  parse(response)
128
- success()
129
126
  }
130
127
 
131
128
  return response;
@@ -160,7 +157,6 @@ const healthGetCertificate = async ({domain,parseOutput = true, overrideForCli =
160
157
 
161
158
  if (parseOutput) {
162
159
  parse(response)
163
- success()
164
160
  }
165
161
 
166
162
  return response;
@@ -191,7 +187,6 @@ const healthGetDB = async ({parseOutput = true, overrideForCli = false, sdk = un
191
187
 
192
188
  if (parseOutput) {
193
189
  parse(response)
194
- success()
195
190
  }
196
191
 
197
192
  return response;
@@ -222,7 +217,6 @@ const healthGetPubSub = async ({parseOutput = true, overrideForCli = false, sdk
222
217
 
223
218
  if (parseOutput) {
224
219
  parse(response)
225
- success()
226
220
  }
227
221
 
228
222
  return response;
@@ -253,7 +247,6 @@ const healthGetQueue = async ({parseOutput = true, overrideForCli = false, sdk =
253
247
 
254
248
  if (parseOutput) {
255
249
  parse(response)
256
- success()
257
250
  }
258
251
 
259
252
  return response;
@@ -288,7 +281,6 @@ const healthGetQueueBuilds = async ({threshold,parseOutput = true, overrideForCl
288
281
 
289
282
  if (parseOutput) {
290
283
  parse(response)
291
- success()
292
284
  }
293
285
 
294
286
  return response;
@@ -323,7 +315,6 @@ const healthGetQueueCertificates = async ({threshold,parseOutput = true, overrid
323
315
 
324
316
  if (parseOutput) {
325
317
  parse(response)
326
- success()
327
318
  }
328
319
 
329
320
  return response;
@@ -362,7 +353,6 @@ const healthGetQueueDatabases = async ({name,threshold,parseOutput = true, overr
362
353
 
363
354
  if (parseOutput) {
364
355
  parse(response)
365
- success()
366
356
  }
367
357
 
368
358
  return response;
@@ -397,7 +387,6 @@ const healthGetQueueDeletes = async ({threshold,parseOutput = true, overrideForC
397
387
 
398
388
  if (parseOutput) {
399
389
  parse(response)
400
- success()
401
390
  }
402
391
 
403
392
  return response;
@@ -433,7 +422,6 @@ const healthGetFailedJobs = async ({name,threshold,parseOutput = true, overrideF
433
422
 
434
423
  if (parseOutput) {
435
424
  parse(response)
436
- success()
437
425
  }
438
426
 
439
427
  return response;
@@ -468,7 +456,6 @@ const healthGetQueueFunctions = async ({threshold,parseOutput = true, overrideFo
468
456
 
469
457
  if (parseOutput) {
470
458
  parse(response)
471
- success()
472
459
  }
473
460
 
474
461
  return response;
@@ -503,7 +490,6 @@ const healthGetQueueLogs = async ({threshold,parseOutput = true, overrideForCli
503
490
 
504
491
  if (parseOutput) {
505
492
  parse(response)
506
- success()
507
493
  }
508
494
 
509
495
  return response;
@@ -538,7 +524,6 @@ const healthGetQueueMails = async ({threshold,parseOutput = true, overrideForCli
538
524
 
539
525
  if (parseOutput) {
540
526
  parse(response)
541
- success()
542
527
  }
543
528
 
544
529
  return response;
@@ -573,7 +558,6 @@ const healthGetQueueMessaging = async ({threshold,parseOutput = true, overrideFo
573
558
 
574
559
  if (parseOutput) {
575
560
  parse(response)
576
- success()
577
561
  }
578
562
 
579
563
  return response;
@@ -608,7 +592,6 @@ const healthGetQueueMigrations = async ({threshold,parseOutput = true, overrideF
608
592
 
609
593
  if (parseOutput) {
610
594
  parse(response)
611
- success()
612
595
  }
613
596
 
614
597
  return response;
@@ -643,7 +626,6 @@ const healthGetQueueUsage = async ({threshold,parseOutput = true, overrideForCli
643
626
 
644
627
  if (parseOutput) {
645
628
  parse(response)
646
- success()
647
629
  }
648
630
 
649
631
  return response;
@@ -678,7 +660,6 @@ const healthGetQueueUsageDump = async ({threshold,parseOutput = true, overrideFo
678
660
 
679
661
  if (parseOutput) {
680
662
  parse(response)
681
- success()
682
663
  }
683
664
 
684
665
  return response;
@@ -713,7 +694,6 @@ const healthGetQueueWebhooks = async ({threshold,parseOutput = true, overrideFor
713
694
 
714
695
  if (parseOutput) {
715
696
  parse(response)
716
- success()
717
697
  }
718
698
 
719
699
  return response;
@@ -744,7 +724,6 @@ const healthGetStorage = async ({parseOutput = true, overrideForCli = false, sdk
744
724
 
745
725
  if (parseOutput) {
746
726
  parse(response)
747
- success()
748
727
  }
749
728
 
750
729
  return response;
@@ -775,7 +754,6 @@ const healthGetStorageLocal = async ({parseOutput = true, overrideForCli = false
775
754
 
776
755
  if (parseOutput) {
777
756
  parse(response)
778
- success()
779
757
  }
780
758
 
781
759
  return response;
@@ -806,7 +784,6 @@ const healthGetTime = async ({parseOutput = true, overrideForCli = false, sdk =
806
784
 
807
785
  if (parseOutput) {
808
786
  parse(response)
809
- success()
810
787
  }
811
788
 
812
789
  return response;
@@ -129,7 +129,7 @@ const initBucket = async () => {
129
129
  fileSecurity: answers.fileSecurity.toLowerCase() === 'yes',
130
130
  enabled: true,
131
131
  });
132
- success();
132
+ success("Initialing bucket");
133
133
  log("Next you can use 'appwrite push bucket' to deploy the changes.");
134
134
  };
135
135
 
@@ -141,7 +141,7 @@ const initTeam = async () => {
141
141
  name: answers.bucket,
142
142
  });
143
143
 
144
- success();
144
+ success("Initialing team");
145
145
  log("Next you can use 'appwrite push team' to deploy the changes.");
146
146
  };
147
147
 
@@ -174,7 +174,7 @@ const initCollection = async () => {
174
174
  enabled: true,
175
175
  });
176
176
 
177
- success();
177
+ success("Initialing collection");
178
178
  log("Next you can use 'appwrite push collection' to deploy the changes.");
179
179
  };
180
180
 
@@ -187,11 +187,13 @@ const initTopic = async () => {
187
187
 
188
188
  });
189
189
 
190
- success();
190
+ success("Initialing topic");
191
191
  log("Next you can use 'appwrite push topic' to deploy the changes.");
192
192
  };
193
193
 
194
194
  const initFunction = async () => {
195
+ process.chdir(localConfig.configDirectoryPath)
196
+
195
197
  // TODO: Add CI/CD support (ID, name, runtime)
196
198
  const answers = await inquirer.prompt(questionsCreateFunction)
197
199
  const functionFolder = path.join(process.cwd(), 'functions');
@@ -203,12 +205,13 @@ const initFunction = async () => {
203
205
  }
204
206
 
205
207
  const functionId = answers.id === 'unique()' ? ID.unique() : answers.id;
206
- const functionDir = path.join(functionFolder, functionId);
208
+ const functionName = answers.name;
209
+ const functionDir = path.join(functionFolder, functionName);
207
210
  const templatesDir = path.join(functionFolder, `${functionId}-templates`);
208
211
  const runtimeDir = path.join(templatesDir, answers.runtime.name);
209
212
 
210
213
  if (fs.existsSync(functionDir)) {
211
- throw new Error(`( ${functionId} ) already exists in the current directory. Please choose another name.`);
214
+ throw new Error(`( ${functionName} ) already exists in the current directory. Please choose another name.`);
212
215
  }
213
216
 
214
217
  if (!answers.runtime.entrypoint) {
@@ -223,21 +226,7 @@ const initFunction = async () => {
223
226
  fs.mkdirSync(templatesDir, "777");
224
227
  const repo = "https://github.com/appwrite/templates";
225
228
  const api = `https://api.github.com/repos/appwrite/templates/contents/${answers.runtime.name}`
226
- let selected = undefined;
227
-
228
- if(answers.template === 'starter') {
229
- selected = { template: 'starter' };
230
- } else {
231
- try {
232
- const res = await fetch(api);
233
- const templates = [];
234
- templates.push(...(await res.json()).map((template) => template.name));
235
- selected = await inquirer.prompt(questionsCreateFunctionSelectTemplate(templates));
236
- } catch {
237
- // Not a problem will go with directory pulling
238
- log('Loading templates...');
239
- }
240
- }
229
+ let selected = { template: 'starter' };
241
230
 
242
231
  const sparse = (selected ? `${answers.runtime.name}/${selected.template}` : answers.runtime.name).toLowerCase();
243
232
 
@@ -299,7 +288,7 @@ const initFunction = async () => {
299
288
 
300
289
  fs.rmSync(templatesDir, { recursive: true, force: true });
301
290
 
302
- const readmePath = path.join(process.cwd(), 'functions', functionId, 'README.md');
291
+ const readmePath = path.join(process.cwd(), 'functions', functionName, 'README.md');
303
292
  const readmeFile = fs.readFileSync(readmePath).toString();
304
293
  const newReadmeFile = readmeFile.split('\n');
305
294
  newReadmeFile[0] = `# ${answers.name}`;
@@ -312,6 +301,7 @@ const initFunction = async () => {
312
301
  runtime: answers.runtime.id,
313
302
  execute: [],
314
303
  events: [],
304
+ scopes: [],
315
305
  schedule: "",
316
306
  timeout: 15,
317
307
  enabled: true,
@@ -319,11 +309,11 @@ const initFunction = async () => {
319
309
  entrypoint: answers.runtime.entrypoint || '',
320
310
  commands: answers.runtime.commands || '',
321
311
  ignore: answers.runtime.ignore || null,
322
- path: `functions/${functionId}`,
312
+ path: `functions/${functionName}`,
323
313
  };
324
314
 
325
315
  localConfig.addFunction(data);
326
- success();
316
+ success("Initialing function");
327
317
  log("Next you can use 'appwrite run function' to develop a function locally. To deploy the function, use 'appwrite push function'");
328
318
  }
329
319
 
@@ -35,7 +35,7 @@ function convertReadStreamToReadableStream(readStream) {
35
35
  });
36
36
  }
37
37
 
38
- const locale = new Command("locale").description(commandDescriptions['locale']).configureHelp({
38
+ const locale = new Command("locale").description(commandDescriptions['locale'] ?? '').configureHelp({
39
39
  helpWidth: process.stdout.columns || 80
40
40
  })
41
41
 
@@ -63,7 +63,6 @@ const localeGet = async ({parseOutput = true, overrideForCli = false, sdk = unde
63
63
 
64
64
  if (parseOutput) {
65
65
  parse(response)
66
- success()
67
66
  }
68
67
 
69
68
  return response;
@@ -94,7 +93,6 @@ const localeListCodes = async ({parseOutput = true, overrideForCli = false, sdk
94
93
 
95
94
  if (parseOutput) {
96
95
  parse(response)
97
- success()
98
96
  }
99
97
 
100
98
  return response;
@@ -125,7 +123,6 @@ const localeListContinents = async ({parseOutput = true, overrideForCli = false,
125
123
 
126
124
  if (parseOutput) {
127
125
  parse(response)
128
- success()
129
126
  }
130
127
 
131
128
  return response;
@@ -156,7 +153,6 @@ const localeListCountries = async ({parseOutput = true, overrideForCli = false,
156
153
 
157
154
  if (parseOutput) {
158
155
  parse(response)
159
- success()
160
156
  }
161
157
 
162
158
  return response;
@@ -187,7 +183,6 @@ const localeListCountriesEU = async ({parseOutput = true, overrideForCli = false
187
183
 
188
184
  if (parseOutput) {
189
185
  parse(response)
190
- success()
191
186
  }
192
187
 
193
188
  return response;
@@ -218,7 +213,6 @@ const localeListCountriesPhones = async ({parseOutput = true, overrideForCli = f
218
213
 
219
214
  if (parseOutput) {
220
215
  parse(response)
221
- success()
222
216
  }
223
217
 
224
218
  return response;
@@ -249,7 +243,6 @@ const localeListCurrencies = async ({parseOutput = true, overrideForCli = false,
249
243
 
250
244
  if (parseOutput) {
251
245
  parse(response)
252
- success()
253
246
  }
254
247
 
255
248
  return response;
@@ -280,7 +273,6 @@ const localeListLanguages = async ({parseOutput = true, overrideForCli = false,
280
273
 
281
274
  if (parseOutput) {
282
275
  parse(response)
283
- success()
284
276
  }
285
277
 
286
278
  return response;