livingdocs-cli 2.4.1 → 2.5.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 CHANGED
@@ -28,6 +28,8 @@ livingdocs-cli --help
28
28
  * [`livingdocs-cli project-config:import-design`](#livingdocs-cli-project-configimport-design)
29
29
  * [`livingdocs-cli project-config:plan`](#livingdocs-cli-project-configplan)
30
30
  * [`livingdocs-cli project-config:publish`](#livingdocs-cli-project-configpublish)
31
+ * [`livingdocs-cli project-config:publish-design`](#livingdocs-cli-project-configpublish-design)
32
+ * [`livingdocs-cli project-config:upload-assets`](#livingdocs-cli-project-configupload-assets)
31
33
 
32
34
  ## `livingdocs-cli component-library:build`
33
35
 
@@ -42,7 +44,7 @@ OPTIONS
42
44
  -s, --src=src The folder with your .html component templates
43
45
  ```
44
46
 
45
- _See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.1/src/commands/component-library/build.js)_
47
+ _See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/component-library/build.js)_
46
48
 
47
49
  ## `livingdocs-cli config:print`
48
50
 
@@ -57,7 +59,7 @@ OPTIONS
57
59
  -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
58
60
  ```
59
61
 
60
- _See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.1/src/commands/config/print.js)_
62
+ _See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/config/print.js)_
61
63
 
62
64
  ## `livingdocs-cli design-server:start`
63
65
 
@@ -76,7 +78,7 @@ OPTIONS
76
78
  --verbose
77
79
  ```
78
80
 
79
- _See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.1/src/commands/design-server/start.js)_
81
+ _See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/design-server/start.js)_
80
82
 
81
83
  ## `livingdocs-cli help [COMMAND]`
82
84
 
@@ -118,7 +120,7 @@ OPTIONS
118
120
  --format=js|js/html|json The format of the files written.
119
121
  ```
120
122
 
121
- _See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.1/src/commands/project-config/download.js)_
123
+ _See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/project-config/download.js)_
122
124
 
123
125
  ## `livingdocs-cli project-config:import-design`
124
126
 
@@ -135,7 +137,7 @@ OPTIONS
135
137
  -u, --designUri=designUri (required) URL of the design to import
136
138
  ```
137
139
 
138
- _See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.1/src/commands/project-config/import-design.js)_
140
+ _See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/project-config/import-design.js)_
139
141
 
140
142
  ## `livingdocs-cli project-config:plan`
141
143
 
@@ -160,7 +162,7 @@ OPTIONS
160
162
  Can be set by the environment variable 'LI_TOKEN'.
161
163
  ```
162
164
 
163
- _See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.1/src/commands/project-config/plan.js)_
165
+ _See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/project-config/plan.js)_
164
166
 
165
167
  ## `livingdocs-cli project-config:publish`
166
168
 
@@ -187,5 +189,50 @@ OPTIONS
187
189
  -y, --yes Confirm
