@botonic/cli 0.40.0 → 0.40.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 (41) hide show
  1. package/README.md +7 -26
  2. package/lib/analytics/credentials-handler.d.ts +0 -4
  3. package/lib/analytics/credentials-handler.js +2 -29
  4. package/lib/analytics/credentials-handler.js.map +1 -1
  5. package/lib/botonic-api-service.d.ts +1 -2
  6. package/lib/botonic-api-service.js +9 -29
  7. package/lib/botonic-api-service.js.map +1 -1
  8. package/lib/commands/deploy.d.ts +1 -2
  9. package/lib/commands/deploy.js +3 -28
  10. package/lib/commands/deploy.js.map +1 -1
  11. package/lib/commands/login.d.ts +0 -1
  12. package/lib/commands/login.js +2 -14
  13. package/lib/commands/login.js.map +1 -1
  14. package/lib/commands/logout.d.ts +0 -1
  15. package/lib/commands/logout.js +0 -3
  16. package/lib/commands/logout.js.map +1 -1
  17. package/lib/commands/new.d.ts +1 -2
  18. package/lib/commands/new.js +2 -12
  19. package/lib/commands/new.js.map +1 -1
  20. package/lib/commands/serve.d.ts +1 -4
  21. package/lib/commands/serve.js +6 -104
  22. package/lib/commands/serve.js.map +1 -1
  23. package/lib/commands/test.d.ts +0 -1
  24. package/lib/commands/test.js +0 -6
  25. package/lib/commands/test.js.map +1 -1
  26. package/lib/constants.d.ts +2 -6
  27. package/lib/constants.js +4 -12
  28. package/lib/constants.js.map +1 -1
  29. package/lib/interfaces.d.ts +0 -21
  30. package/oclif.manifest.json +1 -1
  31. package/package.json +3 -15
  32. package/scripts/postinstall.js +0 -23
  33. package/lib/analytics/telemetry.d.ts +0 -35
  34. package/lib/analytics/telemetry.js +0 -97
  35. package/lib/analytics/telemetry.js.map +0 -1
  36. package/lib/botonic-playground-service.d.ts +0 -21
  37. package/lib/botonic-playground-service.js +0 -98
  38. package/lib/botonic-playground-service.js.map +0 -1
  39. package/lib/commands/destroy.d.ts +0 -13
  40. package/lib/commands/destroy.js +0 -39
  41. package/lib/commands/destroy.js.map +0 -1
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PlaygroundService = void 0;
4
- const tslib_1 = require("tslib");
5
- const axios_1 = tslib_1.__importDefault(require("axios"));
6
- const localtunnel_1 = tslib_1.__importDefault(require("localtunnel"));
7
- const credentials_handler_1 = require("./analytics/credentials-handler");
8
- const file_system_1 = require("./util/file-system");
9
- const PLAYGROUND_API_HOST = 'https://api.playground.botonic.io';
10
- /**
11
- * Temporary solution to allow aborting promise after a certain timeout.
12
- */
13
- function withTimeout(promise, errorMsg, timeoutMs = 2 * 1000) {
14
- return Promise.race([
15
- new Promise(resolve => {
16
- setTimeout(() => resolve(promise), timeoutMs);
17
- }),
18
- // eslint-disable-next-line promise/param-names
19
- new Promise((_, reject) => {
20
- setTimeout(() => reject(new Error(errorMsg)), timeoutMs);
21
- }),
22
- ]);
23
- }
24
- class PlaygroundService {
25
- constructor(port, onClose) {
26
- this.baseUrl = PLAYGROUND_API_HOST;
27
- this.playgroundSessionsApi = `${this.baseUrl}/playground-sessions/`;
28
- this.globalCredentialsHandler = new credentials_handler_1.GlobalCredentialsHandler();
29
- this.port = port;
30
- this.onClose = onClose;
31
- this.tunnel = null;
32
- }
33
- start() {
34
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
35
- try {
36
- this.tunnel = yield withTimeout((0, localtunnel_1.default)({ port: this.port }), 'Tunneling service not reachable.');
37
- this.playgroundSession = yield this.newPlaygroundSession({
38
- anonymous_id: this.globalCredentialsHandler.getAnonymousId(),
39
- url: this.tunnel.url,
40
- app_name: (0, file_system_1.getCurrentDirectory)(),
41
- });
42
- this.onClose && this.tunnel.on('close', this.onClose);
43
- }
44
- catch (e) {
45
- console.error('Error creating local tunnel: ', e);
46
- }
47
- });
48
- }
49
- getPlaygroundSession(id) {
50
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
51
- if (!id)
52
- return null;
53
- try {
54
- const resp = yield axios_1.default.get(`${this.playgroundSessionsApi}${id}/`);
55
- return resp.data;
56
- }
57
- catch (e) {
58
- console.error('Error getting Playground Session: ', e);
59
- return null;
60
- }
61
- });
62
- }
63
- newPlaygroundSession({ url, app_name, anonymous_id, }) {
64
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
65
- try {
66
- const resp = yield axios_1.default.post(`${this.playgroundSessionsApi}`, {
67
- anonymous_id,
68
- url,
69
- app_name,
70
- });
71
- return resp.data;
72
- }
73
- catch (e) {
74
- console.error('Error creating Playground Session: ', e);
75
- return null;
76
- }
77
- });
78
- }
79
- get code() {
80
- var _a;
81
- return (_a = this.playgroundSession) === null || _a === void 0 ? void 0 : _a.code;
82
- }
83
- stop() {
84
- var _a;
85
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
86
- try {
87
- this.tunnel && (yield this.tunnel.close());
88
- ((_a = this.playgroundSession) === null || _a === void 0 ? void 0 : _a.id) &&
89
- (yield axios_1.default.delete(`${this.playgroundSessionsApi}${this.playgroundSession.id}/`));
90
- }
91
- catch (e) {
92
- console.log("Couldn't stop Playground session properly: ", e);
93
- }
94
- });
95
- }
96
- }
97
- exports.PlaygroundService = PlaygroundService;
98
- //# sourceMappingURL=botonic-playground-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"botonic-playground-service.js","sourceRoot":"","sources":["../src/botonic-playground-service.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AACzB,sEAAqC;AAErC,yEAA0E;AAE1E,oDAAwD;AAExD,MAAM,mBAAmB,GAAG,mCAAmC,CAAA;AAC/D;;GAEG;AACH,SAAS,WAAW,CAClB,OAAmB,EACnB,QAAgB,EAChB,SAAS,GAAG,CAAC,GAAG,IAAI;IAEpB,OAAO,OAAO,CAAC,IAAI,CAAC;QAClB,IAAI,OAAO,CAAI,OAAO,CAAC,EAAE;YACvB,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAA;QAC/C,CAAC,CAA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;;KACF;CACF;AA9ED,8CA8EC"}
@@ -1,13 +0,0 @@
1
- import { Command } from '@oclif/command';
2
- export default class Run extends Command {
3
- static description: string;
4
- static examples: string[];
5
- static flags: {};
6
- static args: {
7
- name: string;
8
- options: ("aws" | "hubtype")[];
9
- }[];
10
- private telemetry;
11
- run(): Promise<void>;
12
- destroyHubtype(): Promise<void>;
13
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const command_1 = require("@oclif/command");
5
- const telemetry_1 = require("../analytics/telemetry");
6
- const constants_1 = require("../constants");
7
- class Run extends command_1.Command {
8
- constructor() {
9
- super(...arguments);
10
- this.telemetry = new telemetry_1.Telemetry();
11
- }
12
- /* istanbul ignore next */
13
- run() {
14
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
15
- const { args } = this.parse(Run);
16
- const provider = args.provider || constants_1.CLOUD_PROVIDERS.HUBTYPE;
17
- this.telemetry.trackDestroy1_0({ provider });
18
- console.log(`Destroying ${provider} stack...`);
19
- console.log('This can take a while, do not cancel this process.');
20
- if (provider === constants_1.CLOUD_PROVIDERS.HUBTYPE)
21
- yield this.destroyHubtype();
22
- });
23
- }
24
- destroyHubtype() {
25
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
26
- // TODO: Implement logic to destroy Hubtype bots
27
- });
28
- }
29
- }
30
- exports.default = Run;
31
- Run.description = 'Destroy Botonic project from cloud provider';
32
- Run.examples = [
33
- `$ botonic destroy aws
34
- Destroying AWS stack...
35
- `,
36
- ];
37
- Run.flags = {};
38
- Run.args = [{ name: 'provider', options: Object.values(constants_1.CLOUD_PROVIDERS) }];
39
- //# sourceMappingURL=destroy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"destroy.js","sourceRoot":"","sources":["../../src/commands/destroy.ts"],"names":[],"mappings":";;;AAAA,4CAAwC;AAExC,sDAAkD;AAClD,4CAA8C;AAE9C,MAAqB,GAAI,SAAQ,iBAAO;IAAxC;;QAYU,cAAS,GAAG,IAAI,qBAAS,EAAE,CAAA;IAgBrC,CAAC;IAdC,0BAA0B;IACpB,GAAG;;YACP,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAChC,MAAM,QAAQ,GAAW,IAAI,CAAC,QAAQ,IAAI,2BAAe,CAAC,OAAO,CAAA;YACjE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAA;YAC5C,OAAO,CAAC,GAAG,CAAC,cAAc,QAAQ,WAAW,CAAC,CAAA;YAC9C,OAAO,CAAC,GAAG,CAAC,oDAAoD,CAAC,CAAA;YAEjE,IAAI,QAAQ,KAAK,2BAAe,CAAC,OAAO;gBAAE,MAAM,IAAI,CAAC,cAAc,EAAE,CAAA;QACvE,CAAC;KAAA;IAEK,cAAc;;YAClB,gDAAgD;QAClD,CAAC;KAAA;;AA3BH,sBA4BC;AA3BQ,eAAW,GAAG,6CAA6C,CAAA;AAE3D,YAAQ,GAAG;IAChB;;CAEH;CACE,CAAA;AACM,SAAK,GAAG,EAAE,CAAA;AAEV,QAAI,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,2BAAe,CAAC,EAAE,CAAC,CAAA"}