@knocklabs/cli 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +377 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/dist/commands/ping.js +24 -0
- package/dist/commands/workflow/get.js +161 -0
- package/dist/commands/workflow/list.js +128 -0
- package/dist/commands/workflow/pull.js +139 -0
- package/dist/commands/workflow/push.js +128 -0
- package/dist/index.js +9 -0
- package/dist/lib/api-v1.js +76 -0
- package/dist/lib/base-command.js +91 -0
- package/dist/lib/helpers/date.js +21 -0
- package/dist/lib/helpers/dir-context.js +33 -0
- package/dist/lib/helpers/env.js +63 -0
- package/dist/lib/helpers/error.js +60 -0
- package/dist/lib/helpers/json.js +72 -0
- package/dist/lib/helpers/object.js +111 -0
- package/dist/lib/helpers/page.js +92 -0
- package/dist/lib/helpers/request.js +38 -0
- package/dist/lib/helpers/string.js +34 -0
- package/dist/lib/marshal/conditions/helpers.js +26 -0
- package/dist/lib/marshal/conditions/index.js +17 -0
- package/dist/lib/marshal/conditions/types.js +4 -0
- package/dist/lib/marshal/shared/types.js +4 -0
- package/dist/lib/marshal/workflow/helpers.js +139 -0
- package/dist/lib/marshal/workflow/index.js +19 -0
- package/dist/lib/marshal/workflow/reader.js +233 -0
- package/dist/lib/marshal/workflow/types.js +15 -0
- package/dist/lib/marshal/workflow/writer.js +214 -0
- package/dist/lib/run-context.js +79 -0
- package/dist/lib/user-config.js +83 -0
- package/oclif.manifest.json +220 -0
- package/package.json +94 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Knock Labs, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# @knocklabs/cli
|
|
2
|
+
|
|
3
|
+
A command-line interface for interacting with [Knock](https://knock.app).
|
|
4
|
+
|
|
5
|
+
<!-- toc -->
|
|
6
|
+
* [@knocklabs/cli](#knocklabscli)
|
|
7
|
+
* [Usage](#usage)
|
|
8
|
+
* [Commands](#commands)
|
|
9
|
+
<!-- tocstop -->
|
|
10
|
+
|
|
11
|
+
# Usage
|
|
12
|
+
|
|
13
|
+
<!-- usage -->
|
|
14
|
+
```sh-session
|
|
15
|
+
$ npm install -g @knocklabs/cli
|
|
16
|
+
$ knock COMMAND
|
|
17
|
+
running command...
|
|
18
|
+
$ knock (--version)
|
|
19
|
+
@knocklabs/cli/0.1.0-rc.0 darwin-arm64 node-v16.4.0
|
|
20
|
+
$ knock --help [COMMAND]
|
|
21
|
+
USAGE
|
|
22
|
+
$ knock COMMAND
|
|
23
|
+
...
|
|
24
|
+
```
|
|
25
|
+
<!-- usagestop -->
|
|
26
|
+
|
|
27
|
+
# Commands
|
|
28
|
+
|
|
29
|
+
<!-- commands -->
|
|
30
|
+
* [`knock help [COMMANDS]`](#knock-help-commands)
|
|
31
|
+
* [`knock ping`](#knock-ping)
|
|
32
|
+
* [`knock plugins`](#knock-plugins)
|
|
33
|
+
* [`knock plugins:install PLUGIN...`](#knock-pluginsinstall-plugin)
|
|
34
|
+
* [`knock plugins:inspect PLUGIN...`](#knock-pluginsinspect-plugin)
|
|
35
|
+
* [`knock plugins:install PLUGIN...`](#knock-pluginsinstall-plugin-1)
|
|
36
|
+
* [`knock plugins:link PLUGIN`](#knock-pluginslink-plugin)
|
|
37
|
+
* [`knock plugins:uninstall PLUGIN...`](#knock-pluginsuninstall-plugin)
|
|
38
|
+
* [`knock plugins:uninstall PLUGIN...`](#knock-pluginsuninstall-plugin-1)
|
|
39
|
+
* [`knock plugins:uninstall PLUGIN...`](#knock-pluginsuninstall-plugin-2)
|
|
40
|
+
* [`knock plugins update`](#knock-plugins-update)
|
|
41
|
+
* [`knock workflow get WORKFLOWKEY`](#knock-workflow-get-workflowkey)
|
|
42
|
+
* [`knock workflow list`](#knock-workflow-list)
|
|
43
|
+
* [`knock workflow pull [WORKFLOWKEY]`](#knock-workflow-pull-workflowkey)
|
|
44
|
+
* [`knock workflow push [WORKFLOWKEY]`](#knock-workflow-push-workflowkey)
|
|
45
|
+
|
|
46
|
+
## `knock help [COMMANDS]`
|
|
47
|
+
|
|
48
|
+
Display help for knock.
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
USAGE
|
|
52
|
+
$ knock help [COMMANDS] [-n]
|
|
53
|
+
|
|
54
|
+
ARGUMENTS
|
|
55
|
+
COMMANDS Command to show help for.
|
|
56
|
+
|
|
57
|
+
FLAGS
|
|
58
|
+
-n, --nested-commands Include all nested commands in the output.
|
|
59
|
+
|
|
60
|
+
DESCRIPTION
|
|
61
|
+
Display help for knock.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.2/src/commands/help.ts)_
|
|
65
|
+
|
|
66
|
+
## `knock ping`
|
|
67
|
+
|
|
68
|
+
Ping the Knock management API to verify access.
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
USAGE
|
|
72
|
+
$ knock ping --service-token <value>
|
|
73
|
+
|
|
74
|
+
FLAGS
|
|
75
|
+
--service-token=<value> (required) service token to authenticate with
|
|
76
|
+
|
|
77
|
+
DESCRIPTION
|
|
78
|
+
Ping the Knock management API to verify access.
|
|
79
|
+
|
|
80
|
+
EXAMPLES
|
|
81
|
+
$ knock ping
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
_See code: [dist/commands/ping.ts](https://github.com/knocklabs/knock-cli/blob/v0.1.0-rc.0/dist/commands/ping.ts)_
|
|
85
|
+
|
|
86
|
+
## `knock plugins`
|
|
87
|
+
|
|
88
|
+
List installed plugins.
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
USAGE
|
|
92
|
+
$ knock plugins [--core]
|
|
93
|
+
|
|
94
|
+
FLAGS
|
|
95
|
+
--core Show core plugins.
|
|
96
|
+
|
|
97
|
+
DESCRIPTION
|
|
98
|
+
List installed plugins.
|
|
99
|
+
|
|
100
|
+
EXAMPLES
|
|
101
|
+
$ knock plugins
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.3.0/src/commands/plugins/index.ts)_
|
|
105
|
+
|
|
106
|
+
## `knock plugins:install PLUGIN...`
|
|
107
|
+
|
|
108
|
+
Installs a plugin into the CLI.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
USAGE
|
|
112
|
+
$ knock plugins:install PLUGIN...
|
|
113
|
+
|
|
114
|
+
ARGUMENTS
|
|
115
|
+
PLUGIN Plugin to install.
|
|
116
|
+
|
|
117
|
+
FLAGS
|
|
118
|
+
-f, --force Run yarn install with force flag.
|
|
119
|
+
-h, --help Show CLI help.
|
|
120
|
+
-v, --verbose
|
|
121
|
+
|
|
122
|
+
DESCRIPTION
|
|
123
|
+
Installs a plugin into the CLI.
|
|
124
|
+
Can be installed from npm or a git url.
|
|
125
|
+
|
|
126
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
127
|
+
|
|
128
|
+
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
|
129
|
+
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
|
130
|
+
the CLI without the need to patch and update the whole CLI.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
ALIASES
|
|
134
|
+
$ knock plugins add
|
|
135
|
+
|
|
136
|
+
EXAMPLES
|
|
137
|
+
$ knock plugins:install myplugin
|
|
138
|
+
|
|
139
|
+
$ knock plugins:install https://github.com/someuser/someplugin
|
|
140
|
+
|
|
141
|
+
$ knock plugins:install someuser/someplugin
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## `knock plugins:inspect PLUGIN...`
|
|
145
|
+
|
|
146
|
+
Displays installation properties of a plugin.
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
USAGE
|
|
150
|
+
$ knock plugins:inspect PLUGIN...
|
|
151
|
+
|
|
152
|
+
ARGUMENTS
|
|
153
|
+
PLUGIN [default: .] Plugin to inspect.
|
|
154
|
+
|
|
155
|
+
FLAGS
|
|
156
|
+
-h, --help Show CLI help.
|
|
157
|
+
-v, --verbose
|
|
158
|
+
|
|
159
|
+
GLOBAL FLAGS
|
|
160
|
+
--json Format output as json.
|
|
161
|
+
|
|
162
|
+
DESCRIPTION
|
|
163
|
+
Displays installation properties of a plugin.
|
|
164
|
+
|
|
165
|
+
EXAMPLES
|
|
166
|
+
$ knock plugins:inspect myplugin
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## `knock plugins:install PLUGIN...`
|
|
170
|
+
|
|
171
|
+
Installs a plugin into the CLI.
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
USAGE
|
|
175
|
+
$ knock plugins:install PLUGIN...
|
|
176
|
+
|
|
177
|
+
ARGUMENTS
|
|
178
|
+
PLUGIN Plugin to install.
|
|
179
|
+
|
|
180
|
+
FLAGS
|
|
181
|
+
-f, --force Run yarn install with force flag.
|
|
182
|
+
-h, --help Show CLI help.
|
|
183
|
+
-v, --verbose
|
|
184
|
+
|
|
185
|
+
DESCRIPTION
|
|
186
|
+
Installs a plugin into the CLI.
|
|
187
|
+
Can be installed from npm or a git url.
|
|
188
|
+
|
|
189
|
+
Installation of a user-installed plugin will override a core plugin.
|
|
190
|
+
|
|
191
|
+
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
|
192
|
+
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
|
193
|
+
the CLI without the need to patch and update the whole CLI.
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
ALIASES
|
|
197
|
+
$ knock plugins add
|
|
198
|
+
|
|
199
|
+
EXAMPLES
|
|
200
|
+
$ knock plugins:install myplugin
|
|
201
|
+
|
|
202
|
+
$ knock plugins:install https://github.com/someuser/someplugin
|
|
203
|
+
|
|
204
|
+
$ knock plugins:install someuser/someplugin
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## `knock plugins:link PLUGIN`
|
|
208
|
+
|
|
209
|
+
Links a plugin into the CLI for development.
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
USAGE
|
|
213
|
+
$ knock plugins:link PLUGIN
|
|
214
|
+
|
|
215
|
+
ARGUMENTS
|
|
216
|
+
PATH [default: .] path to plugin
|
|
217
|
+
|
|
218
|
+
FLAGS
|
|
219
|
+
-h, --help Show CLI help.
|
|
220
|
+
-v, --verbose
|
|
221
|
+
|
|
222
|
+
DESCRIPTION
|
|
223
|
+
Links a plugin into the CLI for development.
|
|
224
|
+
Installation of a linked plugin will override a user-installed or core plugin.
|
|
225
|
+
|
|
226
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
|
227
|
+
command will override the user-installed or core plugin implementation. This is useful for development work.
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
EXAMPLES
|
|
231
|
+
$ knock plugins:link myplugin
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## `knock plugins:uninstall PLUGIN...`
|
|
235
|
+
|
|
236
|
+
Removes a plugin from the CLI.
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
USAGE
|
|
240
|
+
$ knock plugins:uninstall PLUGIN...
|
|
241
|
+
|
|
242
|
+
ARGUMENTS
|
|
243
|
+
PLUGIN plugin to uninstall
|
|
244
|
+
|
|
245
|
+
FLAGS
|
|
246
|
+
-h, --help Show CLI help.
|
|
247
|
+
-v, --verbose
|
|
248
|
+
|
|
249
|
+
DESCRIPTION
|
|
250
|
+
Removes a plugin from the CLI.
|
|
251
|
+
|
|
252
|
+
ALIASES
|
|
253
|
+
$ knock plugins unlink
|
|
254
|
+
$ knock plugins remove
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
## `knock plugins:uninstall PLUGIN...`
|
|
258
|
+
|
|
259
|
+
Removes a plugin from the CLI.
|
|
260
|
+
|
|
261
|
+
```
|
|
262
|
+
USAGE
|
|
263
|
+
$ knock plugins:uninstall PLUGIN...
|
|
264
|
+
|
|
265
|
+
ARGUMENTS
|
|
266
|
+
PLUGIN plugin to uninstall
|
|
267
|
+
|
|
268
|
+
FLAGS
|
|
269
|
+
-h, --help Show CLI help.
|
|
270
|
+
-v, --verbose
|
|
271
|
+
|
|
272
|
+
DESCRIPTION
|
|
273
|
+
Removes a plugin from the CLI.
|
|
274
|
+
|
|
275
|
+
ALIASES
|
|
276
|
+
$ knock plugins unlink
|
|
277
|
+
$ knock plugins remove
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## `knock plugins:uninstall PLUGIN...`
|
|
281
|
+
|
|
282
|
+
Removes a plugin from the CLI.
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
USAGE
|
|
286
|
+
$ knock plugins:uninstall PLUGIN...
|
|
287
|
+
|
|
288
|
+
ARGUMENTS
|
|
289
|
+
PLUGIN plugin to uninstall
|
|
290
|
+
|
|
291
|
+
FLAGS
|
|
292
|
+
-h, --help Show CLI help.
|
|
293
|
+
-v, --verbose
|
|
294
|
+
|
|
295
|
+
DESCRIPTION
|
|
296
|
+
Removes a plugin from the CLI.
|
|
297
|
+
|
|
298
|
+
ALIASES
|
|
299
|
+
$ knock plugins unlink
|
|
300
|
+
$ knock plugins remove
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## `knock plugins update`
|
|
304
|
+
|
|
305
|
+
Update installed plugins.
|
|
306
|
+
|
|
307
|
+
```
|
|
308
|
+
USAGE
|
|
309
|
+
$ knock plugins update [-h] [-v]
|
|
310
|
+
|
|
311
|
+
FLAGS
|
|
312
|
+
-h, --help Show CLI help.
|
|
313
|
+
-v, --verbose
|
|
314
|
+
|
|
315
|
+
DESCRIPTION
|
|
316
|
+
Update installed plugins.
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
## `knock workflow get WORKFLOWKEY`
|
|
320
|
+
|
|
321
|
+
```
|
|
322
|
+
USAGE
|
|
323
|
+
$ knock workflow get [WORKFLOWKEY] --service-token <value> [--environment <value>] [--hide-uncommitted-changes]
|
|
324
|
+
[--json]
|
|
325
|
+
|
|
326
|
+
FLAGS
|
|
327
|
+
--environment=<value> [default: development]
|
|
328
|
+
--hide-uncommitted-changes
|
|
329
|
+
--service-token=<value> (required) service token to authenticate with
|
|
330
|
+
|
|
331
|
+
GLOBAL FLAGS
|
|
332
|
+
--json Format output as json.
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## `knock workflow list`
|
|
336
|
+
|
|
337
|
+
```
|
|
338
|
+
USAGE
|
|
339
|
+
$ knock workflow list --service-token <value> [--environment <value>] [--hide-uncommitted-changes] [--after
|
|
340
|
+
<value>] [--before <value>] [--limit <value>] [--json]
|
|
341
|
+
|
|
342
|
+
FLAGS
|
|
343
|
+
--after=<value>
|
|
344
|
+
--before=<value>
|
|
345
|
+
--environment=<value> [default: development]
|
|
346
|
+
--hide-uncommitted-changes
|
|
347
|
+
--limit=<value>
|
|
348
|
+
--service-token=<value> (required) service token to authenticate with
|
|
349
|
+
|
|
350
|
+
GLOBAL FLAGS
|
|
351
|
+
--json Format output as json.
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## `knock workflow pull [WORKFLOWKEY]`
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
USAGE
|
|
358
|
+
$ knock workflow pull [WORKFLOWKEY] --service-token <value> [--environment <value>] [--hide-uncommitted-changes]
|
|
359
|
+
|
|
360
|
+
FLAGS
|
|
361
|
+
--environment=<value> [default: development]
|
|
362
|
+
--hide-uncommitted-changes
|
|
363
|
+
--service-token=<value> (required) service token to authenticate with
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## `knock workflow push [WORKFLOWKEY]`
|
|
367
|
+
|
|
368
|
+
```
|
|
369
|
+
USAGE
|
|
370
|
+
$ knock workflow push [WORKFLOWKEY] --service-token <value> [--environment development]
|
|
371
|
+
|
|
372
|
+
FLAGS
|
|
373
|
+
--environment=<option> [default: development]
|
|
374
|
+
<options: development>
|
|
375
|
+
--service-token=<value> (required) service token to authenticate with
|
|
376
|
+
```
|
|
377
|
+
<!-- commandsstop -->
|
package/bin/dev
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const oclif = require('@oclif/core')
|
|
4
|
+
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const project = path.join(__dirname, '..', 'tsconfig.json')
|
|
7
|
+
|
|
8
|
+
// In dev mode -> use ts-node and dev plugins
|
|
9
|
+
process.env.NODE_ENV = 'development'
|
|
10
|
+
|
|
11
|
+
require('ts-node').register({project})
|
|
12
|
+
|
|
13
|
+
// In dev mode, always show stack traces
|
|
14
|
+
oclif.settings.debug = true;
|
|
15
|
+
|
|
16
|
+
// Start the CLI
|
|
17
|
+
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
package/bin/dev.cmd
ADDED
package/bin/run
ADDED
package/bin/run.cmd
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>Ping
|
|
8
|
+
});
|
|
9
|
+
const _baseCommand = /*#__PURE__*/ _interopRequireDefault(require("../lib/base-command"));
|
|
10
|
+
function _interopRequireDefault(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
class Ping extends _baseCommand.default {
|
|
16
|
+
async run() {
|
|
17
|
+
const resp = await this.apiV1.ping();
|
|
18
|
+
this.log(resp.data);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
Ping.description = "Ping the Knock management API to verify access.";
|
|
22
|
+
Ping.examples = [
|
|
23
|
+
"<%= config.bin %> <%= command.id %>"
|
|
24
|
+
];
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>WorkflowGet
|
|
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 _conditions = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/marshal/conditions"));
|
|
14
|
+
const _workflow = /*#__PURE__*/ _interopRequireWildcard(require("../../lib/marshal/workflow"));
|
|
15
|
+
function _interopRequireDefault(obj) {
|
|
16
|
+
return obj && obj.__esModule ? obj : {
|
|
17
|
+
default: obj
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
21
|
+
if (typeof WeakMap !== "function") return null;
|
|
22
|
+
var cacheBabelInterop = new WeakMap();
|
|
23
|
+
var cacheNodeInterop = new WeakMap();
|
|
24
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
25
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
26
|
+
})(nodeInterop);
|
|
27
|
+
}
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
29
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
30
|
+
return obj;
|
|
31
|
+
}
|
|
32
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
33
|
+
return {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
38
|
+
if (cache && cache.has(obj)) {
|
|
39
|
+
return cache.get(obj);
|
|
40
|
+
}
|
|
41
|
+
var newObj = {};
|
|
42
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
43
|
+
for(var key in obj){
|
|
44
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
45
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
46
|
+
if (desc && (desc.get || desc.set)) {
|
|
47
|
+
Object.defineProperty(newObj, key, desc);
|
|
48
|
+
} else {
|
|
49
|
+
newObj[key] = obj[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
newObj.default = obj;
|
|
54
|
+
if (cache) {
|
|
55
|
+
cache.set(obj, newObj);
|
|
56
|
+
}
|
|
57
|
+
return newObj;
|
|
58
|
+
}
|
|
59
|
+
class WorkflowGet extends _baseCommand.default {
|
|
60
|
+
async run() {
|
|
61
|
+
const resp = await (0, _request.withSpinner)(()=>this.apiV1.getWorkflow(this.props));
|
|
62
|
+
const { flags } = this.props;
|
|
63
|
+
if (flags.json) return resp.data;
|
|
64
|
+
this.render(resp.data);
|
|
65
|
+
}
|
|
66
|
+
render(workflow) {
|
|
67
|
+
const { workflowKey } = this.props.args;
|
|
68
|
+
const { environment: env , "hide-uncommitted-changes": commitedOnly } = this.props.flags;
|
|
69
|
+
const qualifier = env === "development" && !commitedOnly ? "(including uncommitted)" : "";
|
|
70
|
+
this.log(`‣ Showing workflow \`${workflowKey}\` in \`${env}\` environment ${qualifier}\n`);
|
|
71
|
+
/*
|
|
72
|
+
* Workflow table
|
|
73
|
+
*/ const rows = [
|
|
74
|
+
{
|
|
75
|
+
key: "Status",
|
|
76
|
+
value: _workflow.formatStatus(workflow)
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: "Name",
|
|
80
|
+
value: workflow.name
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
key: "Key",
|
|
84
|
+
value: workflow.key
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
key: "Description",
|
|
88
|
+
value: workflow.description || "-"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
key: "Categories",
|
|
92
|
+
value: _workflow.formatCategories(workflow, {
|
|
93
|
+
emptyDisplay: "-"
|
|
94
|
+
})
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
key: "Created at",
|
|
98
|
+
value: (0, _date.formatDateTime)(workflow.created_at)
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
key: "Updated at",
|
|
102
|
+
value: (0, _date.formatDateTime)(workflow.updated_at)
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
_core.CliUx.ux.table(rows, {
|
|
106
|
+
key: {
|
|
107
|
+
header: "Workflow",
|
|
108
|
+
minWidth: 24
|
|
109
|
+
},
|
|
110
|
+
value: {
|
|
111
|
+
header: "",
|
|
112
|
+
minWidth: 24
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
this.log("");
|
|
116
|
+
if (workflow.steps.length === 0) {
|
|
117
|
+
return _core.CliUx.ux.log(" This workflow has no steps to display.");
|
|
118
|
+
}
|
|
119
|
+
/*
|
|
120
|
+
* Workflow steps table
|
|
121
|
+
*/ const steps = workflow.steps.map((step, index)=>({
|
|
122
|
+
...step,
|
|
123
|
+
index
|
|
124
|
+
}));
|
|
125
|
+
_core.CliUx.ux.table(steps, {
|
|
126
|
+
index: {
|
|
127
|
+
header: "Steps",
|
|
128
|
+
get: (step)=>step.index + 1
|
|
129
|
+
},
|
|
130
|
+
ref: {
|
|
131
|
+
header: "Ref",
|
|
132
|
+
minWidth: 18
|
|
133
|
+
},
|
|
134
|
+
type: {
|
|
135
|
+
header: "Type",
|
|
136
|
+
minWidth: 12
|
|
137
|
+
},
|
|
138
|
+
summary: {
|
|
139
|
+
header: "Summary",
|
|
140
|
+
get: (step)=>_workflow.formatStepSummary(step)
|
|
141
|
+
},
|
|
142
|
+
conditions: {
|
|
143
|
+
header: "Conditions",
|
|
144
|
+
get: (step)=>step.conditions ? _conditions.formatConditions(step.conditions) : "-"
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
WorkflowGet.flags = {
|
|
150
|
+
environment: _core.Flags.string({
|
|
151
|
+
default: "development"
|
|
152
|
+
}),
|
|
153
|
+
"hide-uncommitted-changes": _core.Flags.boolean()
|
|
154
|
+
};
|
|
155
|
+
WorkflowGet.args = [
|
|
156
|
+
{
|
|
157
|
+
name: "workflowKey",
|
|
158
|
+
required: true
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
WorkflowGet.enableJsonFlag = true;
|