188
190
  ```
189
191
 
190
- _See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.1/src/commands/project-config/publish.js)_
192
+ _See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/project-config/publish.js)_
193
+
194
+ ## `livingdocs-cli project-config:publish-design`
195
+
196
+ Publish Design to DesignServer
197
+
198
+ ```
199
+ USAGE
200
+ $ livingdocs-cli project-config:publish-design
201
+
202
+ OPTIONS
203
+ -d, --dist=dist (required) The folder to the design.
204
+ -f, --forceUpdate The design name of the assets to upload
205
+
206
+ -h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
207
+ Can be set by the environment variable 'LI_HOST'.
208
+
209
+ -p, --password=password password for login
210
+
211
+ -u, --username=username username for login
212
+ ```
213
+
214
+ _See code: [src/commands/project-config/publish-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/project-config/publish-design.js)_
215
+
216
+ ## `livingdocs-cli project-config:upload-assets`
217
+
218
+ Upload assets to your design
219
+
220
+ ```
221
+ USAGE
222
+ $ livingdocs-cli project-config:upload-assets
223
+
224
+ OPTIONS
225
+ -a, --assets=assets The folder where you asset files are located.
226
+ -d, --designName=designName The design name of the assets to upload
227
+ -d, --designVersion=designVersion The design version of the assets to upload
228
+
229
+ -h, --host=host [default: http://localhost:9090] The livingdocs host.
230
+ Can be set by the environment variable 'LI_HOST'.
231
+
232
+ -t, --token=token (required) Access Token for your project (needs `public-api:config:write`
233
+ permission).
234
+ Can be set by the environment variable 'LI_TOKEN'.
235
+ ```
236
+
237
+ _See code: [src/commands/project-config/upload-assets.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.5.0/src/commands/project-config/upload-assets.js)_
191
238
  <!-- commandsstop -->
@@ -1 +1 @@
1
- {"version":"2.4.1","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},"address":{"name":"address","type":"option","char":"a","description":"The address of the design-server."},"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."},"yes":{"name":"yes","type":"boolean","char":"y","description":"Confirm","allowNo":false},"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":[]}}}
1
+ {"version":"2.5.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},"address":{"name":"address","type":"option","char":"a","description":"The address of the design-server."},"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-design":{"id":"project-config:publish-design","description":"Publish Design to DesignServer","pluginName":"livingdocs-cli","pluginType":"core","aliases":[],"flags":{"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"},"username":{"name":"username","type":"option","char":"us","description":"username for login"},"password":{"name":"password","type":"option","char":"pw","description":"password for login"},"dist":{"name":"dist","type":"option","char":"d","description":"The folder to the design.","required":true},"forceUpdate":{"name":"forceUpdate","type":"boolean","char":"f","description":"The design name of the assets to upload","allowNo":false}},"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."},"yes":{"name":"yes","type":"boolean","char":"y","description":"Confirm","allowNo":false},"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-assets":{"id":"project-config:upload-assets","description":"Upload assets to your design","pluginName":"livingdocs-cli","pluginType":"core","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."},"designName":{"name":"designName","type":"option","char":"dn","description":"The design name of the assets to upload"},"designVersion":{"name":"designVersion","type":"option","char":"dv","description":"The design version of the assets to upload"}},"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":[]}}}
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.1",
4
+ "version": "2.5.0",
5
5
  "author": "Livingdocs AG",
6
6
  "repository": "livingdocsIO/livingdocs-cli",
7
7
  "homepage": "https://github.com/livingdocsIO/livingdocs-cli",
@@ -18,21 +18,23 @@
18
18
  "version": "oclif-dev readme && git add README.md"
19
19
  },
20
20
  "dependencies": {
21
- "@oclif/command": "^1.5.19",
22
- "@oclif/config": "^1.13.3",
23
- "@oclif/plugin-help": "^2.2.1",
24
- "@oclif/plugin-not-found": "^1.2.3",
21
+ "@oclif/command": "^1.8.0",
22
+ "@oclif/config": "^1.17.0",
23
+ "@oclif/plugin-help": "^2.2.3",
24
+ "@oclif/plugin-not-found": "^1.2.4",
25
25
  "@oclif/plugin-warn-if-update-available": "^1.7.0",
26
- "axios": "^0.21.2",
26
+ "axios": "^0.23.0",
27
27
  "chalk": "^2.4.2",
28
28
  "cheerio": "^1.0.0-rc.3",
29
+ "cookie": "^0.4.1",
29
30
  "dedent": "^0.7.0",
30
- "diff": "^5.0.0",
31
+ "diff": "^5.1.0",
31
32
  "fastify": "^3.25.3",
32
33
  "fastify-cors": "^6.0.2",
33
34
  "fastify-static": "^4.5.0",
35
+ "form-data": "^4.0.0",
34
36
  "fs-extra": "^10.0.0",
35
- "globby": "^10.0.1",
37
+ "globby": "^10.0.2",
36
38
  "html-minifier": "^4.0.0",
37
39
  "inquirer": "^7.0.0",
38
40
  "javascript-stringify": "^2.0.0",
@@ -41,19 +43,20 @@
41
43
  "lodash": "^4.17.21",
42
44
  "nanoid": "^2.1.0",
43
45
  "npmlog": "^4.1.2",
44
- "p-queue": "^6.1.1",
45
- "pino-pretty": "^3.2.2",
46
- "prettify-html": "0.0.2",
46
+ "p-queue": "^6.6.2",
47
+ "pino-pretty": "^3.6.1",
48
+ "prettify-html": "^0.0.2",
49
+ "tough-cookie": "^4.0.0",
47
50
  "warning-header-parser": "^2.0.0"
48
51
  },
49
52
  "devDependencies": {
50
- "@oclif/dev-cli": "^1.22.2",
51
- "@oclif/test": "^1.2.5",
52
- "chai": "^4.2.0",
53
+ "@oclif/dev-cli": "^1.26.0",
54
+ "@oclif/test": "^1.2.8",
55
+ "chai": "^4.3.4",
53
56
  "eslint": "^8.5.0",
54
57
  "eslint-config-oclif": "^4.0.0",
55
- "mocha": "^6.2.0",
56
- "nock": "^11.3.3",
58
+ "mocha": "^6.2.3",
59
+ "nock": "^11.9.1",
57
60
  "nyc": "^14.1.1"
58
61
  },
59
62
  "engines": {
@@ -86,11 +89,11 @@
86
89
  "isCi": true,
87
90
  "name": "Drone",
88
91
  "service": "drone",
89
- "commit": "7d697c6169bf306d31b76f4fe85f0e4ce94ac805",
90
- "build": "107",
92
+ "commit": "afcaa6816e1bdf0ab557ac03e2fc656556dd1ab8",
93
+ "build": "122",
91
94
  "branch": "master",
92
95
  "isPr": false,
93
96
  "slug": "livingdocsIO/livingdocs-cli",
94
- "date": "2022-03-25T12:54:58.687Z"
97
+ "date": "2023-07-20T06:53:01.064Z"
95
98
  }
96
99
  }
@@ -0,0 +1,59 @@
1
+ const {Command, flags} = require('@oclif/command')
2
+ const {cli} = require('cli-ux')
3
+ const {buildDesign} = require('../../lib/build_design')
4
+ const sharedFlags = require('../../lib/cli/shared_flags')
5
+ const {uploadAssets} = require('../../lib/upload_assets')
6
+ const liApi = require('../../lib/api/livingdocs_api')
7
+ const chalk = require('chalk')
8
+
9
+ class PublishDesignCommand extends Command {
10
+ static description = `Publish Design to DesignServer`
11
+ static flags = {
12
+ host: {...sharedFlags.host, required: true},
13
+ username: sharedFlags.username,
14
+ password: sharedFlags.password,
15
+ dist: {
16
+ ...sharedFlags.dist,
17
+ required: true,
18
+ description: 'The folder to the design.'
19
+ },
20
+ forceUpdate: flags.boolean({
21
+ char: 'f',
22
+ description: 'The design name of the assets to upload',
23
+ default: false
24
+ })
25
+ }
26
+
27
+ async run () {
28
+ const {host, dist, username, password, forceUpdate} = this.parse(PublishDesignCommand).flags
29
+ let inputUser
30
+ if (!username) {
31
+ inputUser = await cli.prompt('What is your username?')
32
+ }
33
+
34
+ // mask input after enter is pressed
35
+ let inputPassword
36
+ if (!password) {
37
+ inputPassword = await cli.prompt('What is your password?', {type: 'hide'})
38
+ }
39
+
40
+ const {token, axiosInstance} =
41
+ await liApi.authenticate({
42
+ username: username || inputUser, password: password || inputPassword, host})
43
+ const design = await buildDesign({designFolder: dist})
44
+
45
+ if (design.name === undefined) {
46
+ this.log(chalk.red('design.name is not set'))
47
+ return
48
+ }
49
+ if (design.version === undefined) {
50
+ this.log(chalk.red('design.version is not set'))
51
+ return
52
+ }
53
+
54
+ await liApi.publishDesign({design, host, token, forceUpdate})
55
+ await uploadAssets({folderPath: dist, host, token, design, axiosInstance})
56
+ }
57
+ }
58
+
59
+ module.exports = PublishDesignCommand
@@ -0,0 +1,67 @@
1
+ const url = require('url')
2
+ const {Command, flags} = require('@oclif/command')
3
+ const {cli} = require('cli-ux')
4
+ const liApi = require('../../lib/api/livingdocs_api')
5
+ const sharedFlags = require('../../lib/cli/shared_flags')
6
+ const {uploadAssets} = require('../../lib/upload_assets')
7
+
8
+
9
+ class UploadAssetsCommand extends Command {
10
+ static description = `Upload assets to your design`
11
+ static flags = {
12
+ token: {...sharedFlags.configWriteToken, required: true},
13
+ host: sharedFlags.host,
14
+ assets: flags.string({
15
+ char: 'a',
16
+ description: 'The folder where you asset files are located.'
17
+ }),
18
+ designName: flags.string({
19
+ char: 'dn',
20
+ description: 'The design name of the assets to upload'
21
+ }),
22
+ designVersion: flags.string({
23
+ char: 'dv',
24
+ description: 'The design version of the assets to upload'
25
+ })
26
+ }
27
+
28
+ async run () {
29
+ const {host, assets, username, designName, designVersion} =
30
+ this.parse(UploadAssetsCommand).flags
31
+
32
+ const origin = this.parseUrl(host).origin
33
+ if (!origin) return
34
+ if (!assets) {
35
+ this.error(`missing param assets`)
36
+ }
37
+
38
+ let inputUser
39
+ if (!username) {
40
+ inputUser = await cli.prompt('What is your username?')
41
+ }
42
+
43
+ // mask input after enter is pressed
44
+ const password = await cli.prompt('What is your password?', {type: 'hide'})
45
+ const {token, axiosInstance} =
46
+ await liApi.authenticate({username: username || inputUser, password, host})
47
+ await uploadAssets({
48
+ folderPath: assets,
49
+ host: origin,
50
+ token,
51
+ design: {name: designName, version: designVersion},
52
+ axiosInstance
53
+ })
54
+ }
55
+
56
+ parseUrl (host) {
57
+ try {
58
+ return new url.URL(host)
59
+ } catch (err) {
60
+ this.error(`Error parsing host: '${err}'`)
61
+ return {}
62
+ }
63
+ }
64
+
65
+ }
66
+
67
+ module.exports = UploadAssetsCommand
@@ -1,4 +1,11 @@
1
1
  const _axios = require('axios')
2
+ const {CookieJar} = require('tough-cookie')
3
+ const jar = new CookieJar()
4
+ // use the jar cookie for axios to support the login of a user
5
+ const axiosJarInstance = _axios.create({jar})
6
+ const {requestInterceptor, responseInterceptor} = require('../utils/request_interceptor')
7
+ axiosJarInstance.interceptors.request.use(requestInterceptor)
8
+ axiosJarInstance.interceptors.response.use(responseInterceptor)
2
9
 
3
10
  // down- and upload to the ☁️
4
11
  module.exports = {
@@ -50,6 +57,33 @@ module.exports = {
50
57
  .then((response) => {
51
58
  return response.data
52
59
  })
60
+ },
61
+
62
+ // At the moment the user cookie is needed. So the authenticate should be called first.
63
+ async publishDesign ({token, host, design, forceUpdate}) {
64
+ const forceUpdateValue = `?force=${forceUpdate ? 'true' : 'false'}`
65
+ const designUrl = `${host}/designs/${design.name}/${design.version}${forceUpdateValue}`
66
+ const response = await axiosJarInstance({
67
+ withCredentials: true,
68
+ method: 'put',
69
+ url: designUrl,
70
+ headers: {
71
+ Authorization: `Bearer ${token}`
72
+ },
73
+ data: design
74
+ })
75
+
76
+ return response
77
+ },
78
+
79
+ async authenticate ({host, username, password}) {
80
+ const res = await axiosJarInstance({
81
+ withCredentials: true,
82
+ method: 'post',
83
+ url: `${host}/auth/local/login`,
84
+ data: {username, password}
85
+ })
86
+ return {token: res.data.access_token, axiosInstance: axiosJarInstance}
53
87
  }
54
88
  }
55
89
 
@@ -0,0 +1,16 @@
1
+ const parseComponents = require('./parsing/parse_components')
2
+ const path = require('path')
3
+ const fs = require('fs-extra')
4
+
5
+ module.exports = {
6
+ async buildDesign ({designFolder}) {
7
+ const {components} =
8
+ await parseComponents({src: designFolder, templatesDirectory: 'components'})
9
+
10
+ const configFilePath = path.join(designFolder, 'config.json')
11
+ const configFile = await fs.readFile(configFilePath, 'utf8')
12
+ const configFileJson = JSON.parse(configFile)
13
+ configFileJson.components = components
14
+ return configFileJson
15
+ }
16
+ }
@@ -95,6 +95,30 @@ module.exports = {
95
95
  return process.env.LI_DESIGN_URI
96
96
  }
97
97
  }
98
+ }),
99
+ username: flags.string({
100
+ char: 'us',
101
+ description: 'username for login',
102
+ default ({options, flags: givenFlags}) {
103
+ const sessionConfig = getCliConfig(givenFlags)
104
+ if (sessionConfig) {
105
+ return sessionConfig.username
106
+ } else {
107
+ return process.env.LI_USERNAME
108
+ }
109
+ }
110
+ }),
111
+ password: flags.string({
112
+ char: 'pw',
113
+ description: 'password for login',
114
+ default ({options, flags: givenFlags}) {
115
+ const sessionConfig = getCliConfig(givenFlags)
116
+ if (sessionConfig) {
117
+ return sessionConfig.password
118
+ } else {
119
+ return process.env.LI_PASSWORD
120
+ }
121
+ }
98
122
  })
99
123
  }
100
124
 
@@ -3,14 +3,14 @@ const path = require('path')
3
3
  const log = require('npmlog')
4
4
  const {promisify} = require('util')
5
5
  const _each = require('lodash/each')
6
- const axios = require('axios')
7
6
  const {default: PromiseQueue} = require('p-queue')
8
-
7
+ const Glob = require('glob')
9
8
  const {concat} = require('./utils')
9
+ const FormData = require('form-data')
10
10
 
11
11
  module.exports = {
12
- async uploadAssets ({folderPath, host, token}) {
13
- return await uploadAssets({folderPath, host, token})
12
+ async uploadAssets ({folderPath, host, token, design, axiosInstance}) {
13
+ return await uploadAssets({folderPath, host, token, design, axiosInstance})
14
14
  }
15
15
  }
16
16
 
@@ -24,7 +24,7 @@ function allFilesCb (folderPath, callback) {
24
24
 
25
25
  const allFiles = promisify(allFilesCb)
26
26
 
27
- async function uploadAssets ({folderPath, host, token}) {
27
+ async function uploadAssets ({folderPath, host, token, design, axiosInstance}) {
28
28
  const files = await allFiles(folderPath)
29
29
 
30
30
  if (!files.length) {
@@ -38,7 +38,7 @@ async function uploadAssets ({folderPath, host, token}) {
38
38
  _each(assets, (relativePath) => {
39
39
  queue.add(() => {
40
40
  const filePath = path.join(folderPath, relativePath)
41
- return uploadAsset({relativePath, filePath, host, token})
41
+ return uploadAsset({relativePath, filePath, host, token, design, axiosInstance})
42
42
  }).then(() => {
43
43
  log.info(`Asset Uploaded (${relativePath}).`)
44
44
  }).catch((err) => {
@@ -53,19 +53,23 @@ async function uploadAssets ({folderPath, host, token}) {
53
53
  })
54
54
  }
55
55
 
56
- async function uploadAsset ({relativePath, filePath, host, token}) {
57
- const assetApiPath = '/api/v2/content-configuration/cli-draft/assets'
58
-
59
- const response = await axios({
56
+ async function uploadAsset ({relativePath, filePath, host, token, design, axiosInstance}) {
57
+ const assetApiPath = `/designs/${design.name}/${design.version}/assets`
58
+ const url = `${concat(host, assetApiPath)}`
59
+ const form = new FormData()
60
+ const stream = fs.createReadStream(filePath)
61
+ form.append('path', relativePath)
62
+ form.append('file', stream)
63
+ const headers = {
64
+ Authorization: `Bearer ${token}`,
65
+ ...form.getHeaders()
66
+ }
67
+ const response = await axiosInstance({
60
68
  method: 'post',
61
- url: `${concat(host, assetApiPath)}`,
62
- headers: {
63
- Authorization: `Bearer ${token}`
64
- },
65
- formData: {
66
- path: relativePath,
67
- file: fs.createReadStream(filePath)
68
- }
69
+ url: url,
70
+ data: form,
71
+ headers: headers,
72
+ withCredentials: true
69
73
  })
70
74
 
71
75
  return response
@@ -78,11 +82,6 @@ function formatError (err) {
78
82
  } else if (status === 403) {
79
83
  return `AccessToken requires higher privileges`
80
84
  } else {
81
- // if (status) {
82
- // const content = JSON.parse(err.response.body)
83
- // const errorDetails = content.error_details
84
- // }
85
-
86
85
  return err.toString()
87
86
  }
88
87
  }
@@ -0,0 +1,24 @@
1
+ const cookie = require('cookie')
2
+ module.exports = {
3
+ async requestInterceptor (config) {
4
+ const cookies = await config.jar.getCookies(config.url)
5
+ const cookiesEntries = cookies.map((c) => [c.key, c.value])
6
+
7
+ const cookieHeader = Array.from(new Map(cookiesEntries))
8
+ .map(([key, value]) => cookie.serialize(key, value))
9
+ .join('; ')
10
+ config.headers.common['cookie'] = cookieHeader
11
+ return config
12
+ },
13
+
14
+ async responseInterceptor (response) {
15
+ const setCookieHeaders = response.headers['set-cookie']
16
+ if (setCookieHeaders !== undefined) {
17
+ for (const setCookie of setCookieHeaders) {
18
+ await response.config.jar.setCookie(setCookie, response.config.url)
19
+ }
20
+ }
21
+
22
+ return response
23
+ }
24
+ }
@@ -1,47 +0,0 @@
1
- // WIP
2
- const url = require('url')
3
- const {Command, flags} = require('@oclif/command')
4
-
5
- const sharedFlags = require('../../lib/cli/shared_flags')
6
- const liApi = require('../../lib/api/livingdocs_api')
7
-
8
- class UploadAssetsCommand extends Command {
9
- static hidden = true
10
- static description = `Upload assets to your project`
11
- static flags = {
12
- token: {...sharedFlags.configWriteToken, required: true},
13
- host: sharedFlags.host,
14
- assets: flags.string({
15
- char: 'a',
16
- description: 'The folder where you asset files are located.'
17
- })
18
- }
19
-
20
- async run () {
21
- const {token, host, assets} = this.parse(UploadAssetsCommand).flags
22
-
23
- const origin = this.parseUrl(host).origin
24
- if (!origin) return
25
- if (!assets) {
26
- this.error(`missing param assets`)
27
- }
28
-
29
- await liApi.uploadAssets({
30
- folderPath: assets,
31
- host: origin,
32
- token
33
- })
34
- }
35
-
36
- parseUrl (host) {
37
- try {
38
- return new url.URL(host)
39
- } catch (err) {
40
- this.error(`Error parsing host: '${err}'`)
41
- return {}
42
- }
43
- }
44
-
45
- }
46
-
47
- module.exports = UploadAssetsCommand