appwrite-cli 2.0.2 → 3.0.0

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 (102) hide show
  1. package/README.md +11 -6
  2. package/docs/examples/account/delete-identity.md +2 -0
  3. package/docs/examples/account/list-identities.md +2 -0
  4. package/docs/examples/assistant/chat.md +2 -0
  5. package/docs/examples/databases/create-collection.md +1 -0
  6. package/docs/examples/databases/create-string-attribute.md +1 -0
  7. package/docs/examples/databases/create.md +2 -1
  8. package/docs/examples/databases/list-attributes.md +2 -1
  9. package/docs/examples/databases/list-indexes.md +2 -1
  10. package/docs/examples/databases/update.md +2 -1
  11. package/docs/examples/functions/create-deployment.md +3 -2
  12. package/docs/examples/functions/create-execution.md +3 -0
  13. package/docs/examples/functions/create.md +12 -0
  14. package/docs/examples/functions/download-deployment.md +3 -0
  15. package/docs/examples/functions/update.md +9 -0
  16. package/docs/examples/health/get-pub-sub.md +1 -0
  17. package/docs/examples/health/get-queue.md +1 -0
  18. package/docs/examples/locale/list-codes.md +1 -0
  19. package/docs/examples/migrations/create-appwrite-migration.md +5 -0
  20. package/docs/examples/migrations/create-firebase-migration.md +3 -0
  21. package/docs/examples/migrations/create-firebase-o-auth-migration.md +3 -0
  22. package/docs/examples/migrations/create-n-host-migration.md +9 -0
  23. package/docs/examples/migrations/create-supabase-migration.md +8 -0
  24. package/docs/examples/migrations/delete-firebase-auth.md +1 -0
  25. package/docs/examples/migrations/delete.md +2 -0
  26. package/docs/examples/migrations/get-appwrite-report.md +5 -0
  27. package/docs/examples/migrations/get-firebase-report-o-auth.md +3 -0
  28. package/docs/examples/migrations/get-firebase-report.md +3 -0
  29. package/docs/examples/migrations/get-n-host-report.md +9 -0
  30. package/docs/examples/migrations/get-supabase-report.md +8 -0
  31. package/docs/examples/migrations/get.md +2 -0
  32. package/docs/examples/migrations/list-firebase-projects.md +1 -0
  33. package/docs/examples/migrations/list.md +3 -0
  34. package/docs/examples/migrations/retry.md +2 -0
  35. package/docs/examples/project/create-variable.md +3 -0
  36. package/docs/examples/project/delete-variable.md +2 -0
  37. package/docs/examples/project/get-usage.md +2 -0
  38. package/docs/examples/project/get-variable.md +2 -0
  39. package/docs/examples/project/list-variables.md +1 -0
  40. package/docs/examples/project/update-variable.md +4 -0
  41. package/docs/examples/projects/create.md +1 -1
  42. package/docs/examples/projects/delete-email-template.md +4 -0
  43. package/docs/examples/projects/delete-sms-template.md +4 -0
  44. package/docs/examples/projects/delete.md +1 -2
  45. package/docs/examples/projects/get-email-template.md +4 -0
  46. package/docs/examples/projects/get-sms-template.md +4 -0
  47. package/docs/examples/projects/update-email-template.md +9 -0
  48. package/docs/examples/projects/update-personal-data-check.md +3 -0
  49. package/docs/examples/projects/update-service-status-all.md +3 -0
  50. package/docs/examples/projects/update-sms-template.md +5 -0
  51. package/docs/examples/projects/update-smtp-configuration.md +11 -0
  52. package/docs/examples/projects/update-team.md +3 -0
  53. package/docs/examples/proxy/create-rule.md +4 -0
  54. package/docs/examples/proxy/delete-rule.md +2 -0
  55. package/docs/examples/proxy/get-rule.md +2 -0
  56. package/docs/examples/proxy/list-rules.md +3 -0
  57. package/docs/examples/proxy/update-rule-verification.md +2 -0
  58. package/docs/examples/storage/update-file.md +1 -0
  59. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +1 -1
  60. package/docs/examples/users/delete-identity.md +2 -0
  61. package/docs/examples/users/list-identities.md +3 -0
  62. package/docs/examples/users/update-labels.md +3 -0
  63. package/docs/examples/vcs/create-repository-detection.md +4 -0
  64. package/docs/examples/vcs/create-repository.md +4 -0
  65. package/docs/examples/vcs/delete-installation.md +2 -0
  66. package/docs/examples/vcs/get-installation.md +2 -0
  67. package/docs/examples/vcs/get-repository.md +3 -0
  68. package/docs/examples/vcs/list-installations.md +3 -0
  69. package/docs/examples/vcs/list-repositories.md +3 -0
  70. package/docs/examples/vcs/list-repository-branches.md +3 -0
  71. package/docs/examples/vcs/update-external-deployments.md +4 -0
  72. package/index.js +10 -0
  73. package/install.ps1 +2 -2
  74. package/install.sh +1 -1
  75. package/lib/client.js +3 -3
  76. package/lib/commands/account.js +122 -67
  77. package/lib/commands/assistant.js +53 -0
  78. package/lib/commands/avatars.js +21 -21
  79. package/lib/commands/console.js +2 -2
  80. package/lib/commands/databases.js +146 -104
  81. package/lib/commands/functions.js +277 -70
  82. package/lib/commands/generic.js +1 -0
  83. package/lib/commands/graphql.js +4 -4
  84. package/lib/commands/health.js +68 -22
  85. package/lib/commands/locale.js +37 -14
  86. package/lib/commands/migrations.js +708 -0
  87. package/lib/commands/project.js +204 -0
  88. package/lib/commands/projects.js +459 -196
  89. package/lib/commands/proxy.js +177 -0
  90. package/lib/commands/storage.js +47 -40
  91. package/lib/commands/teams.js +33 -33
  92. package/lib/commands/users.js +147 -52
  93. package/lib/commands/vcs.js +305 -0
  94. package/lib/config.js +1 -2
  95. package/lib/parser.js +2 -2
  96. package/package.json +1 -1
  97. package/scoop/appwrite.json +30 -0
  98. package/docs/examples/projects/create-domain.md +0 -3
  99. package/docs/examples/projects/delete-domain.md +0 -3
  100. package/docs/examples/projects/get-domain.md +0 -3
  101. package/docs/examples/projects/list-domains.md +0 -2
  102. package/docs/examples/projects/update-domain-verification.md +0 -3
