livingdocs-cli 2.1.2 → 2.4.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
@@ -9,11 +9,15 @@ Livingdocs Command Line Interface
9
9
 
10
10
  ## Setup
11
11
 
12
- ```sh-session
13
- $ npm install -g livingdocs-cli
14
- $ livingdocs-cli --help
12
+ ```bash
13
+ npm install -g livingdocs-cli
14
+ livingdocs-cli --help
15
15
  ```
16
16
 
17
+ ## Documentation
18
+
19
+ [Livingdocs CLI documentation](https://docs.livingdocs.io/reference-docs/cli)
20
+
17
21
  # Commands Reference
18
22
  <!-- commands -->
19
23
  * [`livingdocs-cli component-library:build`](#livingdocs-cli-component-librarybuild)
@@ -38,7 +42,7 @@ OPTIONS
38
42
  -s, --src=src The folder with your .html component templates
39
43
  ```
40
44
 
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)_
45
+ _See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.0/src/commands/component-library/build.js)_
42
46
 
43
47
  ## `livingdocs-cli config:print`
44
48
 
@@ -53,7 +57,7 @@ OPTIONS
53
57
  -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
54
58
  ```
55
59
 
56
- _See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.1.2/src/commands/config/print.js)_
60
+ _See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.0/src/commands/config/print.js)_
57
61
 
58
62
  ## `livingdocs-cli design-server:start`
59
63
 
@@ -64,14 +68,15 @@ USAGE
64
68
  $ livingdocs-cli design-server:start
65
69
 
66
70
  OPTIONS
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`.
71
+ -a, --address=address The address of the design-server.
72
+ -d, --dist=dist (required) The folder to load designs from.
73
+ -p, --port=port [default: 9030] The port of the design-server.
74
+ --assets=assets Asset folder to serve static files.
75
+ --basePath=basePath The basePath to set in `assets.basePath`.
71
76
  --verbose
72
77
  ```
73
78
 
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)_
79
+ _See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.0/src/commands/design-server/start.js)_
75
80
 
76
81
  ## `livingdocs-cli help [COMMAND]`
77
82
 
@@ -113,7 +118,7 @@ OPTIONS
113
118
  --format=js|js/html|json The format of the files written.
114
119
  ```
115
120
 
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)_
121
+ _See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.0/src/commands/project-config/download.js)_
117
122
 
118
123
  ## `livingdocs-cli project-config:import-design`
119
124
 
@@ -130,7 +135,7 @@ OPTIONS
130
135
  -u, --designUri=designUri (required) URL of the design to import
131
136
  ```
132
137
 
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)_
138
+ _See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.0/src/commands/project-config/import-design.js)_
134
139
 
135
140
  ## `livingdocs-cli project-config:plan`
136
141
 
@@ -141,7 +146,7 @@ USAGE
141
146
  $ livingdocs-cli project-config:plan
142
147
 
143
148
  OPTIONS
144
- -d, --dist=dist (required) The folder or filename to the channelConfig.
149
+ -d, --dist=dist The folder where the output will be written.
145
150
  -e, --env=env If used configuration options are loaded from .livingdocs-cli file.
146
151
 
147
152
  -h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
@@ -149,22 +154,24 @@ OPTIONS
149
154
 
150
155
  -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
151
156
 
157
+ -s, --source=source The folder or filename to the project config.
158
+
152
159
  -t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
153
160
  Can be set by the environment variable 'LI_TOKEN'.
154
161
  ```
155
162
 
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)_
163
+ _See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.0/src/commands/project-config/plan.js)_
157
164
 
158
165
  ## `livingdocs-cli project-config:publish`
159
166
 
160
- Publish a ChannelConfig to your project
167
+ Publish a project configuration to your project
161
168
 
