@knocklabs/cli 0.1.6 → 0.1.7
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 +74 -30
- package/dist/commands/commit/get.js +76 -0
- package/dist/commands/commit/list.js +99 -0
- package/dist/commands/commit/promote.js +36 -3
- package/dist/lib/api-v1.js +16 -0
- package/dist/lib/marshal/commit/helpers.js +13 -0
- package/dist/lib/marshal/commit/index.js +17 -0
- package/dist/lib/marshal/commit/types.js +5 -0
- package/oclif.manifest.json +111 -4
- package/package.json +8 -8
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
|
+
@knocklabs/cli/0.1.7 linux-x64 node-v18.18.2
|
|
20
20
|
$ knock --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ knock COMMAND
|
|
@@ -28,6 +28,8 @@ USAGE
|
|
|
28
28
|
|
|
29
29
|
<!-- commands -->
|
|
30
30
|
* [`knock commit`](#knock-commit)
|
|
31
|
+
* [`knock commit get ID`](#knock-commit-get-id)
|
|
32
|
+
* [`knock commit list`](#knock-commit-list)
|
|
31
33
|
* [`knock commit promote`](#knock-commit-promote)
|
|
32
34
|
* [`knock help [COMMANDS]`](#knock-help-commands)
|
|
33
35
|
* [`knock layout get EMAILLAYOUTKEY`](#knock-layout-get-emaillayoutkey)
|
|
@@ -75,23 +77,65 @@ FLAGS
|
|
|
75
77
|
--service-token=<value> (required) The service token to authenticate with.
|
|
76
78
|
```
|
|
77
79
|
|
|
78
|
-
_See code: [
|
|
80
|
+
_See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/commit/index.ts)_
|
|
81
|
+
|
|
82
|
+
## `knock commit get ID`
|
|
83
|
+
|
|
84
|
+
Display a single commit
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
USAGE
|
|
88
|
+
$ knock commit get ID --service-token <value> [--json]
|
|
89
|
+
|
|
90
|
+
FLAGS
|
|
91
|
+
--service-token=<value> (required) The service token to authenticate with.
|
|
92
|
+
|
|
93
|
+
GLOBAL FLAGS
|
|
94
|
+
--json Format output as json.
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
_See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/commit/get.ts)_
|
|
98
|
+
|
|
99
|
+
## `knock commit list`
|
|
100
|
+
|
|
101
|
+
Display all commits in an environment
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
USAGE
|
|
105
|
+
$ knock commit list --service-token <value> [--environment <value>] [--promoted] [--after <value>] [--before
|
|
106
|
+
<value>] [--limit <value>] [--json]
|
|
107
|
+
|
|
108
|
+
FLAGS
|
|
109
|
+
--after=<value> The cursor after which to fetch the next page.
|
|
110
|
+
--before=<value> The cursor before which to fetch the previous page.
|
|
111
|
+
--environment=<value> [default: development] The environment to use.
|
|
112
|
+
--limit=<value> The total number of entries to fetch per page.
|
|
113
|
+
--[no-]promoted Show only promoted or unpromoted changes between the given environment and the subsequent
|
|
114
|
+
environment.
|
|
115
|
+
--service-token=<value> (required) The service token to authenticate with.
|
|
116
|
+
|
|
117
|
+
GLOBAL FLAGS
|
|
118
|
+
--json Format output as json.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
_See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/commit/list.ts)_
|
|
79
122
|
|
|
80
123
|
## `knock commit promote`
|
|
81
124
|
|
|
82
|
-
Promote all
|
|
125
|
+
Promote one or all commits to the subsequent environment.
|
|
83
126
|
|
|
84
127
|
```
|
|
85
128
|
USAGE
|
|
86
|
-
$ knock commit promote --service-token <value> --to <value> [--force]
|
|
129
|
+
$ knock commit promote --service-token <value> [--to <value>] [--force] [--only <value>]
|
|
87
130
|
|
|
88
131
|
FLAGS
|
|
89
132
|
--force Remove the confirmation prompt.
|
|
133
|
+
--only=<value> The target commit id to promote to the subsequent environment
|
|
90
134
|
--service-token=<value> (required) The service token to authenticate with.
|
|
91
|
-
--to=<value>
|
|
135
|
+
--to=<value> The destination environment to promote all changes from the preceding environment.
|
|
92
136
|
```
|
|
93
137
|
|
|
94
|
-
_See code: [
|
|
138
|
+
_See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/commit/promote.ts)_
|
|
95
139
|
|
|
96
140
|
## `knock help [COMMANDS]`
|
|
97
141
|
|
|
@@ -131,7 +175,7 @@ GLOBAL FLAGS
|
|
|
131
175
|
--json Format output as json.
|
|
132
176
|
```
|
|
133
177
|
|
|
134
|
-
_See code: [
|
|
178
|
+
_See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/layout/get.ts)_
|
|
135
179
|
|
|
136
180
|
## `knock layout list`
|
|
137
181
|
|
|
@@ -154,7 +198,7 @@ GLOBAL FLAGS
|
|
|
154
198
|
--json Format output as json.
|
|
155
199
|
```
|
|
156
200
|
|
|
157
|
-
_See code: [
|
|
201
|
+
_See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/layout/list.ts)_
|
|
158
202
|
|
|
159
203
|
## `knock layout pull [EMAILLAYOUTKEY]`
|
|
160
204
|
|
|
@@ -174,7 +218,7 @@ FLAGS
|
|
|
174
218
|
--service-token=<value> (required) The service token to authenticate with.
|
|
175
219
|
```
|
|
176
220
|
|
|
177
|
-
_See code: [
|
|
221
|
+
_See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/layout/pull.ts)_
|
|
178
222
|
|
|
179
223
|
## `knock layout push [EMAILLAYOUTKEY]`
|
|
180
224
|
|
|
@@ -196,7 +240,7 @@ FLAGS
|
|
|
196
240
|
--service-token=<value> (required) The service token to authenticate with.
|
|
197
241
|
```
|
|
198
242
|
|
|
199
|
-
_See code: [
|
|
243
|
+
_See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/layout/push.ts)_
|
|
200
244
|
|
|
201
245
|
## `knock layout validate [EMAILLAYOUTKEY]`
|
|
202
246
|
|
|
@@ -215,7 +259,7 @@ FLAGS
|
|
|
215
259
|
--service-token=<value> (required) The service token to authenticate with.
|
|
216
260
|
```
|
|
217
261
|
|
|
218
|
-
_See code: [
|
|
262
|
+
_See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/layout/validate.ts)_
|
|
219
263
|
|
|
220
264
|
## `knock plugins`
|
|
221
265
|
|
|
@@ -238,7 +282,7 @@ EXAMPLES
|
|
|
238
282
|
$ knock plugins
|
|
239
283
|
```
|
|
240
284
|
|
|
241
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.
|
|
285
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.4/src/commands/plugins/index.ts)_
|
|
242
286
|
|
|
243
287
|
## `knock plugins:install PLUGIN...`
|
|
244
288
|
|
|
@@ -303,7 +347,7 @@ EXAMPLES
|
|
|
303
347
|
$ knock plugins:inspect myplugin
|
|
304
348
|
```
|
|
305
349
|
|
|
306
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.
|
|
350
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.4/src/commands/plugins/inspect.ts)_
|
|
307
351
|
|
|
308
352
|
## `knock plugins:install PLUGIN...`
|
|
309
353
|
|
|
@@ -343,7 +387,7 @@ EXAMPLES
|
|
|
343
387
|
$ knock plugins:install someuser/someplugin
|
|
344
388
|
```
|
|
345
389
|
|
|
346
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.
|
|
390
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.4/src/commands/plugins/install.ts)_
|
|
347
391
|
|
|
348
392
|
## `knock plugins:link PLUGIN`
|
|
349
393
|
|
|
@@ -373,7 +417,7 @@ EXAMPLES
|
|
|
373
417
|
$ knock plugins:link myplugin
|
|
374
418
|
```
|
|
375
419
|
|
|
376
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.
|
|
420
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.4/src/commands/plugins/link.ts)_
|
|
377
421
|
|
|
378
422
|
## `knock plugins:uninstall PLUGIN...`
|
|
379
423
|
|
|
@@ -421,7 +465,7 @@ ALIASES
|
|
|
421
465
|
$ knock plugins remove
|
|
422
466
|
```
|
|
423
467
|
|
|
424
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.
|
|
468
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.4/src/commands/plugins/uninstall.ts)_
|
|
425
469
|
|
|
426
470
|
## `knock plugins:uninstall PLUGIN...`
|
|
427
471
|
|
|
@@ -462,7 +506,7 @@ DESCRIPTION
|
|
|
462
506
|
Update installed plugins.
|
|
463
507
|
```
|
|
464
508
|
|
|
465
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.
|
|
509
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.9.4/src/commands/plugins/update.ts)_
|
|
466
510
|
|
|
467
511
|
## `knock translation get TRANSLATIONREF`
|
|
468
512
|
|
|
@@ -487,7 +531,7 @@ GLOBAL FLAGS
|
|
|
487
531
|
--json Format output as json.
|
|
488
532
|
```
|
|
489
533
|
|
|
490
|
-
_See code: [
|
|
534
|
+
_See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/translation/get.ts)_
|
|
491
535
|
|
|
492
536
|
## `knock translation list`
|
|
493
537
|
|
|
@@ -510,7 +554,7 @@ GLOBAL FLAGS
|
|
|
510
554
|
--json Format output as json.
|
|
511
555
|
```
|
|
512
556
|
|
|
513
|
-
_See code: [
|
|
557
|
+
_See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/translation/list.ts)_
|
|
514
558
|
|
|
515
559
|
## `knock translation pull [TRANSLATIONREF]`
|
|
516
560
|
|
|
@@ -535,7 +579,7 @@ FLAGS
|
|
|
535
579
|
--translations-dir=<value> The target directory path to pull all translations into.
|
|
536
580
|
```
|
|
537
581
|
|
|
538
|
-
_See code: [
|
|
582
|
+
_See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/translation/pull.ts)_
|
|
539
583
|
|
|
540
584
|
## `knock translation push [TRANSLATIONREF]`
|
|
541
585
|
|
|
@@ -562,7 +606,7 @@ FLAGS
|
|
|
562
606
|
--translations-dir=<value> The target directory path to find all translations to push.
|
|
563
607
|
```
|
|
564
608
|
|
|
565
|
-
_See code: [
|
|
609
|
+
_See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/translation/push.ts)_
|
|
566
610
|
|
|
567
611
|
## `knock translation validate [TRANSLATIONREF]`
|
|
568
612
|
|
|
@@ -587,7 +631,7 @@ FLAGS
|
|
|
587
631
|
--translations-dir=<value> The target directory path to find all translations to validate.
|
|
588
632
|
```
|
|
589
633
|
|
|
590
|
-
_See code: [
|
|
634
|
+
_See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/translation/validate.ts)_
|
|
591
635
|
|
|
592
636
|
## `knock whoami`
|
|
593
637
|
|
|
@@ -604,7 +648,7 @@ GLOBAL FLAGS
|
|
|
604
648
|
--json Format output as json.
|
|
605
649
|
```
|
|
606
650
|
|
|
607
|
-
_See code: [
|
|
651
|
+
_See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/whoami.ts)_
|
|
608
652
|
|
|
609
653
|
## `knock workflow activate WORKFLOWKEY`
|
|
610
654
|
|
|
@@ -631,7 +675,7 @@ DESCRIPTION
|
|
|
631
675
|
with `false` in order to deactivate it.
|
|
632
676
|
```
|
|
633
677
|
|
|
634
|
-
_See code: [
|
|
678
|
+
_See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/workflow/activate.ts)_
|
|
635
679
|
|
|
636
680
|
## `knock workflow get WORKFLOWKEY`
|
|
637
681
|
|
|
@@ -651,7 +695,7 @@ GLOBAL FLAGS
|
|
|
651
695
|
--json Format output as json.
|
|
652
696
|
```
|
|
653
697
|
|
|
654
|
-
_See code: [
|
|
698
|
+
_See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/workflow/get.ts)_
|
|
655
699
|
|
|
656
700
|
## `knock workflow list`
|
|
657
701
|
|
|
@@ -674,7 +718,7 @@ GLOBAL FLAGS
|
|
|
674
718
|
--json Format output as json.
|
|
675
719
|
```
|
|
676
720
|
|
|
677
|
-
_See code: [
|
|
721
|
+
_See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/workflow/list.ts)_
|
|
678
722
|
|
|
679
723
|
## `knock workflow pull [WORKFLOWKEY]`
|
|
680
724
|
|
|
@@ -694,7 +738,7 @@ FLAGS
|
|
|
694
738
|
--workflows-dir=<value> The target directory path to pull all workflows into.
|
|
695
739
|
```
|
|
696
740
|
|
|
697
|
-
_See code: [
|
|
741
|
+
_See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/workflow/pull.ts)_
|
|
698
742
|
|
|
699
743
|
## `knock workflow push [WORKFLOWKEY]`
|
|
700
744
|
|
|
@@ -715,7 +759,7 @@ FLAGS
|
|
|
715
759
|
--workflows-dir=<value> The target directory path to find all workflows to push.
|
|
716
760
|
```
|
|
717
761
|
|
|
718
|
-
_See code: [
|
|
762
|
+
_See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/workflow/push.ts)_
|
|
719
763
|
|
|
720
764
|
## `knock workflow run WORKFLOWKEY`
|
|
721
765
|
|
|
@@ -736,7 +780,7 @@ FLAGS
|
|
|
736
780
|
--tenant=<value> A tenant id for the workflow run.
|
|
737
781
|
```
|
|
738
782
|
|
|
739
|
-
_See code: [
|
|
783
|
+
_See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/workflow/run.ts)_
|
|
740
784
|
|
|
741
785
|
## `knock workflow validate [WORKFLOWKEY]`
|
|
742
786
|
|
|
@@ -755,5 +799,5 @@ FLAGS
|
|
|
755
799
|
--workflows-dir=<value> The target directory path to find all workflows to validate.
|
|
756
800
|
```
|
|
757
801
|
|
|
758
|
-
_See code: [
|
|
802
|
+
_See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.7/src/commands/workflow/validate.ts)_
|
|
759
803
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>CommitGet
|
|
8
|
+
});
|
|
9
|
+
const _core = require("@oclif/core");
|
|
10
|
+
const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
|
|
11
|
+
const _date = require("../../lib/helpers/date");
|
|
12
|
+
const _request = require("../../lib/helpers/request");
|
|
13
|
+
const _commit = require("../../lib/marshal/commit");
|
|
14
|
+
function _interopRequireDefault(obj) {
|
|
15
|
+
return obj && obj.__esModule ? obj : {
|
|
16
|
+
default: obj
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
class CommitGet extends _baseCommand.default {
|
|
20
|
+
async run() {
|
|
21
|
+
const { flags } = this.props;
|
|
22
|
+
const resp = await (0, _request.withSpinner)(()=>this.apiV1.getCommit(this.props));
|
|
23
|
+
if (flags.json) return resp.data;
|
|
24
|
+
this.render(resp.data);
|
|
25
|
+
}
|
|
26
|
+
render(commit) {
|
|
27
|
+
this.log(`‣ Showing commit \`${commit.id}\` in \`${commit.environment}\` environment`);
|
|
28
|
+
/*
|
|
29
|
+
* Commit table
|
|
30
|
+
*/ const rows = [
|
|
31
|
+
{
|
|
32
|
+
key: "ID",
|
|
33
|
+
value: commit.id
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
key: "Resource",
|
|
37
|
+
value: commit.resource.type
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "Identifier",
|
|
41
|
+
value: commit.resource.identifier
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: "Author",
|
|
45
|
+
value: (0, _commit.formatCommitAuthor)(commit)
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
key: "Created at",
|
|
49
|
+
value: (0, _date.formatDate)(commit.created_at)
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
this.log("");
|
|
53
|
+
_core.ux.table(rows, {
|
|
54
|
+
key: {
|
|
55
|
+
header: "Commit",
|
|
56
|
+
minWidth: 18
|
|
57
|
+
},
|
|
58
|
+
value: {
|
|
59
|
+
header: "",
|
|
60
|
+
minWidth: 16
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this.log("");
|
|
64
|
+
if (commit.commit_message) {
|
|
65
|
+
this.log(commit.commit_message);
|
|
66
|
+
this.log("");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
CommitGet.summary = "Display a single commit";
|
|
71
|
+
CommitGet.args = {
|
|
72
|
+
id: _core.Args.string({
|
|
73
|
+
required: true
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
CommitGet.enableJsonFlag = true;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>CommitList
|
|
8
|
+
});
|
|
9
|
+
const _core = require("@oclif/core");
|
|
10
|
+
const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
|
|
11
|
+
const _date = require("../../lib/helpers/date");
|
|
12
|
+
const _object = require("../../lib/helpers/object");
|
|
13
|
+
const _page = require("../../lib/helpers/page");
|
|
14
|
+
const _request = require("../../lib/helpers/request");
|
|
15
|
+
const _commit = require("../../lib/marshal/commit");
|
|
16
|
+
function _interopRequireDefault(obj) {
|
|
17
|
+
return obj && obj.__esModule ? obj : {
|
|
18
|
+
default: obj
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
class CommitList extends _baseCommand.default {
|
|
22
|
+
async run() {
|
|
23
|
+
const resp = await this.request();
|
|
24
|
+
const { flags } = this.props;
|
|
25
|
+
if (flags.json) return resp.data;
|
|
26
|
+
this.render(resp.data);
|
|
27
|
+
}
|
|
28
|
+
async request(pageParams = {}) {
|
|
29
|
+
const props = (0, _object.merge)(this.props, {
|
|
30
|
+
flags: {
|
|
31
|
+
...pageParams
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return (0, _request.withSpinner)(()=>this.apiV1.listCommits(props));
|
|
35
|
+
}
|
|
36
|
+
async render(data) {
|
|
37
|
+
const { entries } = data;
|
|
38
|
+
const { environment: env , promoted } = this.props.flags;
|
|
39
|
+
let qualifier = "";
|
|
40
|
+
if (promoted === true) {
|
|
41
|
+
qualifier = "(showing only promoted)";
|
|
42
|
+
}
|
|
43
|
+
if (promoted === false) {
|
|
44
|
+
qualifier = "(showing only unpromoted)";
|
|
45
|
+
}
|
|
46
|
+
this.log(`‣ Showing ${entries.length} commits in \`${env}\` environment ${qualifier}\n`);
|
|
47
|
+
/*
|
|
48
|
+
* Commits table
|
|
49
|
+
*/ _core.ux.table(entries, {
|
|
50
|
+
id: {
|
|
51
|
+
header: "ID"
|
|
52
|
+
},
|
|
53
|
+
resource: {
|
|
54
|
+
header: "Resource",
|
|
55
|
+
get: (entry)=>entry.resource.type
|
|
56
|
+
},
|
|
57
|
+
identifier: {
|
|
58
|
+
header: "Identifier",
|
|
59
|
+
get: (entry)=>entry.resource.identifier
|
|
60
|
+
},
|
|
61
|
+
author: {
|
|
62
|
+
header: "Author",
|
|
63
|
+
get: (entry)=>(0, _commit.formatCommitAuthor)(entry)
|
|
64
|
+
},
|
|
65
|
+
commit_message: {
|
|
66
|
+
header: "Commit message",
|
|
67
|
+
get: (entry)=>entry.commit_message ? entry.commit_message.trim() : ""
|
|
68
|
+
},
|
|
69
|
+
created_at: {
|
|
70
|
+
header: "Created at",
|
|
71
|
+
get: (entry)=>(0, _date.formatDate)(entry.created_at)
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return this.prompt(data);
|
|
75
|
+
}
|
|
76
|
+
async prompt(data) {
|
|
77
|
+
const { page_info } = data;
|
|
78
|
+
const pageAction = await (0, _page.maybePromptPageAction)(page_info);
|
|
79
|
+
const pageParams = pageAction && (0, _page.paramsForPageAction)(pageAction, page_info);
|
|
80
|
+
if (pageParams) {
|
|
81
|
+
this.log("\n");
|
|
82
|
+
const resp = await this.request(pageParams);
|
|
83
|
+
return this.render(resp.data);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
CommitList.summary = "Display all commits in an environment";
|
|
88
|
+
CommitList.flags = {
|
|
89
|
+
environment: _core.Flags.string({
|
|
90
|
+
default: "development",
|
|
91
|
+
summary: "The environment to use."
|
|
92
|
+
}),
|
|
93
|
+
promoted: _core.Flags.boolean({
|
|
94
|
+
summary: "Show only promoted or unpromoted changes between the given environment and the subsequent environment.",
|
|
95
|
+
allowNo: true
|
|
96
|
+
}),
|
|
97
|
+
..._page.pageFlags
|
|
98
|
+
};
|
|
99
|
+
CommitList.enableJsonFlag = true;
|
|
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
});
|
|
9
9
|
const _core = require("@oclif/core");
|
|
10
10
|
const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../../lib/base-command"));
|
|
11
|
+
const _error = require("../../lib/helpers/error");
|
|
11
12
|
const _request = require("../../lib/helpers/request");
|
|
13
|
+
const _string = require("../../lib/helpers/string");
|
|
12
14
|
const _ux = require("../../lib/helpers/ux");
|
|
13
15
|
function _interopRequireDefault(obj) {
|
|
14
16
|
return obj && obj.__esModule ? obj : {
|
|
@@ -17,6 +19,35 @@ function _interopRequireDefault(obj) {
|
|
|
17
19
|
}
|
|
18
20
|
class CommitPromote extends _baseCommand.default {
|
|
19
21
|
async run() {
|
|
22
|
+
const { flags } = this.props;
|
|
23
|
+
// Currently this command support two modes of operation based on the flags:
|
|
24
|
+
// * --to : Promotes all changes to the destination environment.
|
|
25
|
+
// * --only: Promotes one commit to the subsequent enviroment
|
|
26
|
+
// The absence or presence of both flags will result in an error.
|
|
27
|
+
if (flags.to && flags.only) {
|
|
28
|
+
throw new Error("`--to` and `--only` flags cannot be used together.\n See more help with --help");
|
|
29
|
+
}
|
|
30
|
+
if (!flags.to && !flags.only) {
|
|
31
|
+
throw new Error("You must specify either `--to` or `--only` flag.\n See more help with --help");
|
|
32
|
+
}
|
|
33
|
+
return flags.only ? this.promoteOneChange() : this.promoteAllChanges();
|
|
34
|
+
}
|
|
35
|
+
async promoteOneChange() {
|
|
36
|
+
const { flags } = this.props;
|
|
37
|
+
// Confirm first as we are about to promote the commit, unless forced.
|
|
38
|
+
const prompt = `Promote the commit \`${flags.only}\` ?`;
|
|
39
|
+
const input = flags.force || await (0, _ux.promptToConfirm)(prompt);
|
|
40
|
+
if (!input) return;
|
|
41
|
+
const resp = await (0, _request.withSpinner)(()=>this.apiV1.promoteOneChange(this.props));
|
|
42
|
+
if (!(0, _request.isSuccessResp)(resp)) {
|
|
43
|
+
const message = (0, _request.formatErrorRespMessage)(resp);
|
|
44
|
+
return this.error(new _error.ApiError(message));
|
|
45
|
+
}
|
|
46
|
+
const { commit } = resp.data;
|
|
47
|
+
this.log(`‣ Successfully promoted the commit \`${flags.only}\` into \`${commit.environment}\` environment`);
|
|
48
|
+
this.log((0, _string.indentString)(`Commit id: ${commit.id}`, 4));
|
|
49
|
+
}
|
|
50
|
+
async promoteAllChanges() {
|
|
20
51
|
const { flags } = this.props;
|
|
21
52
|
// Confirm first as we are about to promote changes to go live in the target
|
|
22
53
|
// environment, unless forced.
|
|
@@ -27,13 +58,15 @@ class CommitPromote extends _baseCommand.default {
|
|
|
27
58
|
this.log(`‣ Successfully promoted all changes to \`${flags.to}\` environment`);
|
|
28
59
|
}
|
|
29
60
|
}
|
|
30
|
-
CommitPromote.summary = "Promote all
|
|
61
|
+
CommitPromote.summary = "Promote one or all commits to the subsequent environment.";
|
|
31
62
|
CommitPromote.flags = {
|
|
32
63
|
to: _core.Flags.string({
|
|
33
|
-
summary: "The destination environment to promote changes from the preceding environment."
|
|
34
|
-
required: true
|
|
64
|
+
summary: "The destination environment to promote all changes from the preceding environment."
|
|
35
65
|
}),
|
|
36
66
|
force: _core.Flags.boolean({
|
|
37
67
|
summary: "Remove the confirmation prompt."
|
|
68
|
+
}),
|
|
69
|
+
only: _core.Flags.string({
|
|
70
|
+
summary: "The target commit id to promote to the subsequent environment"
|
|
38
71
|
})
|
|
39
72
|
};
|
package/dist/lib/api-v1.js
CHANGED
|
@@ -94,6 +94,19 @@ class ApiV1 {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
// By resources: Commits
|
|
97
|
+
async listCommits({ flags }) {
|
|
98
|
+
const params = (0, _object.prune)({
|
|
99
|
+
environment: flags.environment,
|
|
100
|
+
promoted: flags.promoted,
|
|
101
|
+
...(0, _page.toPageParams)(flags)
|
|
102
|
+
});
|
|
103
|
+
return this.get("/commits", {
|
|
104
|
+
params
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
async getCommit({ args }) {
|
|
108
|
+
return this.get(`/commits/${args.id}`);
|
|
109
|
+
}
|
|
97
110
|
async commitAllChanges({ flags }) {
|
|
98
111
|
const params = (0, _object.prune)({
|
|
99
112
|
environment: flags.environment,
|
|
@@ -111,6 +124,9 @@ class ApiV1 {
|
|
|
111
124
|
params
|
|
112
125
|
});
|
|
113
126
|
}
|
|
127
|
+
async promoteOneChange({ flags }) {
|
|
128
|
+
return this.put(`/commits/${flags.only}/promote`);
|
|
129
|
+
}
|
|
114
130
|
// By resources: Translations
|
|
115
131
|
async listTranslations({ flags }, filters = {}) {
|
|
116
132
|
const params = (0, _object.prune)({
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formatCommitAuthor", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>formatCommitAuthor
|
|
8
|
+
});
|
|
9
|
+
function formatCommitAuthor(commit) {
|
|
10
|
+
const email = commit.author.email;
|
|
11
|
+
const name = commit.author.name;
|
|
12
|
+
return name ? `${name} <${email}>` : `<${email}>`;
|
|
13
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_exportStar(require("./helpers"), exports);
|
|
6
|
+
_exportStar(require("./types"), exports);
|
|
7
|
+
function _exportStar(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
return from;
|
|
17
|
+
}
|
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.
|
|
2
|
+
"version": "0.1.7",
|
|
3
3
|
"commands": {
|
|
4
4
|
"knock": {
|
|
5
5
|
"id": "knock",
|
|
@@ -86,6 +86,44 @@
|
|
|
86
86
|
},
|
|
87
87
|
"args": {}
|
|
88
88
|
},
|
|
89
|
+
"commit:get": {
|
|
90
|
+
"id": "commit:get",
|
|
91
|
+
"summary": "Display a single commit",
|
|
92
|
+
"strict": true,
|
|
93
|
+
"pluginName": "@knocklabs/cli",
|
|
94
|
+
"pluginAlias": "@knocklabs/cli",
|
|
95
|
+
"pluginType": "core",
|
|
96
|
+
"aliases": [],
|
|
97
|
+
"flags": {
|
|
98
|
+
"service-token": {
|
|
99
|
+
"name": "service-token",
|
|
100
|
+
"type": "option",
|
|
101
|
+
"summary": "The service token to authenticate with.",
|
|
102
|
+
"required": true,
|
|
103
|
+
"multiple": false
|
|
104
|
+
},
|
|
105
|
+
"api-origin": {
|
|
106
|
+
"name": "api-origin",
|
|
107
|
+
"type": "option",
|
|
108
|
+
"hidden": true,
|
|
109
|
+
"required": false,
|
|
110
|
+
"multiple": false
|
|
111
|
+
},
|
|
112
|
+
"json": {
|
|
113
|
+
"name": "json",
|
|
114
|
+
"type": "boolean",
|
|
115
|
+
"description": "Format output as json.",
|
|
116
|
+
"helpGroup": "GLOBAL",
|
|
117
|
+
"allowNo": false
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"args": {
|
|
121
|
+
"id": {
|
|
122
|
+
"name": "id",
|
|
123
|
+
"required": true
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
89
127
|
"commit": {
|
|
90
128
|
"id": "commit",
|
|
91
129
|
"summary": "Commit all changes in development environment.",
|
|
@@ -135,9 +173,73 @@
|
|
|
135
173
|
},
|
|
136
174
|
"args": {}
|
|
137
175
|
},
|
|
176
|
+
"commit:list": {
|
|
177
|
+
"id": "commit:list",
|
|
178
|
+
"summary": "Display all commits in an environment",
|
|
179
|
+
"strict": true,
|
|
180
|
+
"pluginName": "@knocklabs/cli",
|
|
181
|
+
"pluginAlias": "@knocklabs/cli",
|
|
182
|
+
"pluginType": "core",
|
|
183
|
+
"aliases": [],
|
|
184
|
+
"flags": {
|
|
185
|
+
"service-token": {
|
|
186
|
+
"name": "service-token",
|
|
187
|
+
"type": "option",
|
|
188
|
+
"summary": "The service token to authenticate with.",
|
|
189
|
+
"required": true,
|
|
190
|
+
"multiple": false
|
|
191
|
+
},
|
|
192
|
+
"api-origin": {
|
|
193
|
+
"name": "api-origin",
|
|
194
|
+
"type": "option",
|
|
195
|
+
"hidden": true,
|
|
196
|
+
"required": false,
|
|
197
|
+
"multiple": false
|
|
198
|
+
},
|
|
199
|
+
"environment": {
|
|
200
|
+
"name": "environment",
|
|
201
|
+
"type": "option",
|
|
202
|
+
"summary": "The environment to use.",
|
|
203
|
+
"multiple": false,
|
|
204
|
+
"default": "development"
|
|
205
|
+
},
|
|
206
|
+
"promoted": {
|
|
207
|
+
"name": "promoted",
|
|
208
|
+
"type": "boolean",
|
|
209
|
+
"summary": "Show only promoted or unpromoted changes between the given environment and the subsequent environment.",
|
|
210
|
+
"allowNo": true
|
|
211
|
+
},
|
|
212
|
+
"after": {
|
|
213
|
+
"name": "after",
|
|
214
|
+
"type": "option",
|
|
215
|
+
"summary": "The cursor after which to fetch the next page.",
|
|
216
|
+
"multiple": false
|
|
217
|
+
},
|
|
218
|
+
"before": {
|
|
219
|
+
"name": "before",
|
|
220
|
+
"type": "option",
|
|
221
|
+
"summary": "The cursor before which to fetch the previous page.",
|
|
222
|
+
"multiple": false
|
|
223
|
+
},
|
|
224
|
+
"limit": {
|
|
225
|
+
"name": "limit",
|
|
226
|
+
"type": "option",
|
|
227
|
+
"summary": "The total number of entries to fetch per page.",
|
|
228
|
+
"multiple": false
|
|
229
|
+
},
|
|
230
|
+
"json": {
|
|
231
|
+
"name": "json",
|
|
232
|
+
"type": "boolean",
|
|
233
|
+
"description": "Format output as json.",
|
|
234
|
+
"helpGroup": "GLOBAL",
|
|
235
|
+
"allowNo": false
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"args": {}
|
|
239
|
+
},
|
|
138
240
|
"commit:promote": {
|
|
139
241
|
"id": "commit:promote",
|
|
140
|
-
"summary": "Promote all
|
|
242
|
+
"summary": "Promote one or all commits to the subsequent environment.",
|
|
141
243
|
"strict": true,
|
|
142
244
|
"pluginName": "@knocklabs/cli",
|
|
143
245
|
"pluginAlias": "@knocklabs/cli",
|
|
@@ -161,8 +263,7 @@
|
|
|
161
263
|
"to": {
|
|
162
264
|
"name": "to",
|
|
163
265
|
"type": "option",
|
|
164
|
-
"summary": "The destination environment to promote changes from the preceding environment.",
|
|
165
|
-
"required": true,
|
|
266
|
+
"summary": "The destination environment to promote all changes from the preceding environment.",
|
|
166
267
|
"multiple": false
|
|
167
268
|
},
|
|
168
269
|
"force": {
|
|
@@ -170,6 +271,12 @@
|
|
|
170
271
|
"type": "boolean",
|
|
171
272
|
"summary": "Remove the confirmation prompt.",
|
|
172
273
|
"allowNo": false
|
|
274
|
+
},
|
|
275
|
+
"only": {
|
|
276
|
+
"name": "only",
|
|
277
|
+
"type": "option",
|
|
278
|
+
"summary": "The target commit id to promote to the subsequent environment",
|
|
279
|
+
"multiple": false
|
|
173
280
|
}
|
|
174
281
|
},
|
|
175
282
|
"args": {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knocklabs/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Knock CLI",
|
|
5
5
|
"author": "@knocklabs",
|
|
6
6
|
"bin": {
|
|
@@ -21,24 +21,24 @@
|
|
|
21
21
|
"@oclif/plugin-help": "^5",
|
|
22
22
|
"@oclif/plugin-plugins": "^3",
|
|
23
23
|
"@prantlf/jsonlint": "^14.0.3",
|
|
24
|
-
"axios": "^1.
|
|
24
|
+
"axios": "^1.5.1",
|
|
25
25
|
"date-fns": "^2.30.0",
|
|
26
26
|
"enquirer": "^2.4.1",
|
|
27
27
|
"fs-extra": "^11.1.1",
|
|
28
|
-
"liquidjs": "^10.
|
|
28
|
+
"liquidjs": "^10.9.3",
|
|
29
29
|
"locale-codes": "^1.3.1",
|
|
30
30
|
"lodash": "^4.17.21",
|
|
31
|
-
"yup": "^1.2
|
|
31
|
+
"yup": "^1.3.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@oclif/test": "^2.
|
|
34
|
+
"@oclif/test": "^2.5.6",
|
|
35
35
|
"@swc/cli": "^0.1.62",
|
|
36
36
|
"@swc/core": "^1.3.37",
|
|
37
37
|
"@swc/helpers": "^0.4.14",
|
|
38
38
|
"@types/chai": "^4",
|
|
39
|
-
"@types/fs-extra": "^11.0.
|
|
39
|
+
"@types/fs-extra": "^11.0.3",
|
|
40
40
|
"@types/mocha": "^10.0.1",
|
|
41
|
-
"@types/node": "^20.
|
|
41
|
+
"@types/node": "^20.9.0",
|
|
42
42
|
"chai": "^4",
|
|
43
43
|
"eslint": "^7.32.0",
|
|
44
44
|
"eslint-config-oclif": "^4",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"eslint-plugin-prettier": "^4.2.1",
|
|
48
48
|
"eslint-plugin-simple-import-sort": "^10.0.0",
|
|
49
49
|
"mocha": "^10",
|
|
50
|
-
"nock": "^13.3.
|
|
50
|
+
"nock": "^13.3.8",
|
|
51
51
|
"oclif": "^3",
|
|
52
52
|
"prettier": "2.8.8",
|
|
53
53
|
"shx": "^0.3.4",
|