livingdocs-cli 2.1.0 → 2.3.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 +28 -99
- package/oclif.manifest.json +1 -1
- package/package.json +8 -7
- package/src/commands/config/print.js +4 -2
- package/src/commands/project-config/drafts.js +1 -0
- package/src/commands/project-config/plan.js +6 -7
- package/src/commands/project-config/publish.js +25 -19
- package/src/commands/project-config/upload.js +7 -7
- 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/shared_flags.js +13 -0
package/README.md
CHANGED
|
@@ -1,45 +1,33 @@
|
|
|
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.1.0 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
|
-
|
|
16
|
+
|
|
17
|
+
## Documentation
|
|
18
|
+
|
|
19
|
+
[Livingdocs CLI documentation](https://docs.livingdocs.io/reference-docs/cli)
|
|
20
|
+
|
|
21
|
+
# Commands Reference
|
|
31
22
|
<!-- commands -->
|
|
32
23
|
* [`livingdocs-cli component-library:build`](#livingdocs-cli-component-librarybuild)
|
|
33
24
|
* [`livingdocs-cli config:print`](#livingdocs-cli-configprint)
|
|
34
25
|
* [`livingdocs-cli design-server:start`](#livingdocs-cli-design-serverstart)
|
|
35
26
|
* [`livingdocs-cli help [COMMAND]`](#livingdocs-cli-help-command)
|
|
36
27
|
* [`livingdocs-cli project-config:download`](#livingdocs-cli-project-configdownload)
|
|
37
|
-
* [`livingdocs-cli project-config:drafts`](#livingdocs-cli-project-configdrafts)
|
|
38
28
|
* [`livingdocs-cli project-config:import-design`](#livingdocs-cli-project-configimport-design)
|
|
39
29
|
* [`livingdocs-cli project-config:plan`](#livingdocs-cli-project-configplan)
|
|
40
30
|
* [`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
31
|
|
|
44
32
|
## `livingdocs-cli component-library:build`
|
|
45
33
|
|
|
@@ -54,7 +42,7 @@ OPTIONS
|
|
|
54
42
|
-s, --src=src The folder with your .html component templates
|
|
55
43
|
```
|
|
56
44
|
|
|
57
|
-
_See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.
|
|
45
|
+
_See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.3.0/src/commands/component-library/build.js)_
|
|
58
46
|
|
|
59
47
|
## `livingdocs-cli config:print`
|
|
60
48
|
|
|
@@ -69,7 +57,7 @@ OPTIONS
|
|
|
69
57
|
-p, --project=project If used configuration options are loaded from .livingdocs-cli file.
|
|
70
58
|
```
|
|
71
59
|
|
|
72
|
-
_See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.
|
|
60
|
+
_See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.3.0/src/commands/config/print.js)_
|
|
73
61
|
|
|
74
62
|
## `livingdocs-cli design-server:start`
|
|
75
63
|
|
|
@@ -87,7 +75,7 @@ OPTIONS
|
|
|
87
75
|
--verbose
|
|
88
76
|
```
|
|
89
77
|
|
|
90
|
-
_See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.
|
|
78
|
+
_See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.3.0/src/commands/design-server/start.js)_
|
|
91
79
|
|
|
92
80
|
## `livingdocs-cli help [COMMAND]`
|
|
93
81
|
|
|
@@ -129,25 +117,7 @@ OPTIONS
|
|
|
129
117
|
--format=js|js/html|json The format of the files written.
|
|
130
118
|
```
|
|
131
119
|
|
|
132
|
-
_See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.
|
|
133
|
-
|
|
134
|
-
## `livingdocs-cli project-config:drafts`
|
|
135
|
-
|
|
136
|
-
List project configuration drafts
|
|
137
|
-
|
|
138
|
-
```
|
|
139
|
-
USAGE
|
|
140
|
-
$ livingdocs-cli project-config:drafts
|
|
141
|
-
|
|
142
|
-
OPTIONS
|
|
143
|
-
-h, --host=host [default: http://localhost:9090] The livingdocs host.
|
|
144
|
-
Can be set by the environment variable 'LI_HOST'.
|
|
145
|
-
|
|
146
|
-
-t, --token=token (required) Access Token for your project (needs `public-api:config:read` permission).
|
|
147
|
-
Can be set by the environment variable 'LI_TOKEN'.
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
_See code: [src/commands/project-config/drafts.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.0/src/commands/project-config/drafts.js)_
|
|
120
|
+
_See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.3.0/src/commands/project-config/download.js)_
|
|
151
121
|
|
|
152
122
|
## `livingdocs-cli project-config:import-design`
|
|
153
123
|
|
|
@@ -164,7 +134,7 @@ OPTIONS
|
|
|
164
134
|
-u, --designUri=designUri (required) URL of the design to import
|
|
165
135
|
```
|
|
166
136
|
|
|
167
|
-
_See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.
|
|
137
|
+
_See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.3.0/src/commands/project-config/import-design.js)_
|
|
168
138
|
|
|
169
139
|
## `livingdocs-cli project-config:plan`
|
|
170
140
|
|
|
@@ -175,7 +145,7 @@ USAGE
|
|
|
175
145
|
$ livingdocs-cli project-config:plan
|
|
176
146
|
|
|
177
147
|
OPTIONS
|
|
178
|
-
-d, --dist=dist
|
|
148
|
+
-d, --dist=dist The folder where the output will be written.
|
|
179
149
|
-e, --env=env If used configuration options are loaded from .livingdocs-cli file.
|
|
180
150
|
|
|
181
151
|
-h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
|
|
@@ -183,22 +153,24 @@ OPTIONS
|
|
|
183
153
|
|
|
184
154
|
-p, --project=project If used configuration options are loaded from .livingdocs-cli file.
|
|
185
155
|
|
|
156
|
+
-s, --source=source The folder or filename to the project config.
|
|
157
|
+
|
|
186
158
|
-t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
|
|
187
159
|
Can be set by the environment variable 'LI_TOKEN'.
|
|
188
160
|
```
|
|
189
161
|
|
|
190
|
-
_See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.
|
|
162
|
+
_See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.3.0/src/commands/project-config/plan.js)_
|
|
191
163
|
|
|
192
164
|
## `livingdocs-cli project-config:publish`
|
|
193
165
|
|
|
194
|
-
Publish a
|
|
166
|
+
Publish a project configuration to your project
|
|
195
167
|
|
|
196
168
|
```
|
|
197
169
|
USAGE
|
|
198
170
|
$ livingdocs-cli project-config:publish
|
|
199
171
|
|
|
200
172
|
OPTIONS
|
|
201
|
-
-d, --dist=dist
|
|
173
|
+
-d, --dist=dist The folder where the output will be written.
|
|
202
174
|
-e, --env=env If used configuration options are loaded from .livingdocs-cli file.
|
|
203
175
|
|
|
204
176
|
-h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
|
|
@@ -206,54 +178,11 @@ OPTIONS
|
|
|
206
178
|
|
|
207
179
|
-p, --project=project If used configuration options are loaded from .livingdocs-cli file.
|
|
208
180
|
|
|
209
|
-
-
|
|
210
|
-
Can be set by the environment variable 'LI_TOKEN'.
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
_See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.0/src/commands/project-config/publish.js)_
|
|
214
|
-
|
|
215
|
-
## `livingdocs-cli project-config:upload`
|
|
216
|
-
|
|
217
|
-
Upload a ChannelConfig into a draft for your project
|
|
218
|
-
|
|
219
|
-
```
|
|
220
|
-
USAGE
|
|
221
|
-
$ livingdocs-cli project-config:upload
|
|
222
|
-
|
|
223
|
-
OPTIONS
|
|
224
|
-
-d, --dist=dist (required) The folder or filename to the channelConfig.
|
|
225
|
-
-e, --env=env If used configuration options are loaded from .livingdocs-cli file.
|
|
226
|
-
|
|
227
|
-
-h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
|
|
228
|
-
Can be set by the environment variable 'LI_HOST'.
|
|
229
|
-
|
|
230
|
-
-p, --project=project If used configuration options are loaded from .livingdocs-cli file.
|
|
181
|
+
-s, --source=source The folder or filename to the project config.
|
|
231
182
|
|
|
232
183
|
-t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
|
|
233
184
|
Can be set by the environment variable 'LI_TOKEN'.
|
|
234
|
-
|
|
235
|
-
--draftName=draftName (required) The name of the draft the config will be saved under.
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
_See code: [src/commands/project-config/upload.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.0/src/commands/project-config/upload.js)_
|
|
239
|
-
|
|
240
|
-
## `livingdocs-cli project-config:upload_assets`
|
|
241
|
-
|
|
242
|
-
Upload assets to your project
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
USAGE
|
|
246
|
-
$ livingdocs-cli project-config:upload_assets
|
|
247
|
-
|
|
248
|
-
OPTIONS
|
|
249
|
-
-a, --assets=assets The folder where you asset files are located.
|
|
250
|
-
|
|
251
|
-
-h, --host=host [default: http://localhost:9090] The livingdocs host.
|
|
252
|
-
Can be set by the environment variable 'LI_HOST'.
|
|
253
|
-
|
|
254
|
-
-t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
|
|
255
|
-
Can be set by the environment variable 'LI_TOKEN'.
|
|
256
185
|
```
|
|
257
186
|
|
|
258
|
-
_See code: [src/commands/project-config/
|
|
187
|
+
_See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.3.0/src/commands/project-config/publish.js)_
|
|
259
188
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.
|
|
1
|
+
{"version":"2.3.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"},"source":{"name":"source","type":"option","char":"s","description":"The folder or filename to the project config."},"dist":{"name":"dist","type":"option","char":"d","description":"The folder where the output will be written."}},"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"},"source":{"name":"source","type":"option","char":"s","description":"The folder or filename to the project config."},"dist":{"name":"dist","type":"option","char":"d","description":"The folder where the output will be written."}},"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"},"source":{"name":"source","type":"option","char":"s","description":"The folder or filename to the project config.","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.
|
|
4
|
+
"version": "2.3.0",
|
|
5
5
|
"author": "Livingdocs AG",
|
|
6
6
|
"repository": "livingdocsIO/livingdocs-cli",
|
|
7
7
|
"homepage": "https://github.com/livingdocsIO/livingdocs-cli",
|
|
@@ -27,9 +27,10 @@
|
|
|
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-
|
|
30
|
+
"diff": "^5.0.0",
|
|
31
|
+
"fastify": "^3.25.3",
|
|
32
|
+
"fastify-cors": "^6.0.2",
|
|
33
|
+
"fastify-static": "^4.5.0",
|
|
33
34
|
"fs-extra": "^10.0.0",
|
|
34
35
|
"globby": "^10.0.1",
|
|
35
36
|
"html-minifier": "^4.0.0",
|
|
@@ -85,11 +86,11 @@
|
|
|
85
86
|
"isCi": true,
|
|
86
87
|
"name": "Drone",
|
|
87
88
|
"service": "drone",
|
|
88
|
-
"commit": "
|
|
89
|
-
"build": "
|
|
89
|
+
"commit": "b794df59cabaa3a259571d0bf38ffa215820f09c",
|
|
90
|
+
"build": "94",
|
|
90
91
|
"branch": "master",
|
|
91
92
|
"isPr": false,
|
|
92
93
|
"slug": "livingdocsIO/livingdocs-cli",
|
|
93
|
-
"date": "2022-01-
|
|
94
|
+
"date": "2022-01-08T14:01:02.392Z"
|
|
94
95
|
}
|
|
95
96
|
}
|
|
@@ -21,13 +21,15 @@ class ListConfigCommand extends Command {
|
|
|
21
21
|
|
|
22
22
|
this.printVar(`LI_HOST`, 'host', sessionConfig)
|
|
23
23
|
this.printVar(`LI_TOKEN`, 'token', sessionConfig)
|
|
24
|
+
this.printVar(`LI_SOURCE_FOLDER`, 'sourceFolder', sessionConfig)
|
|
24
25
|
this.printVar(`LI_DIST_FOLDER`, 'distFolder', sessionConfig)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
printVar (name, prop, sessionConfig) {
|
|
28
29
|
const varObj = getVar(name, prop, sessionConfig)
|
|
29
30
|
|
|
30
|
-
this.log(chalk.green(`${name}`), chalk.gray(` (source: ${varObj.source})`))
|
|
31
|
+
if (varObj.source) this.log(chalk.green(`${name}`), chalk.gray(` (source: ${varObj.source})`))
|
|
32
|
+
else this.log(chalk.green(`${name}`))
|
|
31
33
|
this.log(chalk.gray(`${varObj.value}\n`))
|
|
32
34
|
}
|
|
33
35
|
}
|
|
@@ -51,7 +53,7 @@ function getVar (key, prop, sessionConfig) {
|
|
|
51
53
|
} else {
|
|
52
54
|
return {
|
|
53
55
|
value: '[undefined]',
|
|
54
|
-
source:
|
|
56
|
+
source: undefined
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
}
|
|
@@ -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},
|
|
@@ -13,18 +13,17 @@ class PlanCommand extends Command {
|
|
|
13
13
|
env: sharedFlags.env,
|
|
14
14
|
token: {...sharedFlags.configWriteToken, required: true},
|
|
15
15
|
host: {...sharedFlags.host, required: true},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
required: true,
|
|
19
|
-
description: 'The folder or filename to the channelConfig.'
|
|
20
|
-
}
|
|
16
|
+
source: {...sharedFlags.source},
|
|
17
|
+
dist: {...sharedFlags.dist}
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
async run () {
|
|
24
|
-
const {token, host, dist} = this.parse(PlanCommand).flags
|
|
21
|
+
const {token, host, source, dist} = this.parse(PlanCommand).flags
|
|
25
22
|
const reportError = errorReporter(this.log, host, {verbose: true})
|
|
26
23
|
|
|
27
|
-
|
|
24
|
+
if (!source && !dist) throw new Error('Missing a source param')
|
|
25
|
+
|
|
26
|
+
const config = await readChannelConfig({source: source || dist})
|
|
28
27
|
|
|
29
28
|
await liApi.plan({host, token, channelConfig: config})
|
|
30
29
|
.then((result) => {
|
|
@@ -10,46 +10,52 @@ 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,
|
|
17
17
|
token: {...sharedFlags.configWriteToken, required: true},
|
|
18
18
|
host: {...sharedFlags.host, required: true},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
required: true,
|
|
22
|
-
description: 'The folder or filename to the channelConfig.'
|
|
23
|
-
}
|
|
19
|
+
source: {...sharedFlags.source},
|
|
20
|
+
dist: {...sharedFlags.dist}
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
async run () {
|
|
27
|
-
const {token, host,
|
|
24
|
+
const {token, host, source, dist} = this.parse(PublishCommand).flags
|
|
28
25
|
const reportError = errorReporter(this.log, host, {verbose: true})
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
if (!source && !dist) throw new Error('Missing a source param')
|
|
28
|
+
|
|
29
|
+
const config = await readChannelConfig({source: source || dist})
|
|
31
30
|
.catch((err) => {
|
|
32
31
|
this.log(chalk.red('✕ Parsing Failed'))
|
|
33
32
|
throw err
|
|
34
33
|
})
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
let ok = false
|
|
36
|
+
await liApi.plan({host, token, channelConfig: config})
|
|
37
|
+
.then((result) => {
|
|
38
|
+
ok = result.ok
|
|
39
|
+
resultReporter(result, this.log)
|
|
40
|
+
})
|
|
41
|
+
.catch(reportError)
|
|
42
|
+
|
|
43
|
+
if (!ok) return
|
|
44
|
+
|
|
45
|
+
const answers = await inquirer.prompt([{
|
|
46
|
+
name: 'continue',
|
|
47
|
+
type: 'confirm',
|
|
48
|
+
default: false,
|
|
49
|
+
message: `Are you sure to publish to production?`
|
|
50
|
+
}])
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
}
|
|
52
|
+
if (!answers.continue) return
|
|
47
53
|
|
|
48
54
|
await liApi.publish({host, token, channelConfig: config})
|
|
49
55
|
.then((result) => {
|
|
50
56
|
resultReporter(result, this.log)
|
|
51
57
|
updateRevisionNumber({
|
|
52
|
-
source: dist,
|
|
58
|
+
source: source || dist,
|
|
53
59
|
revisionNumberBefore: config.$baseRevision,
|
|
54
60
|
revisionNumber: result.revisionNumber
|
|
55
61
|
})
|
|
@@ -8,17 +8,17 @@ 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,
|
|
14
15
|
env: sharedFlags.env,
|
|
15
16
|
token: {...sharedFlags.configWriteToken, required: true},
|
|
16
17
|
host: {...sharedFlags.host, required: true},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
required: true
|
|
20
|
-
|
|
21
|
-
}),
|
|
18
|
+
source: {
|
|
19
|
+
...sharedFlags.source,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
22
|
draftName: flags.string({
|
|
23
23
|
description: 'The name of the draft the config will be saved under.',
|
|
24
24
|
required: true
|
|
@@ -26,10 +26,10 @@ class UploadCommand extends Command {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
async run () {
|
|
29
|
-
const {token, host,
|
|
29
|
+
const {token, host, source} = this.parse(UploadCommand).flags
|
|
30
30
|
const reportError = errorReporter(this.log, host, {verbose: true})
|
|
31
31
|
|
|
32
|
-
const config = await readChannelConfig({source
|
|
32
|
+
const config = await readChannelConfig({source})
|
|
33
33
|
.catch((err) => {
|
|
34
34
|
this.log(chalk.red('✕ Parsing Failed'))
|
|
35
35
|
throw err
|
|
@@ -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
|
|
@@ -66,6 +66,19 @@ module.exports = {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
}),
|
|
69
|
+
source: flags.string({
|
|
70
|
+
char: 's',
|
|
71
|
+
description: 'The folder or filename to the project config.',
|
|
72
|
+
|
|
73
|
+
default ({options, flags: givenFlags}) {
|
|
74
|
+
const sessionConfig = getCliConfig(givenFlags)
|
|
75
|
+
if (sessionConfig) {
|
|
76
|
+
return sessionConfig.sourceFolder
|
|
77
|
+
} else {
|
|
78
|
+
return process.env.LI_SOURCE_FOLDER
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
69
82
|
designUri: flags.string({
|
|
70
83
|
char: 'u',
|
|
71
84
|
description: 'URL of the design to import',
|