livingdocs-cli 1.3.0 → 2.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 +61 -30
- package/oclif.manifest.json +1 -0
- package/package.json +9 -9
- package/src/commands/cli-config/print.js +5 -8
- package/src/commands/component-library/build.js +9 -11
- package/src/commands/design-server/start.js +35 -27
- package/src/commands/project-config/download.js +13 -16
- package/src/commands/project-config/drafts.js +5 -8
- package/src/commands/project-config/import-design.js +20 -1
- package/src/commands/project-config/plan.js +12 -15
- package/src/commands/project-config/publish.js +12 -15
- package/src/commands/project-config/upload.js +16 -19
- package/src/commands/project-config/upload_assets.js +9 -12
- package/src/lib/framework/livingdocs-framework.js +4 -3
- package/src/lib/parsing/parse_design_to_v2.js +28 -7
- package/src/lib/read_channel_config.js +3 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
const chalk = require('chalk')
|
|
2
2
|
const dedent = require('dedent')
|
|
3
3
|
const _ = require('lodash')
|
|
4
|
-
const
|
|
4
|
+
const prettifyHtml = require('prettify-html')
|
|
5
|
+
const {parseComponent, design: designCache} = require('../framework/livingdocs-framework')
|
|
5
6
|
|
|
6
|
-
module.exports = function (design) {
|
|
7
|
+
module.exports = function (design, log) {
|
|
7
8
|
if (design.v === 2) return design // already v2, nothing to do
|
|
8
|
-
|
|
9
|
+
const parsedDesignV1 = designCache.load(design)
|
|
9
10
|
const parsedDesign = {
|
|
10
11
|
v: 2,
|
|
11
12
|
designSettings: {
|
|
@@ -26,7 +27,18 @@ module.exports = function (design) {
|
|
|
26
27
|
return url.href
|
|
27
28
|
})
|
|
28
29
|
},
|
|
29
|
-
componentGroups: design.
|
|
30
|
+
componentGroups: _.reduce(design.layouts, (acc, layout) => {
|
|
31
|
+
_.each(layout.groups, group => {
|
|
32
|
+
const name = _.toLower(group.label)
|
|
33
|
+
let groupEntry = _.find(acc, g => g.name === name)
|
|
34
|
+
if (!groupEntry) {
|
|
35
|
+
groupEntry = {label: group.label, name, components: []}
|
|
36
|
+
acc.push(groupEntry)
|
|
37
|
+
}
|
|
38
|
+
groupEntry.components = _.union(groupEntry.components, group.components)
|
|
39
|
+
})
|
|
40
|
+
return acc
|
|
41
|
+
}, []),
|
|
30
42
|
defaultComponents: design.defaultComponents,
|
|
31
43
|
fieldExtractor: design.metadata,
|
|
32
44
|
prefilledComponents: _.map(_.keys(design.prefilledComponents), (k) => {
|
|
@@ -56,18 +68,27 @@ module.exports = function (design) {
|
|
|
56
68
|
}, ['directives'])
|
|
57
69
|
if (!_.isEmpty(componentV1.directives)) {
|
|
58
70
|
try {
|
|
59
|
-
const {structure} = parseComponent(componentV1)
|
|
71
|
+
const {structure} = parseComponent(componentV1, parsedDesignV1)
|
|
60
72
|
const cleaned = []
|
|
61
73
|
structure.directives.each((d) => {
|
|
74
|
+
// change the properties property of a doc-style directive to an array
|
|
75
|
+
if (d.type === 'style') {
|
|
76
|
+
d.properties = _.keys(d.properties)
|
|
77
|
+
}
|
|
78
|
+
// change the image ratios to just contain the name
|
|
79
|
+
if (d.type === 'image') {
|
|
80
|
+
d.imageRatios = _.map(d.imageRatios, i => i.name)
|
|
81
|
+
}
|
|
62
82
|
cleaned.push(_.omit(d, ['index']))
|
|
63
83
|
})
|
|
64
84
|
componentV2.directives = cleaned
|
|
85
|
+
componentV2.html = prettifyHtml(componentV2.html)
|
|
65
86
|
} catch (e) {
|
|
66
|
-
chalk.red(dedent`
|
|
87
|
+
log(chalk.red(dedent`
|
|
67
88
|
✕ Component Parse Error
|
|
68
89
|
"${componentV1.name}":
|
|
69
90
|
${e.message}`
|
|
70
|
-
)
|
|
91
|
+
))
|
|
71
92
|
}
|
|
72
93
|
}
|
|
73
94
|
|
|
@@ -29,6 +29,8 @@ function loadChannelConfig (source) {
|
|
|
29
29
|
const channelConfig = require(rootFolder)
|
|
30
30
|
return {rootFolder, channelConfig}
|
|
31
31
|
} catch (err) {
|
|
32
|
-
throw new Error(`Could not load channel config from path '${source}'
|
|
32
|
+
throw new Error(`Could not load channel config from path '${source}'.
|
|
33
|
+
Error Stack: ${err.stack}
|
|
34
|
+
Error: ${err.message}`)
|
|
33
35
|
}
|
|
34
36
|
}
|