appwrite-cli 4.2.0 → 4.2.2

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.
@@ -9,223 +9,328 @@ const { Command } = require('commander');
9
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
11
  const { localConfig, globalConfig } = require("../config");
12
+ const { File } = require('undici');
13
+ const { ReadableStream } = require('stream/web');
14
+
15
+ /**
16
+ * @param {fs.ReadStream} readStream
17
+ * @returns {ReadableStream}
18
+ */
19
+ function convertReadStreamToReadableStream(readStream) {
20
+ return new ReadableStream({
21
+ start(controller) {
22
+ readStream.on("data", (chunk) => {
23
+ controller.enqueue(chunk);
24
+ });
25
+ readStream.on("end", () => {
26
+ controller.close();
27
+ });
28
+ readStream.on("error", (err) => {
29
+ controller.error(err);
30
+ });
31
+ },
32
+ cancel() {
33
+ readStream.destroy();
34
+ },
35
+ });
36
+ }
12
37
 
13
38
  const vcs = new Command("vcs").description(commandDescriptions['vcs']).configureHelp({
14
39
  helpWidth: process.stdout.columns || 80
15
- })
16
-
40
+ })
41
+
42
+ /**
43
+ * @typedef {Object} VcsListRepositoriesRequestParams
44
+ * @property {string} installationId Installation Id
45
+ * @property {string} search Search term to filter your list results. Max length: 256 chars.
46
+ * @property {boolean} parseOutput
47
+ * @property {libClient | undefined} sdk
48
+ */
49
+
50
+ /**
51
+ * @param {VcsListRepositoriesRequestParams} params
52
+ */
17
53
  const vcsListRepositories = async ({ installationId, search, parseOutput = true, sdk = undefined}) => {
18
- /* @param {string} installationId */
19
- /* @param {string} search */
20
-
21
54
  let client = !sdk ? await sdkForProject() : sdk;
22
55
  let apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replace('{installationId}', installationId);
23
56
  let payload = {};
24
-
25
- /** Query Params */
26
57
  if (typeof search !== 'undefined') {
27
58
  payload['search'] = search;
28
59
  }
60
+
29
61
  let response = undefined;
62
+
30
63
  response = await client.call('get', apiPath, {
31
64
  'content-type': 'application/json',
32
65
  }, payload);
33
-
66
+
34
67
  if (parseOutput) {
35
68
  parse(response)
36
69
  success()
37
70
  }
71
+
38
72
  return response;
39
73
  }
40
74
 
75
+ /**
76
+ * @typedef {Object} VcsCreateRepositoryRequestParams
77
+ * @property {string} installationId Installation Id
78
+ * @property {string} name Repository name (slug)
79
+ * @property {boolean} xprivate Mark repository public or private
80
+ * @property {boolean} parseOutput
81
+ * @property {libClient | undefined} sdk
82
+ */
83
+
84
+ /**
85
+ * @param {VcsCreateRepositoryRequestParams} params
86
+ */
41
87
  const vcsCreateRepository = async ({ installationId, name, xprivate, parseOutput = true, sdk = undefined}) => {
42
- /* @param {string} installationId */
43
- /* @param {string} name */
44
- /* @param {boolean} xprivate */
45
-
46
88
  let client = !sdk ? await sdkForProject() : sdk;
47
89
  let apiPath = '/vcs/github/installations/{installationId}/providerRepositories'.replace('{installationId}', installationId);
48
90
  let payload = {};
49
-
50
- /** Body Params */
51
-
52
91
  if (typeof name !== 'undefined') {
53
92
  payload['name'] = name;
54
93
  }
55
-
56
-
57
94
  if (typeof xprivate !== 'undefined') {
58
95
  payload['private'] = xprivate;
59
96
  }
60
97
 
61
98
  let response = undefined;
99
+
62
100
  response = await client.call('post', apiPath, {
63
101
  'content-type': 'application/json',
64
102
  }, payload);
65
-
103
+
66
104
  if (parseOutput) {
67
105
  parse(response)
68
106
  success()
69
107
  }
108
+
70
109
  return response;
71
110
  }
72
111
 
