@swell/cli 1.0.2 → 2.0.1-alpha.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 (105) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +1 -1
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +7 -0
  5. package/bin/run.cmd +3 -0
  6. package/bin/run.js +7 -0
  7. package/dist/app-command.d.ts +22 -0
  8. package/dist/app-command.js +45 -0
  9. package/dist/commands/app/_pull.d.ts +8 -0
  10. package/dist/commands/app/_pull.js +45 -0
  11. package/dist/commands/app/_uninstall.d.ts +12 -0
  12. package/dist/commands/app/_uninstall.js +45 -0
  13. package/dist/commands/app/info.d.ts +15 -0
  14. package/dist/commands/app/info.js +92 -0
  15. package/dist/commands/app/install.d.ts +17 -0
  16. package/dist/commands/app/install.js +177 -0
  17. package/dist/commands/app/push.d.ts +17 -0
  18. package/dist/commands/app/push.js +158 -0
  19. package/dist/commands/app/version.d.ts +18 -0
  20. package/dist/commands/app/version.js +156 -0
  21. package/dist/commands/app/watch.d.ts +15 -0
  22. package/dist/commands/app/watch.js +110 -0
  23. package/dist/commands/create/app.d.ts +21 -0
  24. package/dist/commands/create/app.js +210 -0
  25. package/dist/commands/create/content.d.ts +19 -0
  26. package/dist/commands/create/content.js +87 -0
  27. package/dist/commands/create/function.d.ts +25 -0
  28. package/dist/commands/create/function.js +191 -0
  29. package/dist/commands/create/index.d.ts +6 -0
  30. package/dist/commands/create/index.js +34 -0
  31. package/dist/commands/create/model.d.ts +19 -0
  32. package/dist/commands/create/model.js +87 -0
  33. package/dist/commands/create/notification.d.ts +25 -0
  34. package/dist/commands/create/notification.js +170 -0
  35. package/dist/commands/login.d.ts +22 -0
  36. package/dist/commands/login.js +77 -0
  37. package/dist/commands/logout.d.ts +8 -0
  38. package/dist/commands/logout.js +45 -0
  39. package/dist/commands/logs.d.ts +23 -0
  40. package/dist/commands/logs.js +207 -0
  41. package/dist/commands/switch.d.ts +10 -0
  42. package/dist/commands/switch.js +41 -0
  43. package/dist/commands/whoami.d.ts +7 -0
  44. package/dist/commands/whoami.js +24 -0
  45. package/dist/create-collection-command.d.ts +26 -0
  46. package/dist/create-collection-command.js +97 -0
  47. package/dist/create-command.d.ts +16 -0
  48. package/dist/create-command.js +59 -0
  49. package/dist/index.d.ts +1 -0
  50. package/dist/index.js +1 -0
  51. package/dist/lib/api.d.ts +13 -0
  52. package/dist/lib/api.js +117 -0
  53. package/dist/lib/app-config.d.ts +29 -0
  54. package/dist/lib/app-config.js +127 -0
  55. package/dist/lib/apps/app-config.d.ts +42 -0
  56. package/dist/lib/apps/app-config.js +167 -0
  57. package/dist/lib/apps/index.d.ts +67 -0
  58. package/dist/lib/apps/index.js +167 -0
  59. package/dist/lib/apps/paths.d.ts +18 -0
  60. package/dist/lib/apps/paths.js +54 -0
  61. package/dist/lib/bundle.d.ts +1 -0
  62. package/dist/lib/bundle.js +40 -0
  63. package/dist/lib/config.d.ts +37 -0
  64. package/dist/lib/config.js +131 -0
  65. package/dist/lib/constants.d.ts +5 -0
  66. package/dist/lib/constants.js +17 -0
  67. package/dist/lib/create/content.d.ts +23 -0
  68. package/dist/lib/create/content.js +40 -0
  69. package/dist/lib/create/function.d.ts +17 -0
  70. package/dist/lib/create/function.js +36 -0
  71. package/dist/lib/create/index.d.ts +13 -0
  72. package/dist/lib/create/index.js +20 -0
  73. package/dist/lib/create/model.d.ts +22 -0
  74. package/dist/lib/create/model.js +30 -0
  75. package/dist/lib/create/notification.d.ts +25 -0
  76. package/dist/lib/create/notification.js +1 -0
  77. package/dist/lib/info.d.ts +38 -0
  78. package/dist/lib/info.js +91 -0
  79. package/dist/lib/logs/index.d.ts +23 -0
  80. package/dist/lib/logs/index.js +88 -0
  81. package/dist/lib/logs/line-output.d.ts +5 -0
  82. package/dist/lib/logs/line-output.js +13 -0
  83. package/dist/lib/logs/output.d.ts +7 -0
  84. package/dist/lib/logs/output.js +8 -0
  85. package/dist/lib/logs/table-output.d.ts +11 -0
  86. package/dist/lib/logs/table-output.js +128 -0
  87. package/dist/lib/sessions.d.ts +9 -0
  88. package/dist/lib/sessions.js +110 -0
  89. package/dist/lib/stores.d.ts +63 -0
  90. package/dist/lib/stores.js +173 -0
  91. package/dist/lib/style.d.ts +24 -0
  92. package/dist/lib/style.js +29 -0
  93. package/dist/lib/swell-function-wrapper.d.ts +88 -0
  94. package/dist/lib/swell-function-wrapper.js +302 -0
  95. package/dist/remote-app-command.d.ts +36 -0
  96. package/dist/remote-app-command.js +367 -0
  97. package/dist/swell-command.d.ts +21 -0
  98. package/dist/swell-command.js +43 -0
  99. package/oclif.manifest.json +1085 -0
  100. package/package.json +89 -42
  101. package/LICENSE +0 -674
  102. package/dist/bin/multipart-parser-85ef9626.js +0 -456
  103. package/dist/bin/swell-0f71f07d.js +0 -30670
  104. package/dist/bin/swell.js +0 -24
  105. package/dist/man/swell.1 +0 -85
