livingdocs-cli 2.0.1 → 2.2.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/README.md +35 -110
- package/oclif.manifest.json +1 -1
- package/package.json +13 -11
- package/src/commands/config/print.js +59 -0
- package/src/commands/project-config/drafts.js +1 -0
- package/src/commands/project-config/plan.js +1 -1
- package/src/commands/project-config/publish.js +20 -13
- package/src/commands/project-config/upload.js +1 -0
- package/src/commands/project-config/upload_assets.js +1 -0
- package/src/lib/api/channel_config_result_reporter.js +33 -5
- package/src/lib/cli/load_cli_config.js +4 -1
- package/src/commands/cli-config/print.js +0 -45
package/README.md
CHANGED
|
@@ -1,71 +1,59 @@
|
|
|
1
|
-
livingdocs-cli
|
|
2
|
-
==============
|
|
3
|
-
|
|
4
|
-
Livingdocs Command Line Interface
|
|
5
|
-
|
|
6
1
|
[](https://oclif.io)
|
|
7
2
|
[](https://npmjs.org/package/livingdocs-cli)
|
|
8
|
-
[](https://codecov.io/gh/livingdocsIO/livingdocs-cli)
|
|
9
3
|
[](https://npmjs.org/package/livingdocs-cli)
|
|
10
4
|
[](https://github.com/livingdocsIO/livingdocs-cli/blob/master/package.json)
|
|
11
5
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
running command...
|
|
22
|
-
$ livingdocs-cli (-v|--version|version)
|
|
23
|
-
livingdocs-cli/2.0.1 linux-x64 node-v16.11.1
|
|
24
|
-
$ livingdocs-cli --help [COMMAND]
|
|
25
|
-
USAGE
|
|
26
|
-
$ livingdocs-cli COMMAND
|
|
27
|
-
...
|
|
6
|
+
# livingdocs-cli
|
|
7
|
+
|
|
8
|
+
Livingdocs Command Line Interface
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g livingdocs-cli
|
|
14
|
+
livingdocs-cli --help
|
|
28
15
|
```
|
|
29
|
-
|
|
30
|
-
# Commands
|
|
16
|
+
|
|
17
|
+
# Commands Reference
|
|
31
18
|
<!-- commands -->
|
|
32
|
-
* [`livingdocs-cli cli-config:print`](#livingdocs-cli-cli-configprint)
|
|
33
19
|
* [`livingdocs-cli component-library:build`](#livingdocs-cli-component-librarybuild)
|
|
20
|
+
* [`livingdocs-cli config:print`](#livingdocs-cli-configprint)
|
|
34
21
|
* [`livingdocs-cli design-server:start`](#livingdocs-cli-design-serverstart)
|
|
35
22
|
* [`livingdocs-cli help [COMMAND]`](#livingdocs-cli-help-command)
|
|
36
23
|
* [`livingdocs-cli project-config:download`](#livingdocs-cli-project-configdownload)
|
|
37
|
-
* [`livingdocs-cli project-config:drafts`](#livingdocs-cli-project-configdrafts)
|
|
38
24
|
* [`livingdocs-cli project-config:import-design`](#livingdocs-cli-project-configimport-design)
|
|
39
25
|
* [`livingdocs-cli project-config:plan`](#livingdocs-cli-project-configplan)
|
|
40
26
|
* [`livingdocs-cli project-config:publish`](#livingdocs-cli-project-configpublish)
|
|
41
|
-
* [`livingdocs-cli project-config:upload`](#livingdocs-cli-project-configupload)
|
|
42
|
-
* [`livingdocs-cli project-config:upload_assets`](#livingdocs-cli-project-configupload_assets)
|
|
43
27
|
|
|
44
|
-
## `livingdocs-cli
|
|
28
|
+
## `livingdocs-cli component-library:build`
|
|
45
29
|
|
|
46
|
-
|
|
30
|
+
Build a Component Library JSON file
|
|
47
31
|
|
|
48
32
|
```
|
|
49
33
|
USAGE
|
|
50
|
-
$ livingdocs-cli
|
|
34
|
+
$ livingdocs-cli component-library:build
|
|
35
|
+
|
|
36
|
+
OPTIONS
|
|
37
|
+
-d, --dist=dist The folder where the output will be written.
|
|
38
|
+
-s, --src=src The folder with your .html component templates
|
|
51
39
|
```
|
|
52
40
|
|
|
53
|
-
_See code: [src/commands/
|
|
41
|
+
_See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.2.0/src/commands/component-library/build.js)_
|
|
54
42
|
|
|
55
|
-
## `livingdocs-cli
|
|
43
|
+
## `livingdocs-cli config:print`
|
|
56
44
|
|
|
57
|
-
|
|
45
|
+
Print current CLI configuration
|
|
58
46
|
|
|
59
47
|
```
|
|
60
48
|
USAGE
|
|
61
|
-
$ livingdocs-cli
|
|
49
|
+
$ livingdocs-cli config:print
|
|
62
50
|
|
|
63
51
|
OPTIONS
|
|
64
|
-
-
|
|
65
|
-
-
|
|
52
|
+
-e, --env=env If used configuration options are loaded from .livingdocs-cli file.
|
|
53
|
+
-p, --project=project If used configuration options are loaded from .livingdocs-cli file.
|
|
66
54
|
```
|
|
67
55
|
|
|
68
|
-
_See code: [src/commands/
|
|
56
|
+
_See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.2.0/src/commands/config/print.js)_
|
|
69
57
|
|
|
70
58
|
## `livingdocs-cli design-server:start`
|
|
71
59
|
|
|
@@ -83,7 +71,7 @@ OPTIONS
|
|
|
83
71
|
--verbose
|
|
84
72
|
```
|
|
85
73
|
|
|
86
|
-
_See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.0
|
|
74
|
+
_See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.2.0/src/commands/design-server/start.js)_
|
|
87
75
|
|
|
88
76
|
## `livingdocs-cli help [COMMAND]`
|
|
89
77
|
|
|
@@ -100,7 +88,7 @@ OPTIONS
|
|
|
100
88
|
--all see all commands in CLI
|
|
101
89
|
```
|
|
102
90
|
|
|
103
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.
|
|
91
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_
|
|
104
92
|
|
|
105
93
|
## `livingdocs-cli project-config:download`
|
|
106
94
|
|
|
@@ -125,25 +113,7 @@ OPTIONS
|
|
|
125
113
|
--format=js|js/html|json The format of the files written.
|
|
126
114
|
```
|
|
127
115
|
|
|
128
|
-
_See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.0
|
|
129
|
-
|
|
130
|
-
## `livingdocs-cli project-config:drafts`
|
|
131
|
-
|
|
132
|
-
List project configuration drafts
|
|
133
|
-
|
|
134
|
-
```
|
|
135
|
-
USAGE
|
|
136
|
-
$ livingdocs-cli project-config:drafts
|
|
137
|
-
|
|
138
|
-
OPTIONS
|
|
139
|
-
-h, --host=host [default: http://localhost:9090] The livingdocs host.
|
|
140
|
-
Can be set by the environment variable 'LI_HOST'.
|
|
141
|
-
|
|
142
|
-
-t, --token=token (required) Access Token for your project (needs `public-api:config:read` permission).
|
|
143
|
-
Can be set by the environment variable 'LI_TOKEN'.
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
_See code: [src/commands/project-config/drafts.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.0.1/src/commands/project-config/drafts.js)_
|
|
116
|
+
_See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.2.0/src/commands/project-config/download.js)_
|
|
147
117
|
|
|
148
118
|
## `livingdocs-cli project-config:import-design`
|
|
149
119
|
|
|
@@ -160,7 +130,7 @@ OPTIONS
|
|
|
160
130
|
-u, --designUri=designUri (required) URL of the design to import
|
|
161
131
|
```
|
|
162
132
|
|
|
163
|
-
_See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.0
|
|
133
|
+
_See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.2.0/src/commands/project-config/import-design.js)_
|
|
164
134
|
|
|
165
135
|
## `livingdocs-cli project-config:plan`
|
|
166
136
|
|
|
@@ -171,7 +141,7 @@ USAGE
|
|
|
171
141
|
$ livingdocs-cli project-config:plan
|
|
172
142
|
|
|
173
143
|
OPTIONS
|
|
174
|
-
-d, --dist=dist (required) The folder or filename to the
|
|
144
|
+
-d, --dist=dist (required) The folder or filename to the project config.
|
|
175
145
|
-e, --env=env If used configuration options are loaded from .livingdocs-cli file.
|
|
176
146
|
|
|
177
147
|
-h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
|
|
@@ -183,41 +153,18 @@ OPTIONS
|
|
|
183
153
|
Can be set by the environment variable 'LI_TOKEN'.
|
|
184
154
|
```
|
|
185
155
|
|
|
186
|
-
_See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.0
|
|
156
|
+
_See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.2.0/src/commands/project-config/plan.js)_
|
|
187
157
|
|
|
188
158
|
## `livingdocs-cli project-config:publish`
|
|
189
159
|
|
|
190
|
-
Publish a
|
|
160
|
+
Publish a project configuration to your project
|
|
191
161
|
|
|
192
162
|
```
|
|
193
163
|
USAGE
|
|
194
164
|
$ livingdocs-cli project-config:publish
|
|
195
165
|
|
|
196
166
|
OPTIONS
|
|
197
|
-
-d, --dist=dist (required) The folder or filename to the
|
|
198
|
-
-e, --env=env If used configuration options are loaded from .livingdocs-cli file.
|
|
199
|
-
|
|
200
|
-
-h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
|
|
201
|
-
Can be set by the environment variable 'LI_HOST'.
|
|
202
|
-
|
|
203
|
-
-p, --project=project If used configuration options are loaded from .livingdocs-cli file.
|
|
204
|
-
|
|
205
|
-
-t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
|
|
206
|
-
Can be set by the environment variable 'LI_TOKEN'.
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
_See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.0.1/src/commands/project-config/publish.js)_
|
|
210
|
-
|
|
211
|
-
## `livingdocs-cli project-config:upload`
|
|
212
|
-
|
|
213
|
-
Upload a ChannelConfig into a draft for your project
|
|
214
|
-
|
|
215
|
-
```
|
|
216
|
-
USAGE
|
|
217
|
-
$ livingdocs-cli project-config:upload
|
|
218
|
-
|
|
219
|
-
OPTIONS
|
|
220
|
-
-d, --dist=dist (required) The folder or filename to the channelConfig.
|
|
167
|
+
-d, --dist=dist (required) The folder or filename to the project config.
|
|
221
168
|
-e, --env=env If used configuration options are loaded from .livingdocs-cli file.
|
|
222
169
|
|
|
223
170
|
-h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
|
|
@@ -227,29 +174,7 @@ OPTIONS
|
|
|
227
174
|
|
|
228
175
|
-t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
|
|
229
176
|
Can be set by the environment variable 'LI_TOKEN'.
|
|
230
|
-
|
|
231
|
-
--draftName=draftName (required) The name of the draft the config will be saved under.
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
_See code: [src/commands/project-config/upload.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.0.1/src/commands/project-config/upload.js)_
|
|
235
|
-
|
|
236
|
-
## `livingdocs-cli project-config:upload_assets`
|
|
237
|
-
|
|
238
|
-
Upload assets to your project
|
|
239
|
-
|
|
240
|
-
```
|
|
241
|
-
USAGE
|
|
242
|
-
$ livingdocs-cli project-config:upload_assets
|
|
243
|
-
|
|
244
|
-
OPTIONS
|
|
245
|
-
-a, --assets=assets The folder where you asset files are located.
|
|
246
|
-
|
|
247
|
-
-h, --host=host [default: http://localhost:9090] The livingdocs host.
|
|
248
|
-
Can be set by the environment variable 'LI_HOST'.
|
|
249
|
-
|
|
250
|
-
-t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
|
|
251
|
-
Can be set by the environment variable 'LI_TOKEN'.
|
|
252
177
|
```
|
|
253
178
|
|
|
254
|
-
_See code: [src/commands/project-config/
|
|
179
|
+
_See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.2.0/src/commands/project-config/publish.js)_
|
|
255
180
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.0
|
|
1
|
+
{"version":"2.2.0","commands":{"component-library:build":{"id":"component-library:build","description":"Build a Component Library JSON file","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"src":{"name":"src","type":"option","char":"s","description":"The folder with your .html component templates"},"dist":{"name":"dist","type":"option","char":"d","description":"The folder where the output will be written."}},"args":[]},"config:print":{"id":"config:print","description":"Print current CLI configuration","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"project":{"name":"project","type":"option","char":"p","description":"If used configuration options are loaded from .livingdocs-cli file."},"env":{"name":"env","type":"option","char":"e","description":"If used configuration options are loaded from .livingdocs-cli file."}},"args":[]},"design-server:start":{"id":"design-server:start","description":"Start a design server for development","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"port":{"name":"port","type":"option","char":"p","description":"The port of the design-server.","default":9030},"dist":{"name":"dist","type":"option","char":"d","description":"The folder to load designs from.","required":true},"assets":{"name":"assets","type":"option","description":"Asset folder to serve static files."},"basePath":{"name":"basePath","type":"option","description":"The basePath to set in `assets.basePath`."},"verbose":{"name":"verbose","type":"boolean","allowNo":false}},"args":[]},"project-config:download":{"id":"project-config:download","description":"Download a project configuration","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"project":{"name":"project","type":"option","char":"p","description":"If used configuration options are loaded from .livingdocs-cli file."},"env":{"name":"env","type":"option","char":"e","description":"If used configuration options are loaded from .livingdocs-cli file."},"token":{"name":"token","type":"option","char":"t","description":"Access Token for your project (needs `public-api:config:read` permission).\nCan be set by the environment variable 'LI_TOKEN'.","required":true},"host":{"name":"host","type":"option","char":"h","description":"The livingdocs host.\nCan be set by the environment variable 'LI_HOST'.","required":true,"default":"http://localhost:9090"},"dist":{"name":"dist","type":"option","char":"d","description":"The folder where the output will be written."},"format":{"name":"format","type":"option","description":"The format of the files written.","options":["js","js/html","json"]}},"args":[]},"project-config:drafts":{"id":"project-config:drafts","description":"List project configuration drafts","pluginName":"livingdocs-cli","pluginType":"core","hidden":true,"aliases":[],"flags":{"token":{"name":"token","type":"option","char":"t","description":"Access Token for your project (needs `public-api:config:read` permission).\nCan be set by the environment variable 'LI_TOKEN'.","required":true},"host":{"name":"host","type":"option","char":"h","description":"The livingdocs host.\nCan be set by the environment variable 'LI_HOST'.","default":"http://localhost:9090"}},"args":[]},"project-config:import-design":{"id":"project-config:import-design","description":"Import a design into a given project configuration","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"project":{"name":"project","type":"option","char":"p","description":"If used configuration options are loaded from .livingdocs-cli file."},"env":{"name":"env","type":"option","char":"e","description":"If used configuration options are loaded from .livingdocs-cli file."},"dist":{"name":"dist","type":"option","char":"d","description":"The folder where the output will be written.","required":true},"designUri":{"name":"designUri","type":"option","char":"u","description":"URL of the design to import","required":true}},"args":[]},"project-config:plan":{"id":"project-config:plan","description":"See what would be updated in a publish command","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"project":{"name":"project","type":"option","char":"p","description":"If used configuration options are loaded from .livingdocs-cli file."},"env":{"name":"env","type":"option","char":"e","description":"If used configuration options are loaded from .livingdocs-cli file."},"token":{"name":"token","type":"option","char":"t","description":"Access Token for your project (needs `public-api:config:write` permission).\nCan be set by the environment variable 'LI_TOKEN'.","required":true},"host":{"name":"host","type":"option","char":"h","description":"The livingdocs host.\nCan be set by the environment variable 'LI_HOST'.","required":true,"default":"http://localhost:9090"},"dist":{"name":"dist","type":"option","char":"d","description":"The folder or filename to the project config.","required":true}},"args":[]},"project-config:publish":{"id":"project-config:publish","description":"Publish a project configuration to your project","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"project":{"name":"project","type":"option","char":"p","description":"If used configuration options are loaded from .livingdocs-cli file."},"env":{"name":"env","type":"option","char":"e","description":"If used configuration options are loaded from .livingdocs-cli file."},"token":{"name":"token","type":"option","char":"t","description":"Access Token for your project (needs `public-api:config:write` permission).\nCan be set by the environment variable 'LI_TOKEN'.","required":true},"host":{"name":"host","type":"option","char":"h","description":"The livingdocs host.\nCan be set by the environment variable 'LI_HOST'.","required":true,"default":"http://localhost:9090"},"dist":{"name":"dist","type":"option","char":"d","description":"The folder or filename to the project config.","required":true}},"args":[]},"project-config:upload":{"id":"project-config:upload","description":"Upload a ChannelConfig into a draft for your project","pluginName":"livingdocs-cli","pluginType":"core","hidden":true,"aliases":[],"flags":{"project":{"name":"project","type":"option","char":"p","description":"If used configuration options are loaded from .livingdocs-cli file."},"env":{"name":"env","type":"option","char":"e","description":"If used configuration options are loaded from .livingdocs-cli file."},"token":{"name":"token","type":"option","char":"t","description":"Access Token for your project (needs `public-api:config:write` permission).\nCan be set by the environment variable 'LI_TOKEN'.","required":true},"host":{"name":"host","type":"option","char":"h","description":"The livingdocs host.\nCan be set by the environment variable 'LI_HOST'.","required":true,"default":"http://localhost:9090"},"dist":{"name":"dist","type":"option","char":"d","description":"The folder or filename to the channelConfig.","required":true},"draftName":{"name":"draftName","type":"option","description":"The name of the draft the config will be saved under.","required":true}},"args":[]},"project-config:upload_assets":{"id":"project-config:upload_assets","description":"Upload assets to your project","pluginName":"livingdocs-cli","pluginType":"core","hidden":true,"aliases":[],"flags":{"token":{"name":"token","type":"option","char":"t","description":"Access Token for your project (needs `public-api:config:write` permission).\nCan be set by the environment variable 'LI_TOKEN'.","required":true},"host":{"name":"host","type":"option","char":"h","description":"The livingdocs host.\nCan be set by the environment variable 'LI_HOST'.","default":"http://localhost:9090"},"assets":{"name":"assets","type":"option","char":"a","description":"The folder where you asset files are located."}},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livingdocs-cli",
|
|
3
3
|
"description": "Livingdocs Command Line Utility",
|
|
4
|
-
"version": "2.0
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"author": "Livingdocs AG",
|
|
6
6
|
"repository": "livingdocsIO/livingdocs-cli",
|
|
7
7
|
"homepage": "https://github.com/livingdocsIO/livingdocs-cli",
|
|
@@ -27,16 +27,18 @@
|
|
|
27
27
|
"chalk": "^2.4.2",
|
|
28
28
|
"cheerio": "^1.0.0-rc.3",
|
|
29
29
|
"dedent": "^0.7.0",
|
|
30
|
-
"
|
|
31
|
-
"fastify
|
|
32
|
-
"fastify-
|
|
33
|
-
"
|
|
30
|
+
"diff": "^5.0.0",
|
|
31
|
+
"fastify": "^3.25.3",
|
|
32
|
+
"fastify-cors": "^6.0.2",
|
|
33
|
+
"fastify-static": "^4.5.0",
|
|
34
|
+
"fs-extra": "^10.0.0",
|
|
34
35
|
"globby": "^10.0.1",
|
|
35
36
|
"html-minifier": "^4.0.0",
|
|
36
37
|
"inquirer": "^7.0.0",
|
|
37
38
|
"javascript-stringify": "^2.0.0",
|
|
38
39
|
"js-beautify": "^1.10.2",
|
|
39
|
-
"
|
|
40
|
+
"js-yaml": "^4.1.0",
|
|
41
|
+
"lodash": "^4.17.21",
|
|
40
42
|
"nanoid": "^2.1.0",
|
|
41
43
|
"npmlog": "^4.1.2",
|
|
42
44
|
"p-queue": "^6.1.1",
|
|
@@ -48,8 +50,8 @@
|
|
|
48
50
|
"@oclif/dev-cli": "^1.22.2",
|
|
49
51
|
"@oclif/test": "^1.2.5",
|
|
50
52
|
"chai": "^4.2.0",
|
|
51
|
-
"eslint": "^8.0
|
|
52
|
-
"eslint-config-oclif": "^
|
|
53
|
+
"eslint": "^8.5.0",
|
|
54
|
+
"eslint-config-oclif": "^4.0.0",
|
|
53
55
|
"mocha": "^6.2.0",
|
|
54
56
|
"nock": "^11.3.3",
|
|
55
57
|
"nyc": "^14.1.1"
|
|
@@ -84,11 +86,11 @@
|
|
|
84
86
|
"isCi": true,
|
|
85
87
|
"name": "Drone",
|
|
86
88
|
"service": "drone",
|
|
87
|
-
"commit": "
|
|
88
|
-
"build": "
|
|
89
|
+
"commit": "d2d84b77ee70e61b52d84a7a100c07e1acbc2c8e",
|
|
90
|
+
"build": "91",
|
|
89
91
|
"branch": "master",
|
|
90
92
|
"isPr": false,
|
|
91
93
|
"slug": "livingdocsIO/livingdocs-cli",
|
|
92
|
-
"date": "
|
|
94
|
+
"date": "2022-01-05T21:32:08.848Z"
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const chalk = require('chalk')
|
|
2
|
+
const {Command} = require('@oclif/command')
|
|
3
|
+
|
|
4
|
+
const sharedFlags = require('../../lib/cli/shared_flags')
|
|
5
|
+
const loadCliConfig = require('../../lib/cli/load_cli_config')
|
|
6
|
+
|
|
7
|
+
const defaults = {
|
|
8
|
+
LI_HOST: 'http://localhost:9090'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
class ListConfigCommand extends Command {
|
|
12
|
+
static description = `Print current CLI configuration`
|
|
13
|
+
static flags = {
|
|
14
|
+
project: sharedFlags.project,
|
|
15
|
+
env: sharedFlags.env
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async run () {
|
|
19
|
+
const {project, env} = this.parse(ListConfigCommand).flags
|
|
20
|
+
const sessionConfig = loadCliConfig({project, env})
|
|
21
|
+
|
|
22
|
+
this.printVar(`LI_HOST`, 'host', sessionConfig)
|
|
23
|
+
this.printVar(`LI_TOKEN`, 'token', sessionConfig)
|
|
24
|
+
this.printVar(`LI_DIST_FOLDER`, 'distFolder', sessionConfig)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
printVar (name, prop, sessionConfig) {
|
|
28
|
+
const varObj = getVar(name, prop, sessionConfig)
|
|
29
|
+
|
|
30
|
+
this.log(chalk.green(`${name}`), chalk.gray(` (source: ${varObj.source})`))
|
|
31
|
+
this.log(chalk.gray(`${varObj.value}\n`))
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getVar (key, prop, sessionConfig) {
|
|
36
|
+
if (sessionConfig?.[prop] !== undefined) {
|
|
37
|
+
return {
|
|
38
|
+
value: sessionConfig?.[prop],
|
|
39
|
+
source: '.livingdocs-cli file'
|
|
40
|
+
}
|
|
41
|
+
} else if (process.env[key]) {
|
|
42
|
+
return {
|
|
43
|
+
value: process.env[key],
|
|
44
|
+
source: 'environment variable'
|
|
45
|
+
}
|
|
46
|
+
} else if (defaults[key]) {
|
|
47
|
+
return {
|
|
48
|
+
value: defaults[key],
|
|
49
|
+
source: 'default value'
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
return {
|
|
53
|
+
value: '[undefined]',
|
|
54
|
+
source: 'not set'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = ListConfigCommand
|
|
@@ -6,6 +6,7 @@ const liApi = require('../../lib/api/livingdocs_api')
|
|
|
6
6
|
const errorReporter = require('../../lib/api/error_reporter')
|
|
7
7
|
|
|
8
8
|
class DraftsCommand extends Command {
|
|
9
|
+
static hidden = true
|
|
9
10
|
static description = `List project configuration drafts`
|
|
10
11
|
static flags = {
|
|
11
12
|
token: {...sharedFlags.configReadToken, required: true},
|
|
@@ -10,7 +10,7 @@ const readChannelConfig = require('../../lib/read_channel_config')
|
|
|
10
10
|
const updateRevisionNumber = require('../../lib/update_revision_number')
|
|
11
11
|
|
|
12
12
|
class PublishCommand extends Command {
|
|
13
|
-
static description = `Publish a
|
|
13
|
+
static description = `Publish a project configuration to your project`
|
|
14
14
|
static flags = {
|
|
15
15
|
project: sharedFlags.project,
|
|
16
16
|
env: sharedFlags.env,
|
|
@@ -19,12 +19,12 @@ class PublishCommand extends Command {
|
|
|
19
19
|
dist: {
|
|
20
20
|
...sharedFlags.dist,
|
|
21
21
|
required: true,
|
|
22
|
-
description: 'The folder or filename to the
|
|
22
|
+
description: 'The folder or filename to the project config.'
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async run () {
|
|
27
|
-
const {token, host, dist
|
|
27
|
+
const {token, host, dist} = this.parse(PublishCommand).flags
|
|
28
28
|
const reportError = errorReporter(this.log, host, {verbose: true})
|
|
29
29
|
|
|
30
30
|
const config = await readChannelConfig({source: dist})
|
|
@@ -33,17 +33,24 @@ class PublishCommand extends Command {
|
|
|
33
33
|
throw err
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}])
|
|
36
|
+
let ok = false
|
|
37
|
+
await liApi.plan({host, token, channelConfig: config})
|
|
38
|
+
.then((result) => {
|
|
39
|
+
ok = result.ok
|
|
40
|
+
resultReporter(result, this.log)
|
|
41
|
+
})
|
|
42
|
+
.catch(reportError)
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
if (!ok) return
|
|
45
|
+
|
|
46
|
+
const answers = await inquirer.prompt([{
|
|
47
|
+
name: 'continue',
|
|
48
|
+
type: 'confirm',
|
|
49
|
+
default: false,
|
|
50
|
+
message: `Are you sure to publish to production?`
|
|
51
|
+
}])
|
|
52
|
+
|
|
53
|
+
if (!answers.continue) return
|
|
47
54
|
|
|
48
55
|
await liApi.publish({host, token, channelConfig: config})
|
|
49
56
|
.then((result) => {
|
|
@@ -8,6 +8,7 @@ const resultReporter = require('../../lib/api/channel_config_result_reporter')
|
|
|
8
8
|
const readChannelConfig = require('../../lib/read_channel_config')
|
|
9
9
|
|
|
10
10
|
class UploadCommand extends Command {
|
|
11
|
+
static hidden = true
|
|
11
12
|
static description = `Upload a ChannelConfig into a draft for your project`
|
|
12
13
|
static flags = {
|
|
13
14
|
project: sharedFlags.project,
|
|
@@ -6,6 +6,7 @@ const sharedFlags = require('../../lib/cli/shared_flags')
|
|
|
6
6
|
const liApi = require('../../lib/api/livingdocs_api')
|
|
7
7
|
|
|
8
8
|
class UploadAssetsCommand extends Command {
|
|
9
|
+
static hidden = true
|
|
9
10
|
static description = `Upload assets to your project`
|
|
10
11
|
static flags = {
|
|
11
12
|
token: {...sharedFlags.configWriteToken, required: true},
|
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
const chalk = require('chalk')
|
|
2
2
|
const dedent = require('dedent')
|
|
3
|
+
const diff = require('diff')
|
|
3
4
|
|
|
4
5
|
module.exports = function (result, log) {
|
|
5
6
|
function info (msg) { log(msg) }
|
|
6
7
|
function success (msg) { log(chalk.green(msg)) }
|
|
7
8
|
function error (msg) { log(chalk.red(msg)) }
|
|
9
|
+
function print (obj) { return JSON.stringify(obj, null, 2) }
|
|
10
|
+
|
|
11
|
+
function colorUpdate (entry) {
|
|
12
|
+
if (entry.added) return chalk.green(entry.value)
|
|
13
|
+
if (entry.removed) return chalk.red(entry.value)
|
|
14
|
+
return entry.value
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function calcDiff (patch) {
|
|
18
|
+
|
|
19
|
+
if (patch.action === 'update') {
|
|
20
|
+
const items = diff.diffJson(patch.valueBefore || '', patch.value)
|
|
21
|
+
return items.reduce((str, item) => {
|
|
22
|
+
return `${str}${colorUpdate(item)}`
|
|
23
|
+
}, '')
|
|
24
|
+
} else if (patch.action === 'remove') {
|
|
25
|
+
return patch.valueBefore
|
|
26
|
+
? chalk.red(print(patch.valueBefore))
|
|
27
|
+
: ''
|
|
28
|
+
} else {
|
|
29
|
+
return chalk.green(print(patch.value))
|
|
30
|
+
}
|
|
31
|
+
}
|
|
8
32
|
|
|
9
33
|
if (result.ok) {
|
|
10
|
-
|
|
34
|
+
const count = result.patches.length
|
|
35
|
+
if (!result.patches || count === 0) {
|
|
11
36
|
info(dedent`
|
|
12
37
|
✓ No Changes.
|
|
13
38
|
`)
|
|
@@ -16,9 +41,8 @@ module.exports = function (result, log) {
|
|
|
16
41
|
info(dedent`
|
|
17
42
|
Plan
|
|
18
43
|
----
|
|
19
|
-
✓ Everything looks ok.
|
|
20
44
|
`)
|
|
21
|
-
info(`\
|
|
45
|
+
info(`\nPatches (${count}):\n`)
|
|
22
46
|
} else {
|
|
23
47
|
success(dedent`
|
|
24
48
|
✓ Success. Channel Config Published.
|
|
@@ -30,9 +54,13 @@ module.exports = function (result, log) {
|
|
|
30
54
|
}
|
|
31
55
|
|
|
32
56
|
for (const patch of result.patches) {
|
|
33
|
-
info(
|
|
57
|
+
info(`• [${patch.action}] ${patch.pointer}`)
|
|
58
|
+
info(`${calcDiff(patch)}`)
|
|
34
59
|
}
|
|
35
|
-
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if (count === 1) info(`\n✓ The patch looks good.\n`)
|
|
63
|
+
else info(`\n✓ All ${count} patches look good.\n`)
|
|
36
64
|
}
|
|
37
65
|
|
|
38
66
|
return
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const fs = require('fs-extra')
|
|
2
|
+
const yaml = require('js-yaml')
|
|
3
|
+
|
|
2
4
|
const _get = require('lodash/get')
|
|
3
5
|
|
|
4
6
|
let cliConfig
|
|
@@ -31,7 +33,8 @@ function readFile () {
|
|
|
31
33
|
const filepath = `${workingDir}/.livingdocs-cli`
|
|
32
34
|
|
|
33
35
|
if (fs.existsSync(filepath)) {
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
const config = yaml.load(fs.readFileSync(filepath))
|
|
35
38
|
return config
|
|
36
39
|
|
|
37
40
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
const {Command} = require('@oclif/command')
|
|
3
|
-
|
|
4
|
-
const defaults = {
|
|
5
|
-
LI_HOST: 'http://localhost:9090'
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
class ListConfigCommand extends Command {
|
|
9
|
-
static description = `Print current CLI configuration`
|
|
10
|
-
static flags = {}
|
|
11
|
-
|
|
12
|
-
async run () {
|
|
13
|
-
this.printVar(`LI_HOST`)
|
|
14
|
-
this.printVar(`LI_TOKEN`)
|
|
15
|
-
this.printVar(`LI_DIST_FOLDER`)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
printVar (name) {
|
|
19
|
-
const varObj = getVar(name)
|
|
20
|
-
|
|
21
|
-
this.log(chalk.green(`${name}`), chalk.gray(` (source: ${varObj.source})`))
|
|
22
|
-
this.log(chalk.gray(`${varObj.value}\n`))
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function getVar (key) {
|
|
27
|
-
if (process.env[key]) {
|
|
28
|
-
return {
|
|
29
|
-
value: process.env[key],
|
|
30
|
-
source: 'environment variable'
|
|
31
|
-
}
|
|
32
|
-
} else if (defaults[key]) {
|
|
33
|
-
return {
|
|
34
|
-
value: defaults[key],
|
|
35
|
-
source: 'default value'
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
return {
|
|
39
|
-
value: '[undefined]',
|
|
40
|
-
source: 'not set'
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
module.exports = ListConfigCommand
|