112
+ /**
113
+ * @typedef {Object} VcsGetRepositoryRequestParams
114
+ * @property {string} installationId Installation Id
115
+ * @property {string} providerRepositoryId Repository Id
116
+ * @property {boolean} parseOutput
117
+ * @property {libClient | undefined} sdk
118
+ */
119
+
120
+ /**
121
+ * @param {VcsGetRepositoryRequestParams} params
122
+ */
73
123
  const vcsGetRepository = async ({ installationId, providerRepositoryId, parseOutput = true, sdk = undefined}) => {
74
- /* @param {string} installationId */
75
- /* @param {string} providerRepositoryId */
76
-
77
124
  let client = !sdk ? await sdkForProject() : sdk;
78
125
  let apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}'.replace('{installationId}', installationId).replace('{providerRepositoryId}', providerRepositoryId);
79
126
  let payload = {};
127
+
80
128
  let response = undefined;
129
+
81
130
  response = await client.call('get', apiPath, {
82
131
  'content-type': 'application/json',
83
132
  }, payload);
84
-
133
+
85
134
  if (parseOutput) {
86
135
  parse(response)
87
136
  success()
88
137
  }
138
+
89
139
  return response;
90
140
  }
91
141
 
142
+ /**
143
+ * @typedef {Object} VcsListRepositoryBranchesRequestParams
144
+ * @property {string} installationId Installation Id
145
+ * @property {string} providerRepositoryId Repository Id
146
+ * @property {boolean} parseOutput
147
+ * @property {libClient | undefined} sdk
148
+ */
149
+
150
+ /**
151
+ * @param {VcsListRepositoryBranchesRequestParams} params
152
+ */
92
153
  const vcsListRepositoryBranches = async ({ installationId, providerRepositoryId, parseOutput = true, sdk = undefined}) => {
93
- /* @param {string} installationId */
94
- /* @param {string} providerRepositoryId */
95
-
96
154
  let client = !sdk ? await sdkForProject() : sdk;
97
155
  let apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/branches'.replace('{installationId}', installationId).replace('{providerRepositoryId}', providerRepositoryId);
98
156
  let payload = {};
157
+
99
158
  let response = undefined;
159
+
100
160
  response = await client.call('get', apiPath, {
101
161
  'content-type': 'application/json',
102
162
  }, payload);
103
-
163
+
104
164
  if (parseOutput) {
105
165
  parse(response)
106
166
  success()
107
167
  }
168
+
108
169
  return response;
109
170
  }
110
171
 
172
+ /**
173
+ * @typedef {Object} VcsCreateRepositoryDetectionRequestParams
174
+ * @property {string} installationId Installation Id
175
+ * @property {string} providerRepositoryId Repository Id
176
+ * @property {string} providerRootDirectory Path to Root Directory
177
+ * @property {boolean} parseOutput
178
+ * @property {libClient | undefined} sdk
179
+ */
180
+
181
+ /**
182
+ * @param {VcsCreateRepositoryDetectionRequestParams} params
183
+ */
111
184
  const vcsCreateRepositoryDetection = async ({ installationId, providerRepositoryId, providerRootDirectory, parseOutput = true, sdk = undefined}) => {
112
- /* @param {string} installationId */
113
- /* @param {string} providerRepositoryId */
114
- /* @param {string} providerRootDirectory */
115
-
116
185
  let client = !sdk ? await sdkForProject() : sdk;
117
186
  let apiPath = '/vcs/github/installations/{installationId}/providerRepositories/{providerRepositoryId}/detection'.replace('{installationId}', installationId).replace('{providerRepositoryId}', providerRepositoryId);
118
187
  let payload = {};
119
-
120
- /** Body Params */
121
-
122
188
  if (typeof providerRootDirectory !== 'undefined') {
123
189
  payload['providerRootDirectory'] = providerRootDirectory;
124
190
  }
125
191
 
126
192
  let response = undefined;
193
+
127
194
  response = await client.call('post', apiPath, {
128
195
  'content-type': 'application/json',
129
196
  }, payload);
130
-
197
+
131
198
  if (parseOutput) {
132
199
  parse(response)
133
200
  success()
134
201
  }
202
+
135
203
  return response;
136
204
  }
137
205
 
