@knocklabs/cli 0.1.19 → 0.1.20

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 CHANGED
@@ -16,7 +16,7 @@ $ npm install -g @knocklabs/cli
16
16
  $ knock COMMAND
17
17
  running command...
18
18
  $ knock (--version)
19
- @knocklabs/cli/0.1.19 linux-x64 node-v18.20.4
19
+ @knocklabs/cli/0.1.20 linux-x64 node-v18.20.7
20
20
  $ knock --help [COMMAND]
21
21
  USAGE
22
22
  $ knock COMMAND
@@ -73,7 +73,7 @@ FLAGS
73
73
  --service-token=<value> (required) The service token to authenticate with.
74
74
  ```
75
75
 
76
- _See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/commit/index.ts)_
76
+ _See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/index.ts)_
77
77
 
78
78
  ## `knock commit get ID`
79
79
 
@@ -90,7 +90,7 @@ GLOBAL FLAGS
90
90
  --json Format output as json.
91
91
  ```
92
92
 
93
- _See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/commit/get.ts)_
93
+ _See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/get.ts)_
94
94
 
95
95
  ## `knock commit list`
96
96
 
@@ -114,7 +114,7 @@ GLOBAL FLAGS
114
114
  --json Format output as json.
115
115
  ```
116
116
 
117
- _See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/commit/list.ts)_
117
+ _See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/list.ts)_
118
118
 
119
119
  ## `knock commit promote`
120
120
 
@@ -131,7 +131,7 @@ FLAGS
131
131
  --to=<value> The destination environment to promote all changes from the preceding environment.
132
132
  ```
133
133
 
134
- _See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/commit/promote.ts)_
134
+ _See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/commit/promote.ts)_
135
135
 
136
136
  ## `knock help [COMMAND]`
137
137
 
@@ -151,7 +151,7 @@ DESCRIPTION
151
151
  Display help for knock.
152
152
  ```
153
153
 
154
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.8/src/commands/help.ts)_
154
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.20/src/commands/help.ts)_
155
155
 
156
156
  ## `knock layout get EMAILLAYOUTKEY`
157
157
 
@@ -171,7 +171,7 @@ GLOBAL FLAGS
171
171
  --json Format output as json.
172
172
  ```
173
173
 
174
- _See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/layout/get.ts)_
174
+ _See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/get.ts)_
175
175
 
176
176
  ## `knock layout list`
177
177
 
@@ -194,7 +194,7 @@ GLOBAL FLAGS
194
194
  --json Format output as json.
195
195
  ```
196
196
 
197
- _See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/layout/list.ts)_
197
+ _See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/list.ts)_
198
198
 
199
199
  ## `knock layout pull [EMAILLAYOUTKEY]`
200
200
 
@@ -214,7 +214,7 @@ FLAGS
214
214
  --service-token=<value> (required) The service token to authenticate with.
215
215
  ```
216
216
 
217
- _See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/layout/pull.ts)_
217
+ _See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/pull.ts)_
218
218
 
219
219
  ## `knock layout push [EMAILLAYOUTKEY]`
220
220
 
@@ -236,7 +236,7 @@ FLAGS
236
236
  --service-token=<value> (required) The service token to authenticate with.
237
237
  ```
238
238
 
239
- _See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/layout/push.ts)_
239
+ _See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/push.ts)_
240
240
 
241
241
  ## `knock layout validate [EMAILLAYOUTKEY]`
242
242
 
@@ -255,7 +255,7 @@ FLAGS
255
255
  --service-token=<value> (required) The service token to authenticate with.
256
256
  ```
257
257
 
258
- _See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/layout/validate.ts)_
258
+ _See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/layout/validate.ts)_
259
259
 
260
260
  ## `knock partial get PARTIALKEY`
261
261
 
@@ -275,7 +275,7 @@ GLOBAL FLAGS
275
275
  --json Format output as json.
276
276
  ```
277
277
 
278
- _See code: [src/commands/partial/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/partial/get.ts)_
278
+ _See code: [src/commands/partial/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/get.ts)_
279
279
 
280
280
  ## `knock partial list`
281
281
 
@@ -298,7 +298,7 @@ GLOBAL FLAGS
298
298
  --json Format output as json.
299
299
  ```
300
300
 
