@nutin/cli 2.1.0 → 2.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/CHANGELOG.md +54 -0
- package/README.md +1 -1
- package/package.json +4 -4
- package/templates/base/.gitignore.hbs +1 -0
- package/templates/base/AGENTS.md.hbs +3 -2
- package/templates/base/GETTING_STARTED.md.hbs +11 -8
- package/templates/base/nutin.config.js.hbs +1 -1
- package/templates/base/src/app/components/.gitkeep +0 -0
- package/templates/base/src/app/routes.ts.hbs +2 -1
- package/templates/base/src/app/services/.gitkeep +0 -0
- package/templates/base/src/core/base-classes/base-component/helpers/children.helper.test.js.hbs +24 -0
- package/templates/base/src/core/base-classes/base-component/helpers/dom.helper.test.js.hbs +39 -0
- package/templates/base/src/core/base-classes/base-component/helpers/dom.helper.ts.hbs +14 -0
- package/templates/base/src/core/base-classes/base-component/helpers/event.helper.ts.hbs +14 -3
- package/templates/base/src/core/services/router/helpers/navigation-manager.helper.test.js.hbs +34 -0
- package/templates/base/src/core/services/router/helpers/navigation-manager.helper.ts.hbs +25 -3
- package/templates/base/src/core/services/router/router.test.js.hbs +15 -0
- package/templates/base/src/core/services/router/router.ts.hbs +19 -11
- package/templates/base/src/index.html.hbs +1 -0
- package/templates/base/src/styles/_styles.scss.hbs +1 -113
- package/templates/base/src/styles/main.scss.hbs +1 -1
- package/templates/base/tools/builder/builder.js.hbs +8 -2
- package/templates/base/tools/builder/core/html-index/add-tags.js.hbs +1 -4
- package/templates/base/tools/builder/core/html-index/add-tags.test.js.hbs +3 -3
- package/templates/base/tools/builder/core/prod-bundle/esbuild.js.hbs +11 -2
- package/templates/base/tools/builder/core/seo/generate-seo-html.js.hbs +19 -3
- package/templates/base/tools/builder/core/seo/html-substitutions.js.hbs +24 -1
- package/templates/base/tools/builder/core/seo/route-output.js.hbs +2 -2
- package/templates/base/tools/builder/core/seo/ssr/ssr-render.js.hbs +5 -1
- package/templates/base/tools/builder/core/styles/sass.js.hbs +5 -4
- package/templates/base/tools/dev/dev-serve.js.hbs +43 -4
- package/templates/base/tools/dev/watcher.js.hbs +42 -26
- package/templates/base/tools/generator/generator.js.hbs +22 -17
- package/templates/base/tools/generator/handle-file.js.hbs +0 -22
- package/templates/base/tools/generator/handle-file.test.js.hbs +1 -20
- package/templates/base/tools/utils/build-lock.js.hbs +69 -0
- package/templates/base/tools/utils/index.js.hbs +1 -0
- package/templates/features/docker/tools/docker/Dockerfile.template.hbs +2 -2
- package/templates/features/docker/tools/docker/nginx.conf.template +15 -0
- package/templates/features/docker/tools/docker/scripts/validate-docker.js.hbs +12 -0
- package/templates/base/src/app/components/index.ts.hbs +0 -1
- package/templates/base/src/app/services/index.ts.hbs +0 -1
- package/templates/base/src/app/views/index.ts.hbs +0 -3
|
@@ -42,6 +42,11 @@ server {
|
|
|
42
42
|
__PORTS_PLACEHOLDER__
|
|
43
43
|
server_name _;
|
|
44
44
|
|
|
45
|
+
# Keep nginx's own automatic redirects (e.g. the missing-trailing-slash 301 on a
|
|
46
|
+
# prerendered route directory) relative, so they never leak this container's
|
|
47
|
+
# internal port/scheme when served behind a reverse proxy or a remapped port.
|
|
48
|
+
absolute_redirect off;
|
|
49
|
+
|
|
45
50
|
# ---------------------------
|
|
46
51
|
# ROOT + ROUTING
|
|
47
52
|
# ---------------------------
|
|
@@ -51,6 +56,10 @@ server {
|
|
|
51
56
|
# Hide nginx version
|
|
52
57
|
server_tokens off;
|
|
53
58
|
|
|
59
|
+
# With i18n enabled, redirects bare "/" to the default language so the served URL
|
|
60
|
+
# always matches each page's canonical/og:url (filled in by validate-docker).
|
|
61
|
+
__ROOT_REDIRECT_PLACEHOLDER__
|
|
62
|
+
|
|
54
63
|
# SPA routing: serve index.html for unknown paths
|
|
55
64
|
location / {
|
|
56
65
|
try_files $uri $uri/ /index.html;
|
|
@@ -112,6 +121,12 @@ server {
|
|
|
112
121
|
# --------------------------
|
|
113
122
|
error_page 404 /404.html;
|
|
114
123
|
|
|
124
|
+
# A route directory that exists on disk but has no index.html of its own (e.g. a
|
|
125
|
+
# parent route whose only prerendered pages are its children) makes try_files'
|
|
126
|
+
# $uri/ candidate match the directory and stop there, returning 403 instead of
|
|
127
|
+
# falling through to the SPA shell. Serve the shell for that case too.
|
|
128
|
+
error_page 403 = /index.html;
|
|
129
|
+
|
|
115
130
|
location = /404.html {
|
|
116
131
|
internal;
|
|
117
132
|
try_files /404.html =404;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
1
2
|
import path from 'path';
|
|
2
3
|
import { errorExit } from '../../utils/index.js';
|
|
3
4
|
import nutinConfig from '../../../nutin.config.js';
|
|
@@ -6,6 +7,16 @@ import { renderFromTemplate } from './render-docker-template.js';
|
|
|
6
7
|
|
|
7
8
|
const DOCKER_DIR = path.join(process.cwd(), 'tools', 'docker');
|
|
8
9
|
const PLACEHOLDER = '__PORTS_PLACEHOLDER__';
|
|
10
|
+
const ROOT_REDIRECT_PLACEHOLDER = '__ROOT_REDIRECT_PLACEHOLDER__';
|
|
11
|
+
|
|
12
|
+
// Only i18n builds serve every page under a language prefix — without it, "/" is a real page.
|
|
13
|
+
function rootRedirect() {
|
|
14
|
+
if (!nutinConfig.i18n) return '';
|
|
15
|
+
|
|
16
|
+
const languagesConfigPath = path.join(process.cwd(), 'config', 'languages.json');
|
|
17
|
+
const { defaultLanguage } = JSON.parse(fs.readFileSync(languagesConfigPath, 'utf-8'));
|
|
18
|
+
return `location = / {\n return 301 /${defaultLanguage}/$is_args$args;\n }`;
|
|
19
|
+
}
|
|
9
20
|
|
|
10
21
|
async function validateDocker() {
|
|
11
22
|
let ports;
|
|
@@ -22,6 +33,7 @@ async function validateDocker() {
|
|
|
22
33
|
|
|
23
34
|
await renderFromTemplate(DOCKER_DIR, 'nginx.conf.template', 'nginx.conf', [
|
|
24
35
|
[PLACEHOLDER, ports.map((port) => `listen ${port};`).join('\n ')],
|
|
36
|
+
[ROOT_REDIRECT_PLACEHOLDER, rootRedirect()],
|
|
25
37
|
]).catch((err) => errorExit(err.message));
|
|
26
38
|
}
|
|
27
39
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// global components export
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// global services export
|