206
+ /**
207
+ * @typedef {Object} VcsUpdateExternalDeploymentsRequestParams
208
+ * @property {string} installationId Installation Id
209
+ * @property {string} repositoryId VCS Repository Id
210
+ * @property {string} providerPullRequestId GitHub Pull Request Id
211
+ * @property {boolean} parseOutput
212
+ * @property {libClient | undefined} sdk
213
+ */
214
+
215
+ /**
216
+ * @param {VcsUpdateExternalDeploymentsRequestParams} params
217
+ */
138
218
  const vcsUpdateExternalDeployments = async ({ installationId, repositoryId, providerPullRequestId, parseOutput = true, sdk = undefined}) => {
139
- /* @param {string} installationId */
140
- /* @param {string} repositoryId */
141
- /* @param {string} providerPullRequestId */
142
-
143
219
  let client = !sdk ? await sdkForProject() : sdk;
144
220
  let apiPath = '/vcs/github/installations/{installationId}/repositories/{repositoryId}'.replace('{installationId}', installationId).replace('{repositoryId}', repositoryId);
145
221
  let payload = {};
146
-
147
- /** Body Params */
148
-
149
222
  if (typeof providerPullRequestId !== 'undefined') {
150
223
  payload['providerPullRequestId'] = providerPullRequestId;
151
224
  }
152
225
 
153
226
  let response = undefined;
227
+
154
228
  response = await client.call('patch', apiPath, {
155
229
  'content-type': 'application/json',
156
230
  }, payload);
157
-
231
+
158
232
  if (parseOutput) {
159
233
  parse(response)
160
234
  success()
161
235
  }
236
+
162
237
  return response;
163
238
  }
164
239
 
240
+ /**
241
+ * @typedef {Object} VcsListInstallationsRequestParams
242
+ * @property {string[]} 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
243
+ * @property {string} search Search term to filter your list results. Max length: 256 chars.
244
+ * @property {boolean} parseOutput
245
+ * @property {libClient | undefined} sdk
246
+ */
247
+
248
+ /**
249
+ * @param {VcsListInstallationsRequestParams} params
250
+ */
165
251
  const vcsListInstallations = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
166
- /* @param {string[]} queries */
167
- /* @param {string} search */
168
-
169
252
  let client = !sdk ? await sdkForProject() : sdk;
170
253
  let apiPath = '/vcs/installations';
171
254
  let payload = {};
172
-
173
- /** Query Params */
174
255
  if (typeof queries !== 'undefined') {
175
256
  payload['queries'] = queries;
176
257
  }
177
258
  if (typeof search !== 'undefined') {
178
259
  payload['search'] = search;
179
260
  }
261
+
180
262
  let response = undefined;
263
+
181
264
  response = await client.call('get', apiPath, {
182
265
  'content-type': 'application/json',
183
266
  }, payload);
184
-
267
+
185
268
  if (parseOutput) {
186
269
  parse(response)
187
270
  success()
188
271
  }
272
+
189
273
  return response;
190
274
  }
191
275
 
