@nitro/app 6.0.11 → 6.1.2
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/app/lib/lint.js +18 -42
- package/app/templating/hbs/helpers/pattern.js +1 -2
- package/app/templating/hbs/helpers/placeholder.js +1 -2
- package/app/templating/twig/helpers/component.js +1 -2
- package/app/templating/twig/helpers/pattern.js +1 -2
- package/app/templating/twig/helpers/placeholder.js +1 -2
- package/package.json +7 -8
package/app/lib/lint.js
CHANGED
|
@@ -1,55 +1,31 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const fs = require('fs');
|
|
4
3
|
const config = require('config');
|
|
5
|
-
const
|
|
6
|
-
const textTable = require('text-table');
|
|
4
|
+
const { HtmlValidate, formatterFactory } = require('html-validate');
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let htmllintOptions = {};
|
|
11
|
-
if (fs.existsSync(configPath)) {
|
|
12
|
-
htmllintOptions = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
13
|
-
}
|
|
14
|
-
if (isSnippet) {
|
|
15
|
-
htmllintOptions['doctype-first'] = false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return htmllintOptions;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function htmllintReporter(filepath, issues) {
|
|
22
|
-
if (issues.length > 0) {
|
|
23
|
-
const filePath = filepath.toString().replace(config.get('nitro.basePath'), '');
|
|
24
|
-
const tableData = [];
|
|
6
|
+
const htmlvalidate = new HtmlValidate();
|
|
7
|
+
const format = formatterFactory('stylish');
|
|
25
8
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const table = textTable(tableData);
|
|
33
|
-
|
|
34
|
-
// output
|
|
35
|
-
console.log(`\n[htmllint] ${filePath}`);
|
|
36
|
-
console.log(table);
|
|
37
|
-
console.log('\n');
|
|
38
|
-
|
|
39
|
-
process.exitCode = 1;
|
|
9
|
+
function _getHtmlvalidateConfig() {
|
|
10
|
+
try {
|
|
11
|
+
return require(`${config.get('nitro.basePath')}.htmlvalidate.js`);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return {};
|
|
40
14
|
}
|
|
41
15
|
}
|
|
42
16
|
|
|
43
|
-
function lintSnippet(templatePath, markup
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
17
|
+
function lintSnippet(templatePath, markup) {
|
|
18
|
+
const report = htmlvalidate.validateString(markup, _getHtmlvalidateConfig());
|
|
19
|
+
const filePath = templatePath.replace(config.get('nitro.basePath'), '');
|
|
20
|
+
if (!report.valid) {
|
|
21
|
+
console.log(`\nMarkup error in: ${filePath}`);
|
|
22
|
+
console.log(format(report.results));
|
|
23
|
+
} else if (report.warningCount) {
|
|
24
|
+
console.log(`\nMarkup warning in: ${filePath}`);
|
|
25
|
+
console.log(format(report.results));
|
|
26
|
+
}
|
|
49
27
|
}
|
|
50
28
|
|
|
51
29
|
module.exports = {
|
|
52
|
-
getHtmllintOptions,
|
|
53
30
|
lintSnippet,
|
|
54
|
-
htmllintReporter,
|
|
55
31
|
};
|
|
@@ -25,7 +25,6 @@ const ajv = new Ajv({ allErrors: true });
|
|
|
25
25
|
const config = require('config');
|
|
26
26
|
const hbsUtils = require('../utils');
|
|
27
27
|
const lint = require('../../../lib/lint');
|
|
28
|
-
const htmllintOptions = lint.getHtmllintOptions(true);
|
|
29
28
|
|
|
30
29
|
function getPatternBasePaths(type) {
|
|
31
30
|
let patternTypeKeys;
|
|
@@ -211,7 +210,7 @@ module.exports = function () {
|
|
|
211
210
|
|
|
212
211
|
// lint html snippet
|
|
213
212
|
if (!config.get('server.production') && config.get('code.validation.htmllint.live')) {
|
|
214
|
-
lint.lintSnippet(pattern.templateFilePath, html
|
|
213
|
+
lint.lintSnippet(pattern.templateFilePath, html);
|
|
215
214
|
}
|
|
216
215
|
|
|
217
216
|
return new hbs.handlebars.SafeString(html);
|
|
@@ -7,7 +7,6 @@ const extend = require('extend');
|
|
|
7
7
|
const config = require('config');
|
|
8
8
|
const hbsUtils = require('../utils');
|
|
9
9
|
const lint = require('../../../lib/lint');
|
|
10
|
-
const htmllintOptions = lint.getHtmllintOptions(true);
|
|
11
10
|
|
|
12
11
|
module.exports = function () {
|
|
13
12
|
try {
|
|
@@ -53,7 +52,7 @@ module.exports = function () {
|
|
|
53
52
|
|
|
54
53
|
// lint html snippet
|
|
55
54
|
if (!config.get('server.production') && config.get('code.validation.htmllint.live')) {
|
|
56
|
-
lint.lintSnippet(templatePath, html
|
|
55
|
+
lint.lintSnippet(templatePath, html);
|
|
57
56
|
}
|
|
58
57
|
return new hbs.handlebars.SafeString(html);
|
|
59
58
|
}
|
|
@@ -17,7 +17,6 @@ const ajv = new Ajv({ allErrors: true });
|
|
|
17
17
|
const config = require('config');
|
|
18
18
|
const twigUtils = require('../utils');
|
|
19
19
|
const lint = require('../../../lib/lint');
|
|
20
|
-
const htmllintOptions = lint.getHtmllintOptions(true);
|
|
21
20
|
|
|
22
21
|
const patternBasePaths = Object.keys(config.get('nitro.patterns')).map((key) => {
|
|
23
22
|
const configKey = `nitro.patterns.${key}.path`;
|
|
@@ -242,7 +241,7 @@ module.exports = function (Twig) {
|
|
|
242
241
|
|
|
243
242
|
// lint html snippet
|
|
244
243
|
if (!config.get('server.production') && config.get('code.validation.htmllint.live')) {
|
|
245
|
-
lint.lintSnippet(pattern.templateFilePath, html
|
|
244
|
+
lint.lintSnippet(pattern.templateFilePath, html);
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
// return the rendered template
|
|
@@ -17,7 +17,6 @@ const ajv = new Ajv({ allErrors: true });
|
|
|
17
17
|
const config = require('config');
|
|
18
18
|
const twigUtils = require('../utils');
|
|
19
19
|
const lint = require('../../../lib/lint');
|
|
20
|
-
const htmllintOptions = lint.getHtmllintOptions(true);
|
|
21
20
|
|
|
22
21
|
const patternBasePaths = Object.keys(config.get('nitro.patterns')).map((key) => {
|
|
23
22
|
const configKey = `nitro.patterns.${key}.path`;
|
|
@@ -242,7 +241,7 @@ module.exports = function (Twig) {
|
|
|
242
241
|
|
|
243
242
|
// lint html snippet
|
|
244
243
|
if (!config.get('server.production') && config.get('code.validation.htmllint.live')) {
|
|
245
|
-
lint.lintSnippet(pattern.templateFilePath, html
|
|
244
|
+
lint.lintSnippet(pattern.templateFilePath, html);
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
// return the rendered template
|
|
@@ -14,7 +14,6 @@ const extend = require('extend');
|
|
|
14
14
|
const config = require('config');
|
|
15
15
|
const twigUtils = require('../utils');
|
|
16
16
|
const lint = require('../../../lib/lint');
|
|
17
|
-
const htmllintOptions = lint.getHtmllintOptions(true);
|
|
18
17
|
|
|
19
18
|
module.exports = function (Twig) {
|
|
20
19
|
return {
|
|
@@ -142,7 +141,7 @@ module.exports = function (Twig) {
|
|
|
142
141
|
|
|
143
142
|
// lint html snippet
|
|
144
143
|
if (!config.get('server.production') && config.get('code.validation.htmllint.live')) {
|
|
145
|
-
lint.lintSnippet(templateFilePath, html
|
|
144
|
+
lint.lintSnippet(templateFilePath, html);
|
|
146
145
|
}
|
|
147
146
|
|
|
148
147
|
// return the rendered template
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitro/app",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.2",
|
|
4
4
|
"description": "Nitro server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "merkle-open/generator-nitro",
|
|
@@ -36,23 +36,22 @@
|
|
|
36
36
|
"cookie-session": "2.0.0",
|
|
37
37
|
"config": "3.3.7",
|
|
38
38
|
"dot-object": "2.1.4",
|
|
39
|
-
"express": "4.
|
|
39
|
+
"express": "4.18.1",
|
|
40
40
|
"extend": "3.0.2",
|
|
41
41
|
"globby": "11.0.4",
|
|
42
42
|
"hbs": "4.2.0",
|
|
43
43
|
"hbs-utils": "0.0.4",
|
|
44
|
-
"
|
|
45
|
-
"i18next": "21.
|
|
44
|
+
"html-validate": "6.11.1",
|
|
45
|
+
"i18next": "21.8.3",
|
|
46
46
|
"i18next-http-middleware": "3.2.0",
|
|
47
47
|
"i18next-fs-backend": "1.1.4",
|
|
48
48
|
"i18next-sprintf-postprocessor": "0.2.2",
|
|
49
|
-
"jasmine": "4.0
|
|
50
|
-
"jasmine-core": "4.
|
|
49
|
+
"jasmine": "4.1.0",
|
|
50
|
+
"jasmine-core": "4.1.1",
|
|
51
51
|
"lodash": "4.17.21",
|
|
52
|
-
"text-table": "0.2.0",
|
|
53
52
|
"twig": "1.13.3",
|
|
54
53
|
"webpack": "4.46.0",
|
|
55
|
-
"webpack-dev-middleware": "5.3.
|
|
54
|
+
"webpack-dev-middleware": "5.3.3",
|
|
56
55
|
"webpack-hot-middleware": "2.25.1"
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|