@nitro/app 10.0.3 → 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.
@@ -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: {
@@ -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
- const wildcard = '*';
32
- const patternBasePaths = Object.keys(config.get('nitro.patterns')).map((key) => {
33
- return config.get(`nitro.patterns.${key}.path`);
34
- });
35
- const patternGlobs = patternBasePaths
36
- .map((patternBasePath) => {
37
- return `${patternBasePath}/${wildcard}`;
38
- })
39
- .concat(
40
- patternBasePaths.map((patternBasePath) => {
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
- const logMissingSchemaAsError = config.has('code.validation.jsonSchema.logMissingSchemaAsError')
45
- ? config.get('code.validation.jsonSchema.logMissingSchemaAsError')
46
- : false;
47
- const logMissingSchemaAsWarning = config.has('code.validation.jsonSchema.logMissingSchemaAsWarning')
48
- ? config.get('code.validation.jsonSchema.logMissingSchemaAsWarning')
49
- : true;
50
-
51
- let errorCouter = 0;
52
- let patternCouter = 0;
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
69
- globby.sync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
70
- const schemaFilePath = `${patternPath}/schema.json`;
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
- return true;
83
- }
68
+ });
84
69
 
85
- globby.sync([`${patternPath}/_data/${wildcard}.json`]).forEach((patternDataFilePath) => {
86
- const patternData = JSON.parse(fs.readFileSync(patternDataFilePath, 'utf8'));
87
- const schema = JSON.parse(fs.readFileSync(schemaFilePath, 'utf8'));
70
+ // validate pattern data
71
+ globbySync(patternGlobs, { onlyFiles: false }).forEach((patternPath) => {
72
+ const schemaFilePath = `${patternPath}/schema.json`;
73
+ patternCounter++;
88
74
 
89
- // console.log(`validate ${schemaFilePath} with ${patternDataFilePath}`);
90
- const schemaToUse = schema.$id || schema;
91
- const valid = ajv.validate(schemaToUse, patternData);
92
- if (!valid) {
93
- errorCouter += 1;
94
- console.log(`${clc.red('Error')} (${patternDataFilePath}): ${ajv.errorsText()}`);
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 (errorCouter <= 0) {
100
- console.log(`${clc.green('Success:')} all data from each of the ${patternCouter} patterns are valid!\n`);
101
- } else {
102
- console.log(`${clc.red('Error:')} we detected ${errorCouter} errors in your data.\n`);
103
- process.exitCode = 1;
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
- globby.sync(elementGlobs).forEach((templatePath) => {
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
- globby.sync(elementGlobs).forEach((templatePath) => {
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
- globby.sync(elementGlobs).forEach((templatePath) => {
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": "10.0.3",
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": ">=20.18.1 <21",
13
- "npm": ">=10.8.2 <11"
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",
@@ -33,34 +33,36 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "ajv": "8.17.1",
36
- "body-parser": "2.2.1",
36
+ "body-parser": "2.2.2",
37
37
  "cli-color": "2.0.4",
38
38
  "compression": "1.8.1",
39
39
  "cookie-session": "2.1.1",
40
- "config": "4.1.1",
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": "11.1.0",
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.7.2",
49
- "i18next-http-middleware": "3.9.0",
48
+ "i18next": "25.8.6",
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": "5.13.0",
53
- "jasmine-core": "5.13.0",
54
- "lodash": "4.17.21",
52
+ "jasmine": "6.0.0",
53
+ "lodash": "4.17.23",
55
54
  "twig": "1.13.3",
56
- "webpack": "4.47.0",
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"