appwrite-cli 5.0.5 → 6.0.0-rc.1
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.
- package/README.md +4 -4
- package/docs/examples/functions/create-build.md +1 -1
- package/docs/examples/functions/create-execution.md +1 -0
- package/docs/examples/functions/create.md +1 -0
- package/docs/examples/functions/delete-execution.md +3 -0
- package/docs/examples/functions/update-deployment-build.md +3 -0
- package/docs/examples/functions/update.md +1 -0
- package/docs/examples/projects/create-j-w-t.md +4 -0
- package/docs/examples/projects/update-mock-numbers.md +3 -0
- package/docs/examples/projects/update-session-alerts.md +3 -0
- package/docs/examples/users/create-j-w-t.md +4 -0
- package/docs/examples/vcs/get-repository-contents.md +4 -0
- package/index.js +34 -7
- package/install.ps1 +3 -3
- package/install.sh +2 -2
- package/lib/client.js +17 -3
- package/lib/commands/account.js +306 -152
- package/lib/commands/assistant.js +8 -5
- package/lib/commands/avatars.js +114 -58
- package/lib/commands/console.js +8 -5
- package/lib/commands/databases.js +353 -164
- package/lib/commands/functions.js +310 -100
- package/lib/commands/generic.js +206 -54
- package/lib/commands/graphql.js +14 -8
- package/lib/commands/health.js +140 -71
- package/lib/commands/init.js +250 -155
- package/lib/commands/locale.js +50 -26
- package/lib/commands/messaging.js +334 -156
- package/lib/commands/migrations.js +98 -50
- package/lib/commands/project.js +38 -20
- package/lib/commands/projects.js +449 -144
- package/lib/commands/proxy.js +32 -17
- package/lib/commands/pull.js +231 -0
- package/lib/commands/push.js +1518 -0
- package/lib/commands/run.js +282 -0
- package/lib/commands/storage.js +160 -76
- package/lib/commands/teams.js +102 -50
- package/lib/commands/users.js +324 -134
- package/lib/commands/vcs.js +102 -29
- package/lib/config.js +190 -18
- package/lib/emulation/docker.js +187 -0
- package/lib/emulation/utils.js +177 -0
- package/lib/id.js +30 -0
- package/lib/paginate.js +1 -2
- package/lib/parser.js +69 -12
- package/lib/questions.js +452 -80
- package/lib/sdks.js +1 -1
- package/lib/spinner.js +103 -0
- package/lib/utils.js +242 -4
- package/lib/validations.js +17 -0
- package/package.json +6 -2
- package/scoop/appwrite.json +3 -3
- package/lib/commands/deploy.js +0 -940
|
@@ -4,7 +4,7 @@ const tar = require("tar");
|
|
|
4
4
|
const ignore = require("ignore");
|
|
5
5
|
const { promisify } = require('util');
|
|
6
6
|
const libClient = require('../client.js');
|
|
7
|
-
const { getAllFiles } = require('../utils.js');
|
|
7
|
+
const { getAllFiles, showConsoleLink } = require('../utils.js');
|
|
8
8
|
const { Command } = require('commander');
|
|
9
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -42,6 +42,7 @@ const assistant = new Command("assistant").description(commandDescriptions['assi
|
|
|
42
42
|
/**
|
|
43
43
|
* @typedef {Object} AssistantChatRequestParams
|
|
44
44
|
* @property {string} prompt Prompt. A string containing questions asked to the AI assistant.
|
|
45
|
+
* @property {boolean} overrideForCli
|
|
45
46
|
* @property {boolean} parseOutput
|
|
46
47
|
* @property {libClient | undefined} sdk
|
|
47
48
|
*/
|
|
@@ -49,8 +50,9 @@ const assistant = new Command("assistant").description(commandDescriptions['assi
|
|
|
49
50
|
/**
|
|
50
51
|
* @param {AssistantChatRequestParams} params
|
|
51
52
|
*/
|
|
52
|
-
const assistantChat = async ({
|
|
53
|
-
let client = !sdk ? await sdkForProject() :
|
|
53
|
+
const assistantChat = async ({prompt,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
54
|
+
let client = !sdk ? await sdkForProject() :
|
|
55
|
+
sdk;
|
|
54
56
|
let apiPath = '/console/assistant';
|
|
55
57
|
let payload = {};
|
|
56
58
|
if (typeof prompt !== 'undefined') {
|
|
@@ -67,8 +69,9 @@ const assistantChat = async ({ prompt, parseOutput = true, sdk = undefined}) =>
|
|
|
67
69
|
parse(response)
|
|
68
70
|
success()
|
|
69
71
|
}
|
|
70
|
-
|
|
72
|
+
|
|
71
73
|
return response;
|
|
74
|
+
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
assistant
|
|
@@ -80,4 +83,4 @@ assistant
|
|
|
80
83
|
module.exports = {
|
|
81
84
|
assistant,
|
|
82
85
|
assistantChat
|
|
83
|
-
};
|
|
86
|
+
};
|
package/lib/commands/avatars.js
CHANGED
|
@@ -4,7 +4,7 @@ const tar = require("tar");
|
|
|
4
4
|
const ignore = require("ignore");
|
|
5
5
|
const { promisify } = require('util');
|
|
6
6
|
const libClient = require('../client.js');
|
|
7
|
-
const { getAllFiles } = require('../utils.js');
|
|
7
|
+
const { getAllFiles, showConsoleLink } = require('../utils.js');
|
|
8
8
|
const { Command } = require('commander');
|
|
9
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -45,6 +45,7 @@ const avatars = new Command("avatars").description(commandDescriptions['avatars'
|
|
|
45
45
|
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
46
46
|
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
47
47
|
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
48
|
+
* @property {boolean} overrideForCli
|
|
48
49
|
* @property {boolean} parseOutput
|
|
49
50
|
* @property {libClient | undefined} sdk
|
|
50
51
|
* @property {string} destination
|
|
@@ -53,8 +54,9 @@ const avatars = new Command("avatars").description(commandDescriptions['avatars'
|
|
|
53
54
|
/**
|
|
54
55
|
* @param {AvatarsGetBrowserRequestParams} params
|
|
55
56
|
*/
|
|
56
|
-
const avatarsGetBrowser = async ({
|
|
57
|
-
let client = !sdk ? await sdkForProject() :
|
|
57
|
+
const avatarsGetBrowser = async ({code,width,height,quality,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
58
|
+
let client = !sdk ? await sdkForProject() :
|
|
59
|
+
sdk;
|
|
58
60
|
let apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
|
|
59
61
|
let payload = {};
|
|
60
62
|
if (typeof width !== 'undefined') {
|
|
@@ -66,10 +68,12 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
|
|
|
66
68
|
if (typeof quality !== 'undefined') {
|
|
67
69
|
payload['quality'] = quality;
|
|
68
70
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
if (!overrideForCli) {
|
|
72
|
+
payload['project'] = localConfig.getProject().projectId
|
|
73
|
+
payload['key'] = globalConfig.getKey();
|
|
74
|
+
const queryParams = new URLSearchParams(payload);
|
|
75
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
76
|
+
}
|
|
73
77
|
|
|
74
78
|
let response = undefined;
|
|
75
79
|
|
|
@@ -77,14 +81,18 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
|
|
|
77
81
|
'content-type': 'application/json',
|
|
78
82
|
}, payload, 'arraybuffer');
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
if (overrideForCli) {
|
|
85
|
+
response = Buffer.from(response);
|
|
86
|
+
}
|
|
81
87
|
|
|
88
|
+
fs.writeFileSync(destination, response);
|
|
82
89
|
if (parseOutput) {
|
|
83
90
|
parse(response)
|
|
84
91
|
success()
|
|
85
92
|
}
|
|
86
|
-
|
|
93
|
+
|
|
87
94
|
return response;
|
|
95
|
+
|
|
88
96
|
}
|
|
89
97
|
|
|
90
98
|
/**
|
|
@@ -93,6 +101,7 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
|
|
|
93
101
|
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
94
102
|
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
95
103
|
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
104
|
+
* @property {boolean} overrideForCli
|
|
96
105
|
* @property {boolean} parseOutput
|
|
97
106
|
* @property {libClient | undefined} sdk
|
|
98
107
|
* @property {string} destination
|
|
@@ -101,8 +110,9 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
|
|
|
101
110
|
/**
|
|
102
111
|
* @param {AvatarsGetCreditCardRequestParams} params
|
|
103
112
|
*/
|
|
104
|
-
const avatarsGetCreditCard = async ({
|
|
105
|
-
let client = !sdk ? await sdkForProject() :
|
|
113
|
+
const avatarsGetCreditCard = async ({code,width,height,quality,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
114
|
+
let client = !sdk ? await sdkForProject() :
|
|
115
|
+
sdk;
|
|
106
116
|
let apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
|
|
107
117
|
let payload = {};
|
|
108
118
|
if (typeof width !== 'undefined') {
|
|
@@ -114,10 +124,12 @@ const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput
|
|
|
114
124
|
if (typeof quality !== 'undefined') {
|
|
115
125
|
payload['quality'] = quality;
|
|
116
126
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
if (!overrideForCli) {
|
|
128
|
+
payload['project'] = localConfig.getProject().projectId
|
|
129
|
+
payload['key'] = globalConfig.getKey();
|
|
130
|
+
const queryParams = new URLSearchParams(payload);
|
|
131
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
132
|
+
}
|
|
121
133
|
|
|
122
134
|
let response = undefined;
|
|
123
135
|
|
|
@@ -125,19 +137,24 @@ const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput
|
|
|
125
137
|
'content-type': 'application/json',
|
|
126
138
|
}, payload, 'arraybuffer');
|
|
127
139
|
|
|
128
|
-
|
|
140
|
+
if (overrideForCli) {
|
|
141
|
+
response = Buffer.from(response);
|
|
142
|
+
}
|
|
129
143
|
|
|
144
|
+
fs.writeFileSync(destination, response);
|
|
130
145
|
if (parseOutput) {
|
|
131
146
|
parse(response)
|
|
132
147
|
success()
|
|
133
148
|
}
|
|
134
|
-
|
|
149
|
+
|
|
135
150
|
return response;
|
|
151
|
+
|
|
136
152
|
}
|
|
137
153
|
|
|
138
154
|
/**
|
|
139
155
|
* @typedef {Object} AvatarsGetFaviconRequestParams
|
|
140
156
|
* @property {string} url Website URL which you want to fetch the favicon from.
|
|
157
|
+
* @property {boolean} overrideForCli
|
|
141
158
|
* @property {boolean} parseOutput
|
|
142
159
|
* @property {libClient | undefined} sdk
|
|
143
160
|
* @property {string} destination
|
|
@@ -146,17 +163,20 @@ const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput
|
|
|
146
163
|
/**
|
|
147
164
|
* @param {AvatarsGetFaviconRequestParams} params
|
|
148
165
|
*/
|
|
149
|
-
const avatarsGetFavicon = async ({
|
|
150
|
-
let client = !sdk ? await sdkForProject() :
|
|
166
|
+
const avatarsGetFavicon = async ({url,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
167
|
+
let client = !sdk ? await sdkForProject() :
|
|
168
|
+
sdk;
|
|
151
169
|
let apiPath = '/avatars/favicon';
|
|
152
170
|
let payload = {};
|
|
153
171
|
if (typeof url !== 'undefined') {
|
|
154
172
|
payload['url'] = url;
|
|
155
173
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
174
|
+
if (!overrideForCli) {
|
|
175
|
+
payload['project'] = localConfig.getProject().projectId
|
|
176
|
+
payload['key'] = globalConfig.getKey();
|
|
177
|
+
const queryParams = new URLSearchParams(payload);
|
|
178
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
179
|
+
}
|
|
160
180
|
|
|
161
181
|
let response = undefined;
|
|
162
182
|
|
|
@@ -164,14 +184,18 @@ const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, des
|
|
|
164
184
|
'content-type': 'application/json',
|
|
165
185
|
}, payload, 'arraybuffer');
|
|
166
186
|
|
|
167
|
-
|
|
187
|
+
if (overrideForCli) {
|
|
188
|
+
response = Buffer.from(response);
|
|
189
|
+
}
|
|
168
190
|
|
|
191
|
+
fs.writeFileSync(destination, response);
|
|
169
192
|
if (parseOutput) {
|
|
170
193
|
parse(response)
|
|
171
194
|
success()
|
|
172
195
|
}
|
|
173
|
-
|
|
196
|
+
|
|
174
197
|
return response;
|
|
198
|
+
|
|
175
199
|
}
|
|
176
200
|
|
|
177
201
|
/**
|
|
@@ -180,6 +204,7 @@ const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, des
|
|
|
180
204
|
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
181
205
|
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
182
206
|
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
207
|
+
* @property {boolean} overrideForCli
|
|
183
208
|
* @property {boolean} parseOutput
|
|
184
209
|
* @property {libClient | undefined} sdk
|
|
185
210
|
* @property {string} destination
|
|
@@ -188,8 +213,9 @@ const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, des
|
|
|
188
213
|
/**
|
|
189
214
|
* @param {AvatarsGetFlagRequestParams} params
|
|
190
215
|
*/
|
|
191
|
-
const avatarsGetFlag = async ({
|
|
192
|
-
let client = !sdk ? await sdkForProject() :
|
|
216
|
+
const avatarsGetFlag = async ({code,width,height,quality,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
217
|
+
let client = !sdk ? await sdkForProject() :
|
|
218
|
+
sdk;
|
|
193
219
|
let apiPath = '/avatars/flags/{code}'.replace('{code}', code);
|
|
194
220
|
let payload = {};
|
|
195
221
|
if (typeof width !== 'undefined') {
|
|
@@ -201,10 +227,12 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
|
|
|
201
227
|
if (typeof quality !== 'undefined') {
|
|
202
228
|
payload['quality'] = quality;
|
|
203
229
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
230
|
+
if (!overrideForCli) {
|
|
231
|
+
payload['project'] = localConfig.getProject().projectId
|
|
232
|
+
payload['key'] = globalConfig.getKey();
|
|
233
|
+
const queryParams = new URLSearchParams(payload);
|
|
234
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
235
|
+
}
|
|
208
236
|
|
|
209
237
|
let response = undefined;
|
|
210
238
|
|
|
@@ -212,14 +240,18 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
|
|
|
212
240
|
'content-type': 'application/json',
|
|
213
241
|
}, payload, 'arraybuffer');
|
|
214
242
|
|
|
215
|
-
|
|
243
|
+
if (overrideForCli) {
|
|
244
|
+
response = Buffer.from(response);
|
|
245
|
+
}
|
|
216
246
|
|
|
247
|
+
fs.writeFileSync(destination, response);
|
|
217
248
|
if (parseOutput) {
|
|
218
249
|
parse(response)
|
|
219
250
|
success()
|
|
220
251
|
}
|
|
221
|
-
|
|
252
|
+
|
|
222
253
|
return response;
|
|
254
|
+
|
|
223
255
|
}
|
|
224
256
|
|
|
225
257
|
/**
|
|
@@ -227,6 +259,7 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
|
|
|
227
259
|
* @property {string} url Image URL which you want to crop.
|
|
228
260
|
* @property {number} width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.
|
|
229
261
|
* @property {number} height Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.
|
|
262
|
+
* @property {boolean} overrideForCli
|
|
230
263
|
* @property {boolean} parseOutput
|
|
231
264
|
* @property {libClient | undefined} sdk
|
|
232
265
|
* @property {string} destination
|
|
@@ -235,8 +268,9 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
|
|
|
235
268
|
/**
|
|
236
269
|
* @param {AvatarsGetImageRequestParams} params
|
|
237
270
|
*/
|
|
238
|
-
const avatarsGetImage = async ({
|
|
239
|
-
let client = !sdk ? await sdkForProject() :
|
|
271
|
+
const avatarsGetImage = async ({url,width,height,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
272
|
+
let client = !sdk ? await sdkForProject() :
|
|
273
|
+
sdk;
|
|
240
274
|
let apiPath = '/avatars/image';
|
|
241
275
|
let payload = {};
|
|
242
276
|
if (typeof url !== 'undefined') {
|
|
@@ -248,10 +282,12 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
|
|
|
248
282
|
if (typeof height !== 'undefined') {
|
|
249
283
|
payload['height'] = height;
|
|
250
284
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
285
|
+
if (!overrideForCli) {
|
|
286
|
+
payload['project'] = localConfig.getProject().projectId
|
|
287
|
+
payload['key'] = globalConfig.getKey();
|
|
288
|
+
const queryParams = new URLSearchParams(payload);
|
|
289
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
290
|
+
}
|
|
255
291
|
|
|
256
292
|
let response = undefined;
|
|
257
293
|
|
|
@@ -259,14 +295,18 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
|
|
|
259
295
|
'content-type': 'application/json',
|
|
260
296
|
}, payload, 'arraybuffer');
|
|
261
297
|
|
|
262
|
-
|
|
298
|
+
if (overrideForCli) {
|
|
299
|
+
response = Buffer.from(response);
|
|
300
|
+
}
|
|
263
301
|
|
|
302
|
+
fs.writeFileSync(destination, response);
|
|
264
303
|
if (parseOutput) {
|
|
265
304
|
parse(response)
|
|
266
305
|
success()
|
|
267
306
|
}
|
|
268
|
-
|
|
307
|
+
|
|
269
308
|
return response;
|
|
309
|
+
|
|
270
310
|
}
|
|
271
311
|
|
|
272
312
|
/**
|
|
@@ -275,6 +315,7 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
|
|
|
275
315
|
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
276
316
|
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
277
317
|
* @property {string} background Changes background color. By default a random color will be picked and stay will persistent to the given name.
|
|
318
|
+
* @property {boolean} overrideForCli
|
|
278
319
|
* @property {boolean} parseOutput
|
|
279
320
|
* @property {libClient | undefined} sdk
|
|
280
321
|
* @property {string} destination
|
|
@@ -283,8 +324,9 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
|
|
|
283
324
|
/**
|
|
284
325
|
* @param {AvatarsGetInitialsRequestParams} params
|
|
285
326
|
*/
|
|
286
|
-
const avatarsGetInitials = async ({
|
|
287
|
-
let client = !sdk ? await sdkForProject() :
|
|
327
|
+
const avatarsGetInitials = async ({name,width,height,background,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
328
|
+
let client = !sdk ? await sdkForProject() :
|
|
329
|
+
sdk;
|
|
288
330
|
let apiPath = '/avatars/initials';
|
|
289
331
|
let payload = {};
|
|
290
332
|
if (typeof name !== 'undefined') {
|
|
@@ -299,10 +341,12 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
|
|
|
299
341
|
if (typeof background !== 'undefined') {
|
|
300
342
|
payload['background'] = background;
|
|
301
343
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
344
|
+
if (!overrideForCli) {
|
|
345
|
+
payload['project'] = localConfig.getProject().projectId
|
|
346
|
+
payload['key'] = globalConfig.getKey();
|
|
347
|
+
const queryParams = new URLSearchParams(payload);
|
|
348
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
349
|
+
}
|
|
306
350
|
|
|
307
351
|
let response = undefined;
|
|
308
352
|
|
|
@@ -310,14 +354,18 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
|
|
|
310
354
|
'content-type': 'application/json',
|
|
311
355
|
}, payload, 'arraybuffer');
|
|
312
356
|
|
|
313
|
-
|
|
357
|
+
if (overrideForCli) {
|
|
358
|
+
response = Buffer.from(response);
|
|
359
|
+
}
|
|
314
360
|
|
|
361
|
+
fs.writeFileSync(destination, response);
|
|
315
362
|
if (parseOutput) {
|
|
316
363
|
parse(response)
|
|
317
364
|
success()
|
|
318
365
|
}
|
|
319
|
-
|
|
366
|
+
|
|
320
367
|
return response;
|
|
368
|
+
|
|
321
369
|
}
|
|
322
370
|
|
|
323
371
|
/**
|
|
@@ -326,6 +374,7 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
|
|
|
326
374
|
* @property {number} size QR code size. Pass an integer between 1 to 1000. Defaults to 400.
|
|
327
375
|
* @property {number} margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1.
|
|
328
376
|
* @property {boolean} download Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.
|
|
377
|
+
* @property {boolean} overrideForCli
|
|
329
378
|
* @property {boolean} parseOutput
|
|
330
379
|
* @property {libClient | undefined} sdk
|
|
331
380
|
* @property {string} destination
|
|
@@ -334,8 +383,9 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
|
|
|
334
383
|
/**
|
|
335
384
|
* @param {AvatarsGetQRRequestParams} params
|
|
336
385
|
*/
|
|
337
|
-
const avatarsGetQR = async ({
|
|
338
|
-
let client = !sdk ? await sdkForProject() :
|
|
386
|
+
const avatarsGetQR = async ({text,size,margin,download,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
|
|
387
|
+
let client = !sdk ? await sdkForProject() :
|
|
388
|
+
sdk;
|
|
339
389
|
let apiPath = '/avatars/qr';
|
|
340
390
|
let payload = {};
|
|
341
391
|
if (typeof text !== 'undefined') {
|
|
@@ -350,10 +400,12 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
|
|
|
350
400
|
if (typeof download !== 'undefined') {
|
|
351
401
|
payload['download'] = download;
|
|
352
402
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
403
|
+
if (!overrideForCli) {
|
|
404
|
+
payload['project'] = localConfig.getProject().projectId
|
|
405
|
+
payload['key'] = globalConfig.getKey();
|
|
406
|
+
const queryParams = new URLSearchParams(payload);
|
|
407
|
+
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
408
|
+
}
|
|
357
409
|
|
|
358
410
|
let response = undefined;
|
|
359
411
|
|
|
@@ -361,14 +413,18 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
|
|
|
361
413
|
'content-type': 'application/json',
|
|
362
414
|
}, payload, 'arraybuffer');
|
|
363
415
|
|
|
364
|
-
|
|
416
|
+
if (overrideForCli) {
|
|
417
|
+
response = Buffer.from(response);
|
|
418
|
+
}
|
|
365
419
|
|
|
420
|
+
fs.writeFileSync(destination, response);
|
|
366
421
|
if (parseOutput) {
|
|
367
422
|
parse(response)
|
|
368
423
|
success()
|
|
369
424
|
}
|
|
370
|
-
|
|
425
|
+
|
|
371
426
|
return response;
|
|
427
|
+
|
|
372
428
|
}
|
|
373
429
|
|
|
374
430
|
avatars
|
|
@@ -446,4 +502,4 @@ module.exports = {
|
|
|
446
502
|
avatarsGetImage,
|
|
447
503
|
avatarsGetInitials,
|
|
448
504
|
avatarsGetQR
|
|
449
|
-
};
|
|
505
|
+
};
|
package/lib/commands/console.js
CHANGED
|
@@ -4,7 +4,7 @@ const tar = require("tar");
|
|
|
4
4
|
const ignore = require("ignore");
|
|
5
5
|
const { promisify } = require('util');
|
|
6
6
|
const libClient = require('../client.js');
|
|
7
|
-
const { getAllFiles } = require('../utils.js');
|
|
7
|
+
const { getAllFiles, showConsoleLink } = require('../utils.js');
|
|
8
8
|
const { Command } = require('commander');
|
|
9
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
@@ -41,6 +41,7 @@ const console = new Command("console").description(commandDescriptions['console'
|
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @typedef {Object} ConsoleVariablesRequestParams
|
|
44
|
+
* @property {boolean} overrideForCli
|
|
44
45
|
* @property {boolean} parseOutput
|
|
45
46
|
* @property {libClient | undefined} sdk
|
|
46
47
|
*/
|
|
@@ -48,8 +49,9 @@ const console = new Command("console").description(commandDescriptions['console'
|
|
|
48
49
|
/**
|
|
49
50
|
* @param {ConsoleVariablesRequestParams} params
|
|
50
51
|
*/
|
|
51
|
-
const consoleVariables = async ({
|
|
52
|
-
let client = !sdk ? await sdkForProject() :
|
|
52
|
+
const consoleVariables = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
53
|
+
let client = !sdk ? await sdkForProject() :
|
|
54
|
+
sdk;
|
|
53
55
|
let apiPath = '/console/variables';
|
|
54
56
|
let payload = {};
|
|
55
57
|
|
|
@@ -63,8 +65,9 @@ const consoleVariables = async ({ parseOutput = true, sdk = undefined}) => {
|
|
|
63
65
|
parse(response)
|
|
64
66
|
success()
|
|
65
67
|
}
|
|
66
|
-
|
|
68
|
+
|
|
67
69
|
return response;
|
|
70
|
+
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
console
|
|
@@ -75,4 +78,4 @@ console
|
|
|
75
78
|
module.exports = {
|
|
76
79
|
console,
|
|
77
80
|
consoleVariables
|
|
78
|
-
};
|
|
81
|
+
};
|