301
- _See code: [src/commands/partial/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/partial/list.ts)_
301
+ _See code: [src/commands/partial/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/list.ts)_
302
302
 
303
303
  ## `knock partial pull [PARTIALKEY]`
304
304
 
@@ -318,7 +318,7 @@ FLAGS
318
318
  --service-token=<value> (required) The service token to authenticate with.
319
319
  ```
320
320
 
321
- _See code: [src/commands/partial/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/partial/pull.ts)_
321
+ _See code: [src/commands/partial/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/pull.ts)_
322
322
 
323
323
  ## `knock partial push [PARTIALKEY]`
324
324
 
@@ -339,7 +339,7 @@ FLAGS
339
339
  --service-token=<value> (required) The service token to authenticate with.
340
340
  ```
341
341
 
342
- _See code: [src/commands/partial/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/partial/push.ts)_
342
+ _See code: [src/commands/partial/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/push.ts)_
343
343
 
344
344
  ## `knock partial validate [PARTIALKEY]`
345
345
 
@@ -358,7 +358,7 @@ FLAGS
358
358
  --service-token=<value> (required) The service token to authenticate with.
359
359
  ```
360
360
 
361
- _See code: [src/commands/partial/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/partial/validate.ts)_
361
+ _See code: [src/commands/partial/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/partial/validate.ts)_
362
362
 
363
363
  ## `knock translation get TRANSLATIONREF`
364
364
 
@@ -385,7 +385,7 @@ GLOBAL FLAGS
385
385
  --json Format output as json.
386
386
  ```
387
387
 
388
- _See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/translation/get.ts)_
388
+ _See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/get.ts)_
389
389
 
390
390
  ## `knock translation list`
391
391
 
@@ -408,7 +408,7 @@ GLOBAL FLAGS
408
408
  --json Format output as json.
409
409
  ```
410
410
 
411
- _See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/translation/list.ts)_
411
+ _See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/list.ts)_
412
412
 
413
413
  ## `knock translation pull [TRANSLATIONREF]`
414
414
 
@@ -435,7 +435,7 @@ FLAGS
435
435
  --translations-dir=<value> The target directory path to pull all translations into.
436
436
  ```
437
437
 
438
- _See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/translation/pull.ts)_
438
+ _See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/pull.ts)_
439
439
 
440
440
  ## `knock translation push [TRANSLATIONREF]`
441
441
 
@@ -462,7 +462,7 @@ FLAGS
462
462
  --translations-dir=<value> The target directory path to find all translations to push.
463
463
  ```
464
464
 
465
- _See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/translation/push.ts)_
465
+ _See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/push.ts)_
466
466
 
467
467
  ## `knock translation validate [TRANSLATIONREF]`
468
468
 
@@ -487,7 +487,7 @@ FLAGS
487
487
  --translations-dir=<value> The target directory path to find all translations to validate.
488
488
  ```
489
489
 
490
- _See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/translation/validate.ts)_
490
+ _See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/translation/validate.ts)_
491
491
 
492
492
  ## `knock whoami`
493
493
 
@@ -504,7 +504,7 @@ GLOBAL FLAGS
504
504
  --json Format output as json.
505
505
  ```
506
506
 
507
- _See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/whoami.ts)_
507
+ _See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/whoami.ts)_
508
508
 
509
509
  ## `knock workflow activate WORKFLOWKEY`
510
510
 
@@ -531,7 +531,7 @@ DESCRIPTION
531
531
  with `false` in order to deactivate it.
532
532
  ```
533
533
 
534
- _See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/workflow/activate.ts)_
534
+ _See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/activate.ts)_
535
535
 
536
536
  ## `knock workflow get WORKFLOWKEY`
537
537
 
@@ -551,7 +551,7 @@ GLOBAL FLAGS
551
551
  --json Format output as json.
552
552
  ```
553
553
 
554
- _See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/workflow/get.ts)_
554
+ _See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/get.ts)_
555
555
 
556
556
  ## `knock workflow list`
557
557
 
@@ -574,7 +574,7 @@ GLOBAL FLAGS
574
574
  --json Format output as json.
575
575
  ```
576
576
 
577
- _See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/workflow/list.ts)_
577
+ _See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/list.ts)_
578
578
 
