@knocklabs/cli 0.2.0 → 0.2.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 +35 -35
- package/dist/commands/branch/create.js +56 -0
- package/dist/commands/branch/delete.js +60 -0
- package/dist/commands/branch/list.js +89 -0
- package/dist/commands/whoami.js +7 -8
- package/dist/lib/api-v1.js +22 -8
- package/dist/lib/helpers/arg.js +23 -0
- package/dist/lib/helpers/request.js +48 -2
- package/dist/lib/marshal/index.isomorphic.js +8 -4
- package/dist/lib/marshal/reusable-step/helpers.js +72 -0
- package/dist/lib/marshal/reusable-step/index.js +19 -0
- package/dist/lib/marshal/reusable-step/processor.isomorphic.js +86 -0
- package/dist/lib/marshal/reusable-step/types.js +4 -0
- package/oclif.manifest.json +174 -1
- package/package.json +5 -3
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.2.
|
|
19
|
+
@knocklabs/cli/0.2.1 linux-x64 node-v18.20.8
|
|
20
20
|
$ knock --help [COMMAND]
|
|
21
21
|
USAGE
|
|
22
22
|
$ knock COMMAND
|
|
@@ -80,7 +80,7 @@ FLAGS
|
|
|
80
80
|
--service-token=<value> The service token to authenticate with.
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
_See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
83
|
+
_See code: [src/commands/commit/index.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/commit/index.ts)_
|
|
84
84
|
|
|
85
85
|
## `knock commit get ID`
|
|
86
86
|
|
|
@@ -97,7 +97,7 @@ GLOBAL FLAGS
|
|
|
97
97
|
--json Format output as json.
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
_See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
100
|
+
_See code: [src/commands/commit/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/commit/get.ts)_
|
|
101
101
|
|
|
102
102
|
## `knock commit list`
|
|
103
103
|
|
|
@@ -127,7 +127,7 @@ GLOBAL FLAGS
|
|
|
127
127
|
--json Format output as json.
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
_See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
130
|
+
_See code: [src/commands/commit/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/commit/list.ts)_
|
|
131
131
|
|
|
132
132
|
## `knock commit promote`
|
|
133
133
|
|
|
@@ -144,7 +144,7 @@ FLAGS
|
|
|
144
144
|
--to=<value> The destination environment to promote all changes from the preceding environment.
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
_See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
147
|
+
_See code: [src/commands/commit/promote.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/commit/promote.ts)_
|
|
148
148
|
|
|
149
149
|
## `knock guide activate GUIDEKEY`
|
|
150
150
|
|
|
@@ -174,7 +174,7 @@ DESCRIPTION
|
|
|
174
174
|
or deactivated at a later time using the --from and --until flags.
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
_See code: [src/commands/guide/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
177
|
+
_See code: [src/commands/guide/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/guide/activate.ts)_
|
|
178
178
|
|
|
179
179
|
## `knock guide generate-types`
|
|
180
180
|
|
|
@@ -195,7 +195,7 @@ DESCRIPTION
|
|
|
195
195
|
Generate types for all guides in an environment and write them to a file.
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
_See code: [src/commands/guide/generate-types.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
198
|
+
_See code: [src/commands/guide/generate-types.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/guide/generate-types.ts)_
|
|
199
199
|
|
|
200
200
|
## `knock help [COMMAND]`
|
|
201
201
|
|
|
@@ -235,7 +235,7 @@ GLOBAL FLAGS
|
|
|
235
235
|
--json Format output as json.
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
-
_See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
238
|
+
_See code: [src/commands/layout/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/layout/get.ts)_
|
|
239
239
|
|
|
240
240
|
## `knock layout list`
|
|
241
241
|
|
|
@@ -258,7 +258,7 @@ GLOBAL FLAGS
|
|
|
258
258
|
--json Format output as json.
|
|
259
259
|
```
|
|
260
260
|
|
|
261
|
-
_See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
261
|
+
_See code: [src/commands/layout/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/layout/list.ts)_
|
|
262
262
|
|
|
263
263
|
## `knock layout pull [EMAILLAYOUTKEY]`
|
|
264
264
|
|
|
@@ -278,7 +278,7 @@ FLAGS
|
|
|
278
278
|
--service-token=<value> The service token to authenticate with.
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
-
_See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
281
|
+
_See code: [src/commands/layout/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/layout/pull.ts)_
|
|
282
282
|
|
|
283
283
|
## `knock layout push [EMAILLAYOUTKEY]`
|
|
284
284
|
|
|
@@ -300,7 +300,7 @@ FLAGS
|
|
|
300
300
|
--service-token=<value> The service token to authenticate with.
|
|
301
301
|
```
|
|
302
302
|
|
|
303
|
-
_See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
303
|
+
_See code: [src/commands/layout/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/layout/push.ts)_
|
|
304
304
|
|
|
305
305
|
## `knock layout validate [EMAILLAYOUTKEY]`
|
|
306
306
|
|
|
@@ -319,7 +319,7 @@ FLAGS
|
|
|
319
319
|
--service-token=<value> The service token to authenticate with.
|
|
320
320
|
```
|
|
321
321
|
|
|
322
|
-
_See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
322
|
+
_See code: [src/commands/layout/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/layout/validate.ts)_
|
|
323
323
|
|
|
324
324
|
## `knock login`
|
|
325
325
|
|
|
@@ -331,7 +331,7 @@ FLAGS
|
|
|
331
331
|
--service-token=<value> The service token to authenticate with.
|
|
332
332
|
```
|
|
333
333
|
|
|
334
|
-
_See code: [src/commands/login.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
334
|
+
_See code: [src/commands/login.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/login.ts)_
|
|
335
335
|
|
|
336
336
|
## `knock logout`
|
|
337
337
|
|
|
@@ -343,7 +343,7 @@ FLAGS
|
|
|
343
343
|
--service-token=<value> The service token to authenticate with.
|
|
344
344
|
```
|
|
345
345
|
|
|
346
|
-
_See code: [src/commands/logout.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
346
|
+
_See code: [src/commands/logout.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/logout.ts)_
|
|
347
347
|
|
|
348
348
|
## `knock partial get PARTIALKEY`
|
|
349
349
|
|
|
@@ -363,7 +363,7 @@ GLOBAL FLAGS
|
|
|
363
363
|
--json Format output as json.
|
|
364
364
|
```
|
|
365
365
|
|
|
366
|
-
_See code: [src/commands/partial/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
366
|
+
_See code: [src/commands/partial/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/partial/get.ts)_
|
|
367
367
|
|
|
368
368
|
## `knock partial list`
|
|
369
369
|
|
|
@@ -386,7 +386,7 @@ GLOBAL FLAGS
|
|
|
386
386
|
--json Format output as json.
|
|
387
387
|
```
|
|
388
388
|
|
|
389
|
-
_See code: [src/commands/partial/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
389
|
+
_See code: [src/commands/partial/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/partial/list.ts)_
|
|
390
390
|
|
|
391
391
|
## `knock partial pull [PARTIALKEY]`
|
|
392
392
|
|
|
@@ -406,7 +406,7 @@ FLAGS
|
|
|
406
406
|
--service-token=<value> The service token to authenticate with.
|
|
407
407
|
```
|
|
408
408
|
|
|
409
|
-
_See code: [src/commands/partial/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
409
|
+
_See code: [src/commands/partial/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/partial/pull.ts)_
|
|
410
410
|
|
|
411
411
|
## `knock partial push [PARTIALKEY]`
|
|
412
412
|
|
|
@@ -427,7 +427,7 @@ FLAGS
|
|
|
427
427
|
--service-token=<value> The service token to authenticate with.
|
|
428
428
|
```
|
|
429
429
|
|
|
430
|
-
_See code: [src/commands/partial/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
430
|
+
_See code: [src/commands/partial/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/partial/push.ts)_
|
|
431
431
|
|
|
432
432
|
## `knock partial validate [PARTIALKEY]`
|
|
433
433
|
|
|
@@ -446,7 +446,7 @@ FLAGS
|
|
|
446
446
|
--service-token=<value> The service token to authenticate with.
|
|
447
447
|
```
|
|
448
448
|
|
|
449
|
-
_See code: [src/commands/partial/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
449
|
+
_See code: [src/commands/partial/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/partial/validate.ts)_
|
|
450
450
|
|
|
451
451
|
## `knock pull`
|
|
452
452
|
|
|
@@ -465,7 +465,7 @@ FLAGS
|
|
|
465
465
|
--service-token=<value> The service token to authenticate with.
|
|
466
466
|
```
|
|
467
467
|
|
|
468
|
-
_See code: [src/commands/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
468
|
+
_See code: [src/commands/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/pull.ts)_
|
|
469
469
|
|
|
470
470
|
## `knock push`
|
|
471
471
|
|
|
@@ -485,7 +485,7 @@ FLAGS
|
|
|
485
485
|
--service-token=<value> The service token to authenticate with.
|
|
486
486
|
```
|
|
487
487
|
|
|
488
|
-
_See code: [src/commands/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
488
|
+
_See code: [src/commands/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/push.ts)_
|
|
489
489
|
|
|
490
490
|
## `knock translation get TRANSLATIONREF`
|
|
491
491
|
|
|
@@ -512,7 +512,7 @@ GLOBAL FLAGS
|
|
|
512
512
|
--json Format output as json.
|
|
513
513
|
```
|
|
514
514
|
|
|
515
|
-
_See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
515
|
+
_See code: [src/commands/translation/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/translation/get.ts)_
|
|
516
516
|
|
|
517
517
|
## `knock translation list`
|
|
518
518
|
|
|
@@ -535,7 +535,7 @@ GLOBAL FLAGS
|
|
|
535
535
|
--json Format output as json.
|
|
536
536
|
```
|
|
537
537
|
|
|
538
|
-
_See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
538
|
+
_See code: [src/commands/translation/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/translation/list.ts)_
|
|
539
539
|
|
|
540
540
|
## `knock translation pull [TRANSLATIONREF]`
|
|
541
541
|
|
|
@@ -562,7 +562,7 @@ FLAGS
|
|
|
562
562
|
--translations-dir=<value> The target directory path to pull all translations into.
|
|
563
563
|
```
|
|
564
564
|
|
|
565
|
-
_See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
565
|
+
_See code: [src/commands/translation/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/translation/pull.ts)_
|
|
566
566
|
|
|
567
567
|
## `knock translation push [TRANSLATIONREF]`
|
|
568
568
|
|
|
@@ -589,7 +589,7 @@ FLAGS
|
|
|
589
589
|
--translations-dir=<value> The target directory path to find all translations to push.
|
|
590
590
|
```
|
|
591
591
|
|
|
592
|
-
_See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
592
|
+
_See code: [src/commands/translation/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/translation/push.ts)_
|
|
593
593
|
|
|
594
594
|
## `knock translation validate [TRANSLATIONREF]`
|
|
595
595
|
|
|
@@ -614,7 +614,7 @@ FLAGS
|
|
|
614
614
|
--translations-dir=<value> The target directory path to find all translations to validate.
|
|
615
615
|
```
|
|
616
616
|
|
|
617
|
-
_See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
617
|
+
_See code: [src/commands/translation/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/translation/validate.ts)_
|
|
618
618
|
|
|
619
619
|
## `knock whoami`
|
|
620
620
|
|
|
@@ -631,7 +631,7 @@ GLOBAL FLAGS
|
|
|
631
631
|
--json Format output as json.
|
|
632
632
|
```
|
|
633
633
|
|
|
634
|
-
_See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
634
|
+
_See code: [src/commands/whoami.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/whoami.ts)_
|
|
635
635
|
|
|
636
636
|
## `knock workflow activate WORKFLOWKEY`
|
|
637
637
|
|
|
@@ -658,7 +658,7 @@ DESCRIPTION
|
|
|
658
658
|
with `false` in order to deactivate it.
|
|
659
659
|
```
|
|
660
660
|
|
|
661
|
-
_See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
661
|
+
_See code: [src/commands/workflow/activate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/activate.ts)_
|
|
662
662
|
|
|
663
663
|
## `knock workflow generate-types`
|
|
664
664
|
|
|
@@ -679,7 +679,7 @@ DESCRIPTION
|
|
|
679
679
|
Generate types for all workflows in an environment and write them to a file.
|
|
680
680
|
```
|
|
681
681
|
|
|
682
|
-
_See code: [src/commands/workflow/generate-types.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
682
|
+
_See code: [src/commands/workflow/generate-types.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/generate-types.ts)_
|
|
683
683
|
|
|
684
684
|
## `knock workflow get WORKFLOWKEY`
|
|
685
685
|
|
|
@@ -699,7 +699,7 @@ GLOBAL FLAGS
|
|
|
699
699
|
--json Format output as json.
|
|
700
700
|
```
|
|
701
701
|
|
|
702
|
-
_See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
702
|
+
_See code: [src/commands/workflow/get.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/get.ts)_
|
|
703
703
|
|
|
704
704
|
## `knock workflow list`
|
|
705
705
|
|
|
@@ -722,7 +722,7 @@ GLOBAL FLAGS
|
|
|
722
722
|
--json Format output as json.
|
|
723
723
|
```
|
|
724
724
|
|
|
725
|
-
_See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
725
|
+
_See code: [src/commands/workflow/list.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/list.ts)_
|
|
726
726
|
|
|
727
727
|
## `knock workflow pull [WORKFLOWKEY]`
|
|
728
728
|
|
|
@@ -742,7 +742,7 @@ FLAGS
|
|
|
742
742
|
--workflows-dir=<value> The target directory path to pull all workflows into.
|
|
743
743
|
```
|
|
744
744
|
|
|
745
|
-
_See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
745
|
+
_See code: [src/commands/workflow/pull.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/pull.ts)_
|
|
746
746
|
|
|
747
747
|
## `knock workflow push [WORKFLOWKEY]`
|
|
748
748
|
|
|
@@ -763,7 +763,7 @@ FLAGS
|
|
|
763
763
|
--workflows-dir=<value> The target directory path to find all workflows to push.
|
|
764
764
|
```
|
|
765
765
|
|
|
766
|
-
_See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
766
|
+
_See code: [src/commands/workflow/push.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/push.ts)_
|
|
767
767
|
|
|
768
768
|
## `knock workflow run WORKFLOWKEY`
|
|
769
769
|
|
|
@@ -784,7 +784,7 @@ FLAGS
|
|
|
784
784
|
--tenant=<value> A tenant id for the workflow run.
|
|
785
785
|
```
|
|
786
786
|
|
|
787
|
-
_See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
787
|
+
_See code: [src/commands/workflow/run.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/run.ts)_
|
|
788
788
|
|
|
789
789
|
## `knock workflow validate [WORKFLOWKEY]`
|
|
790
790
|
|
|
@@ -803,5 +803,5 @@ FLAGS
|
|
|
803
803
|
--workflows-dir=<value> The target directory path to find all workflows to validate.
|
|
804
804
|
```
|
|
805
805
|
|
|
806
|
-
_See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.
|
|
806
|
+
_See code: [src/commands/workflow/validate.ts](https://github.com/knocklabs/knock-cli/blob/v0.2.1/src/commands/workflow/validate.ts)_
|
|
807
807
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,56 @@
|
|
|
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 BranchCreate;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
12
|
+
const _arg = require("../../lib/helpers/arg");
|
|
13
|
+
const _request = require("../../lib/helpers/request");
|
|
14
|
+
function _define_property(obj, key, value) {
|
|
15
|
+
if (key in obj) {
|
|
16
|
+
Object.defineProperty(obj, key, {
|
|
17
|
+
value: value,
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
} else {
|
|
23
|
+
obj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
return obj;
|
|
26
|
+
}
|
|
27
|
+
function _interop_require_default(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
class BranchCreate extends _basecommand.default {
|
|
33
|
+
async run() {
|
|
34
|
+
const { args, flags } = this.props;
|
|
35
|
+
const resp = await this.request(args.slug);
|
|
36
|
+
if (flags.json) return resp;
|
|
37
|
+
this.render(resp);
|
|
38
|
+
}
|
|
39
|
+
async request(slug) {
|
|
40
|
+
return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.post(`/v1/branches/${slug}`));
|
|
41
|
+
}
|
|
42
|
+
async render(data) {
|
|
43
|
+
this.log(`‣ Successfully created branch \`${data.slug}\``);
|
|
44
|
+
this.log(` Created at: ${data.created_at}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Hide until branches are released in GA
|
|
48
|
+
_define_property(BranchCreate, "hidden", true);
|
|
49
|
+
_define_property(BranchCreate, "summary", "Creates a new branch off of the development environment.");
|
|
50
|
+
_define_property(BranchCreate, "enableJsonFlag", true);
|
|
51
|
+
_define_property(BranchCreate, "args", {
|
|
52
|
+
slug: _arg.CustomArgs.slugArg({
|
|
53
|
+
required: true,
|
|
54
|
+
description: "The slug for the new branch"
|
|
55
|
+
})
|
|
56
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
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 BranchDelete;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _core = require("@oclif/core");
|
|
12
|
+
const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
|
|
13
|
+
const _arg = require("../../lib/helpers/arg");
|
|
14
|
+
const _request = require("../../lib/helpers/request");
|
|
15
|
+
const _ux = require("../../lib/helpers/ux");
|
|
16
|
+
function _define_property(obj, key, value) {
|
|
17
|
+
if (key in obj) {
|
|
18
|
+
Object.defineProperty(obj, key, {
|
|
19
|
+
value: value,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
obj[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
function _interop_require_default(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
class BranchDelete extends _basecommand.default {
|
|
35
|
+
async run() {
|
|
36
|
+
const { args, flags } = this.props;
|
|
37
|
+
// Confirm before deleting the branch, unless forced
|
|
38
|
+
const prompt = `Delete branch \`${args.slug}\`?`;
|
|
39
|
+
const input = flags.force || await (0, _ux.promptToConfirm)(prompt);
|
|
40
|
+
if (!input) return;
|
|
41
|
+
await (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.delete(`/v1/branches/${args.slug}`), {
|
|
42
|
+
action: "‣ Deleting branch"
|
|
43
|
+
});
|
|
44
|
+
this.log(`‣ Successfully deleted branch \`${args.slug}\``);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Hide until branches are released in GA
|
|
48
|
+
_define_property(BranchDelete, "hidden", true);
|
|
49
|
+
_define_property(BranchDelete, "summary", "Deletes an existing branch with the given slug.");
|
|
50
|
+
_define_property(BranchDelete, "args", {
|
|
51
|
+
slug: _arg.CustomArgs.slugArg({
|
|
52
|
+
required: true,
|
|
53
|
+
description: "The slug of the branch to delete"
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
_define_property(BranchDelete, "flags", {
|
|
57
|
+
force: _core.Flags.boolean({
|
|
58
|
+
summary: "Remove the confirmation prompt."
|
|
59
|
+
})
|
|
60
|
+
});
|
|
@@ -0,0 +1,89 @@
|
|
|
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 BranchList;
|
|
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 _page = require("../../lib/helpers/page");
|
|
15
|
+
const _request = require("../../lib/helpers/request");
|
|
16
|
+
function _define_property(obj, key, value) {
|
|
17
|
+
if (key in obj) {
|
|
18
|
+
Object.defineProperty(obj, key, {
|
|
19
|
+
value: value,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
obj[key] = value;
|
|
26
|
+
}
|
|
27
|
+
return obj;
|
|
28
|
+
}
|
|
29
|
+
function _interop_require_default(obj) {
|
|
30
|
+
return obj && obj.__esModule ? obj : {
|
|
31
|
+
default: obj
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
class BranchList extends _basecommand.default {
|
|
35
|
+
async run() {
|
|
36
|
+
const resp = await this.request();
|
|
37
|
+
const { flags } = this.props;
|
|
38
|
+
if (flags.json) return resp;
|
|
39
|
+
this.render(resp);
|
|
40
|
+
}
|
|
41
|
+
async request(pageParams = {}) {
|
|
42
|
+
const queryParams = (0, _page.toPageParams)({
|
|
43
|
+
...this.props.flags,
|
|
44
|
+
...pageParams
|
|
45
|
+
});
|
|
46
|
+
return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.get("/v1/branches", {
|
|
47
|
+
query: queryParams
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
async render(data) {
|
|
51
|
+
const { entries } = data;
|
|
52
|
+
this.log(`‣ Showing ${entries.length} branches off of the development environment\n`);
|
|
53
|
+
_core.ux.table(entries, {
|
|
54
|
+
slug: {
|
|
55
|
+
header: "Slug"
|
|
56
|
+
},
|
|
57
|
+
created_at: {
|
|
58
|
+
header: "Created at",
|
|
59
|
+
get: (entry)=>(0, _date.formatDate)(entry.created_at)
|
|
60
|
+
},
|
|
61
|
+
updated_at: {
|
|
62
|
+
header: "Updated at",
|
|
63
|
+
get: (entry)=>(0, _date.formatDate)(entry.updated_at)
|
|
64
|
+
},
|
|
65
|
+
last_commit_at: {
|
|
66
|
+
header: "Last commit at",
|
|
67
|
+
get: (entry)=>entry.last_commit_at ? (0, _date.formatDate)(entry.last_commit_at) : "Never"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return this.prompt(data);
|
|
71
|
+
}
|
|
72
|
+
async prompt(data) {
|
|
73
|
+
const { page_info } = data;
|
|
74
|
+
const pageAction = await (0, _page.maybePromptPageAction)(page_info);
|
|
75
|
+
const pageParams = pageAction && (0, _page.paramsForPageAction)(pageAction, page_info);
|
|
76
|
+
if (pageParams) {
|
|
77
|
+
this.log("\n");
|
|
78
|
+
const resp = await this.request(pageParams);
|
|
79
|
+
return this.render(resp);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Hide until branches are released in GA
|
|
84
|
+
_define_property(BranchList, "hidden", true);
|
|
85
|
+
_define_property(BranchList, "summary", "Display all existing branches off of the development environment.");
|
|
86
|
+
_define_property(BranchList, "flags", {
|
|
87
|
+
..._page.pageFlags
|
|
88
|
+
});
|
|
89
|
+
_define_property(BranchList, "enableJsonFlag", true);
|
package/dist/commands/whoami.js
CHANGED
|
@@ -31,17 +31,16 @@ function _interop_require_default(obj) {
|
|
|
31
31
|
}
|
|
32
32
|
class Whoami extends _basecommand.default {
|
|
33
33
|
async run() {
|
|
34
|
-
const resp = await (0, _request.
|
|
34
|
+
const resp = await (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.auth.verify());
|
|
35
35
|
const { flags } = this.props;
|
|
36
|
-
if (flags.json) return resp
|
|
36
|
+
if (flags.json) return resp;
|
|
37
37
|
this.log(`‣ Successfully authenticated:`);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`
|
|
41
|
-
`Service token name: ${resp.data.service_token_name}`
|
|
38
|
+
const info = resp.service_token_name ? [
|
|
39
|
+
`Account name: ${resp.account_name}`,
|
|
40
|
+
`Service token name: ${resp.service_token_name}`
|
|
42
41
|
] : [
|
|
43
|
-
`Account name: ${resp.
|
|
44
|
-
`User ID: ${resp.
|
|
42
|
+
`Account name: ${resp.account_name}`,
|
|
43
|
+
`User ID: ${resp.user_id}`
|
|
45
44
|
];
|
|
46
45
|
this.log((0, _string.indentString)(info.join("\n"), 4));
|
|
47
46
|
}
|
package/dist/lib/api-v1.js
CHANGED
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return ApiV1;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
const _mgmt = /*#__PURE__*/ _interop_require_default(require("@knocklabs/mgmt"));
|
|
11
12
|
const _axios = /*#__PURE__*/ _interop_require_default(require("axios"));
|
|
12
13
|
const _objectisomorphic = require("./helpers/object.isomorphic");
|
|
13
14
|
const _page = require("./helpers/page");
|
|
@@ -30,6 +31,11 @@ function _interop_require_default(obj) {
|
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
const API_VERSION = "v1";
|
|
34
|
+
/**
|
|
35
|
+
* KnockMgmt client requires a service token, but we set the Authorization
|
|
36
|
+
* request header directly, so use a placeholder when service token is not
|
|
37
|
+
* provided.
|
|
38
|
+
*/ const PLACEHOLDER_SERVICE_TOKEN = "placeholder-service-token";
|
|
33
39
|
class ApiV1 {
|
|
34
40
|
getToken(sessionContext) {
|
|
35
41
|
return sessionContext.session ? sessionContext.session.accessToken : sessionContext.token;
|
|
@@ -406,21 +412,29 @@ class ApiV1 {
|
|
|
406
412
|
constructor(sessionContext, config){
|
|
407
413
|
var _sessionContext_session;
|
|
408
414
|
_define_property(this, "client", void 0);
|
|
415
|
+
_define_property(this, "mgmtClient", void 0);
|
|
409
416
|
const baseURL = sessionContext.apiOrigin;
|
|
410
417
|
const token = this.getToken(sessionContext);
|
|
411
418
|
var _sessionContext_session_clientId;
|
|
419
|
+
const headers = {
|
|
420
|
+
// Used to authenticate the request to the API.
|
|
421
|
+
Authorization: `Bearer ${token}`,
|
|
422
|
+
// Used in conjunction with the JWT access token, to allow the OAuth server to
|
|
423
|
+
// verify the client ID of the OAuth client that issued the access token.
|
|
424
|
+
"x-knock-client-id": (_sessionContext_session_clientId = (_sessionContext_session = sessionContext.session) === null || _sessionContext_session === void 0 ? void 0 : _sessionContext_session.clientId) !== null && _sessionContext_session_clientId !== void 0 ? _sessionContext_session_clientId : undefined,
|
|
425
|
+
"User-Agent": `${config.userAgent}`
|
|
426
|
+
};
|
|
412
427
|
this.client = _axios.default.create({
|
|
413
428
|
baseURL,
|
|
414
|
-
headers
|
|
415
|
-
// Used to authenticate the request to the API.
|
|
416
|
-
Authorization: `Bearer ${token}`,
|
|
417
|
-
// Used in conjunction with the JWT access token, to allow the OAuth server to
|
|
418
|
-
// verify the client ID of the OAuth client that issued the access token.
|
|
419
|
-
"x-knock-client-id": (_sessionContext_session_clientId = (_sessionContext_session = sessionContext.session) === null || _sessionContext_session === void 0 ? void 0 : _sessionContext_session.clientId) !== null && _sessionContext_session_clientId !== void 0 ? _sessionContext_session_clientId : undefined,
|
|
420
|
-
"User-Agent": `${config.userAgent}`
|
|
421
|
-
},
|
|
429
|
+
headers,
|
|
422
430
|
// Don't reject the promise based on a response status code.
|
|
423
431
|
validateStatus: null
|
|
424
432
|
});
|
|
433
|
+
// This should eventually replace the Axios client
|
|
434
|
+
this.mgmtClient = new _mgmt.default({
|
|
435
|
+
serviceToken: sessionContext.token || PLACEHOLDER_SERVICE_TOKEN,
|
|
436
|
+
baseURL,
|
|
437
|
+
defaultHeaders: headers
|
|
438
|
+
});
|
|
425
439
|
}
|
|
426
440
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "CustomArgs", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return CustomArgs;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _core = require("@oclif/core");
|
|
12
|
+
const slugArg = _core.Args.custom({
|
|
13
|
+
parse: async (str)=>{
|
|
14
|
+
const slug = str.toLowerCase().trim().replace(/\s+/g, "-");
|
|
15
|
+
if (!slug) {
|
|
16
|
+
throw new Error("Invalid slug provided");
|
|
17
|
+
}
|
|
18
|
+
return slug;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
const CustomArgs = {
|
|
22
|
+
slugArg
|
|
23
|
+
};
|
|
@@ -12,16 +12,28 @@ _export(exports, {
|
|
|
12
12
|
get formatErrorRespMessage () {
|
|
13
13
|
return formatErrorRespMessage;
|
|
14
14
|
},
|
|
15
|
+
get formatMgmtError () {
|
|
16
|
+
return formatMgmtError;
|
|
17
|
+
},
|
|
15
18
|
get isSuccessResp () {
|
|
16
19
|
return isSuccessResp;
|
|
17
20
|
},
|
|
18
21
|
get withSpinner () {
|
|
19
22
|
return withSpinner;
|
|
23
|
+
},
|
|
24
|
+
get withSpinnerV2 () {
|
|
25
|
+
return withSpinnerV2;
|
|
20
26
|
}
|
|
21
27
|
});
|
|
28
|
+
const _mgmt = /*#__PURE__*/ _interop_require_default(require("@knocklabs/mgmt"));
|
|
22
29
|
const _core = require("@oclif/core");
|
|
23
30
|
const _error = require("./error");
|
|
24
31
|
const _ux = require("./ux");
|
|
32
|
+
function _interop_require_default(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
25
37
|
const isSuccessResp = (resp)=>resp.status >= 200 && resp.status < 300;
|
|
26
38
|
const formatErrorRespMessage = ({ status, data })=>{
|
|
27
39
|
if (status === 500) {
|
|
@@ -36,16 +48,50 @@ const formatErrorRespMessage = ({ status, data })=>{
|
|
|
36
48
|
}
|
|
37
49
|
return message;
|
|
38
50
|
};
|
|
51
|
+
const formatMgmtError = (apiError)=>{
|
|
52
|
+
if (apiError.status === 500) {
|
|
53
|
+
return "An internal server error occurred";
|
|
54
|
+
}
|
|
55
|
+
var _apiError_error_message;
|
|
56
|
+
// Prefer the error message from the error object over
|
|
57
|
+
// the error message formatted by the Stainless SDK
|
|
58
|
+
const description = `${(_apiError_error_message = apiError.error.message) !== null && _apiError_error_message !== void 0 ? _apiError_error_message : apiError.message} (status: ${apiError.status})`;
|
|
59
|
+
var _apiError_error_errors;
|
|
60
|
+
const inputErrors = (_apiError_error_errors = apiError.error.errors) !== null && _apiError_error_errors !== void 0 ? _apiError_error_errors : [];
|
|
61
|
+
if (Array.isArray(inputErrors) && inputErrors.length > 0) {
|
|
62
|
+
const errs = inputErrors.map((e)=>new _error.JsonDataError(e.message, e.field));
|
|
63
|
+
return errs.length === 0 ? description : description + "\n\n" + (0, _error.formatErrors)(errs, {
|
|
64
|
+
indentBy: 2
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
return description;
|
|
68
|
+
};
|
|
39
69
|
const withSpinner = async (requestFn, opts = {})=>{
|
|
40
|
-
const { action = "‣ Loading"
|
|
70
|
+
const { action = "‣ Loading" } = opts;
|
|
41
71
|
// Suppress printing the spinner in tests, oclif doesn't for some reasons.
|
|
42
72
|
_ux.spinner.start(action);
|
|
43
73
|
const resp = await requestFn();
|
|
44
74
|
// Error out before the action stop so the spinner can update accordingly.
|
|
45
|
-
if (
|
|
75
|
+
if (!isSuccessResp(resp)) {
|
|
46
76
|
const message = formatErrorRespMessage(resp);
|
|
47
77
|
_core.ux.error(new _error.ApiError(message));
|
|
48
78
|
}
|
|
49
79
|
_ux.spinner.stop();
|
|
50
80
|
return resp;
|
|
51
81
|
};
|
|
82
|
+
const withSpinnerV2 = async (requestFn, opts = {})=>{
|
|
83
|
+
const { action = "‣ Loading" } = opts;
|
|
84
|
+
// Suppress printing the spinner in tests, oclif doesn't for some reasons.
|
|
85
|
+
_ux.spinner.start(action);
|
|
86
|
+
try {
|
|
87
|
+
const resp = await requestFn();
|
|
88
|
+
_ux.spinner.stop();
|
|
89
|
+
return resp;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error instanceof _mgmt.default.APIError) {
|
|
92
|
+
const message = formatMgmtError(error);
|
|
93
|
+
return _core.ux.error(new _error.ApiError(message));
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
@@ -23,16 +23,20 @@ _export(exports, {
|
|
|
23
23
|
get buildPartialDirBundle () {
|
|
24
24
|
return _processorisomorphic3.buildPartialDirBundle;
|
|
25
25
|
},
|
|
26
|
+
get buildReusableStepDirBundle () {
|
|
27
|
+
return _processorisomorphic4.buildReusableStepDirBundle;
|
|
28
|
+
},
|
|
26
29
|
get buildTranslationDirBundle () {
|
|
27
|
-
return
|
|
30
|
+
return _processorisomorphic5.buildTranslationDirBundle;
|
|
28
31
|
},
|
|
29
32
|
get buildWorkflowDirBundle () {
|
|
30
|
-
return
|
|
33
|
+
return _processorisomorphic6.buildWorkflowDirBundle;
|
|
31
34
|
}
|
|
32
35
|
});
|
|
33
36
|
const _processorisomorphic = require("./email-layout/processor.isomorphic");
|
|
34
37
|
const _processorisomorphic1 = require("./guide/processor.isomorphic");
|
|
35
38
|
const _processorisomorphic2 = require("./message-type/processor.isomorphic");
|
|
36
39
|
const _processorisomorphic3 = require("./partial/processor.isomorphic");
|
|
37
|
-
const _processorisomorphic4 = require("./
|
|
38
|
-
const _processorisomorphic5 = require("./
|
|
40
|
+
const _processorisomorphic4 = require("./reusable-step/processor.isomorphic");
|
|
41
|
+
const _processorisomorphic5 = require("./translation/processor.isomorphic");
|
|
42
|
+
const _processorisomorphic6 = require("./workflow/processor.isomorphic");
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get isReusableStepDir () {
|
|
13
|
+
return isReusableStepDir;
|
|
14
|
+
},
|
|
15
|
+
get lsReusableStepJson () {
|
|
16
|
+
return lsReusableStepJson;
|
|
17
|
+
},
|
|
18
|
+
get reusableStepJsonPath () {
|
|
19
|
+
return reusableStepJsonPath;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
23
|
+
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
24
|
+
const _processorisomorphic = require("./processor.isomorphic");
|
|
25
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
26
|
+
if (typeof WeakMap !== "function") return null;
|
|
27
|
+
var cacheBabelInterop = new WeakMap();
|
|
28
|
+
var cacheNodeInterop = new WeakMap();
|
|
29
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
30
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
31
|
+
})(nodeInterop);
|
|
32
|
+
}
|
|
33
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
34
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
35
|
+
return obj;
|
|
36
|
+
}
|
|
37
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
38
|
+
return {
|
|
39
|
+
default: obj
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
43
|
+
if (cache && cache.has(obj)) {
|
|
44
|
+
return cache.get(obj);
|
|
45
|
+
}
|
|
46
|
+
var newObj = {
|
|
47
|
+
__proto__: null
|
|
48
|
+
};
|
|
49
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
50
|
+
for(var key in obj){
|
|
51
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
52
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
53
|
+
if (desc && (desc.get || desc.set)) {
|
|
54
|
+
Object.defineProperty(newObj, key, desc);
|
|
55
|
+
} else {
|
|
56
|
+
newObj[key] = obj[key];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
newObj.default = obj;
|
|
61
|
+
if (cache) {
|
|
62
|
+
cache.set(obj, newObj);
|
|
63
|
+
}
|
|
64
|
+
return newObj;
|
|
65
|
+
}
|
|
66
|
+
const reusableStepJsonPath = (reusableStepDirCtx)=>_nodepath.resolve(reusableStepDirCtx.abspath, _processorisomorphic.REUSABLE_STEP_JSON);
|
|
67
|
+
const isReusableStepDir = async (dirPath)=>Boolean(await lsReusableStepJson(dirPath));
|
|
68
|
+
const lsReusableStepJson = async (dirPath)=>{
|
|
69
|
+
const reusableStepJsonPath = _nodepath.resolve(dirPath, _processorisomorphic.REUSABLE_STEP_JSON);
|
|
70
|
+
const exists = await _fsextra.pathExists(reusableStepJsonPath);
|
|
71
|
+
return exists ? reusableStepJsonPath : undefined;
|
|
72
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./processor.isomorphic"), exports);
|
|
6
|
+
_export_star(require("./types"), exports);
|
|
7
|
+
function _export_star(from, to) {
|
|
8
|
+
Object.keys(from).forEach(function(k) {
|
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
+
Object.defineProperty(to, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return from[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return from;
|
|
19
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* IMPORTANT:
|
|
3
|
+
*
|
|
4
|
+
* This file is suffixed with `.isomorphic` because the code in this file is
|
|
5
|
+
* meant to run not just in a nodejs environment but also in a browser. For this
|
|
6
|
+
* reason there are some restrictions for which nodejs imports are allowed in
|
|
7
|
+
* this module. See `.eslintrc.json` for more details.
|
|
8
|
+
*/ "use strict";
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: true
|
|
11
|
+
});
|
|
12
|
+
function _export(target, all) {
|
|
13
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
_export(exports, {
|
|
19
|
+
get REUSABLE_STEP_JSON () {
|
|
20
|
+
return REUSABLE_STEP_JSON;
|
|
21
|
+
},
|
|
22
|
+
get buildReusableStepDirBundle () {
|
|
23
|
+
return buildReusableStepDirBundle;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
const _lodash = require("lodash");
|
|
27
|
+
const _objectisomorphic = require("../../helpers/object.isomorphic");
|
|
28
|
+
const _constisomorphic = require("../shared/const.isomorphic");
|
|
29
|
+
const _helpersisomorphic = require("../shared/helpers.isomorphic");
|
|
30
|
+
const REUSABLE_STEP_JSON = "reusable_step.json";
|
|
31
|
+
const compileExtractionSettings = (reusableStep)=>{
|
|
32
|
+
const extractableFields = (0, _lodash.get)(reusableStep, [
|
|
33
|
+
"__annotation",
|
|
34
|
+
"extractable_fields"
|
|
35
|
+
], {});
|
|
36
|
+
const map = new Map();
|
|
37
|
+
for (const key of Object.keys(reusableStep)){
|
|
38
|
+
// If the field we are on is extractable, then add its extraction
|
|
39
|
+
// settings to the map with the current object path.
|
|
40
|
+
if (key in extractableFields) {
|
|
41
|
+
map.set([
|
|
42
|
+
key
|
|
43
|
+
], extractableFields[key]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return map;
|
|
47
|
+
};
|
|
48
|
+
const buildReusableStepDirBundle = (remoteReusableStep, localReusableStep = {})=>{
|
|
49
|
+
const bundle = {};
|
|
50
|
+
const mutRemoteReusableStep = (0, _lodash.cloneDeep)(remoteReusableStep);
|
|
51
|
+
// A map of extraction settings of every field in the reusable step
|
|
52
|
+
const compiledExtractionSettings = compileExtractionSettings(mutRemoteReusableStep);
|
|
53
|
+
// Iterate through each extractable field, determine whether we need to
|
|
54
|
+
// extract the field content, and if so, perform the extraction.
|
|
55
|
+
for (const [objPathParts, extractionSettings] of compiledExtractionSettings){
|
|
56
|
+
// If this reusable step doesn't have this field path, then we don't extract.
|
|
57
|
+
if (!(0, _lodash.has)(mutRemoteReusableStep, objPathParts)) continue;
|
|
58
|
+
// If the field at this path is extracted in the local reusable step, then
|
|
59
|
+
// always extract; otherwise extract based on the field settings default.
|
|
60
|
+
const objPathStr = _objectisomorphic.ObjPath.stringify(objPathParts);
|
|
61
|
+
const extractedFilePath = (0, _lodash.get)(localReusableStep, `${objPathStr}${_constisomorphic.FILEPATH_MARKER}`);
|
|
62
|
+
const { default: extractByDefault, file_ext: fileExt } = extractionSettings;
|
|
63
|
+
if (!extractedFilePath && !extractByDefault) continue;
|
|
64
|
+
// By this point, we have a field where we need to extract its content.
|
|
65
|
+
const data = (0, _lodash.get)(mutRemoteReusableStep, objPathParts);
|
|
66
|
+
const fileName = objPathParts.pop();
|
|
67
|
+
// If we have an extracted file path from the local reusable step, we use that.
|
|
68
|
+
// In the other case we use the default path.
|
|
69
|
+
const relpath = typeof extractedFilePath === "string" ? extractedFilePath : `${fileName}.${fileExt}`;
|
|
70
|
+
// Perform the extraction by adding the content and its file path to the
|
|
71
|
+
// bundle for writing to the file system later. Then replace the field
|
|
72
|
+
// content with the extracted file path and mark the field as extracted
|
|
73
|
+
// with @ suffix.
|
|
74
|
+
const content = typeof data === "string" ? data : JSON.stringify(data, null, 2);
|
|
75
|
+
(0, _lodash.set)(bundle, [
|
|
76
|
+
relpath
|
|
77
|
+
], content);
|
|
78
|
+
(0, _lodash.set)(mutRemoteReusableStep, `${objPathStr}${_constisomorphic.FILEPATH_MARKER}`, relpath);
|
|
79
|
+
(0, _lodash.unset)(mutRemoteReusableStep, objPathStr);
|
|
80
|
+
}
|
|
81
|
+
// At this point the bundle contains all extractable files, so we finally add
|
|
82
|
+
// the reusable step JSON relative path + the file content.
|
|
83
|
+
return (0, _lodash.set)(bundle, [
|
|
84
|
+
REUSABLE_STEP_JSON
|
|
85
|
+
], (0, _helpersisomorphic.prepareResourceJson)(mutRemoteReusableStep));
|
|
86
|
+
};
|
package/oclif.manifest.json
CHANGED
|
@@ -335,6 +335,179 @@
|
|
|
335
335
|
"whoami.js"
|
|
336
336
|
]
|
|
337
337
|
},
|
|
338
|
+
"branch:create": {
|
|
339
|
+
"aliases": [],
|
|
340
|
+
"args": {
|
|
341
|
+
"slug": {
|
|
342
|
+
"description": "The slug for the new branch",
|
|
343
|
+
"name": "slug",
|
|
344
|
+
"required": true
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
"flags": {
|
|
348
|
+
"json": {
|
|
349
|
+
"description": "Format output as json.",
|
|
350
|
+
"helpGroup": "GLOBAL",
|
|
351
|
+
"name": "json",
|
|
352
|
+
"allowNo": false,
|
|
353
|
+
"type": "boolean"
|
|
354
|
+
},
|
|
355
|
+
"service-token": {
|
|
356
|
+
"env": "KNOCK_SERVICE_TOKEN",
|
|
357
|
+
"name": "service-token",
|
|
358
|
+
"required": false,
|
|
359
|
+
"summary": "The service token to authenticate with.",
|
|
360
|
+
"hasDynamicHelp": false,
|
|
361
|
+
"multiple": false,
|
|
362
|
+
"type": "option"
|
|
363
|
+
},
|
|
364
|
+
"api-origin": {
|
|
365
|
+
"hidden": true,
|
|
366
|
+
"name": "api-origin",
|
|
367
|
+
"required": false,
|
|
368
|
+
"hasDynamicHelp": false,
|
|
369
|
+
"multiple": false,
|
|
370
|
+
"type": "option"
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
"hasDynamicHelp": false,
|
|
374
|
+
"hidden": true,
|
|
375
|
+
"hiddenAliases": [],
|
|
376
|
+
"id": "branch:create",
|
|
377
|
+
"pluginAlias": "@knocklabs/cli",
|
|
378
|
+
"pluginName": "@knocklabs/cli",
|
|
379
|
+
"pluginType": "core",
|
|
380
|
+
"strict": true,
|
|
381
|
+
"summary": "Creates a new branch off of the development environment.",
|
|
382
|
+
"enableJsonFlag": true,
|
|
383
|
+
"isESM": false,
|
|
384
|
+
"relativePath": [
|
|
385
|
+
"dist",
|
|
386
|
+
"commands",
|
|
387
|
+
"branch",
|
|
388
|
+
"create.js"
|
|
389
|
+
]
|
|
390
|
+
},
|
|
391
|
+
"branch:delete": {
|
|
392
|
+
"aliases": [],
|
|
393
|
+
"args": {
|
|
394
|
+
"slug": {
|
|
395
|
+
"description": "The slug of the branch to delete",
|
|
396
|
+
"name": "slug",
|
|
397
|
+
"required": true
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
"flags": {
|
|
401
|
+
"service-token": {
|
|
402
|
+
"env": "KNOCK_SERVICE_TOKEN",
|
|
403
|
+
"name": "service-token",
|
|
404
|
+
"required": false,
|
|
405
|
+
"summary": "The service token to authenticate with.",
|
|
406
|
+
"hasDynamicHelp": false,
|
|
407
|
+
"multiple": false,
|
|
408
|
+
"type": "option"
|
|
409
|
+
},
|
|
410
|
+
"api-origin": {
|
|
411
|
+
"hidden": true,
|
|
412
|
+
"name": "api-origin",
|
|
413
|
+
"required": false,
|
|
414
|
+
"hasDynamicHelp": false,
|
|
415
|
+
"multiple": false,
|
|
416
|
+
"type": "option"
|
|
417
|
+
},
|
|
418
|
+
"force": {
|
|
419
|
+
"name": "force",
|
|
420
|
+
"summary": "Remove the confirmation prompt.",
|
|
421
|
+
"allowNo": false,
|
|
422
|
+
"type": "boolean"
|
|
423
|
+
}
|
|
424
|
+
},
|
|
425
|
+
"hasDynamicHelp": false,
|
|
426
|
+
"hidden": true,
|
|
427
|
+
"hiddenAliases": [],
|
|
428
|
+
"id": "branch:delete",
|
|
429
|
+
"pluginAlias": "@knocklabs/cli",
|
|
430
|
+
"pluginName": "@knocklabs/cli",
|
|
431
|
+
"pluginType": "core",
|
|
432
|
+
"strict": true,
|
|
433
|
+
"summary": "Deletes an existing branch with the given slug.",
|
|
434
|
+
"enableJsonFlag": false,
|
|
435
|
+
"isESM": false,
|
|
436
|
+
"relativePath": [
|
|
437
|
+
"dist",
|
|
438
|
+
"commands",
|
|
439
|
+
"branch",
|
|
440
|
+
"delete.js"
|
|
441
|
+
]
|
|
442
|
+
},
|
|
443
|
+
"branch:list": {
|
|
444
|
+
"aliases": [],
|
|
445
|
+
"args": {},
|
|
446
|
+
"flags": {
|
|
447
|
+
"json": {
|
|
448
|
+
"description": "Format output as json.",
|
|
449
|
+
"helpGroup": "GLOBAL",
|
|
450
|
+
"name": "json",
|
|
451
|
+
"allowNo": false,
|
|
452
|
+
"type": "boolean"
|
|
453
|
+
},
|
|
454
|
+
"service-token": {
|
|
455
|
+
"env": "KNOCK_SERVICE_TOKEN",
|
|
456
|
+
"name": "service-token",
|
|
457
|
+
"required": false,
|
|
458
|
+
"summary": "The service token to authenticate with.",
|
|
459
|
+
"hasDynamicHelp": false,
|
|
460
|
+
"multiple": false,
|
|
461
|
+
"type": "option"
|
|
462
|
+
},
|
|
463
|
+
"api-origin": {
|
|
464
|
+
"hidden": true,
|
|
465
|
+
"name": "api-origin",
|
|
466
|
+
"required": false,
|
|
467
|
+
"hasDynamicHelp": false,
|
|
468
|
+
"multiple": false,
|
|
469
|
+
"type": "option"
|
|
470
|
+
},
|
|
471
|
+
"after": {
|
|
472
|
+
"name": "after",
|
|
473
|
+
"summary": "The cursor after which to fetch the next page.",
|
|
474
|
+
"hasDynamicHelp": false,
|
|
475
|
+
"multiple": false,
|
|
476
|
+
"type": "option"
|
|
477
|
+
},
|
|
478
|
+
"before": {
|
|
479
|
+
"name": "before",
|
|
480
|
+
"summary": "The cursor before which to fetch the previous page.",
|
|
481
|
+
"hasDynamicHelp": false,
|
|
482
|
+
"multiple": false,
|
|
483
|
+
"type": "option"
|
|
484
|
+
},
|
|
485
|
+
"limit": {
|
|
486
|
+
"name": "limit",
|
|
487
|
+
"summary": "The total number of entries to fetch per page.",
|
|
488
|
+
"hasDynamicHelp": false,
|
|
489
|
+
"multiple": false,
|
|
490
|
+
"type": "option"
|
|
491
|
+
}
|
|
492
|
+
},
|
|
493
|
+
"hasDynamicHelp": false,
|
|
494
|
+
"hidden": true,
|
|
495
|
+
"hiddenAliases": [],
|
|
496
|
+
"id": "branch:list",
|
|
497
|
+
"pluginAlias": "@knocklabs/cli",
|
|
498
|
+
"pluginName": "@knocklabs/cli",
|
|
499
|
+
"pluginType": "core",
|
|
500
|
+
"strict": true,
|
|
501
|
+
"summary": "Display all existing branches off of the development environment.",
|
|
502
|
+
"enableJsonFlag": true,
|
|
503
|
+
"isESM": false,
|
|
504
|
+
"relativePath": [
|
|
505
|
+
"dist",
|
|
506
|
+
"commands",
|
|
507
|
+
"branch",
|
|
508
|
+
"list.js"
|
|
509
|
+
]
|
|
510
|
+
},
|
|
338
511
|
"commit:get": {
|
|
339
512
|
"aliases": [],
|
|
340
513
|
"args": {
|
|
@@ -3387,5 +3560,5 @@
|
|
|
3387
3560
|
]
|
|
3388
3561
|
}
|
|
3389
3562
|
},
|
|
3390
|
-
"version": "0.2.
|
|
3563
|
+
"version": "0.2.1"
|
|
3391
3564
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knocklabs/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Knock CLI",
|
|
5
5
|
"author": "@knocklabs",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"/oclif.manifest.json"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@knocklabs/mgmt": "^0.5.0",
|
|
20
21
|
"@oclif/core": "^3",
|
|
21
22
|
"@oclif/plugin-help": "^6",
|
|
22
23
|
"@prantlf/jsonlint": "^14.1.0",
|
|
@@ -91,8 +92,9 @@
|
|
|
91
92
|
"type.check": "tsc",
|
|
92
93
|
"postpack": "shx rm -f oclif.manifest.json",
|
|
93
94
|
"prepack": "yarn build && oclif manifest && oclif readme",
|
|
94
|
-
"test": "mocha
|
|
95
|
-
"version": "oclif readme && git add README.md"
|
|
95
|
+
"test": "mocha \"test/**/*.test.ts\"",
|
|
96
|
+
"version": "oclif readme && git add README.md",
|
|
97
|
+
"check": "yarn run lint && yarn run format.check && yarn run type.check"
|
|
96
98
|
},
|
|
97
99
|
"engines": {
|
|
98
100
|
"node": ">=18.17.0"
|