@@ -0,0 +1,305 @@
1
+ const fs = require('fs');
2
+ const pathLib = require('path');
3
+ const tar = require("tar");
4
+ const ignore = require("ignore");
5
+ const { promisify } = require('util');
6
+ const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
8
+ const { Command } = require('commander');
9
+ const { sdkForProject, sdkForConsole } = require('../sdks')
10
+ const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
+ const { localConfig, globalConfig } = require("../config");
12
+
13
+ const vcs = new Command("vcs").description(commandDescriptions['vcs']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
16
+
17
+ const vcsListRepositories = async ({ installationId, search, parseOutput = true, sdk = undefined}) => {
18
+ /* @param {string} installationId */
19
+ /* @param {string} search */
20
+
21
+ let client = !sdk ? await sdkForProject() : sdk;
22
+ let apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replace('{installationId}', installationId);
23
+ let payload = {};
24
+
25
+ /** Query Params */
26
+ if (typeof search !== 'undefined') {
27
+ payload['search'] = search;
28
+ }
29
+ let response = undefined;
30
+ response = await client.call('get', apiPath, {
31
+ 'content-type': 'application/json',
32
+ }, payload);
33
+
34
+ if (parseOutput) {
35
+ parse(response)
36
+ success()
37
+ }
38
+ return response;
39
+ }
40
+
41
+ const vcsCreateRepository = async ({ installationId, name, xprivate, parseOutput = true, sdk = undefined}) => {
42
+ /* @param {string} installationId */
43
+ /* @param {string} name */
44
+ /* @param {boolean} xprivate */
45
+
46
+ let client = !sdk ? await sdkForProject() : sdk;
47
+ let apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replace('{installationId}', installationId);
48
+ let payload = {};
49
+
50
+ /** Body Params */
51
+
52
+ if (typeof name !== 'undefined') {
53
+ payload['name'] = name;
54
+ }
55
+
56
+
57
+ if (typeof xprivate !== 'undefined') {
58
+ payload['private'] = xprivate;
59
+ }
60
+
61
+ let response = undefined;
62
+ response = await client.call('post', apiPath, {
63
+ 'content-type': 'application/json',
64
+ }, payload);
65
+
66
+ if (parseOutput) {
67
+ parse(response)
68
+ success()
69
+ }
70
+ return response;
71
+ }
72
+
73
+ const vcsGetRepository = async ({ installationId, providerRepositoryId, parseOutput = true, sdk = undefined}) => {
74
+ /* @param {string} installationId */
75
+ /* @param {string} providerRepositoryId */
76
+
77
+ let client = !sdk ? await sdkForProject() : sdk;
78
+ let apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}'.replace('{installationId}', installationId).replace('{providerRepositoryId}', providerRepositoryId);
79
+ let payload = {};
80
+ let response = undefined;
81
+ response = await client.call('get', apiPath, {
82
+ 'content-type': 'application/json',
83
+ }, payload);
84
+
85
+ if (parseOutput) {
86
+ parse(response)
87
+ success()
88
+ }
89
+ return response;
90
+ }
91
+
92
+ const vcsListRepositoryBranches = async ({ installationId, providerRepositoryId, parseOutput = true, sdk = undefined}) => {
93
+ /* @param {string} installationId */
94
+ /* @param {string} providerRepositoryId */
95
+
96
+ let client = !sdk ? await sdkForProject() : sdk;
97
+ let apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches'.replace('{installationId}', installationId).replace('{providerRepositoryId}', providerRepositoryId);
98
+ let payload = {};
99
+ let response = undefined;
100
+ response = await client.call('get', apiPath, {
101
+ 'content-type': 'application/json',
102
+ }, payload);
103
+
104
+ if (parseOutput) {
105
+ parse(response)
106
+ success()
107
+ }
108
+ return response;
109
+ }
110
+
111
+ const vcsCreateRepositoryDetection = async ({ installationId, providerRepositoryId, providerRootDirectory, parseOutput = true, sdk = undefined}) => {
112
+ /* @param {string} installationId */
113
+ /* @param {string} providerRepositoryId */
114
+ /* @param {string} providerRootDirectory */
115
+
116
+ let client = !sdk ? await sdkForProject() : sdk;
117
+ let apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/detection'.replace('{installationId}', installationId).replace('{providerRepositoryId}', providerRepositoryId);
118
+ let payload = {};
119
+
120
+ /** Body Params */
121
+
122
+ if (typeof providerRootDirectory !== 'undefined') {
123
+ payload['providerRootDirectory'] = providerRootDirectory;
124
+ }
125
+
126
+ let response = undefined;
127
+ response = await client.call('post', apiPath, {
128
+ 'content-type': 'application/json',
129
+ }, payload);
130
+
131
+ if (parseOutput) {
132
+ parse(response)
133
+ success()
134
+ }
135
+ return response;
136
+ }
137
+
138
+ const vcsUpdateExternalDeployments = async ({ installationId, repositoryId, providerPullRequestId, parseOutput = true, sdk = undefined}) => {
139
+ /* @param {string} installationId */
140
+ /* @param {string} repositoryId */
141
+ /* @param {string} providerPullRequestId */
142
+
143
+ let client = !sdk ? await sdkForProject() : sdk;
144
+ let apiPath = '/vcs/github/installations/{installationId}/repositories/{repositoryId}'.replace('{installationId}', installationId).replace('{repositoryId}', repositoryId);
145
+ let payload = {};
146
+
147
+ /** Body Params */
148
+
149
+ if (typeof providerPullRequestId !== 'undefined') {
150
+ payload['providerPullRequestId'] = providerPullRequestId;
151
+ }
152
+
153
+ let response = undefined;
154
+ response = await client.call('patch', apiPath, {
155
+ 'content-type': 'application/json',
156
+ }, payload);
157
+
158
+ if (parseOutput) {
159
+ parse(response)
160
+ success()
161
+ }
162
+ return response;
163
+ }
164
+
165
+ const vcsListInstallations = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
166
+ /* @param {string[]} queries */
167
+ /* @param {string} search */
168
+
169
+ let client = !sdk ? await sdkForProject() : sdk;
170
+ let apiPath = '/vcs/installations';
171
+ let payload = {};
172
+
173
+ /** Query Params */
174
+ if (typeof queries !== 'undefined') {
175
+ payload['queries'] = queries;
176
+ }
177
+ if (typeof search !== 'undefined') {
178
+ payload['search'] = search;
179
+ }
180
+ let response = undefined;
181
+ response = await client.call('get', apiPath, {
182
+ 'content-type': 'application/json',
183
+ }, payload);
184
+
185
+ if (parseOutput) {
186
+ parse(response)
187
+ success()
188
+ }
189
+ return response;
190
+ }
191
+
192
+ const vcsGetInstallation = async ({ installationId, parseOutput = true, sdk = undefined}) => {
193
+ /* @param {string} installationId */
194
+
195
+ let client = !sdk ? await sdkForProject() : sdk;
196
+ let apiPath = '/vcs/installations/{installationId}'.replace('{installationId}', installationId);
197
+ let payload = {};
198
+ let response = undefined;
199
+ response = await client.call('get', apiPath, {
200
+ 'content-type': 'application/json',
201
+ }, payload);
202
+
203
+ if (parseOutput) {
204
+ parse(response)
205
+ success()
206
+ }
207
+ return response;
208
+ }
209
+
210
+ const vcsDeleteInstallation = async ({ installationId, parseOutput = true, sdk = undefined}) => {
211
+ /* @param {string} installationId */
212
+
213
+ let client = !sdk ? await sdkForProject() : sdk;
214
+ let apiPath = '/vcs/installations/{installationId}'.replace('{installationId}', installationId);
215
+ let payload = {};
216
+ let response = undefined;
217
+ response = await client.call('delete', apiPath, {
218
+ 'content-type': 'application/json',
219
+ }, payload);
220
+
221
+ if (parseOutput) {
222
+ parse(response)
223
+ success()
224
+ }
225
+ return response;
226
+ }
227
+
228
+
229
+ vcs
230
+ .command(`listRepositories`)
231
+ .description(``)
232
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
233
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
234
+ .action(actionRunner(vcsListRepositories))
235
+
236
+ vcs
237
+ .command(`createRepository`)
238
+ .description(``)
239
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
240
+ .requiredOption(`--name <name>`, `Repository name (slug)`)
241
+ .requiredOption(`--xprivate <xprivate>`, `Mark repository public or private`, parseBool)
242
+ .action(actionRunner(vcsCreateRepository))
243
+
244
+ vcs
245
+ .command(`getRepository`)
246
+ .description(``)
247
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
248
+ .requiredOption(`--providerRepositoryId <providerRepositoryId>`, `Repository Id`)
249
+ .action(actionRunner(vcsGetRepository))
250
+
251
+ vcs
252
+ .command(`listRepositoryBranches`)
253
+ .description(``)
254
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
255
+ .requiredOption(`--providerRepositoryId <providerRepositoryId>`, `Repository Id`)
256
+ .action(actionRunner(vcsListRepositoryBranches))
257
+
258
+ vcs
259
+ .command(`createRepositoryDetection`)
260
+ .description(``)
261
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
262
+ .requiredOption(`--providerRepositoryId <providerRepositoryId>`, `Repository Id`)
263
+ .option(`--providerRootDirectory <providerRootDirectory>`, `Path to Root Directory`)
264
+ .action(actionRunner(vcsCreateRepositoryDetection))
265
+
266
+ vcs
267
+ .command(`updateExternalDeployments`)
268
+ .description(``)
269
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
270
+ .requiredOption(`--repositoryId <repositoryId>`, `VCS Repository Id`)
271
+ .requiredOption(`--providerPullRequestId <providerPullRequestId>`, `GitHub Pull Request Id`)
272
+ .action(actionRunner(vcsUpdateExternalDeployments))
273
+
274
+ vcs
275
+ .command(`listInstallations`)
276
+ .description(``)
277
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: provider, organization`)
278
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
279
+ .action(actionRunner(vcsListInstallations))
280
+
281
+ vcs
282
+ .command(`getInstallation`)
283
+ .description(``)
284
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
285
+ .action(actionRunner(vcsGetInstallation))
286
+
287
+ vcs
288
+ .command(`deleteInstallation`)
289
+ .description(``)
290
+ .requiredOption(`--installationId <installationId>`, `Installation Id`)
291
+ .action(actionRunner(vcsDeleteInstallation))
292
+
293
+
294
+ module.exports = {
295
+ vcs,
296
+ vcsListRepositories,
297
+ vcsCreateRepository,
298
+ vcsGetRepository,
299
+ vcsListRepositoryBranches,
300
+ vcsCreateRepositoryDetection,
301
+ vcsUpdateExternalDeployments,
302
+ vcsListInstallations,
303
+ vcsGetInstallation,
304
+ vcsDeleteInstallation
305
+ };
package/lib/config.js CHANGED
@@ -15,7 +15,6 @@ class Config {
15
15
  const file = fs.readFileSync(this.path).toString();
16
16
  this.data = JSONbig.parse(file);
17
17
  } catch (e) {
18
- // console.log(`${this.path} not found. Empty data`);
19
18
  this.data = {};
20
19
  }
21
20
  }
@@ -25,7 +24,7 @@ class Config {
25
24
  if (!fs.existsSync(dir)) {
26
25
  fs.mkdirSync(dir, { recursive: true });
27
26
  }
28
- fs.writeFileSync(this.path, JSONbig.stringify(this.data, null, 4));
27
+ fs.writeFileSync(this.path, JSONbig.stringify(this.data, null, 4), { mode: 0o600 });
29
28
  }
30
29
 
31
30
  get(key) {
package/lib/parser.js CHANGED
@@ -23,11 +23,11 @@ const parse = (data) => {
23
23
  drawJSON(data[key]);
24
24
  }
25
25
  } else if (typeof data[key] === 'object') {
26
- if (data[key] && data[key].constructor.name === 'BigNumber') {
26
+ if (data[key]?.constructor?.name === 'BigNumber') {
27
27
  console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
28
28
  } else {
29
29
  console.log(`${chalk.yellow.bold.underline(key)}`)
30
- parse(data[key]);
30
+ drawTable([data[key]]);
31
31
  }
32
32
  } else {
33
33
  console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "appwrite-cli",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "2.0.2",
5
+ "version": "3.0.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
+ "version": "3.0.0",
4
+ "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
5
+ "homepage": "https://github.com/appwrite/sdk-for-cli",
6
+ "license": "BSD-3-Clause",
7
+ "architecture": {
8
+ "64bit": {
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/3.0.0/appwrite-cli-win-x64.exe",
10
+ "bin": [
11
+ [
12
+ "appwrite-cli-win-x64.exe",
13
+ "appwrite"
14
+ ]
15
+ ]
16
+ },
17
+ "arm64": {
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/3.0.0/appwrite-cli-win-arm64.exe",
19
+ "bin": [
20
+ [
21
+ "appwrite-cli-win-arm64.exe",
22
+ "appwrite"
23
+ ]
24
+ ]
25
+ }
26
+ },
27
+ "checkver": {
28
+ "github": "https://github.com/appwrite/sdk-for-cli"
29
+ }
30
+ }
@@ -1,3 +0,0 @@
1
- appwrite projects createDomain \
2
- --projectId [PROJECT_ID] \
3
- --domain ''
@@ -1,3 +0,0 @@
1
- appwrite projects deleteDomain \
2
- --projectId [PROJECT_ID] \
3
- --domainId [DOMAIN_ID]
@@ -1,3 +0,0 @@
1
- appwrite projects getDomain \
2
- --projectId [PROJECT_ID] \
3
- --domainId [DOMAIN_ID]
@@ -1,2 +0,0 @@
1
- appwrite projects listDomains \
2
- --projectId [PROJECT_ID]
@@ -1,3 +0,0 @@
1
- appwrite projects updateDomainVerification \
2
- --projectId [PROJECT_ID] \
3
- --domainId [DOMAIN_ID]