579
579
  ## `knock workflow pull [WORKFLOWKEY]`
580
580
 
@@ -594,7 +594,7 @@ FLAGS
594
594
  --workflows-dir=<value> The target directory path to pull all workflows into.
595
595
  ```
596
596
 
597
- _See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/workflow/pull.ts)_
597
+ _See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/pull.ts)_
598
598
 
599
599
  ## `knock workflow push [WORKFLOWKEY]`
600
600
 
@@ -615,7 +615,7 @@ FLAGS
615
615
  --workflows-dir=<value> The target directory path to find all workflows to push.
616
616
  ```
617
617
 
618
- _See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/workflow/push.ts)_
618
+ _See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/push.ts)_
619
619
 
620
620
  ## `knock workflow run WORKFLOWKEY`
621
621
 
@@ -636,7 +636,7 @@ FLAGS
636
636
  --tenant=<value> A tenant id for the workflow run.
637
637
  ```
638
638
 
639
- _See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/workflow/run.ts)_
639
+ _See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/run.ts)_
640
640
 
641
641
  ## `knock workflow validate [WORKFLOWKEY]`
642
642
 
@@ -655,5 +655,5 @@ FLAGS
655
655
  --workflows-dir=<value> The target directory path to find all workflows to validate.
656
656
  ```
657
657
 