162
169
  ```
163
170
  USAGE
164
171
  $ livingdocs-cli project-config:publish
165
172
 
166
173
  OPTIONS
167
- -d, --dist=dist (required) The folder or filename to the channelConfig.
174
+ -d, --dist=dist The folder where the output will be written.
168
175
  -e, --env=env If used configuration options are loaded from .livingdocs-cli file.
169
176
 
170
177
  -h, --host=host (required) [default: http://localhost:9090] The livingdocs host.
@@ -172,9 +179,11 @@ OPTIONS
172
179
 
173
180
  -p, --project=project If used configuration options are loaded from .livingdocs-cli file.
174
181
 
182
+ -s, --source=source The folder or filename to the project config.
183
+
175
184
  -t, --token=token (required) Access Token for your project (needs `public-api:config:write` permission).
176
185
  Can be set by the environment variable 'LI_TOKEN'.
177
186
  ```
178
187
 
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)_
188
+ _See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v2.4.0/src/commands/project-config/publish.js)_
180
189
  <!-- commandsstop -->
@@ -1 +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":[]}}}
1
+ {"version":"2.4.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":{"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.1.2",
4
+ "version": "2.4.0",
5
5
  "author": "Livingdocs AG",
6
6
  "repository": "livingdocsIO/livingdocs-cli",
7
7
  "homepage": "https://github.com/livingdocsIO/livingdocs-cli",
@@ -27,6 +27,7 @@
27
27
  "chalk": "^2.4.2",
28
28
  "cheerio": "^1.0.0-rc.3",
29
29
  "dedent": "^0.7.0",
30
+ "diff": "^5.0.0",
30
31
  "fastify": "^3.25.3",
31
32
  "fastify-cors": "^6.0.2",
32
33
  "fastify-static": "^4.5.0",
@@ -85,11 +86,11 @@
85
86
  "isCi": true,
86
87
  "name": "Drone",
87
88
  "service": "drone",
88
- "commit": "5a1d56a52c578fc950d7bad0c488f627c92629a3",
89
- "build": "87",
89
+ "commit": "073bb133c9abdc5cca5ab3f6e12648a010f595dd",
90
+ "build": "103",
90
91
  "branch": "master",
91
92
  "isPr": false,
92
93
  "slug": "livingdocsIO/livingdocs-cli",
93
- "date": "2022-01-03T13:58:43.325Z"
94
+ "date": "2022-02-11T21:50:28.394Z"
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: 'not set'
56
+ source: undefined
55
57
  }
56
58
  }
57
59
  }
@@ -13,6 +13,10 @@ class DesignServerCommand extends Command {
13
13
  description: 'The port of the design-server.',
14
14
  default: 9030
15
15
  }),
