livingdocs-cli 1.3.1 → 2.1.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 +75 -40
- package/oclif.manifest.json +1 -0
- package/package.json +13 -12
- package/src/commands/component-library/build.js +9 -11
- package/src/commands/config/print.js +59 -0
- 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/cli/load_cli_config.js +4 -1
- package/src/lib/framework/livingdocs-framework.js +4 -3
- package/src/lib/parsing/parse_design_to_v2.js +28 -7
- package/src/commands/cli-config/print.js +0 -48
|
@@ -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
|
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk')
|
|
2
|
-
const {Command} = require('@oclif/command')
|
|
3
|
-
|
|
4
|
-
const description = `Print current CLI configuration`
|
|
5
|
-
const commandFlags = {}
|
|
6
|
-
|
|
7
|
-
class ListConfigCommand extends Command {
|
|
8
|
-
|
|
9
|
-
async run () {
|
|
10
|
-
this.printVar(`LI_HOST`)
|
|
11
|
-
this.printVar(`LI_TOKEN`)
|
|
12
|
-
this.printVar(`LI_DIST_FOLDER`)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
printVar (name) {
|
|
16
|
-
const varObj = getVar(name)
|
|
17
|
-
|
|
18
|
-
this.log(chalk.green(`${name}`), chalk.gray(` (source: ${varObj.source})`))
|
|
19
|
-
this.log(chalk.gray(`${varObj.value}\n`))
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getVar (key) {
|
|
24
|
-
if (process.env[key]) {
|
|
25
|
-
return {
|
|
26
|
-
value: process.env[key],
|
|
27
|
-
source: 'environment variable'
|
|
28
|
-
}
|
|
29
|
-
} else if (defaults[key]) {
|
|
30
|
-
return {
|
|
31
|
-
value: defaults[key],
|
|
32
|
-
source: 'default value'
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
return {
|
|
36
|
-
value: '[undefined]',
|
|
37
|
-
source: 'not set'
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const defaults = {
|
|
43
|
-
LI_HOST: 'http://localhost:9090'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
ListConfigCommand.description = description
|
|
47
|
-
ListConfigCommand.flags = commandFlags
|
|
48
|
-
module.exports = ListConfigCommand
|