@nitro/app 5.10.16 → 6.0.0-rc.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/core/config.js +3 -2
- package/app/core/i18n.js +2 -2
- package/app/scripts/validate-pattern-data.js +21 -4
- package/app/templating/hbs/helpers/pattern.js +10 -2
- package/app/templating/twig/helpers/component.js +7 -2
- package/app/templating/twig/helpers/pattern.js +7 -2
- package/package.json +11 -11
package/app/core/config.js
CHANGED
|
@@ -118,7 +118,7 @@ const defaultConfig = {
|
|
|
118
118
|
*/
|
|
119
119
|
options: {
|
|
120
120
|
// defaultNS: 'translation',
|
|
121
|
-
//
|
|
121
|
+
// supportedLngs: ['en', 'de', 'default'],
|
|
122
122
|
fallbackLng: 'default',
|
|
123
123
|
backend: {
|
|
124
124
|
loadPath: 'project/locales/{{lng}}/{{ns}}.json',
|
|
@@ -129,7 +129,8 @@ const defaultConfig = {
|
|
|
129
129
|
// keys or params to lookup language from
|
|
130
130
|
lookupQuerystring: 'lang',
|
|
131
131
|
},
|
|
132
|
-
|
|
132
|
+
// compatibilityJSON: 'v3',
|
|
133
|
+
debug: false
|
|
133
134
|
},
|
|
134
135
|
middlewareOptions: {
|
|
135
136
|
ignoreRoutes: ['api/', 'assets/', 'dist/', 'proto/'],
|
package/app/core/i18n.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Init Translation Library i18next
|
|
5
|
-
* Documentation: https://
|
|
5
|
+
* Documentation: https://github.com/i18next/i18next-http-middleware
|
|
6
6
|
*
|
|
7
7
|
* Configuration in config package ('./config.js').
|
|
8
8
|
*
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
const i18next = require('i18next');
|
|
12
12
|
const FilesystemBackend = require('i18next-node-fs-backend');
|
|
13
13
|
const sprintf = require('i18next-sprintf-postprocessor');
|
|
14
|
-
const i18nextMiddleware = require('i18next-
|
|
14
|
+
const i18nextMiddleware = require('i18next-http-middleware');
|
|
15
15
|
const config = require('config');
|
|
16
16
|
const cloneDeep = require('lodash/cloneDeep');
|
|
17
17
|
|
|
@@ -26,9 +26,8 @@ const chalk = require('chalk');
|
|
|
26
26
|
const fs = require('fs');
|
|
27
27
|
const globby = require('globby');
|
|
28
28
|
const Ajv = require('ajv');
|
|
29
|
+
const ajv = new Ajv({ allErrors: true });
|
|
29
30
|
const config = require('config');
|
|
30
|
-
const ajv = new Ajv({ schemaId: 'auto', allErrors: true });
|
|
31
|
-
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
|
|
32
31
|
const wildcard = '*';
|
|
33
32
|
const patternBasePaths = Object.keys(config.get('nitro.patterns')).map((key) => {
|
|
34
33
|
return config.get(`nitro.patterns.${key}.path`);
|
|
@@ -52,6 +51,21 @@ const logMissingSchemaAsWarning = config.has('code.validation.jsonSchema.logMiss
|
|
|
52
51
|
let errorCouter = 0;
|
|
53
52
|
let patternCouter = 0;
|
|
54
53
|
|
|
54
|
+
// collect all schemas
|
|
55
|
+
globby.sync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
|
|
56
|
+
const schemaFilePath = `${patternPath}/schema.json`;
|
|
57
|
+
|
|
58
|
+
if (fs.existsSync(schemaFilePath)) {
|
|
59
|
+
// console.log(`Add ${schemaFilePath}`);
|
|
60
|
+
const schema = JSON.parse(fs.readFileSync(schemaFilePath, 'utf8'));
|
|
61
|
+
if (schema.$id) {
|
|
62
|
+
// ajv.addSchema(schema);
|
|
63
|
+
ajv.addMetaSchema(schema);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// validate pattern data
|
|
55
69
|
globby.sync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
|
|
56
70
|
const schemaFilePath = `${patternPath}/schema.json`;
|
|
57
71
|
patternCouter += 1;
|
|
@@ -72,7 +86,9 @@ globby.sync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
|
|
|
72
86
|
const patternData = JSON.parse(fs.readFileSync(patternDataFilePath, 'utf8'));
|
|
73
87
|
const schema = JSON.parse(fs.readFileSync(schemaFilePath, 'utf8'));
|
|
74
88
|
|
|
75
|
-
|
|
89
|
+
// console.log(`validate ${schemaFilePath} with ${patternDataFilePath}`);
|
|
90
|
+
const schemaToUse = schema.$id || schema;
|
|
91
|
+
const valid = ajv.validate(schemaToUse, patternData);
|
|
76
92
|
if (!valid) {
|
|
77
93
|
errorCouter += 1;
|
|
78
94
|
console.log(`${chalk.red('Error')} (${patternDataFilePath}): ${ajv.errorsText()}`);
|
|
@@ -83,5 +99,6 @@ globby.sync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
|
|
|
83
99
|
if (errorCouter <= 0) {
|
|
84
100
|
console.log(`${chalk.green('Success:')} all data from each of the ${patternCouter} patterns are valid!\n`);
|
|
85
101
|
} else {
|
|
86
|
-
|
|
102
|
+
console.log(`${chalk.red('Error:')} we detected ${errorCouter} errors in your data.\n`);
|
|
103
|
+
process.exitCode = 1;
|
|
87
104
|
}
|
|
@@ -21,8 +21,7 @@ const path = require('path');
|
|
|
21
21
|
const extend = require('extend');
|
|
22
22
|
const globby = require('globby');
|
|
23
23
|
const Ajv = require('ajv');
|
|
24
|
-
const ajv = new Ajv({
|
|
25
|
-
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
|
|
24
|
+
const ajv = new Ajv({ allErrors: true });
|
|
26
25
|
const config = require('config');
|
|
27
26
|
const hbsUtils = require('../utils');
|
|
28
27
|
const lint = require('../../../lib/lint');
|
|
@@ -185,16 +184,25 @@ module.exports = function () {
|
|
|
185
184
|
patternData.children = context.fn(this);
|
|
186
185
|
}
|
|
187
186
|
|
|
187
|
+
|
|
188
188
|
// Validate with JSON schema
|
|
189
|
+
/* eslint-disable max-depth */
|
|
189
190
|
if (!config.get('server.production') && config.get('code.validation.jsonSchema.live')) {
|
|
190
191
|
if (fs.existsSync(pattern.schemaFilePath)) {
|
|
191
192
|
const schema = JSON.parse(fs.readFileSync(pattern.schemaFilePath, 'utf8'));
|
|
193
|
+
if (schema.$id) {
|
|
194
|
+
// remove if already known to avoid collision
|
|
195
|
+
if (ajv.getSchema(schema.$id)) {
|
|
196
|
+
ajv.removeSchema(schema);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
192
199
|
const valid = ajv.validate(schema, patternData);
|
|
193
200
|
if (!valid) {
|
|
194
201
|
throw new Error(`JSON Schema: ${ajv.errorsText()}`);
|
|
195
202
|
}
|
|
196
203
|
}
|
|
197
204
|
}
|
|
205
|
+
/* eslint-enable max-depth */
|
|
198
206
|
|
|
199
207
|
const html = hbs.handlebars.compile(fs.readFileSync(pattern.templateFilePath, 'utf8'))(
|
|
200
208
|
patternData,
|
|
@@ -13,8 +13,7 @@ const path = require('path');
|
|
|
13
13
|
const extend = require('extend');
|
|
14
14
|
const globby = require('globby');
|
|
15
15
|
const Ajv = require('ajv');
|
|
16
|
-
const ajv = new Ajv({
|
|
17
|
-
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
|
|
16
|
+
const ajv = new Ajv({ allErrors: true });
|
|
18
17
|
const config = require('config');
|
|
19
18
|
const twigUtils = require('../utils');
|
|
20
19
|
const lint = require('../../../lib/lint');
|
|
@@ -199,6 +198,12 @@ module.exports = function (Twig) {
|
|
|
199
198
|
if (!config.get('server.production') && config.get('code.validation.jsonSchema.live')) {
|
|
200
199
|
if (fs.existsSync(pattern.schemaFilePath)) {
|
|
201
200
|
const schema = JSON.parse(fs.readFileSync(pattern.schemaFilePath, 'utf8'));
|
|
201
|
+
if (schema.$id) {
|
|
202
|
+
// remove if already known to avoid collision
|
|
203
|
+
if (ajv.getSchema(schema.$id)) {
|
|
204
|
+
ajv.removeSchema(schema);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
202
207
|
const valid = ajv.validate(schema, patternData);
|
|
203
208
|
if (!valid) {
|
|
204
209
|
return {
|
|
@@ -13,8 +13,7 @@ const path = require('path');
|
|
|
13
13
|
const extend = require('extend');
|
|
14
14
|
const globby = require('globby');
|
|
15
15
|
const Ajv = require('ajv');
|
|
16
|
-
const ajv = new Ajv({
|
|
17
|
-
ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
|
|
16
|
+
const ajv = new Ajv({ allErrors: true });
|
|
18
17
|
const config = require('config');
|
|
19
18
|
const twigUtils = require('../utils');
|
|
20
19
|
const lint = require('../../../lib/lint');
|
|
@@ -199,6 +198,12 @@ module.exports = function (Twig) {
|
|
|
199
198
|
if (!config.get('server.production') && config.get('code.validation.jsonSchema.live')) {
|
|
200
199
|
if (fs.existsSync(pattern.schemaFilePath)) {
|
|
201
200
|
const schema = JSON.parse(fs.readFileSync(pattern.schemaFilePath, 'utf8'));
|
|
201
|
+
if (schema.$id) {
|
|
202
|
+
// remove if already known to avoid collision
|
|
203
|
+
if (ajv.getSchema(schema.$id)) {
|
|
204
|
+
ajv.removeSchema(schema);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
202
207
|
const valid = ajv.validate(schema, patternData);
|
|
203
208
|
if (!valid) {
|
|
204
209
|
return {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitro/app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-rc.1",
|
|
4
4
|
"description": "Nitro server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "merkle-open/generator-nitro",
|
|
7
7
|
"author": "The Nitro Team",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": ">=
|
|
10
|
-
"npm": ">=6.
|
|
9
|
+
"node": ">=12.13.0 <17",
|
|
10
|
+
"npm": ">=6.12.0 <9"
|
|
11
11
|
},
|
|
12
12
|
"bin": {
|
|
13
13
|
"nitro-app-validate-pattern-data": "./bin/validate-pattern-data.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint .",
|
|
18
|
-
"prepublishOnly": "npx pkg-ok@2.3.1",
|
|
18
|
+
"prepublishOnly": "npx -y pkg-ok@2.3.1",
|
|
19
19
|
"pretest": "npm run lint",
|
|
20
20
|
"test": "jasmine --config=./tests/jasmine/support/jasmine.json"
|
|
21
21
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"nitro"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"ajv": "
|
|
32
|
+
"ajv": "8.7.1",
|
|
33
33
|
"body-parser": "1.19.0",
|
|
34
34
|
"chalk": "4.1.2",
|
|
35
35
|
"compression": "1.7.4",
|
|
@@ -42,23 +42,23 @@
|
|
|
42
42
|
"hbs": "4.1.2",
|
|
43
43
|
"hbs-utils": "0.0.4",
|
|
44
44
|
"htmllint": "0.8.0",
|
|
45
|
-
"i18next": "
|
|
46
|
-
"i18next-
|
|
45
|
+
"i18next": "21.4.2",
|
|
46
|
+
"i18next-http-middleware": "3.1.4",
|
|
47
47
|
"i18next-node-fs-backend": "2.1.3",
|
|
48
48
|
"i18next-sprintf-postprocessor": "0.2.2",
|
|
49
|
-
"jasmine": "3.
|
|
50
|
-
"jasmine-core": "3.
|
|
49
|
+
"jasmine": "3.10.0",
|
|
50
|
+
"jasmine-core": "3.10.1",
|
|
51
51
|
"lodash": "4.17.21",
|
|
52
52
|
"text-table": "0.2.0",
|
|
53
53
|
"twig": "1.13.3",
|
|
54
54
|
"webpack": "4.46.0",
|
|
55
|
-
"webpack-dev-middleware": "
|
|
55
|
+
"webpack-dev-middleware": "5.2.1",
|
|
56
56
|
"webpack-hot-middleware": "2.25.1"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@namics/eslint-config": "9.1.1",
|
|
60
60
|
"eslint": "7.32.0",
|
|
61
|
-
"eslint-plugin-import": "2.25.
|
|
61
|
+
"eslint-plugin-import": "2.25.3"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|