generator-nitro 8.1.1 → 9.0.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.
@@ -343,6 +343,7 @@ module.exports = class extends Generator {
343
343
  'config/default/themes.js',
344
344
  'project/docs/nitro-themes.md',
345
345
  'project/routes/_themes.js',
346
+ 'project/viewData/_themes.js',
346
347
  'src/patterns/molecules/example/css/theme/dark.scss',
347
348
  'src/patterns/molecules/example/css/theme/light.scss',
348
349
  'src/shared/utils/colors/css/theme/dark.scss',
@@ -1 +1 @@
1
- 18.18.2
1
+ 20.9.0
@@ -6,8 +6,8 @@
6
6
  "private": true,
7
7
  "author": "The Nitro Team",
8
8
  "engines": {
9
- "node": ">=16.13.0 <21",
10
- "npm": ">=8.1.0 <11"
9
+ "node": ">=18.12.0 <21",
10
+ "npm": ">=8.19.2 <11"
11
11
  },
12
12
  "scripts": {
13
13
  "\n# PROJECT ------- ": "",
@@ -81,7 +81,7 @@
81
81
  "@gondel/core": "1.2.8",
82
82
  "@gondel/plugin-hot": "1.2.8",
83
83
  "bootstrap": "5.3.2",<% } %>
84
- "core-js": "3.33.1"<% if (options.exampleCode) { %>,
84
+ "core-js": "3.33.2"<% if (options.exampleCode) { %>,
85
85
  "flatpickr": "4.6.13",
86
86
  "handlebars": "4.7.8",
87
87
  "jquery": "3.7.1",
@@ -92,7 +92,7 @@
92
92
  "svg4everybody": "2.1.9"<% } %>
93
93
  },
94
94
  "devDependencies": {<% if (options.jsCompiler === 'js') { %>
95
- "@babel/eslint-parser": "7.22.15",<% } %>
95
+ "@babel/eslint-parser": "7.23.3",<% } %>
96
96
  "@merkle-open/eslint-config": "3.0.0",
97
97
  "@merkle-open/html-validate-config": "1.0.1",
98
98
  "@merkle-open/prettier-config": "1.2.0",
@@ -103,19 +103,19 @@
103
103
  "@nitro/gulp": "<%= version %>",
104
104
  "@nitro/webpack": "<%= version %>",
105
105
  "@playwright/test": "1.39.0",<% if (options.jsCompiler === 'ts') { %>
106
- "@types/bootstrap": "5.2.8",<% if (options.exampleCode ) { %>
107
- "@types/jquery": "3.5.24",<% } %>
108
- "@types/svg4everybody": "2.1.4",
109
- "@types/webpack-env": "1.18.3",<% } %>
106
+ "@types/bootstrap": "5.2.9",<% if (options.exampleCode ) { %>
107
+ "@types/jquery": "3.5.27",<% } %>
108
+ "@types/svg4everybody": "2.1.5",
109
+ "@types/webpack-env": "1.18.4",<% } %>
110
110
  "backstopjs": "6.2.2",
111
111
  "check-node-version": "4.2.1",
112
112
  "commitizen": "4.3.0",
113
113
  "config": "3.3.9",
114
114
  "cross-env": "7.0.3",
115
- "cypress": "13.3.2",
115
+ "cypress": "13.5.0",
116
116
  "cz-conventional-changelog": "3.3.0",
117
117
  "env-linter": "1.0.0",
118
- "eslint": "8.46.0",
118
+ "eslint": "8.53.0",
119
119
  "eslint-plugin-import": "2.29.0",
120
120
  "extend": "3.0.2",
121
121
  "generator-nitro": "<%= version %>",
@@ -123,8 +123,8 @@
123
123
  "html-validate": "7.18.1",
124
124
  "husky": "8.0.3",
125
125
  "license-checker": "25.0.1",
