livingdocs-cli 2.5.8 → 3.0.1
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 +9 -9
- package/oclif.manifest.json +1 -1
- package/package.json +6 -6
- package/src/commands/project-config/download.js +2 -2
- package/src/commands/project-config/import-design.js +4 -4
- package/src/commands/project-config/plan.js +3 -3
- package/src/commands/project-config/publish.js +4 -4
- package/src/lib/api/livingdocs_api.js +9 -27
- package/src/lib/api/project_config_result_reporter.js +1 -1
- package/src/lib/{read_channel_config.js → read_project_config.js} +9 -9
- package/src/lib/{write_channel_config.js → write_project_config.js} +5 -5
- package/src/commands/project-config/drafts.js +0 -35
- package/src/commands/project-config/upload.js +0 -47
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ OPTIONS
|
|
|
44
44
|
-s, --src=src The folder with your .html component templates
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
_See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
47
|
+
_See code: [src/commands/component-library/build.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/component-library/build.js)_
|
|
48
48
|
|
|
49
49
|
## `livingdocs-cli config:print`
|
|
50
50
|
|
|
@@ -59,7 +59,7 @@ OPTIONS
|
|
|
59
59
|
-p, --project=project If used configuration options are loaded from .livingdocs-cli file.
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
_See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
62
|
+
_See code: [src/commands/config/print.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/config/print.js)_
|
|
63
63
|
|
|
64
64
|
## `livingdocs-cli design-server:start`
|
|
65
65
|
|
|
@@ -78,7 +78,7 @@ OPTIONS
|
|
|
78
78
|
--verbose
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
_See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
81
|
+
_See code: [src/commands/design-server/start.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/design-server/start.js)_
|
|
82
82
|
|
|
83
83
|
## `livingdocs-cli help [COMMAND]`
|
|
84
84
|
|
|
@@ -120,7 +120,7 @@ OPTIONS
|
|
|
120
120
|
--format=js|js/html|json The format of the files written.
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
-
_See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
123
|
+
_See code: [src/commands/project-config/download.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/project-config/download.js)_
|
|
124
124
|
|
|
125
125
|
## `livingdocs-cli project-config:import-design`
|
|
126
126
|
|
|
@@ -137,7 +137,7 @@ OPTIONS
|
|
|
137
137
|
-u, --designUri=designUri (required) URL of the design to import
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
_See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
140
|
+
_See code: [src/commands/project-config/import-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/project-config/import-design.js)_
|
|
141
141
|
|
|
142
142
|
## `livingdocs-cli project-config:plan`
|
|
143
143
|
|
|
@@ -162,7 +162,7 @@ OPTIONS
|
|
|
162
162
|
Can be set by the environment variable 'LI_TOKEN'.
|
|
163
163
|
```
|
|
164
164
|
|
|
165
|
-
_See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
165
|
+
_See code: [src/commands/project-config/plan.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/project-config/plan.js)_
|
|
166
166
|
|
|
167
167
|
## `livingdocs-cli project-config:publish`
|
|
168
168
|
|
|
@@ -189,7 +189,7 @@ OPTIONS
|
|
|
189
189
|
-y, --yes Confirm
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
_See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
192
|
+
_See code: [src/commands/project-config/publish.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/project-config/publish.js)_
|
|
193
193
|
|
|
194
194
|
## `livingdocs-cli project-config:publish-design`
|
|
195
195
|
|
|
@@ -211,7 +211,7 @@ OPTIONS
|
|
|
211
211
|
-u, --username=username username for login
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
-
_See code: [src/commands/project-config/publish-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
214
|
+
_See code: [src/commands/project-config/publish-design.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/project-config/publish-design.js)_
|
|
215
215
|
|
|
216
216
|
## `livingdocs-cli project-config:upload-assets`
|
|
217
217
|
|
|
@@ -234,5 +234,5 @@ OPTIONS
|
|
|
234
234
|
Can be set by the environment variable 'LI_TOKEN'.
|
|
235
235
|
```
|
|
236
236
|
|
|
237
|
-
_See code: [src/commands/project-config/upload-assets.js](https://github.com/livingdocsIO/livingdocs-cli/blob/
|
|
237
|
+
_See code: [src/commands/project-config/upload-assets.js](https://github.com/livingdocsIO/livingdocs-cli/blob/v3.0.1/src/commands/project-config/upload-assets.js)_
|
|
238
238
|
<!-- commandsstop -->
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"
|
|
1
|
+
{"version":"3.0.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: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":[]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "livingdocs-cli",
|
|
3
3
|
"description": "Livingdocs Command Line Utility",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.1",
|
|
5
5
|
"author": "Livingdocs AG",
|
|
6
6
|
"repository": "livingdocsIO/livingdocs-cli",
|
|
7
7
|
"homepage": "https://github.com/livingdocsIO/livingdocs-cli",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@oclif/dev-cli": "^1.26.0",
|
|
54
|
-
"@oclif/test": "^2.
|
|
54
|
+
"@oclif/test": "^2.5.6",
|
|
55
55
|
"chai": "^4.3.4",
|
|
56
56
|
"eslint": "^8.5.0",
|
|
57
|
-
"eslint-config-oclif": "^
|
|
57
|
+
"eslint-config-oclif": "^5.0.0",
|
|
58
58
|
"mocha": "^10.0.0",
|
|
59
59
|
"nock": "^13.0.0",
|
|
60
60
|
"nyc": "^15.0.0"
|
|
@@ -89,11 +89,11 @@
|
|
|
89
89
|
"isCi": true,
|
|
90
90
|
"name": "Drone",
|
|
91
91
|
"service": "drone",
|
|
92
|
-
"commit": "
|
|
93
|
-
"build": "
|
|
92
|
+
"commit": "95f2b2f1164dfc811ea4cf6b44cdc8eaa2cf66f1",
|
|
93
|
+
"build": "205",
|
|
94
94
|
"branch": "master",
|
|
95
95
|
"isPr": false,
|
|
96
96
|
"slug": "livingdocsIO/livingdocs-cli",
|
|
97
|
-
"date": "2023-10-
|
|
97
|
+
"date": "2023-10-16T10:12:24.637Z"
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -5,7 +5,7 @@ const {Command, flags} = require('@oclif/command')
|
|
|
5
5
|
|
|
6
6
|
const sharedFlags = require('../../lib/cli/shared_flags')
|
|
7
7
|
const liApi = require('../../lib/api/livingdocs_api')
|
|
8
|
-
const writeConfig = require('../../lib/
|
|
8
|
+
const writeConfig = require('../../lib/write_project_config')
|
|
9
9
|
const errorReporter = require('../../lib/api/error_reporter')
|
|
10
10
|
const assertDistFolder = require('../../lib/cli/assert_dist_folder')
|
|
11
11
|
|
|
@@ -38,7 +38,7 @@ class DownloadCommand extends Command {
|
|
|
38
38
|
if (dist) {
|
|
39
39
|
const {fileCount, oldFiles} = await writeConfig({
|
|
40
40
|
destination: dist,
|
|
41
|
-
|
|
41
|
+
projectConfig: result,
|
|
42
42
|
fileType: format || 'js',
|
|
43
43
|
componentsAsHtml: false
|
|
44
44
|
})
|
|
@@ -3,8 +3,8 @@ const _ = require('lodash')
|
|
|
3
3
|
const {Command} = require('@oclif/command')
|
|
4
4
|
|
|
5
5
|
const sharedFlags = require('../../lib/cli/shared_flags')
|
|
6
|
-
const writeConfig = require('../../lib/
|
|
7
|
-
const
|
|
6
|
+
const writeConfig = require('../../lib/write_project_config')
|
|
7
|
+
const readProjectConfig = require('../../lib/read_project_config')
|
|
8
8
|
const assertDistFolder = require('../../lib/cli/assert_dist_folder')
|
|
9
9
|
const downloadDesign = require('../../lib/utils/download_design')
|
|
10
10
|
const parseDesignV2 = require('../../lib/parsing/parse_design_to_v2')
|
|
@@ -25,7 +25,7 @@ class ImportDesignCommand extends Command {
|
|
|
25
25
|
|
|
26
26
|
let config
|
|
27
27
|
try {
|
|
28
|
-
config = await
|
|
28
|
+
config = await readProjectConfig({source: dist})
|
|
29
29
|
} catch (err) {
|
|
30
30
|
this.log(chalk.red('✕ Parsing Failed'))
|
|
31
31
|
throw err
|
|
@@ -57,7 +57,7 @@ class ImportDesignCommand extends Command {
|
|
|
57
57
|
|
|
58
58
|
await writeConfig({
|
|
59
59
|
destination: dist,
|
|
60
|
-
|
|
60
|
+
projectConfig: config,
|
|
61
61
|
fileType: 'js',
|
|
62
62
|
componentsAsHtml: false
|
|
63
63
|
})
|
|
@@ -4,7 +4,7 @@ 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
6
|
const resultReporter = require('../../lib/api/project_config_result_reporter')
|
|
7
|
-
const
|
|
7
|
+
const readProjectConfig = require('../../lib/read_project_config')
|
|
8
8
|
|
|
9
9
|
class PlanCommand extends Command {
|
|
10
10
|
static description = `See what would be updated in a publish command`
|
|
@@ -23,9 +23,9 @@ class PlanCommand extends Command {
|
|
|
23
23
|
|
|
24
24
|
if (!source && !dist) throw new Error('Missing a source param')
|
|
25
25
|
|
|
26
|
-
const config = await
|
|
26
|
+
const config = await readProjectConfig({source: source || dist})
|
|
27
27
|
|
|
28
|
-
await liApi.plan({host, token,
|
|
28
|
+
await liApi.plan({host, token, projectConfig: config})
|
|
29
29
|
.then((result) => {
|
|
30
30
|
resultReporter({result, log: this.log})
|
|
31
31
|
})
|
|
@@ -6,7 +6,7 @@ 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
8
|
const resultReporter = require('../../lib/api/project_config_result_reporter')
|
|
9
|
-
const
|
|
9
|
+
const readProjectConfig = require('../../lib/read_project_config')
|
|
10
10
|
const updateRevisionNumber = require('../../lib/update_revision_number')
|
|
11
11
|
|
|
12
12
|
class PublishCommand extends Command {
|
|
@@ -27,14 +27,14 @@ class PublishCommand extends Command {
|
|
|
27
27
|
|
|
28
28
|
if (!source && !dist) throw new Error('Missing a source param')
|
|
29
29
|
|
|
30
|
-
const config = await
|
|
30
|
+
const config = await readProjectConfig({source: source || dist})
|
|
31
31
|
.catch((err) => {
|
|
32
32
|
this.log(chalk.red('✕ Parsing Failed'))
|
|
33
33
|
throw err
|
|
34
34
|
})
|
|
35
35
|
|
|
36
36
|
let ok = false
|
|
37
|
-
await liApi.plan({host, token,
|
|
37
|
+
await liApi.plan({host, token, projectConfig: config})
|
|
38
38
|
.then((result) => {
|
|
39
39
|
ok = result.ok
|
|
40
40
|
|
|
@@ -58,7 +58,7 @@ class PublishCommand extends Command {
|
|
|
58
58
|
if (!answers.continue) return
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
await liApi.publish({host, token,
|
|
61
|
+
await liApi.publish({host, token, projectConfig: config})
|
|
62
62
|
.then((result) => {
|
|
63
63
|
resultReporter({result, log: this.log})
|
|
64
64
|
updateRevisionNumber({
|
|
@@ -10,49 +10,31 @@ axiosJarInstance.interceptors.response.use(responseInterceptor)
|
|
|
10
10
|
// down- and upload to the ☁️
|
|
11
11
|
module.exports = {
|
|
12
12
|
|
|
13
|
-
//
|
|
14
|
-
//
|
|
13
|
+
// Project Config
|
|
14
|
+
// --------------
|
|
15
15
|
|
|
16
16
|
async download ({host, token}) {
|
|
17
|
-
return axios(host, token).get('/api/v1/
|
|
17
|
+
return axios(host, token).get('/api/v1/projectConfig')
|
|
18
18
|
.then((response) => {
|
|
19
19
|
return response.data
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
-
async plan ({host, token,
|
|
25
|
-
return axios(host, token).post('/api/v1/
|
|
24
|
+
async plan ({host, token, projectConfig}) {
|
|
25
|
+
return axios(host, token).post('/api/v1/projectConfig', {
|
|
26
26
|
plan: true,
|
|
27
|
-
channelConfig
|
|
27
|
+
channelConfig: projectConfig
|
|
28
28
|
})
|
|
29
29
|
.then((response) => {
|
|
30
30
|
return response.data
|
|
31
31
|
})
|
|
32
|
-
|
|
33
32
|
},
|
|
34
33
|
|
|
35
|
-
async publish ({host, token,
|
|
36
|
-
return axios(host, token).post('/api/v1/
|
|
34
|
+
async publish ({host, token, projectConfig}) {
|
|
35
|
+
return axios(host, token).post('/api/v1/projectConfig', {
|
|
37
36
|
plan: false,
|
|
38
|
-
channelConfig
|
|
39
|
-
})
|
|
40
|
-
.then((response) => {
|
|
41
|
-
return response.data
|
|
42
|
-
})
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
async listDrafts ({host, token}) {
|
|
46
|
-
return axios(host, token).get('/api/v1/channelConfig/drafts')
|
|
47
|
-
.then((response) => {
|
|
48
|
-
return response.data
|
|
49
|
-
})
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
async uploadDraft ({host, token, draftName, channelConfig}) {
|
|
53
|
-
return axios(host, token).put('/api/v1/channelConfig/drafts', {
|
|
54
|
-
draftName,
|
|
55
|
-
channelConfig
|
|
37
|
+
channelConfig: projectConfig
|
|
56
38
|
})
|
|
57
39
|
.then((response) => {
|
|
58
40
|
return response.data
|
|
@@ -52,7 +52,7 @@ module.exports = function ({result, log, omitPatches}) {
|
|
|
52
52
|
else info(`\n✓ All ${count} patches look good.\n`)
|
|
53
53
|
} else {
|
|
54
54
|
success(dedent`
|
|
55
|
-
✓ Success.
|
|
55
|
+
✓ Success. Project Config Published.
|
|
56
56
|
|
|
57
57
|
Revision: ${result.revisionNumber}
|
|
58
58
|
DesignVersion: ${result.designVersion || '-'}
|
|
@@ -3,11 +3,11 @@ const _map = require('lodash/map')
|
|
|
3
3
|
const parseComponents = require('./parsing/parse_components')
|
|
4
4
|
|
|
5
5
|
module.exports = async function ({source}) {
|
|
6
|
-
const {rootFolder,
|
|
6
|
+
const {rootFolder, projectConfig} = loadProjectConfig(source)
|
|
7
7
|
|
|
8
|
-
if (
|
|
8
|
+
if (projectConfig.components) {
|
|
9
9
|
let needsLoading = false
|
|
10
|
-
const filePaths = _map(
|
|
10
|
+
const filePaths = _map(projectConfig.components, (component) => {
|
|
11
11
|
if (typeof component === 'string') {
|
|
12
12
|
needsLoading = true
|
|
13
13
|
const filePath = path.resolve(rootFolder, component)
|
|
@@ -17,19 +17,19 @@ module.exports = async function ({source}) {
|
|
|
17
17
|
|
|
18
18
|
if (needsLoading) {
|
|
19
19
|
const {components} = await parseComponents({filePaths})
|
|
20
|
-
|
|
20
|
+
projectConfig.components = components
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return projectConfig
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function loadProjectConfig (source) {
|
|
27
27
|
try {
|
|
28
28
|
const rootFolder = path.resolve(source)
|
|
29
|
-
const
|
|
30
|
-
return {rootFolder,
|
|
29
|
+
const projectConfig = require(rootFolder)
|
|
30
|
+
return {rootFolder, projectConfig}
|
|
31
31
|
} catch (err) {
|
|
32
|
-
throw new Error(`Could not load
|
|
32
|
+
throw new Error(`Could not load projectConfig from path '${source}'.
|
|
33
33
|
Error Stack: ${err.stack}
|
|
34
34
|
Error: ${err.message}`)
|
|
35
35
|
}
|
|
@@ -9,15 +9,15 @@ const {stringify: stringifyjs} = require('javascript-stringify')
|
|
|
9
9
|
const buildFile = require('./utils/build_file')
|
|
10
10
|
const {indentString} = require('./utils')
|
|
11
11
|
|
|
12
|
-
module.exports = async function ({destination,
|
|
12
|
+
module.exports = async function ({destination, projectConfig, fileType, componentsAsHtml}) {
|
|
13
13
|
const rootFolder = path.resolve(destination)
|
|
14
14
|
const writeHtml = fileType === 'js/html'
|
|
15
|
-
const baseRevision =
|
|
15
|
+
const baseRevision = projectConfig.$baseRevision
|
|
16
16
|
|
|
17
17
|
await fs.ensureDir(rootFolder)
|
|
18
18
|
|
|
19
19
|
if (fileType === 'json') {
|
|
20
|
-
return writeJsonFile(`${rootFolder}/index.json`,
|
|
20
|
+
return writeJsonFile(`${rootFolder}/index.json`, projectConfig)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
fileType = 'js'
|
|
@@ -36,11 +36,11 @@ module.exports = async function ({destination, channelConfig, fileType, componen
|
|
|
36
36
|
}
|
|
37
37
|
indexFile.line('', 1)
|
|
38
38
|
|
|
39
|
-
for (const key in
|
|
39
|
+
for (const key in projectConfig) {
|
|
40
40
|
if (key === 'v') continue
|
|
41
41
|
if (key === '$baseRevision') continue
|
|
42
42
|
|
|
43
|
-
const prop =
|
|
43
|
+
const prop = projectConfig[key]
|
|
44
44
|
|
|
45
45
|
if (Array.isArray(prop)) {
|
|
46
46
|
const folder = `${rootFolder}/${_kebabCase(key)}`
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
const {Command} = require('@oclif/command')
|
|
3
|
-
|
|
4
|
-
const sharedFlags = require('../../lib/cli/shared_flags')
|
|
5
|
-
const liApi = require('../../lib/api/livingdocs_api')
|
|
6
|
-
const errorReporter = require('../../lib/api/error_reporter')
|
|
7
|
-
|
|
8
|
-
class DraftsCommand extends Command {
|
|
9
|
-
static hidden = true
|
|
10
|
-
static description = `List project configuration drafts`
|
|
11
|
-
static flags = {
|
|
12
|
-
token: {...sharedFlags.configReadToken, required: true},
|
|
13
|
-
host: sharedFlags.host
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async run () {
|
|
17
|
-
const {token, host} = this.parse(DraftsCommand).flags
|
|
18
|
-
const reportError = errorReporter(this.log, host, {verbose: true})
|
|
19
|
-
|
|
20
|
-
await liApi.listDrafts({host, token})
|
|
21
|
-
.then((result) => {
|
|
22
|
-
this.log(`Drafts:`)
|
|
23
|
-
if (!result || !result.length) {
|
|
24
|
-
this.log(chalk.gray(`-> 0 drafts found`))
|
|
25
|
-
} else {
|
|
26
|
-
for (const draftName of result) {
|
|
27
|
-
this.log(` • ${draftName}`)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
.catch(reportError)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = DraftsCommand
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
const {Command, flags} = require('@oclif/command')
|
|
3
|
-
|
|
4
|
-
const sharedFlags = require('../../lib/cli/shared_flags')
|
|
5
|
-
const liApi = require('../../lib/api/livingdocs_api')
|
|
6
|
-
const errorReporter = require('../../lib/api/error_reporter')
|
|
7
|
-
const resultReporter = require('../../lib/api/project_config_result_reporter')
|
|
8
|
-
const readChannelConfig = require('../../lib/read_channel_config')
|
|
9
|
-
|
|
10
|
-
class UploadCommand extends Command {
|
|
11
|
-
static hidden = true
|
|
12
|
-
static description = `Upload a ChannelConfig into a draft for your project`
|
|
13
|
-
static flags = {
|
|
14
|
-
project: sharedFlags.project,
|
|
15
|
-
env: sharedFlags.env,
|
|
16
|
-
token: {...sharedFlags.configWriteToken, required: true},
|
|
17
|
-
host: {...sharedFlags.host, required: true},
|
|
18
|
-
source: {
|
|
19
|
-
...sharedFlags.source,
|
|
20
|
-
required: true
|
|
21
|
-
},
|
|
22
|
-
draftName: flags.string({
|
|
23
|
-
description: 'The name of the draft the config will be saved under.',
|
|
24
|
-
required: true
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async run () {
|
|
29
|
-
const {token, host, source} = this.parse(UploadCommand).flags
|
|
30
|
-
const reportError = errorReporter(this.log, host, {verbose: true})
|
|
31
|
-
|
|
32
|
-
const config = await readChannelConfig({source})
|
|
33
|
-
.catch((err) => {
|
|
34
|
-
this.log(chalk.red('✕ Parsing Failed'))
|
|
35
|
-
throw err
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
await liApi.uploadDraft({host, token, channelConfig: config})
|
|
40
|
-
.then((result) => {
|
|
41
|
-
resultReporter({result, log: this.log})
|
|
42
|
-
})
|
|
43
|
-
.catch(reportError)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = UploadCommand
|