16
+ address: flags.string({
17
+ char: 'a',
18
+ description: 'The address of the design-server.'
19
+ }),
16
20
  dist: flags.string({
17
21
  char: 'd',
18
22
  description: 'The folder to load designs from.',
@@ -29,7 +33,8 @@ class DesignServerCommand extends Command {
29
33
 
30
34
  async run () {
31
35
  let host
32
- const {port, verbose, dist, assets, basePath} = this.parse(DesignServerCommand).flags
36
+ const {port, address: customAddress, verbose, dist, assets, basePath} =
37
+ this.parse(DesignServerCommand).flags
33
38
 
34
39
  const fastify = require('fastify')({
35
40
  logger: verbose ? {prettyPrint: true} : undefined
@@ -108,7 +113,7 @@ class DesignServerCommand extends Command {
108
113
  reply.sendFile(filePath)
109
114
  })
110
115
 
111
- fastify.listen(port, (err, address) => {
116
+ fastify.listen(port, customAddress, (err, address) => {
112
117
  if (err) throw err
113
118
  host = address
114
119
  if (!verbose) this.log(chalk.green(`server listening at ${address}`))
@@ -3,7 +3,7 @@ const {Command} = require('@oclif/command')
3
3
  const sharedFlags = require('../../lib/cli/shared_flags')
4
4
  const liApi = require('../../lib/api/livingdocs_api')
5
5
  const errorReporter = require('../../lib/api/error_reporter')
6
- const resultReporter = require('../../lib/api/channel_config_result_reporter')
6
+ const resultReporter = require('../../lib/api/project_config_result_reporter')
7
7
  const readChannelConfig = require('../../lib/read_channel_config')
8
8
 
9
9
  class PlanCommand extends Command {
@@ -13,22 +13,21 @@ class PlanCommand extends Command {
13
13
  env: sharedFlags.env,
14
14
  token: {...sharedFlags.configWriteToken, required: true},
15
15
  host: {...sharedFlags.host, required: true},
16
- dist: {
17
- ...sharedFlags.dist,
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
- const config = await readChannelConfig({source: dist})
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) => {
31
- resultReporter(result, this.log)
30
+ resultReporter({result, log: this.log})
32
31
  })
33
32
  .catch(reportError)
34
33
  }
@@ -5,54 +5,61 @@ const inquirer = require('inquirer')
5
5
  const sharedFlags = require('../../lib/cli/shared_flags')
6
6
  const liApi = require('../../lib/api/livingdocs_api')
7
7
  const errorReporter = require('../../lib/api/error_reporter')
8
- const resultReporter = require('../../lib/api/channel_config_result_reporter')
8
+ const resultReporter = require('../../lib/api/project_config_result_reporter')
9
9
  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 ChannelConfig to your project`
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
- dist: {
20
- ...sharedFlags.dist,
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, dist} = this.parse(PublishCommand).flags
24
+ const {token, host, source, dist, env} = this.parse(PublishCommand).flags
28
25
  const reportError = errorReporter(this.log, host, {verbose: true})
29
26
 
30
- const config = await readChannelConfig({source: dist})
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
 
35
+ let ok = false
36
36
  await liApi.plan({host, token, channelConfig: config})
37
37
  .then((result) => {
38
- resultReporter(result, this.log)
38
+ ok = result.ok
39
+
40
+ // early return if there are no chagnes
41
+ if (!result.patches?.length) ok = false
42
+
43
+ resultReporter({result, log: this.log})
39
44
  })
40
45
  .catch(reportError)
41
46
 
47
+ if (!ok) return
48
+
42
49
  const answers = await inquirer.prompt([{
43
50
  name: 'continue',
44
51
  type: 'confirm',
45
52
  default: false,
46
- message: `Are you sure to publish to production?`
53
+ message: `Are you sure to publish${env ? ` to ${env}` : ''}?`
47
54
  }])
48
55
 
49
56
  if (!answers.continue) return
50
57
 
51
58
  await liApi.publish({host, token, channelConfig: config})
52
59
  .then((result) => {
53
- resultReporter(result, this.log)
60
+ resultReporter({result, log: this.log})
54
61
  updateRevisionNumber({
55
- source: dist,
62
+ source: source || dist,
56
63
  revisionNumberBefore: config.$baseRevision,
57
64
  revisionNumber: result.revisionNumber
58
65
  })
@@ -4,7 +4,7 @@ const {Command, flags} = require('@oclif/command')
4
4
  const sharedFlags = require('../../lib/cli/shared_flags')
5
5
  const liApi = require('../../lib/api/livingdocs_api')
6
6
  const errorReporter = require('../../lib/api/error_reporter')
7
- const resultReporter = require('../../lib/api/channel_config_result_reporter')
7
+ const resultReporter = require('../../lib/api/project_config_result_reporter')
8
8
  const readChannelConfig = require('../../lib/read_channel_config')
9
9
 
10
10
  class UploadCommand extends Command {
@@ -15,11 +15,10 @@ class UploadCommand extends Command {
15
15
  env: sharedFlags.env,
16
16
  token: {...sharedFlags.configWriteToken, required: true},
17
17
  host: {...sharedFlags.host, required: true},
18
- dist: flags.string({
19
- char: 'd',
20
- required: true,
21
- description: 'The folder or filename to the channelConfig.'
22
- }),
18
+ source: {
19
+ ...sharedFlags.source,
20
+ required: true
21
+ },
23
22
  draftName: flags.string({
24
23
  description: 'The name of the draft the config will be saved under.',
25
24
  required: true
@@ -27,10 +26,10 @@ class UploadCommand extends Command {
27
26
  }
28
27
 
29
28
  async run () {
30
- const {token, host, dist} = this.parse(UploadCommand).flags
29
+ const {token, host, source} = this.parse(UploadCommand).flags
31
30
  const reportError = errorReporter(this.log, host, {verbose: true})
32
31
 
33
- const config = await readChannelConfig({source: dist})
32
+ const config = await readChannelConfig({source})
34
33
  .catch((err) => {
35
34
  this.log(chalk.red('✕ Parsing Failed'))
36
35
  throw err
@@ -39,7 +38,7 @@ class UploadCommand extends Command {
39
38
 
40
39
  await liApi.uploadDraft({host, token, channelConfig: config})
41
40
  .then((result) => {
42
- resultReporter(result, this.log)
41
+ resultReporter({result, log: this.log})
43
42
  })
44
43
  .catch(reportError)
45
44
  }
@@ -0,0 +1,79 @@
1
+ const chalk = require('chalk')
2
+ const dedent = require('dedent')
3
+ const diff = require('diff')
4
+
5
+ module.exports = function ({result, log, omitPatches}) {
6
+ function info (msg) { log(msg) }
7
+ function success (msg) { log(chalk.green(msg)) }
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
+ }
32
+
33
+ if (result.ok) {
34
+ const count = result.patches?.length
35
+ if (!count) {
36
+ info(dedent`
37
+ ✓ No Changes.
38
+ `)
39
+ } else if (result.plan) {
40
+ info(dedent`
41
+ Plan
42
+ ----
43
+ `)
44
+ info(`\nPatches (${count}):\n`)
45
+
46
+ for (const patch of result.patches) {
47
+ info(`• [${patch.action}] ${patch.pointer}`)
48
+ info(`${calcDiff(patch)}`)
49
+ }
50
+
51
+ if (count === 1) info(`\n✓ The patch looks good.\n`)
52
+ else info(`\n✓ All ${count} patches look good.\n`)
53
+ } else {
54
+ success(dedent`
55
+ ✓ Success. Channel Config Published.
56
+
57
+ Revision: ${result.revisionNumber}
58
+ DesignVersion: ${result.designVersion || '-'}
59
+ `)
60
+ info(`\nApplied Patches (${result.patches.length}):`)
61
+ }
62
+ }
63
+
64
+ if (result.schemaErrors) {
65
+ error(`\nInvalid JSON: there have been json schema errors`)
66
+
67
+ for (const err of result.schemaErrors) {
68
+ error(` • ${err.pointer}: ${err.message}`)
69
+ }
70
+ }
71
+
72
+ if (result.violations) {
73
+ error(`\nInvalid Config: there are invliad configuration properties`)
74
+
75
+ for (const err of result.violations) {
76
+ error(` • ${err.pointer}: ${err.message}`)
77
+ }
78
+ }
79
+ }
@@ -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',
@@ -1,56 +0,0 @@
1
- const chalk = require('chalk')
2
- const dedent = require('dedent')
3
-
4
- module.exports = function (result, log) {
5
- function info (msg) { log(msg) }
6
- function success (msg) { log(chalk.green(msg)) }
7
- function error (msg) { log(chalk.red(msg)) }
8
-
9
- if (result.ok) {
10
- if (!result.patches || result.patches.length === 0) {
11
- info(dedent`
12
- ✓ No Changes.
13
- `)
14
- } else {
15
- if (result.plan) {
16
- info(dedent`
17
- Plan
18
- ----
19
- ✓ Everything looks ok.
20
- `)
21
- info(`\nThese patches will be applied (${result.patches.length}):`)
22
- } else {
23
- success(dedent`
24
- ✓ Success. Channel Config Published.
25
-
26
- Revision: ${result.revisionNumber}
27
- DesignVersion: ${result.designVersion || '-'}
28
- `)
29
- info(`\nApplied Patches (${result.patches.length}):`)
30
- }
31
-
32
- for (const patch of result.patches) {
33
- info(` • [${patch.action}] ${patch.pointer}`)
34
- }
35
- info(``)
36
- }
37
-
38
- return
39
- }
40
-
41
- if (result.schemaErrors) {
42
- error(`\nInvalid JSON: there have been json schema errors`)
43
-
44
- for (const err of result.schemaErrors) {
45
- error(` • ${err.pointer}: ${err.message}`)
46
- }
47
- }
48
-
49
- if (result.violations) {
50
- error(`\nInvalid Config: there are invliad configuration properties`)
51
-
52
- for (const err of result.violations) {
53
- error(` • ${err.pointer}: ${err.message}`)
54
- }
55
- }
56
- }