126
- "lighthouse": "11.2.0",
127
- "lint-staged": "14.0.1",<% if (options.themes) { %>
126
+ "lighthouse": "11.3.0",
127
+ "lint-staged": "15.0.2",<% if (options.themes) { %>
128
128
  "node-sass": "8.0.0",<% } %>
129
129
  "npm-check-updates": "16.14.6",
130
130
  "npm-run-all": "4.1.5",
@@ -4,7 +4,7 @@ module.exports = {
4
4
  presets: [[require.resolve('@babel/preset-env'), { useBuiltIns: 'usage', corejs: 3 }]],
5
5
  plugins: [
6
6
  [require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
7
- require.resolve('@babel/plugin-proposal-class-properties'),
8
7
  require.resolve('@babel/plugin-syntax-dynamic-import'),
8
+ require.resolve('@babel/plugin-transform-class-properties'),
9
9
  ],
10
10
  };
@@ -6,9 +6,9 @@ const options = {
6
6
  <% if (options.jsCompiler === 'ts') { %>js: false,
7
7
  ts: true,<% } else { %>js: true,
8
8
  ts: false,<% } %>
9
- scss: {<% if (options.themes) { %>
10
- implementation: require('node-sass'),<% } %>
11
- },
9
+ scss: <% if (options.themes) { %>{
10
+ implementation: require('node-sass'),
11
+ }<% } else { %>true<% } %>,
12
12
  hbs: <% if (options.clientTpl) { %>true<% } else { %>false<% } %>,
13
13
  woff: true,
14
14
  image: true,
@@ -198,6 +198,14 @@ server: {
198
198
 
199
199
  If set to `true`, all requests through express will be compressed.
200
200
 
201
+ ### `server.loadViewDataBeforeRoutes`
202
+
203
+ - Type: Boolean
204
+ - Default: true
205
+
206
+ If set to `true`, viewData is processed before all routes.
207
+ For backwards compatibility, you can set it to `false`, to get the loading behavior before Nitro version 9.
208
+
201
209
  ## Gulp
202
210
 
203
211
  ### `gulp.dumpViews`
@@ -1,60 +1,16 @@
1
1
  'use strict';
2
2
 
3
- const extend = require('extend');
4
- const cookieSession = require('cookie-session');
5
- const config = require('config');
6
- const validThemes = config.has('themes') && Array.isArray(config.get('themes')) ? config.get('themes') : false;
3
+ const utils = require('@nitro/app/app/lib/utils');
4
+
5
+ const validThemes = utils.getValidThemes();
7
6
 
8
7
  /**
9
- * enrich result with theme info
10
- * stores value in session cookie
8
+ * check and handle theme session on production environments
11
9
  */
12
10
 
13
- function getValidatedThemeId(theme) {
14
- if (theme && validThemes.find((t) => t.id === theme)) {
15
- return theme;
16
- }
17
-
18
- return false;
19
- }
20
-
21
- function theme(req, res, next) {
22
- // console.log('Enhancing view data with theme data');
23
-
24
- const isPage =
25
- !req.path.match(/^\/favicon.ico/) &&
26
- !req.path.match(/^\/api\//) &&
27
- !req.path.match(/^\/assets\//) &&
28
- !req.path.match(/^\/content\//) &&
29
- !req.path.match(/^\/proto\//) &&
30
- !req.path.match(/^\/reports\//) &&
31
- !req.path.match(/^\/static\//);
32
-
33
- // enrich locals with theme data on all pages
34
- if (isPage) {
35
- const theme =
36
- getValidatedThemeId(process.env.THEME) ||
37
- (req.session && req.session.theme && getValidatedThemeId(req.session.theme)) ||
38
- validThemes.find((theme) => theme.isDefault).id;
39
- const themeData = validThemes.find((t) => t.id === theme);
40
-
41
- extend(true, res.locals, { theme: themeData });
42
- }
43
-
44
- next();
45
- }
46
-
47
11
  module.exports = (app) => {
48
- if (validThemes) {
49
- // check and handle theme session on production environment
50
- if (app.get('env') === 'production') {
51
- app.use(
52
- cookieSession({
53
- name: 'theme',
54
- keys: ['keeeeeeeeeeey', 'schlüssel'],
55
- }),
56
- );
57
-
12
+ if (app.get('env') === 'production') {
13
+ if (validThemes) {
58
14
  for (const theme of validThemes) {
59
15
  app.route(`/theme/${theme.id}`).get((req, res, next) => {
60
16
  req.session.theme = theme.id;
@@ -67,7 +23,5 @@ module.exports = (app) => {
67
23
  });
68
24
  }
69
25
  }
70
-
71
- app.route('*').get(theme);
72
26
  }
73
27
  };
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ const cookieSession = require('cookie-session');
4
+ const extend = require('extend');
5
+ const utils = require('@nitro/app/app/lib/utils');
6
+ const view = require('@nitro/app/app/lib/view');
7
+
8
+ const validThemes = utils.getValidThemes();
9
+
10
+ /**
11
+ * enrich view data with theme info
12
+ */
13
+
14
+ function getValidatedThemeById(theme) {
15
+ if (theme && validThemes.find((t) => t.id === theme)) {
16
+ return theme;
17
+ }
18
+
19
+ return false;
20
+ }
21
+
22
+ function theme(req, res, next) {
23
+ // enrich locals with theme data on all pages
24
+ if (view.isView(req)) {
25
+ const theme =
26
+ getValidatedThemeById(process.env.THEME) ||
27
+ (req.session && req.session.theme && getValidatedThemeById(req.session.theme)) ||
28
+ validThemes.find((theme) => theme.isDefault).id;
29
+ const themeData = validThemes.find((t) => t.id === theme);
30
+
31
+ extend(true, res.locals, { theme: themeData });
32
+ }
33
+
34
+ next();
35
+ }
36
+
37
+ module.exports = (app) => {
38
+ if (validThemes) {
39
+ if (app.get('env') === 'production') {
40
+ app.use(
41
+ cookieSession({
42
+ name: 'theme',
43
+ keys: ['keeeeeeeeeeey', 'schlüssel'],
44
+ }),
45
+ );
46
+ }
47
+ app.route('*').all(theme);
48
+ }
49
+ };
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "generator-nitro",
3
- "version": "8.1.1",
3
+ "version": "9.0.1",
4
4
  "description": "Yeoman generator for the nitro frontend framework",
5
5
  "license": "MIT",
6
- "repository": "merkle-open/generator-nitro",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/merkle-open/generator-nitro.git"
9
+ },
7
10
  "author": "The Nitro Team",
8
11
  "engines": {
9
- "node": ">=16.13.0 <21",
10
- "npm": ">=8.1.0 <11"
12
+ "node": ">=18.12.0 <21",
13
+ "npm": ">=8.19.2 <11"
11
14
  },
12
15
  "main": "generators/app/index.js",
13
16
  "scripts": {
@@ -40,13 +43,13 @@
40
43
  "glob": "10.3.10",
41
44
  "got": "11.8.5",
42
45
  "lodash": "4.17.21",
43
- "yeoman-generator": "5.9.0",
46
+ "yeoman-generator": "5.10.0",
44
47
  "yosay": "2.0.2"
45
48
  },
46
49
  "devDependencies": {
47
50
  "@merkle-open/eslint-config": "3.0.0",
48
51
  "ejs": "3.1.9",
49
- "eslint": "8.46.0",
52
+ "eslint": "8.53.0",
50
53
  "eslint-plugin-import": "2.29.0",
51
54
  "fs-extra": "11.1.1",
52
55
  "jasmine": "5.1.0",