192
- const vcsGetInstallation = async ({ installationId, parseOutput = true, sdk = undefined}) => {
193
- /* @param {string} installationId */
276
+ /**
277
+ * @typedef {Object} VcsGetInstallationRequestParams
278
+ * @property {string} installationId Installation Id
279
+ * @property {boolean} parseOutput
280
+ * @property {libClient | undefined} sdk
281
+ */
194
282
 
283
+ /**
284
+ * @param {VcsGetInstallationRequestParams} params
285
+ */
286
+ const vcsGetInstallation = async ({ installationId, parseOutput = true, sdk = undefined}) => {
195
287
  let client = !sdk ? await sdkForProject() : sdk;
196
288
  let apiPath = '/vcs/installations/{installationId}'.replace('{installationId}', installationId);
197
289
  let payload = {};
290
+
198
291
  let response = undefined;
292
+
199
293
  response = await client.call('get', apiPath, {
200
294
  'content-type': 'application/json',
201
295
  }, payload);
202
-
296
+
203
297
  if (parseOutput) {
204
298
  parse(response)
205
299
  success()
206
300
  }
301
+
207
302
  return response;
208
303
  }
209
304
 
210
- const vcsDeleteInstallation = async ({ installationId, parseOutput = true, sdk = undefined}) => {
211
- /* @param {string} installationId */
305
+ /**
306
+ * @typedef {Object} VcsDeleteInstallationRequestParams
307
+ * @property {string} installationId Installation Id
308
+ * @property {boolean} parseOutput
309
+ * @property {libClient | undefined} sdk
310
+ */
212
311
 
312
+ /**
313
+ * @param {VcsDeleteInstallationRequestParams} params
314
+ */
315
+ const vcsDeleteInstallation = async ({ installationId, parseOutput = true, sdk = undefined}) => {
213
316
  let client = !sdk ? await sdkForProject() : sdk;
214
317
  let apiPath = '/vcs/installations/{installationId}'.replace('{installationId}', installationId);
215
318
  let payload = {};
319
+
216
320
  let response = undefined;
321
+
217
322
  response = await client.call('delete', apiPath, {
218
323
  'content-type': 'application/json',
219
324
  }, payload);
220
-
325
+
221
326
  if (parseOutput) {
222
327
  parse(response)
223
328
  success()
224
329
  }
330
+
225
331
  return response;
226
332
  }
227
333
 
228
-
229
334
  vcs
230
335
  .command(`listRepositories`)
231
336
  .description(``)
@@ -290,7 +395,6 @@ vcs
290
395
  .requiredOption(`--installationId <installationId>`, `Installation Id`)
291
396
  .action(actionRunner(vcsDeleteInstallation))
292
397
 
293
-
294
398
  module.exports = {
295
399
  vcs,
296
400
  vcsListRepositories,
@@ -302,4 +406,4 @@ module.exports = {
302
406
  vcsListInstallations,
303
407
  vcsGetInstallation,
304
408
  vcsDeleteInstallation
305
- };
409
+ };
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": "4.2.0",
5
+ "version": "4.2.2",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -14,15 +14,15 @@
14
14
  },
15
15
  "scripts": {
16
16
  "test": "echo \"Error: no test specified\" && exit 1",
17
- "linux-x64": "pkg -t node16-linux-x64 -o build/appwrite-cli-linux-x64 package.json",
18
- "linux-arm64": "pkg -t node16-linux-arm64 -o build/appwrite-cli-linux-arm64 package.json",
19
- "mac-x64": "pkg -t node16-macos-x64 -o build/appwrite-cli-darwin-x64 package.json",
20
- "mac-arm64": "pkg -t node16-macos-arm64 -o build/appwrite-cli-darwin-arm64 package.json",
21
- "windows-x64": "pkg -t node16-win-x64 -o build/appwrite-cli-win-x64.exe package.json",
22
- "windows-arm64": "pkg -t node16-win-arm64 -o build/appwrite-cli-win-arm64.exe package.json"
17
+ "linux-x64": "pkg -t node18-linux-x64 -o build/appwrite-cli-linux-x64 package.json",
18
+ "linux-arm64": "pkg -t node18-linux-arm64 -o build/appwrite-cli-linux-arm64 package.json",
19
+ "mac-x64": "pkg -t node18-macos-x64 -o build/appwrite-cli-darwin-x64 package.json",
20
+ "mac-arm64": "pkg -t node18-macos-arm64 -o build/appwrite-cli-darwin-arm64 package.json",
21
+ "windows-x64": "pkg -t node18-win-x64 -o build/appwrite-cli-win-x64.exe package.json",
22
+ "windows-arm64": "pkg -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe package.json"
23
23
  },
24
24
  "dependencies": {
25
- "axios": "1.5.0",
25
+ "undici": "^5.28.2",
26
26
  "chalk": "4.1.2",
27
27
  "cli-table3": "^0.6.2",
28
28
  "commander": "^9.2.0",
@@ -33,7 +33,7 @@
33
33
  "ignore": "^5.2.0"
34
34
  },
35
35
  "devDependencies": {
36
- "pkg": "5.5.1"
36
+ "pkg": "5.8.1"
37
37
  },
38
38
  "pkg": {
39
39
  "scripts": [
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
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
5
  "homepage": "https://github.com/appwrite/sdk-for-cli",
6
6
  "license": "BSD-3-Clause",
7
7
  "architecture": {
8
8
  "64bit": {
9
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.0/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.2/appwrite-cli-win-x64.exe",
10
10
  "bin": [
11
11
  [
12
12
  "appwrite-cli-win-x64.exe",
@@ -15,7 +15,7 @@
15
15
  ]
16
16
  },
17
17
  "arm64": {
18
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.0/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.2/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",