@nitro/app 10.0.4 → 11.0.0-beta.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 +1 -5
- package/app/core/router.js +0 -2
- package/app/scripts/validate-pattern-data.js +75 -70
- package/app/templating/hbs/helpers/pattern.js +7 -2
- package/app/templating/twig/helpers/component.js +7 -2
- package/app/templating/twig/helpers/pattern.js +7 -2
- package/package.json +13 -11
package/app/core/config.js
CHANGED
|
@@ -19,7 +19,6 @@ const defaultConfig = {
|
|
|
19
19
|
templateEngine: 'hbs',
|
|
20
20
|
mode: {
|
|
21
21
|
livereload: true,
|
|
22
|
-
offline: false,
|
|
23
22
|
test: !!(process.env.NITRO_MODE && process.env.NITRO_MODE.replace(/\s/g, '') === 'test'),
|
|
24
23
|
},
|
|
25
24
|
watch: {
|
|
@@ -40,10 +39,6 @@ const defaultConfig = {
|
|
|
40
39
|
},
|
|
41
40
|
server: {
|
|
42
41
|
port: 8080,
|
|
43
|
-
proxy: {
|
|
44
|
-
port: 8081,
|
|
45
|
-
https: false,
|
|
46
|
-
},
|
|
47
42
|
production: !!(process.env.NODE_ENV && process.env.NODE_ENV.replace(/\s/g, '') === 'production'),
|
|
48
43
|
compression: true,
|
|
49
44
|
projectPaths: [
|
|
@@ -125,6 +120,7 @@ const defaultConfig = {
|
|
|
125
120
|
lookupQuerystring: 'lang',
|
|
126
121
|
},
|
|
127
122
|
// compatibilityJSON: 'v3',
|
|
123
|
+
showSupportNotice: false,
|
|
128
124
|
debug: false
|
|
129
125
|
},
|
|
130
126
|
middlewareOptions: {
|
package/app/core/router.js
CHANGED
|
@@ -15,7 +15,6 @@ const router = express.Router({
|
|
|
15
15
|
});
|
|
16
16
|
const isProduction = config.get('server.production');
|
|
17
17
|
const isTest = config.get('nitro.mode.test');
|
|
18
|
-
const isOffline = config.get('nitro.mode.offline');
|
|
19
18
|
const view404 = config.get('nitro.view404');
|
|
20
19
|
|
|
21
20
|
/**
|
|
@@ -34,7 +33,6 @@ function getNitroViewData(pageTitle, req) {
|
|
|
34
33
|
pageTitle,
|
|
35
34
|
production: isProduction,
|
|
36
35
|
test: isTest,
|
|
37
|
-
offline: isOffline,
|
|
38
36
|
},
|
|
39
37
|
};
|
|
40
38
|
}
|
|
@@ -24,81 +24,86 @@
|
|
|
24
24
|
*/
|
|
25
25
|
const clc = require('cli-color');
|
|
26
26
|
const fs = require('fs');
|
|
27
|
-
const globby = require('globby');
|
|
28
27
|
const Ajv = require('ajv');
|
|
29
|
-
const ajv = new Ajv({ allErrors: true });
|
|
30
28
|
const config = require('config');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
return `${patternBasePath}/${wildcard}/elements/${wildcard}`;
|
|
42
|
-
})
|
|
29
|
+
|
|
30
|
+
(async () => {
|
|
31
|
+
|
|
32
|
+
const { globbySync } = await import('globby');
|
|
33
|
+
|
|
34
|
+
const ajv = new Ajv({ allErrors: true });
|
|
35
|
+
const wildcard = '*';
|
|
36
|
+
|
|
37
|
+
const patternBasePaths = Object.keys(config.get('nitro.patterns')).map((key) =>
|
|
38
|
+
config.get(`nitro.patterns.${key}.path`)
|
|
43
39
|
);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
patternCouter += 1;
|
|
72
|
-
|
|
73
|
-
if (!fs.existsSync(schemaFilePath)) {
|
|
74
|
-
if (logMissingSchemaAsError) {
|
|
75
|
-
console.log(`${clc.red('Error')} (${patternPath}): no schema file found`);
|
|
76
|
-
errorCouter += 1;
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
if (logMissingSchemaAsWarning) {
|
|
80
|
-
console.log(`${clc.yellow('Warn')} (${patternPath}): no schema file found`);
|
|
40
|
+
|
|
41
|
+
const patternGlobs = patternBasePaths
|
|
42
|
+
.map((p) => `${p}/${wildcard}`)
|
|
43
|
+
.concat(patternBasePaths.map((p) => `${p}/${wildcard}/elements/${wildcard}`));
|
|
44
|
+
|
|
45
|
+
const logMissingSchemaAsError = config.has('code.validation.jsonSchema.logMissingSchemaAsError')
|
|
46
|
+
? config.get('code.validation.jsonSchema.logMissingSchemaAsError')
|
|
47
|
+
: false;
|
|
48
|
+
|
|
49
|
+
const logMissingSchemaAsWarning = config.has('code.validation.jsonSchema.logMissingSchemaAsWarning')
|
|
50
|
+
? config.get('code.validation.jsonSchema.logMissingSchemaAsWarning')
|
|
51
|
+
: true;
|
|
52
|
+
|
|
53
|
+
let errorCounter = 0;
|
|
54
|
+
let patternCounter = 0;
|
|
55
|
+
|
|
56
|
+
// collect all schemas
|
|
57
|
+
globbySync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
|
|
58
|
+
const schemaFilePath = `${patternPath}/schema.json`;
|
|
59
|
+
|
|
60
|
+
if (fs.existsSync(schemaFilePath)) {
|
|
61
|
+
// console.log(`Add ${schemaFilePath}`);
|
|
62
|
+
const schema = JSON.parse(fs.readFileSync(schemaFilePath, 'utf8'));
|
|
63
|
+
if (schema.$id) {
|
|
64
|
+
// ajv.addSchema(schema);
|
|
65
|
+
ajv.addMetaSchema(schema);
|
|
66
|
+
}
|
|
81
67
|
}
|
|
82
|
-
|
|
83
|
-
}
|
|
68
|
+
});
|
|
84
69
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
70
|
+
// validate pattern data
|
|
71
|
+
globbySync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
|
|
72
|
+
const schemaFilePath = `${patternPath}/schema.json`;
|
|
73
|
+
patternCounter++;
|
|
88
74
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
75
|
+
if (!fs.existsSync(schemaFilePath)) {
|
|
76
|
+
if (logMissingSchemaAsError) {
|
|
77
|
+
console.log(`${clc.red('Error')} (${patternPath}): no schema file found`);
|
|
78
|
+
errorCounter++;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (logMissingSchemaAsWarning) {
|
|
82
|
+
console.log(`${clc.yellow('Warn')} (${patternPath}): no schema file found`);
|
|
83
|
+
}
|
|
84
|
+
return;
|
|
95
85
|
}
|
|
86
|
+
|
|
87
|
+
globbySync([`${patternPath}/_data/${wildcard}.json`]).forEach((dataPath) => {
|
|
88
|
+
const patternData = JSON.parse(fs.readFileSync(dataPath, 'utf8'));
|
|
89
|
+
const schema = JSON.parse(fs.readFileSync(schemaFilePath, 'utf8'));
|
|
90
|
+
const schemaToApply = schema.$id || schema;
|
|
91
|
+
|
|
92
|
+
// console.log(`validate ${schemaFilePath} with ${dataPath}`);
|
|
93
|
+
const valid = ajv.validate(schemaToApply, patternData);
|
|
94
|
+
if (!valid) {
|
|
95
|
+
errorCounter++;
|
|
96
|
+
console.log(`${clc.red('Error')} (${dataPath}): ${ajv.errorsText()}`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
96
99
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
} else {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
100
|
+
|
|
101
|
+
// summary
|
|
102
|
+
if (errorCounter === 0) {
|
|
103
|
+
console.log(`${clc.green('Success:')} all data from each of the ${patternCounter} patterns are valid!\n`);
|
|
104
|
+
} else {
|
|
105
|
+
console.log(`${clc.red('Error:')} we detected ${errorCounter} errors in your data.\n`);
|
|
106
|
+
process.exitCode = 1;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
})();
|
|
@@ -19,13 +19,18 @@ const fs = require('fs');
|
|
|
19
19
|
const hbs = require('hbs');
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const extend = require('extend');
|
|
22
|
-
const globby = require('globby');
|
|
23
22
|
const Ajv = require('ajv');
|
|
24
23
|
const ajv = new Ajv({ allErrors: true });
|
|
25
24
|
const config = require('config');
|
|
26
25
|
const hbsUtils = require('../utils');
|
|
27
26
|
const lint = require('../../../lib/lint');
|
|
28
27
|
|
|
28
|
+
let globbySync;
|
|
29
|
+
(async () => {
|
|
30
|
+
const globbyMod = await import('globby');
|
|
31
|
+
globbySync = globbyMod.globbySync;
|
|
32
|
+
})();
|
|
33
|
+
|
|
29
34
|
function getPatternBasePaths(type) {
|
|
30
35
|
let patternTypeKeys;
|
|
31
36
|
|
|
@@ -96,7 +101,7 @@ function getPattern(folder, templateFile, dataFile, type) {
|
|
|
96
101
|
return `${patternBasePath}/*/elements/${folder}/${templateFile}.${config.get('nitro.viewFileExtension')}`;
|
|
97
102
|
});
|
|
98
103
|
|
|
99
|
-
|
|
104
|
+
globbySync(elementGlobs).forEach((templatePath) => {
|
|
100
105
|
if (!pattern) {
|
|
101
106
|
pattern = {
|
|
102
107
|
templateFilePath: templatePath,
|
|
@@ -11,13 +11,18 @@
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const extend = require('extend');
|
|
14
|
-
const globby = require('globby');
|
|
15
14
|
const Ajv = require('ajv');
|
|
16
15
|
const ajv = new Ajv({ allErrors: true });
|
|
17
16
|
const config = require('config');
|
|
18
17
|
const twigUtils = require('../utils');
|
|
19
18
|
const lint = require('../../../lib/lint');
|
|
20
19
|
|
|
20
|
+
let globbySync;
|
|
21
|
+
(async () => {
|
|
22
|
+
const globbyMod = await import('globby');
|
|
23
|
+
globbySync = globbyMod.globbySync;
|
|
24
|
+
})();
|
|
25
|
+
|
|
21
26
|
const patternBasePaths = Object.keys(config.get('nitro.patterns')).map((key) => {
|
|
22
27
|
const configKey = `nitro.patterns.${key}.path`;
|
|
23
28
|
const patternPath = config.has(configKey) ? config.get(configKey) : false;
|
|
@@ -71,7 +76,7 @@ function getPattern(folder, templateFile, dataFile) {
|
|
|
71
76
|
return `${patternBasePath}/*/elements/${folder}/${templateFile}.${config.get('nitro.viewFileExtension')}`;
|
|
72
77
|
});
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
globbySync(elementGlobs).forEach((templatePath) => {
|
|
75
80
|
if (pattern) {
|
|
76
81
|
throw new Error(`You have multiple elements defined with the name \`${folder}\``);
|
|
77
82
|
} else {
|
|
@@ -11,13 +11,18 @@
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const extend = require('extend');
|
|
14
|
-
const globby = require('globby');
|
|
15
14
|
const Ajv = require('ajv');
|
|
16
15
|
const ajv = new Ajv({ allErrors: true });
|
|
17
16
|
const config = require('config');
|
|
18
17
|
const twigUtils = require('../utils');
|
|
19
18
|
const lint = require('../../../lib/lint');
|
|
20
19
|
|
|
20
|
+
let globbySync;
|
|
21
|
+
(async () => {
|
|
22
|
+
const globbyMod = await import('globby');
|
|
23
|
+
globbySync = globbyMod.globbySync;
|
|
24
|
+
})();
|
|
25
|
+
|
|
21
26
|
const patternBasePaths = Object.keys(config.get('nitro.patterns')).map((key) => {
|
|
22
27
|
const configKey = `nitro.patterns.${key}.path`;
|
|
23
28
|
const patternPath = config.has(configKey) ? config.get(configKey) : false;
|
|
@@ -71,7 +76,7 @@ function getPattern(folder, templateFile, dataFile) {
|
|
|
71
76
|
return `${patternBasePath}/*/elements/${folder}/${templateFile}.${config.get('nitro.viewFileExtension')}`;
|
|
72
77
|
});
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
globbySync(elementGlobs).forEach((templatePath) => {
|
|
75
80
|
if (pattern) {
|
|
76
81
|
throw new Error(`You have multiple elements defined with the name \`${folder}\``);
|
|
77
82
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nitro/app",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-beta.1",
|
|
4
4
|
"description": "Nitro server",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"author": "The Nitro Team",
|
|
11
11
|
"engines": {
|
|
12
|
-
"node": ">=
|
|
13
|
-
"npm": ">=10.
|
|
12
|
+
"node": ">=22.11.0 <25",
|
|
13
|
+
"npm": ">=10.9.0 <12"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
16
|
"nitro-app-validate-pattern-data": "bin/validate-pattern-data.js",
|
|
@@ -37,30 +37,32 @@
|
|
|
37
37
|
"cli-color": "2.0.4",
|
|
38
38
|
"compression": "1.8.1",
|
|
39
39
|
"cookie-session": "2.1.1",
|
|
40
|
-
"config": "4.2.
|
|
40
|
+
"config": "4.2.1",
|
|
41
41
|
"dot-object": "2.1.5",
|
|
42
42
|
"express": "4.22.1",
|
|
43
43
|
"extend": "3.0.2",
|
|
44
|
-
"globby": "
|
|
44
|
+
"globby": "16.1.0",
|
|
45
45
|
"hbs": "4.2.0",
|
|
46
46
|
"hbs-utils": "0.0.4",
|
|
47
47
|
"html-validate": "7.18.1",
|
|
48
|
-
"i18next": "25.8.
|
|
48
|
+
"i18next": "25.8.6",
|
|
49
49
|
"i18next-http-middleware": "3.9.2",
|
|
50
50
|
"i18next-fs-backend": "2.6.1",
|
|
51
51
|
"i18next-sprintf-postprocessor": "0.2.2",
|
|
52
|
-
"jasmine": "
|
|
53
|
-
"jasmine-core": "5.13.0",
|
|
52
|
+
"jasmine": "6.0.0",
|
|
54
53
|
"lodash": "4.17.23",
|
|
55
54
|
"twig": "1.13.3",
|
|
56
|
-
"webpack": "4.
|
|
57
|
-
"webpack-dev-middleware": "5.3.4",
|
|
55
|
+
"webpack-dev-middleware": "7.4.5",
|
|
58
56
|
"webpack-hot-middleware": "2.26.1"
|
|
59
57
|
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"webpack": "^5"
|
|
60
|
+
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@merkle-open/eslint-config": "4.0.1",
|
|
62
63
|
"eslint": "8.57.1",
|
|
63
|
-
"eslint-plugin-import": "2.32.0"
|
|
64
|
+
"eslint-plugin-import": "2.32.0",
|
|
65
|
+
"webpack": "5.105.2"
|
|
64
66
|
},
|
|
65
67
|
"publishConfig": {
|
|
66
68
|
"access": "public"
|