livingdocs-cli 2.0.0 → 2.1.2

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 CHANGED
@@ -1,70 +1,59 @@
1
- livingdocs-cli
2
- ==============
3
-
4
- Livingdocs Command Line Interface
5
-
6
1
  [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
7
2
  [![Version](https://img.shields.io/npm/v/livingdocs-cli.svg)](https://npmjs.org/package/livingdocs-cli)
8
- [![Codecov](https://codecov.io/gh/livingdocsIO/livingdocs-cli/branch/master/graph/badge.svg)](https://codecov.io/gh/livingdocsIO/livingdocs-cli)
9
3
  [![Downloads/week](https://img.shields.io/npm/dw/livingdocs-cli.svg)](https://npmjs.org/package/livingdocs-cli)
10
4
  [![License](https://img.shields.io/npm/l/livingdocs-cli.svg)](https://github.com/livingdocsIO/livingdocs-cli/blob/master/package.json)
11
5
 
12
- <!-- toc -->
13
- * [Usage](#usage)
14
- * [Commands](#commands)
15
- <!-- tocstop -->
16
- # Usage
17
- <!-- usage -->
6
+ # livingdocs-cli
7
+
8
+ Livingdocs Command Line Interface
9
+
10
+ ## Setup
11
+
18
12
  ```sh-session
19
13
  $ npm install -g livingdocs-cli
20
- $ livingdocs-cli COMMAND
21
- running command...
22
- $ livingdocs-cli (-v|--version|version)
23
- livingdocs-cli/0.0.0 darwin-x64 node-v12.10.0
24
- $ livingdocs-cli --help [COMMAND]
25
- USAGE
26
- $ livingdocs-cli COMMAND
27
- ...
14
+ $ livingdocs-cli --help
28
15
  ```
29
- <!-- usagestop -->
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)
24
+ * [`livingdocs-cli project-config:import-design`](#livingdocs-cli-project-configimport-design)
38
25
  * [`livingdocs-cli project-config:plan`](#livingdocs-cli-project-configplan)
39
26
  * [`livingdocs-cli project-config:publish`](#livingdocs-cli-project-configpublish)
40
- * [`livingdocs-cli project-config:upload`](#livingdocs-cli-project-configupload)
41
- * [`livingdocs-cli project-config:upload_assets`](#livingdocs-cli-project-configupload_assets)
42
27
 
43
- ## `livingdocs-cli cli-config:print`
28
+ ## `livingdocs-cli component-library:build`
44
29
 
45
- Print current CLI configuration
30
+ Build a Component Library JSON file
46
31
 
47
32
  ```
48
33
  USAGE
49
- $ livingdocs-cli cli-config:print
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
50
39
  ```
51
40
 
52
- _See code: [src/commands/cli-config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/cli-config/print.js)_
41
+ _See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/component-library/build.js)_
53
42
 
54
- ## `livingdocs-cli component-library:build`
43
+ ## `livingdocs-cli config:print`
55
44
 
56
- Build a Component Library JSON file
45
+ Print current CLI configuration
57
46
 
58
47
  ```
59
48
  USAGE
60
- $ livingdocs-cli component-library:build
49
+ $ livingdocs-cli config:print
61
50
 
62
51
  OPTIONS
63
- -d, --dist=dist The folder where the output will be written.
64
- -s, --src=src The folder with your .html component templates
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.
65
54
  ```
66
55
 
67
- _See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/component-library/build.js)_
56
+ _See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/config/print.js)_
68
57
 
69
58
  ## `livingdocs-cli design-server:start`
70
59
 
@@ -75,13 +64,14 @@ USAGE
75
64
  $ livingdocs-cli design-server:start
76
65
 
77
66
  OPTIONS
78
- -d, --dist=dist (required) The folder to load designs from.
79
- -p, --port=port [default: 9030] The port of the design-server.
80
- --assets=assets Asset folder to serve static files.
67
+ -d, --dist=dist (required) The folder to load designs from.
68
+ -p, --port=port [default: 9030] The port of the design-server.
69
+ --assets=assets Asset folder to serve static files.
70
+ --basePath=basePath The basePath to set in `assets.basePath`.
81
71
  --verbose
82
72
  ```
83
73
 
84
- _See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/design-server/start.js)_
74
+ _See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/design-server/start.js)_
85
75
 
86
76
  ## `livingdocs-cli help [COMMAND]`
87
77
 
@@ -98,7 +88,7 @@ OPTIONS
98
88
  --all see all commands in CLI
99
89
  ```
100
90
 
101
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.1/src/commands/help.ts)_
91
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_
102
92
 
103
93
  ## `livingdocs-cli project-config:download`
104
94
 
@@ -110,35 +100,37 @@ USAGE
110
100
 
111
101
  OPTIONS
112
102
  -d, --dist=dist The folder where the output will be written.
103
+ -e, --env=env If used configuration options are loaded from .livingdocs-cli file.
113
104
 
114
- -h, --host=host [default: http://localhost:9090] The livingdocs host.
105
+ -h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
115
106
  Can be set by the environment variable 'LI_HOST'.
116
107
 
117
- -t, --token=token (required) The Access Token to your project (needs write permission).
108
+ -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
109
+
110
+ -t, --token=token (required) Access Token for your project (needs `public-api:config:read` permission).
118
111
  Can be set by the environment variable 'LI_TOKEN'.
119
112
 
120
113
  --format=js|js/html|json The format of the files written.
121
114
  ```
122
115
 
123
- _See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/project-config/download.js)_
116
+ _See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/project-config/download.js)_
124
117
 
125
- ## `livingdocs-cli project-config:drafts`
118
+ ## `livingdocs-cli project-config:import-design`
126
119
 
127
- List project configuration drafts
120
+ Import a design into a given project configuration
128
121
 
129
122
  ```
130
123
  USAGE
131
- $ livingdocs-cli project-config:drafts
124
+ $ livingdocs-cli project-config:import-design
132
125
 
133
126
  OPTIONS
134
- -h, --host=host [default: http://localhost:9090] The livingdocs host.
135
- Can be set by the environment variable 'LI_HOST'.
136
-
137
- -t, --token=token (required) The Access Token to your project (needs write permission).
138
- Can be set by the environment variable 'LI_TOKEN'.
127
+ -d, --dist=dist (required) The folder where the output will be written.
128
+ -e, --env=env If used configuration options are loaded from .livingdocs-cli file.
129
+ -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
130
+ -u, --designUri=designUri (required) URL of the design to import
139
131
  ```
140
132
 
141
- _See code: [src/commands/project-config/drafts.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/project-config/drafts.js)_
133
+ _See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/project-config/import-design.js)_
142
134
 
143
135
  ## `livingdocs-cli project-config:plan`
144
136
 
@@ -149,16 +141,19 @@ USAGE
149
141
  $ livingdocs-cli project-config:plan
150
142
 
151
143
  OPTIONS
152
- -d, --dist=dist The folder or filename where to download to.
144
+ -d, --dist=dist (required) The folder or filename to the channelConfig.
145
+ -e, --env=env If used configuration options are loaded from .livingdocs-cli file.
146
+
147
+ -h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
148
+ Can be set by the environment variable 'LI_HOST'.
153
149
 
154
- -h, --host=host [default: http://localhost:9090] The livingdocs host.
155
- Can be set by the environment variable 'LI_HOST'.
150
+ -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
156
151
 
157
- -t, --token=token (required) The Access Token to your project (needs write permission).
158
- Can be set by the environment variable 'LI_TOKEN'.
152
+ -t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
153
+ Can be set by the environment variable 'LI_TOKEN'.
159
154
  ```
160
155
 
161
- _See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/project-config/plan.js)_
156
+ _See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/project-config/plan.js)_
162
157
 
163
158
  ## `livingdocs-cli project-config:publish`
164
159
 
@@ -169,56 +164,17 @@ USAGE
169
164
  $ livingdocs-cli project-config:publish
170
165
 
171
166
  OPTIONS
172
- -d, --dist=dist The folder to publish from.
173
-
174
- -h, --host=host [default: http://localhost:9090] The livingdocs host.
175
- Can be set by the environment variable 'LI_HOST'.
176
-
177
- -t, --token=token (required) The Access Token to your project (needs write permission).
178
- Can be set by the environment variable 'LI_TOKEN'.
179
- ```
180
-
181
- _See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/project-config/publish.js)_
182
-
183
- ## `livingdocs-cli project-config:upload`
184
-
185
- Upload a ChannelConfig into a draft for your project
186
-
187
- ```
188
- USAGE
189
- $ livingdocs-cli project-config:upload
190
-
191
- OPTIONS
192
- -d, --dist=dist The folder or filename where to download to.
167
+ -d, --dist=dist (required) The folder or filename to the channelConfig.
168
+ -e, --env=env If used configuration options are loaded from .livingdocs-cli file.
193
169
 
194
- -h, --host=host [default: http://localhost:9090] The livingdocs host.
170
+ -h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
195
171
  Can be set by the environment variable 'LI_HOST'.
196
172
 
197
- -t, --token=token (required) The Access Token to your project (needs write permission).
198
- Can be set by the environment variable 'LI_TOKEN'.
199
-
200
- --draftName=draftName (required) The name of the draft the config will be saved under.
201
- ```
202
-
203
- _See code: [src/commands/project-config/upload.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/project-config/upload.js)_
173
+ -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
204
174
 
205
- ## `livingdocs-cli project-config:upload_assets`
206
-
207
- Upload assets to your project
208
-
209
- ```
210
- USAGE
211
- $ livingdocs-cli project-config:upload_assets
212
-
213
- OPTIONS
214
- -a, --assets=assets The folder where you asset files are located.
215
-
216
- -h, --host=host [default: http://localhost:9090] The livingdocs host.
217
- Can be set by the environment variable 'LI_HOST'.
218
-
219
- -t, --token=token (required) The Access Token to your project (needs write permission).
220
- Can be set by the environment variable 'LI_TOKEN'.
175
+ -t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
176
+ Can be set by the environment variable 'LI_TOKEN'.
221
177
  ```
222
178
 
223
- _See code: [src/commands/project-config/upload_assets.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v0.0.0/src/commands/project-config/upload_assets.js)_
179
+ _See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/project-config/publish.js)_
224
180
  <!-- commandsstop -->
@@ -0,0 +1 @@
1
+ {"version":"2.1.2","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 channelConfig.","required":true}},"args":[]},"project-config:publish":{"id":"project-config:publish","description":"Publish a ChannelConfig 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 channelConfig.","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.0",
4
+ "version": "2.1.2",
5
5
  "author": "Livingdocs AG",
6
6
  "repository": "livingdocsIO/livingdocs-cli",
7
7
  "homepage": "https://github.com/livingdocsIO/livingdocs-cli",
@@ -15,8 +15,7 @@
15
15
  "test": "mocha --forbid-only \"test/**/*.test.js\"",
16
16
  "test:coverage": "nyc mocha --forbid-only \"test/**/*.test.js\"",
17
17
  "posttest": "eslint .",
18
- "version": "oclif-dev readme && git add README.md",
19
- "postversion": "/release/node_modules/.bin/set-ci"
18
+ "version": "oclif-dev readme && git add README.md"
20
19
  },
21
20
  "dependencies": {
22
21
  "@oclif/command": "^1.5.19",
@@ -24,20 +23,21 @@
24
23
  "@oclif/plugin-help": "^2.2.1",
25
24
  "@oclif/plugin-not-found": "^1.2.3",
26
25
  "@oclif/plugin-warn-if-update-available": "^1.7.0",
27
- "axios": "^0.19.0",
26
+ "axios": "^0.21.2",
28
27
  "chalk": "^2.4.2",
29
28
  "cheerio": "^1.0.0-rc.3",
30
29
  "dedent": "^0.7.0",
31
- "fastify": "^2.10.0",
32
- "fastify-cors": "^2.1.3",
33
- "fastify-static": "^2.5.0",
34
- "fs-extra": "^8.1.0",
30
+ "fastify": "^3.25.3",
31
+ "fastify-cors": "^6.0.2",
32
+ "fastify-static": "^4.5.0",
33
+ "fs-extra": "^10.0.0",
35
34
  "globby": "^10.0.1",
36
35
  "html-minifier": "^4.0.0",
37
36
  "inquirer": "^7.0.0",
38
37
  "javascript-stringify": "^2.0.0",
39
38
  "js-beautify": "^1.10.2",
40
- "lodash": "^4.17.15",
39
+ "js-yaml": "^4.1.0",
40
+ "lodash": "^4.17.21",
41
41
  "nanoid": "^2.1.0",
42
42
  "npmlog": "^4.1.2",
43
43
  "p-queue": "^6.1.1",
@@ -49,8 +49,8 @@
49
49
  "@oclif/dev-cli": "^1.22.2",
50
50
  "@oclif/test": "^1.2.5",
51
51
  "chai": "^4.2.0",
52
- "eslint": "^8.0.1",
53
- "eslint-config-oclif": "^3.1.0",
52
+ "eslint": "^8.5.0",
53
+ "eslint-config-oclif": "^4.0.0",
54
54
  "mocha": "^6.2.0",
55
55
  "nock": "^11.3.3",
56
56
  "nyc": "^14.1.1"
@@ -85,11 +85,11 @@
85
85
  "isCi": true,
86
86
  "name": "Drone",
87
87
  "service": "drone",
88
- "commit": "c336b1974fd30ebee4c7bfea493be9281b4bffad",
89
- "build": "72",
88
+ "commit": "5a1d56a52c578fc950d7bad0c488f627c92629a3",
89
+ "build": "87",
90
90
  "branch": "master",
91
91
  "isPr": false,
92
92
  "slug": "livingdocsIO/livingdocs-cli",
93
- "date": "2021-10-19T14:13:12.332Z"
93
+ "date": "2022-01-03T13:58:43.325Z"
94
94
  }
95
95
  }
@@ -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
@@ -85,9 +85,20 @@ class DesignServerCommand extends Command {
85
85
  return
86
86
  }
87
87
 
88
- designConfig.assets = designConfig.assets || {}
89
- const defaultBasePath = `${host}/designs/${designName}/${version}`
90
- designConfig.assets.basePath = basePath || defaultBasePath
88
+ const designBasePath = basePath || `${host}/designs/${designName}/${version}`
89
+ if (
90
+ typeof designConfig.assets === 'object' &&
91
+ !designConfig.assets.basePath
92
+ ) {
93
+ designConfig.assets.basePath = designBasePath
94
+ }
95
+
96
+ if (
97
+ typeof designConfig.designSettings?.assets === 'object' &&
98
+ !designConfig.designSettings.assets.basePath
99
+ ) {
100
+ designConfig.designSettings.assets.basePath = designBasePath
101
+ }
91
102
 
92
103
  reply.send(designConfig)
93
104
  })
@@ -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},
@@ -24,7 +24,7 @@ class PublishCommand extends Command {
24
24
  }
25
25
 
26
26
  async run () {
27
- const {token, host, dist, env} = this.parse(PublishCommand).flags
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,20 @@ class PublishCommand extends Command {
33
33
  throw err
34
34
  })
35
35
 
36
- // safety check for production environment
37
- if (env === 'production') {
38
- const answers = await inquirer.prompt([{
39
- name: 'continue',
40
- type: 'confirm',
41
- default: false,
42
- message: `Are you sure to publish to production?`
43
- }])
36
+ await liApi.plan({host, token, channelConfig: config})
37
+ .then((result) => {
38
+ resultReporter(result, this.log)
39
+ })
40
+ .catch(reportError)
44
41
 
45
- if (!answers.continue) return
46
- }
42
+ const answers = await inquirer.prompt([{
43
+ name: 'continue',
44
+ type: 'confirm',
45
+ default: false,
46
+ message: `Are you sure to publish to production?`
47
+ }])
48
+
49
+ if (!answers.continue) return
47
50
 
48
51
  await liApi.publish({host, token, channelConfig: config})
49
52
  .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,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
- const config = fs.readJsonSync(filepath)
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