baset-baseliner-md
Advanced tools
Comparing version 0.12.0 to 0.12.1
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="0.12.1"></a> | ||
## [0.12.1](https://github.com/Igmat/baset/compare/v0.12.0...v0.12.1) (2018-05-29) | ||
### Bug Fixes | ||
* **baseliner-md:** change html beatifier package ([0078675](https://github.com/Igmat/baset/commit/0078675)) | ||
<a name="0.12.0"></a> | ||
@@ -8,0 +19,0 @@ # [0.12.0](https://github.com/Igmat/baset/compare/v0.11.1...v0.12.0) (2018-05-03) |
@@ -16,3 +16,3 @@ "use strict"; | ||
const baset_core_1 = require("baset-core"); | ||
const html_beautify_1 = __importDefault(require("html-beautify")); | ||
const clean_html_1 = require("clean-html"); | ||
const markdown_1 = require("markdown"); | ||
@@ -22,4 +22,12 @@ const pixelmatch_1 = __importDefault(require("pixelmatch")); | ||
const util_1 = require("util"); | ||
function htmlBeautify(src) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise(resolve => clean_html_1.clean(src, resolve)); | ||
}); | ||
} | ||
function uglifyJson(json) { | ||
return baset_core_1.utils.normalizeEndings(json).split('\n').map(line => line.trim()).join(''); | ||
} | ||
function isEmptyJsonSting(json) { | ||
return !json || json === '[]' || json === '{}'; | ||
return !json || json === '[]' || json === '{}' || uglifyJson(json) === '{"default": {}}'; | ||
} | ||
@@ -48,3 +56,3 @@ const knownTypeTemplates = { | ||
${!isEmptyJsonSting(json) ? renderJson(json) : ''} | ||
${known.map(renderKnown)} | ||
${known.map(renderKnown).join('')} | ||
`; | ||
@@ -58,4 +66,4 @@ class MDBaseliner extends baset_core_1.AbstractBaseliner { | ||
const known = results.length === 1 | ||
? this.cutKnownTypes(results[0], 'exports') | ||
: this.cutKnownTypes(results, 'exports'); | ||
? yield this.cutKnownTypes(results[0], 'exports') | ||
: yield this.cutKnownTypes(results, 'exports'); | ||
return mdTemplate(yield this.jsonBaseliner.create(results), known); | ||
@@ -66,8 +74,11 @@ }); | ||
const known = results.length === 1 | ||
? this.cutKnownTypes(results[0], 'exports') | ||
: this.cutKnownTypes(results, 'exports'); | ||
? yield this.cutKnownTypes(results[0], 'exports') | ||
: yield this.cutKnownTypes(results, 'exports'); | ||
const oldBase = this.parse(baselineValue); | ||
const newJsonValues = yield this.jsonBaseliner.create(results); | ||
const newJson = (isEmptyJsonSting(newJsonValues)) | ||
? '{}' | ||
: newJsonValues; | ||
let isEqual = true; | ||
if (baset_core_1.utils.normalizeEndings(newJsonValues) !== baset_core_1.utils.normalizeEndings(oldBase.json)) | ||
if (baset_core_1.utils.normalizeEndings(newJson) !== baset_core_1.utils.normalizeEndings(oldBase.json)) | ||
isEqual = false; | ||
@@ -115,3 +126,3 @@ if (!(yield compareKnownTypes(oldBase.knownEntities, known))) | ||
}; | ||
this.cutKnownTypes = (parent, path, key) => { | ||
this.cutKnownTypes = (parent, path, key) => __awaiter(this, void 0, void 0, function* () { | ||
const obj = (key !== undefined) | ||
@@ -123,3 +134,3 @@ ? parent[key] | ||
if (Array.isArray(obj)) { | ||
return [].concat(...obj.map((value, index) => this.cutKnownTypes(obj, `${path}[${index}]`, index))); | ||
return [].concat(...yield Promise.all(obj.map((value, index) => this.cutKnownTypes(obj, `${path}[${index}]`, index)))); | ||
} | ||
@@ -136,3 +147,3 @@ const type = obj[baset_core_1.dataTypes.image] | ||
src: (type === baset_core_1.dataTypes.html) | ||
? html_beautify_1.default(obj.value) | ||
? yield htmlBeautify(obj.value) | ||
: obj.value, | ||
@@ -144,5 +155,5 @@ }; | ||
} | ||
return [].concat(...Object.keys(obj) | ||
.map(index => this.cutKnownTypes(obj, `${path}.${index}`, index))); | ||
}; | ||
return [].concat(...yield Promise.all(Object.keys(obj) | ||
.map(index => this.cutKnownTypes(obj, `${path}.${index}`, index)))); | ||
}); | ||
this.jsonBaseliner = new baset_baseliner_json_1.default({}); | ||
@@ -168,4 +179,5 @@ } | ||
else { | ||
if (baset_core_1.utils.normalizeEndings(value.src) !== baset_core_1.utils.normalizeEndings(newValue.src)) | ||
if (baset_core_1.utils.normalizeEndings(value.src) !== baset_core_1.utils.normalizeEndings(newValue.src)) { | ||
return false; | ||
} | ||
} | ||
@@ -172,0 +184,0 @@ } |
{ | ||
"name": "baset-baseliner-md", | ||
"version": "0.12.0", | ||
"version": "0.12.1", | ||
"description": "JSON baseliner plugin for BaseT project.", | ||
@@ -45,3 +45,3 @@ "author": "Ihor Chulinda <ichulinda@gmail.com>", | ||
"baset-core": "^0.12.0", | ||
"html-beautify": "^1.0.4", | ||
"clean-html": "^1.5.0", | ||
"markdown": "^0.5.0", | ||
@@ -48,0 +48,0 @@ "pixelmatch": "^4.0.2", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21250
226
+ Addedclean-html@^1.5.0
+ Addedclean-html@1.5.0(transitive)
+ Addeddom-serializer@0.2.2(transitive)
+ Addeddomelementtype@1.3.12.3.0(transitive)
+ Addeddomhandler@2.4.2(transitive)
+ Addeddomutils@1.7.0(transitive)
+ Addedentities@1.1.22.2.0(transitive)
+ Addedhtmlparser2@3.10.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedhtml-beautify@^1.0.4
- Removedhtml-beautify@1.0.4(transitive)