@@ -1,456 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { F as FormData, a as File } from './swell-0f71f07d.js';
4
- import 'node:assert';
5
- import 'node:child_process';
6
- import 'node:async_hooks';
7
- import 'node:util';
8
- import 'node:process';
9
- import 'node:os';
10
- import 'node:tty';
11
- import 'node:fs';
12
- import 'node:path';
13
- import 'node:stream';
14
- import 'node:string_decoder';
15
- import 'node:buffer';
16
- import 'node:events';
17
- import 'node:url';
18
- import 'node:http';
19
- import 'node:https';
20
- import 'node:zlib';
21
- import 'node:net';
22
- import 'node:readline';
23
- import 'node:constants';
24
- import 'node:crypto';
25
-
26
- let s = 0;
27
- const S = {
28
- START_BOUNDARY: s++,
29
- HEADER_FIELD_START: s++,
30
- HEADER_FIELD: s++,
31
- HEADER_VALUE_START: s++,
32
- HEADER_VALUE: s++,
33
- HEADER_VALUE_ALMOST_DONE: s++,
34
- HEADERS_ALMOST_DONE: s++,
35
- PART_DATA_START: s++,
36
- PART_DATA: s++,
37
- END: s++
38
- };
39
-
40
- let f = 1;
41
- const F = {
42
- PART_BOUNDARY: f,
43
- LAST_BOUNDARY: f *= 2
44
- };
45
-
46
- const LF = 10;
47
- const CR = 13;
48
- const SPACE = 32;
49
- const HYPHEN = 45;
50
- const COLON = 58;
51
- const A = 97;
52
- const Z = 122;
53
-
54
- const lower = c => c | 0x20;
55
-
56
- const noop = () => {};
57
-
58
- class MultipartParser {
59
- /**
60
- * @param {string} boundary
61
- */
62
- constructor(boundary) {
63
- this.index = 0;
64
- this.flags = 0;
65
-
66
- this.onHeaderEnd = noop;
67
- this.onHeaderField = noop;
68
- this.onHeadersEnd = noop;
69
- this.onHeaderValue = noop;
70
- this.onPartBegin = noop;
71
- this.onPartData = noop;
72
- this.onPartEnd = noop;
73
-
74
- this.boundaryChars = {};
75
-
76
- boundary = '\r\n--' + boundary;
77
- const ui8a = new Uint8Array(boundary.length);
78
- for (let i = 0; i < boundary.length; i++) {
79
- ui8a[i] = boundary.charCodeAt(i);
80
- this.boundaryChars[ui8a[i]] = true;
81
- }
82
-
83
- this.boundary = ui8a;
84
- this.lookbehind = new Uint8Array(this.boundary.length + 8);
85
- this.state = S.START_BOUNDARY;
86
- }
87
-
88
- /**
89
- * @param {Uint8Array} data
90
- */
91
- write(data) {
92
- let i = 0;
93
- const length_ = data.length;
94
- let previousIndex = this.index;
95
- let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
96
- const boundaryLength = this.boundary.length;
97
- const boundaryEnd = boundaryLength - 1;
98
- const bufferLength = data.length;
99
- let c;
100
- let cl;
101
-
102
- const mark = name => {
103
- this[name + 'Mark'] = i;
104
- };
105
-
106
- const clear = name => {
107
- delete this[name + 'Mark'];
108
- };
109
-
110
- const callback = (callbackSymbol, start, end, ui8a) => {
111
- if (start === undefined || start !== end) {
112
- this[callbackSymbol](ui8a && ui8a.subarray(start, end));
113
- }
114
- };
115
-
116
- const dataCallback = (name, clear) => {
117
- const markSymbol = name + 'Mark';
118
- if (!(markSymbol in this)) {
119
- return;
120
- }
121
-
122
- if (clear) {
123
- callback(name, this[markSymbol], i, data);
124
- delete this[markSymbol];
125
- } else {
126
- callback(name, this[markSymbol], data.length, data);
127
- this[markSymbol] = 0;
128
- }
129
- };
130
-
131
- for (i = 0; i < length_; i++) {
132
- c = data[i];
133
-
134
- switch (state) {
135
- case S.START_BOUNDARY:
136
- if (index === boundary.length - 2) {
137
- if (c === HYPHEN) {
138
- flags |= F.LAST_BOUNDARY;
139
- } else if (c !== CR) {
140
- return;
141
- }
142
-
143
- index++;
144
- break;
145
- } else if (index - 1 === boundary.length - 2) {
146
- if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
147
- state = S.END;
148
- flags = 0;
149
- } else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
150
- index = 0;
151
- callback('onPartBegin');
152
- state = S.HEADER_FIELD_START;
153
- } else {
154
- return;
155
- }
156
-
157
- break;
158
- }
159
-
160
- if (c !== boundary[index + 2]) {
161
- index = -2;
162
- }
163
-
164
- if (c === boundary[index + 2]) {
165
- index++;
166
- }
167
-
168
- break;
169
- case S.HEADER_FIELD_START:
170
- state = S.HEADER_FIELD;
171
- mark('onHeaderField');
172
- index = 0;
173
- // falls through
174
- case S.HEADER_FIELD:
175
- if (c === CR) {
176
- clear('onHeaderField');
177
- state = S.HEADERS_ALMOST_DONE;
178
- break;
179
- }
180
-
181
- index++;
182
- if (c === HYPHEN) {
183
- break;
184
- }
185
-
186
- if (c === COLON) {
187
- if (index === 1) {
188
- // empty header field
189
- return;
190
- }
191
-
192
- dataCallback('onHeaderField', true);
193
- state = S.HEADER_VALUE_START;
194
- break;
195
- }
196
-
197
- cl = lower(c);
198
- if (cl < A || cl > Z) {
199
- return;
200
- }
201
-
202
- break;
203
- case S.HEADER_VALUE_START:
204
- if (c === SPACE) {
205
- break;
206
- }
207
-
208
- mark('onHeaderValue');
209
- state = S.HEADER_VALUE;
210
- // falls through
211
- case S.HEADER_VALUE:
212
- if (c === CR) {
213
- dataCallback('onHeaderValue', true);
214
- callback('onHeaderEnd');
215
- state = S.HEADER_VALUE_ALMOST_DONE;
216
- }
217
-
218
- break;
219
- case S.HEADER_VALUE_ALMOST_DONE:
220
- if (c !== LF) {
221
- return;
222
- }
223
-
224
- state = S.HEADER_FIELD_START;
225
- break;
226
- case S.HEADERS_ALMOST_DONE:
227
- if (c !== LF) {
228
- return;
229
- }
230
-
231
- callback('onHeadersEnd');
232
- state = S.PART_DATA_START;
233
- break;
234
- case S.PART_DATA_START:
235
- state = S.PART_DATA;
236
- mark('onPartData');
237
- // falls through
238
- case S.PART_DATA:
239
- previousIndex = index;
240
-
241
- if (index === 0) {
242
- // boyer-moore derrived algorithm to safely skip non-boundary data
243
- i += boundaryEnd;
244
- while (i < bufferLength && !(data[i] in boundaryChars)) {
245
- i += boundaryLength;
246
- }
247
-
248
- i -= boundaryEnd;
249
- c = data[i];
250
- }
251
-
252
- if (index < boundary.length) {
253
- if (boundary[index] === c) {
254
- if (index === 0) {
255
- dataCallback('onPartData', true);
256
- }
257
-
258
- index++;
259
- } else {
260
- index = 0;
261
- }
262
- } else if (index === boundary.length) {
263
- index++;
264
- if (c === CR) {
265
- // CR = part boundary
266
- flags |= F.PART_BOUNDARY;
267
- } else if (c === HYPHEN) {
268
- // HYPHEN = end boundary
269
- flags |= F.LAST_BOUNDARY;
270
- } else {
271
- index = 0;
272
- }
273
- } else if (index - 1 === boundary.length) {
274
- if (flags & F.PART_BOUNDARY) {
275
- index = 0;
276
- if (c === LF) {
277
- // unset the PART_BOUNDARY flag
278
- flags &= ~F.PART_BOUNDARY;
279
- callback('onPartEnd');
280
- callback('onPartBegin');
281
- state = S.HEADER_FIELD_START;
282
- break;
283
- }
284
- } else if (flags & F.LAST_BOUNDARY) {
285
- if (c === HYPHEN) {
286
- callback('onPartEnd');
287
- state = S.END;
288
- flags = 0;
289
- } else {
290
- index = 0;
291
- }
292
- } else {
293
- index = 0;
294
- }
295
- }
296
-
297
- if (index > 0) {
298
- // when matching a possible boundary, keep a lookbehind reference
299
- // in case it turns out to be a false lead
300
- lookbehind[index - 1] = c;
301
- } else if (previousIndex > 0) {
302
- // if our boundary turned out to be rubbish, the captured lookbehind
303
- // belongs to partData
304
- const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
305
- callback('onPartData', 0, previousIndex, _lookbehind);
306
- previousIndex = 0;
307
- mark('onPartData');
308
-
309
- // reconsider the current character even so it interrupted the sequence
310
- // it could be the beginning of a new sequence
311
- i--;
312
- }
313
-
314
- break;
315
- case S.END:
316
- break;
317
- default:
318
- throw new Error(`Unexpected state entered: ${state}`);
319
- }
320
- }
321
-
322
- dataCallback('onHeaderField');
323
- dataCallback('onHeaderValue');
324
- dataCallback('onPartData');
325
-
326
- // Update properties for the next call
327
- this.index = index;
328
- this.state = state;
329
- this.flags = flags;
330
- }
331
-
332
- end() {
333
- if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
334
- (this.state === S.PART_DATA && this.index === this.boundary.length)) {
335
- this.onPartEnd();
336
- } else if (this.state !== S.END) {
337
- throw new Error('MultipartParser.end(): stream ended unexpectedly');
338
- }
339
- }
340
- }
341
-
342
- function _fileName(headerValue) {
343
- // matches either a quoted-string or a token (RFC 2616 section 19.5.1)
344
- const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
345
- if (!m) {
346
- return;
347
- }
348
-
349
- const match = m[2] || m[3] || '';
350
- let filename = match.slice(match.lastIndexOf('\\') + 1);
351
- filename = filename.replace(/%22/g, '"');
352
- filename = filename.replace(/&#(\d{4});/g, (m, code) => {
353
- return String.fromCharCode(code);
354
- });
355
- return filename;
356
- }
357
-
358
- async function toFormData(Body, ct) {
359
- if (!/multipart/i.test(ct)) {
360
- throw new TypeError('Failed to fetch');
361
- }
362
-
363
- const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
364
-
365
- if (!m) {
366
- throw new TypeError('no or bad content-type header, no multipart boundary');
367
- }
368
-
369
- const parser = new MultipartParser(m[1] || m[2]);
370
-
371
- let headerField;
372
- let headerValue;
373
- let entryValue;
374
- let entryName;
375
- let contentType;
376
- let filename;
377
- const entryChunks = [];
378
- const formData = new FormData();
379
-
380
- const onPartData = ui8a => {
381
- entryValue += decoder.decode(ui8a, {stream: true});
382
- };
383
-
384
- const appendToFile = ui8a => {
385
- entryChunks.push(ui8a);
386
- };
387
-
388
- const appendFileToFormData = () => {
389
- const file = new File(entryChunks, filename, {type: contentType});
390
- formData.append(entryName, file);
391
- };
392
-
393
- const appendEntryToFormData = () => {
394
- formData.append(entryName, entryValue);
395
- };
396
-
397
- const decoder = new TextDecoder('utf-8');
398
- decoder.decode();
399
-
400
- parser.onPartBegin = function () {
401
- parser.onPartData = onPartData;
402
- parser.onPartEnd = appendEntryToFormData;
403
-
404
- headerField = '';
405
- headerValue = '';
406
- entryValue = '';
407
- entryName = '';
408
- contentType = '';
409
- filename = null;
410
- entryChunks.length = 0;
411
- };
412
-
413
- parser.onHeaderField = function (ui8a) {
414
- headerField += decoder.decode(ui8a, {stream: true});
415
- };
416
-
417
- parser.onHeaderValue = function (ui8a) {
418
- headerValue += decoder.decode(ui8a, {stream: true});
419
- };
420
-
421
- parser.onHeaderEnd = function () {
422
- headerValue += decoder.decode();
423
- headerField = headerField.toLowerCase();
424
-
425
- if (headerField === 'content-disposition') {
426
- // matches either a quoted-string or a token (RFC 2616 section 19.5.1)
427
- const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
428
-
429
- if (m) {
430
- entryName = m[2] || m[3] || '';
431
- }
432
-
433
- filename = _fileName(headerValue);
434
-
435
- if (filename) {
436
- parser.onPartData = appendToFile;
437
- parser.onPartEnd = appendFileToFormData;
438
- }
439
- } else if (headerField === 'content-type') {
440
- contentType = headerValue;
441
- }
442
-
443
- headerValue = '';
444
- headerField = '';
445
- };
446
-
447
- for await (const chunk of Body) {
448
- parser.write(chunk);
449
- }
450
-
451
- parser.end();
452
-
453
- return formData;
454
- }
455
-
456
- export { toFormData };