658
- _See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.19/src/commands/workflow/validate.ts)_
658
+ _See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.20/src/commands/workflow/validate.ts)_
659
659
  <!-- commandsstop -->
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MessageTypeGet;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _date = require("../../lib/helpers/date");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _request = require("../../lib/helpers/request");
16
+ const _ux = require("../../lib/helpers/ux");
17
+ function _define_property(obj, key, value) {
18
+ if (key in obj) {
19
+ Object.defineProperty(obj, key, {
20
+ value: value,
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true
24
+ });
25
+ } else {
26
+ obj[key] = value;
27
+ }
28
+ return obj;
29
+ }
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ class MessageTypeGet extends _basecommand.default {
36
+ async run() {
37
+ _ux.spinner.start("‣ Loading");
38
+ const { messageType } = await this.loadMessageType();
39
+ _ux.spinner.stop();
40
+ const { flags } = this.props;
41
+ if (flags.json) return messageType;
42
+ this.render(messageType);
43
+ }
44
+ async loadMessageType() {
45
+ const messageTypeResp = await this.apiV1.getMessageType(this.props);
46
+ if (!(0, _request.isSuccessResp)(messageTypeResp)) {
47
+ const message = (0, _request.formatErrorRespMessage)(messageTypeResp);
48
+ _core.ux.error(new _error.ApiError(message));
49
+ }
50
+ return {
51
+ messageType: messageTypeResp.data
52
+ };
53
+ }
54
+ render(messageType) {
55
+ const { messageTypeKey } = this.props.args;
56
+ const { environment: env, "hide-uncommitted-changes": commitedOnly } = this.props.flags;
57
+ const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
58
+ this.log(`‣ Showing in-app message type \`${messageTypeKey}\` in \`${env}\` environment ${qualifier}\n`);
59
+ /*
60
+ * Message type table
61
+ */ const rows = [
62
+ {
63
+ key: "Name",
64
+ value: messageType.name
65
+ },
66
+ {
67
+ key: "Key",
68
+ value: messageType.key
69
+ },
70
+ {
71
+ key: "Description",
72
+ value: messageType.description || "-"
73
+ },
74
+ {
75
+ key: "Owner",
76
+ value: messageType.owner
77
+ },
78
+ {
79
+ key: "Created at",
80
+ value: (0, _date.formatDateTime)(messageType.created_at)
81
+ },
82
+ {
83
+ key: "Updated at",
84
+ value: (0, _date.formatDateTime)(messageType.updated_at)
85
+ },
86
+ {
87
+ key: "Schema",
88
+ value: (messageType.variants || []).length > 0 ? "\n" + JSON.stringify(messageType.variants, null, 2) : "-"
89
+ },
90
+ {
91
+ key: "Preview template",
92
+ value: messageType.preview ? "\n" + messageType.preview : "-"
93
+ }
94
+ ];
95
+ _core.ux.table(rows, {
96
+ key: {
97
+ header: "Message type",
98
+ minWidth: 24
99
+ },
100
+ value: {
101
+ header: "",
102
+ minWidth: 24
103
+ }
104
+ });
105
+ }
106
+ }
107
+ // Hide until guides are released in GA.
108
+ _define_property(MessageTypeGet, "hidden", true);
109
+ _define_property(MessageTypeGet, "summary", "Display a single in-app message type from an environment.");
110
+ _define_property(MessageTypeGet, "flags", {
111
+ environment: _core.Flags.string({
112
+ default: "development",
113
+ summary: "The environment to use."
114
+ }),
115
+ "hide-uncommitted-changes": _core.Flags.boolean({
116
+ summary: "Hide any uncommitted changes."
117
+ })
118
+ });
119
+ _define_property(MessageTypeGet, "args", {
120
+ messageTypeKey: _core.Args.string({
121
+ required: true
122
+ })
123
+ });
124
+ _define_property(MessageTypeGet, "enableJsonFlag", true);
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MessageTypeList;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _date = require("../../lib/helpers/date");
14
+ const _objectisomorphic = require("../../lib/helpers/object.isomorphic");
15
+ const _page = require("../../lib/helpers/page");
16
+ const _request = require("../../lib/helpers/request");
17
+ function _define_property(obj, key, value) {
18
+ if (key in obj) {
19
+ Object.defineProperty(obj, key, {
20
+ value: value,
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true
24
+ });
25
+ } else {
26
+ obj[key] = value;
27
+ }
28
+ return obj;
29
+ }
30
+ function _interop_require_default(obj) {
31
+ return obj && obj.__esModule ? obj : {
32
+ default: obj
33
+ };
34
+ }
35
+ class MessageTypeList extends _basecommand.default {
36
+ async run() {
37
+ const resp = await this.request();
38
+ const { flags } = this.props;
39
+ if (flags.json) return resp.data;
40
+ this.render(resp.data);
41
+ }
42
+ async request(pageParams = {}) {
43
+ const props = (0, _objectisomorphic.merge)(this.props, {
44
+ flags: {
45
+ ...pageParams
46
+ }
47
+ });
48
+ return (0, _request.withSpinner)(()=>this.apiV1.listMessageTypes(props));
49
+ }
50
+ async render(data) {
51
+ const { entries } = data;
52
+ const { environment: env, "hide-uncommitted-changes": committedOnly } = this.props.flags;
53
+ const qualifier = env === "development" && !committedOnly ? "(including uncommitted)" : "";
54
+ this.log(`‣ Showing ${entries.length} in-app message types in \`${env}\` environment ${qualifier}\n`);
55
+ /*
56
+ * Message types list table
57
+ */ _core.ux.table(entries, {
58
+ key: {
59
+ header: "Key"
60
+ },
61
+ name: {
62
+ header: "Name"
63
+ },
64
+ description: {
65
+ header: "Description"
66
+ },
67
+ owner: {
68
+ header: "Owner"
69
+ },
70
+ updated_at: {
71
+ header: "Updated at",
72
+ get: (entry)=>(0, _date.formatDate)(entry.updated_at)
73
+ }
74
+ });
75
+ return this.prompt(data);
76
+ }
77
+ async prompt(data) {
78
+ const { page_info } = data;
79
+ const pageAction = await (0, _page.maybePromptPageAction)(page_info);
80
+ const pageParams = pageAction && (0, _page.paramsForPageAction)(pageAction, page_info);
81
+ if (pageParams) {
82
+ this.log("\n");
83
+ const resp = await this.request(pageParams);
84
+ return this.render(resp.data);
85
+ }
86
+ }
87
+ }
88
+ // Hide until guides are released in GA.
89
+ _define_property(MessageTypeList, "hidden", true);
90
+ _define_property(MessageTypeList, "summary", "Display all in-app message types for an environment.");
91
+ _define_property(MessageTypeList, "flags", {
92
+ environment: _core.Flags.string({
93
+ default: "development",
94
+ summary: "The environment to use."
95
+ }),
96
+ "hide-uncommitted-changes": _core.Flags.boolean({
97
+ summary: "Hide any uncommitted changes."
98
+ }),
99
+ ..._page.pageFlags
100
+ });
101
+ _define_property(MessageTypeList, "enableJsonFlag", true);