@nitro/app 6.0.10 → 6.1.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/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 htmllint = require('htmllint');
6
- const textTable = require('text-table');
4
+ const { HtmlValidate, formatterFactory } = require('html-validate');
7
5
 
8
- function getHtmllintOptions(isSnippet) {
9
- const configPath = '.htmllintrc';
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
- issues.forEach((issue) => {
27
- issue.msg = issue.msg || htmllint.messages.renderIssue(issue);
28
- issue.cell = `${` ${issue.line}`.slice(-4)}:${issue.column}`;
29
- tableData.push([issue.cell, issue.msg, issue.rule]);
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, options) {
44
- const htmllintOptions = options || getHtmllintOptions(true);
45
-
46
- return htmllint(markup, htmllintOptions).then((issues) => {
47
- htmllintReporter(templatePath, issues);
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, htmllintOptions);
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, htmllintOptions);
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, htmllintOptions);
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, htmllintOptions);
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, htmllintOptions);
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.0.10",
3
+ "version": "6.1.1",
4
4
  "description": "Nitro server",
5
5
  "license": "MIT",
6
6
  "repository": "merkle-open/generator-nitro",
@@ -30,26 +30,25 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "ajv": "8.11.0",
33
- "body-parser": "1.19.2",
33
+ "body-parser": "1.20.0",
34
34
  "chalk": "4.1.2",
35
35
  "compression": "1.7.4",
36
36
  "cookie-session": "2.0.0",
37
37
  "config": "3.3.7",
38
38
  "dot-object": "2.1.4",
39
- "express": "4.17.3",
39
+ "express": "4.18.0",
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
- "htmllint": "0.8.0",
45
- "i18next": "21.6.14",
44
+ "html-validate": "6.9.0",
45
+ "i18next": "21.6.16",
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.2",
50
- "jasmine-core": "4.0.1",
49
+ "jasmine": "4.1.0",
50
+ "jasmine-core": "4.1.0",
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
54
  "webpack-dev-middleware": "5.3.1",
@@ -58,7 +57,7 @@
58
57
  "devDependencies": {
59
58
  "@namics/eslint-config": "9.1.1",
60
59
  "eslint": "7.32.0",
61
- "eslint-plugin-import": "2.25.4"
60
+ "eslint-plugin-import": "2.26.0"
62
61
  },
63
62
  "publishConfig": {
64
63
  "access": "public"