nibula 1.6.0 → 1.6.2

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.
Files changed (99) hide show
  1. package/.eleventy.js +82 -81
  2. package/CHANGELOG.md +395 -377
  3. package/LICENSE +169 -169
  4. package/NOTICE +4 -4
  5. package/README.md +110 -110
  6. package/bin/create.js +540 -505
  7. package/bin/delegate.js +58 -57
  8. package/bin/nibula.js +302 -302
  9. package/docs/Assistant CLI.md +65 -65
  10. package/docs/Backend.md +201 -201
  11. package/docs/Components.md +140 -140
  12. package/docs/Creating pages.md +69 -69
  13. package/docs/Deploy.md +210 -210
  14. package/docs/Head and SEO.md +139 -139
  15. package/docs/Javascript.md +126 -126
  16. package/docs/Styling with SCSS.md +141 -139
  17. package/nginx.conf +113 -113
  18. package/package.json +69 -69
  19. package/src/backend/.htaccess +6 -6
  20. package/src/backend/_core/composer.json +5 -5
  21. package/src/backend/_core/composer.lock +492 -492
  22. package/src/backend/_core/index.js +267 -267
  23. package/src/backend/_core/index.php +160 -160
  24. package/src/backend/_core/init.js +52 -52
  25. package/src/backend/_core/init.php +33 -33
  26. package/src/backend/_core/modules/RateLimiter.js +58 -58
  27. package/src/backend/_core/modules/RateLimiter.php +30 -30
  28. package/src/backend/_core/modules/Response.js +59 -59
  29. package/src/backend/_core/modules/Response.php +48 -48
  30. package/src/backend/api/protected/example-protected.js +23 -23
  31. package/src/backend/api/protected/example-protected.php +16 -16
  32. package/src/backend/api/public/example-public.js +24 -24
  33. package/src/backend/api/public/example-public.php +16 -16
  34. package/src/backend/database/Database.js +46 -46
  35. package/src/backend/database/Database.php +23 -23
  36. package/src/backend/example.config.js +37 -37
  37. package/src/backend/example.config.php +37 -37
  38. package/src/backend/package.json +17 -17
  39. package/src/backend/web.config +43 -43
  40. package/src/frontend/.htaccess +51 -51
  41. package/src/frontend/404.njk +17 -17
  42. package/src/frontend/assets/brand/favicon.svg +54 -54
  43. package/src/frontend/assets/brand/logo.svg +54 -54
  44. package/src/frontend/components/global/footer.njk +25 -25
  45. package/src/frontend/components/global/header.njk +6 -6
  46. package/src/frontend/components/welcome.njk +115 -115
  47. package/src/frontend/index.njk +8 -8
  48. package/src/frontend/js/global.js +10 -10
  49. package/src/frontend/js/modules/exampleModule.js +2 -2
  50. package/src/frontend/js/pages/404.js +8 -8
  51. package/src/frontend/js/pages/homepage.js +8 -8
  52. package/src/frontend/layouts/base.njk +135 -136
  53. package/src/frontend/layouts/page-components.njk +13 -13
  54. package/src/frontend/llms.njk +17 -17
  55. package/src/frontend/robots.njk +7 -7
  56. package/src/frontend/scss/_global.scss +46 -46
  57. package/src/frontend/scss/_root.scss +13 -13
  58. package/src/frontend/scss/modules/_animations.scss +24 -24
  59. package/src/frontend/scss/modules/_footer.scss +28 -28
  60. package/src/frontend/scss/modules/_header.scss +26 -26
  61. package/src/frontend/scss/modules/_mobile.scss +29 -29
  62. package/src/frontend/scss/modules/_typography.scss +18 -18
  63. package/src/frontend/scss/modules/frameworks/_bootstrap.scss +109 -109
  64. package/src/frontend/scss/modules/frameworks/_bulma.scss +108 -108
  65. package/src/frontend/scss/modules/frameworks/_foundation.scss +137 -137
  66. package/src/frontend/scss/modules/frameworks/_uikit.scss +109 -109
  67. package/src/frontend/scss/pages/404.scss +27 -27
  68. package/src/frontend/scss/pages/homepage.scss +22 -22
  69. package/src/frontend/sitemap.njk +17 -17
  70. package/src/frontend/ts/global.ts +11 -11
  71. package/src/frontend/ts/modules/exampleModule.ts +2 -2
  72. package/src/frontend/ts/pages/404.ts +8 -8
  73. package/src/frontend/ts/pages/homepage.ts +8 -8
  74. package/src/frontend/web.config +51 -51
  75. package/tools/assistant.js +122 -122
  76. package/tools/buildJs.js +39 -39
  77. package/tools/cleanOutput.js +23 -23
  78. package/tools/cli/prompt.js +40 -40
  79. package/tools/cli/ui.js +87 -87
  80. package/tools/config/messages.json +80 -80
  81. package/tools/config/settings.json +130 -130
  82. package/tools/lib/colors.js +17 -17
  83. package/tools/lib/files.js +75 -75
  84. package/tools/lib/logger.js +22 -22
  85. package/tools/lib/outputPath.js +141 -141
  86. package/tools/lib/pageActions.js +146 -146
  87. package/tools/lib/pageArtifacts.js +46 -46
  88. package/tools/lib/pageComponents.js +88 -88
  89. package/tools/lib/pagesData.js +87 -87
  90. package/tools/lib/paths.js +63 -63
  91. package/tools/lib/project.js +54 -54
  92. package/tools/lib/text.js +47 -47
  93. package/tools/lib/validation.js +40 -40
  94. package/tools/res/templates/template.js +7 -7
  95. package/tools/res/templates/template.njk +8 -8
  96. package/tools/res/templates/template.scss +22 -22
  97. package/tools/res/templates/template.ts +8 -8
  98. package/tsconfig.json +24 -24
  99. package/src/frontend/scss/pages/prova.scss +0 -23
package/docs/Deploy.md CHANGED
@@ -1,211 +1,211 @@
1
- # Deploy
2
-
3
- Nibula builds a static site into `out`. Publishing means uploading that folder to
4
- a web server. What you need depends on **where** you publish and **which
5
- backend** you chose (see `docs/Backend.md`).
6
-
7
- ## The one constraint that decides everything
8
-
9
- The two backends run in fundamentally different ways:
10
-
11
- - **PHP** is executed **per request** by the web server through PHP-FPM. There is
12
- no process to keep alive — the server starts it, it answers, it exits.
13
- - **Node** **is** the server: a long-running process listening on
14
- `127.0.0.1:3000`, which the web server reverse-proxies `/api` to. Something has
15
- to start it and keep it alive across reboots and crashes.
16
-
17
- This is why **shared hosting cannot run the Node backend**. On Aruba, cPanel and
18
- similar, you upload files into a web root — you have no shell to start a daemon,
19
- no systemd, and any process you did manage to launch would be killed. If your
20
- host is shared hosting, choose PHP. It is not a limitation of Nibula.
21
-
22
- ## Where you can publish
23
-
24
- | Target | Frontend | PHP backend | Node backend |
25
- |---|---|---|---|
26
- | Shared hosting (Apache — Aruba, cPanel) | ✅ | ✅ | ❌ no persistent process |
27
- | Windows hosting (IIS) | ✅ | ✅ FastCGI | ⚠️ needs ARR reverse proxy |
28
- | Your own VPS (Nginx on Ubuntu) | ✅ | ✅ | ✅ |
29
- | Static hosting (Netlify, Vercel, GitHub Pages) | ✅ | ❌ | ❌ |
30
-
31
- Static hosting serves files and nothing else — fine if your site has no `/api`
32
- endpoints, unusable otherwise.
33
-
34
- ## Requirements
35
-
36
- **PHP backend:** a server with PHP support and Composer for the backend
37
- dependencies.
38
-
39
- **Node backend:** Node.js 18+ and shell access to run a persistent process — a
40
- VPS you control.
41
-
42
- ---
43
-
44
- ## Shared hosting (Apache)
45
-
46
- Upload the **contents of `out`** to the web root (often `htdocs`, `public_html`
47
- or `www`). Done — `.htaccess` is already inside `out` and Apache reads it
48
- automatically: directory listing off, 403/404 → `/404.html`, sensitive files
49
- blocked, backend source sealed, `/api/*` routed.
50
-
51
- **Backend routing:** if `mod_proxy` is available, `/api` is proxied to Node on
52
- `127.0.0.1:3000`; if not — the usual case on shared hosting — `/api` is
53
- rewritten to the PHP front controller. To force PHP on a proxy-enabled server,
54
- comment the `mod_proxy` block in `.htaccess`.
55
-
56
- ## Windows hosting (IIS)
57
-
58
- Same idea: upload the contents of `out`, `web.config` is already there and read
59
- automatically.
60
-
61
- **Backend routing:** `/api` is rewritten to the PHP front controller. To use the
62
- Node backend instead, uncomment the `ApiToNode` rule in `web.config` and delete
63
- `ApiToPhp` — this needs the ARR and URL Rewrite modules with proxying enabled,
64
- so a server you control, not shared hosting.
65
-
66
- > ⚠️ **If you chose the Node backend and your host has no ARR** (Aruba and other
67
- > Windows shared hosting), don't upload the `backend` folder at all. The static
68
- > site works, and `/api/*` answers with your `404.html`. Upload it and every
69
- > `/api` request returns an empty 404 instead: IIS rewrites it onto the PHP
70
- > front controller, which a Node project doesn't contain.
71
-
72
- ---
73
-
74
- ## Your own server (Nginx on a VPS)
75
-
76
- Nginx doesn't read per-directory config files — the whole site lives in one file.
77
- Nibula ships `nginx.conf` in the project root as a ready-to-use site file that
78
- **covers both backends without edits**: `/api` goes to Node, and if Node is
79
- unreachable the request falls through to PHP automatically.
80
-
81
- Upload the contents of `out` to `/var/www/SITE_FOLDER`, then follow the steps
82
- below.
83
-
84
- ### 1. Replace
85
-
86
- | Placeholder | Where |
87
- |---|---|
88
- | `YOUR_DOMAIN` | `server_name`, twice (port 80 and 443) |
89
- | `SITE_FOLDER` | document root under `/var/www/` |
90
- | `YOUR_CERTIFICATE` | dir under `/etc/letsencrypt/live/` |
91
- | `SITE_NAME` | file name in the commands below |
92
-
93
- ### 2. Install (skip if already present)
94
-
95
- ```bash
96
- sudo apt update
97
- sudo apt install -y nginx certbot python3-certbot-nginx
98
- ```
99
-
100
- If you are using PHP as backend:
101
-
102
- ```bash
103
- sudo apt install -y php-fpm
104
- ```
105
-
106
- ### 3. Certificate
107
-
108
- ```bash
109
- sudo certbot certonly --nginx --cert-name SITE_NAME -d YOUR_DOMAIN
110
- sudo systemctl enable --now certbot.timer # auto-renew every 90 days
111
- ```
112
-
113
- ### 4. Install the site
114
-
115
- ```bash
116
- # Move to nginx folders
117
- cd /etc/nginx/sites-available
118
-
119
- # Create and write a new file
120
- sudo nano SITE_NAME
121
- # CTRL + O, ENTER, CTRL + X
122
-
123
- # Copy the config to sites-enabled
124
- sudo cp SITE_NAME ../sites-enabled/
125
-
126
- # Test and reload the nginx configuration
127
- sudo nginx -t && sudo systemctl reload nginx
128
- ```
129
-
130
- ### If it fails
131
-
132
- | Symptom | Cause |
133
- |---|---|
134
- | `cannot load certificate ... Permission denied` | `nginx -t` needs sudo |
135
- | `cannot load certificate ... No such file` | wrong certificate name |
136
- | `no alternative certificate subject name` | certificate doesn't cover domain |
137
- | `unknown directive "http2"` | nginx < 1.25, check with `nginx -v` |
138
- | NXDOMAIN / timeout during certbot | DNS not pointing here |
139
- | 500 instead of the 404 page | `404.html` missing |
140
- | 502 on `/api`, Node deployed | Node process not running |
141
- | 502 on `/api`, PHP deployed | wrong php-fpm socket path |
142
-
143
- ---
144
-
145
- ## Starting the Node backend on the server
146
-
147
- After uploading `out`:
148
-
149
- 1. Install the backend's runtime deps:
150
- ```bash
151
- cd /var/www/SITE_FOLDER/backend
152
- npm install
153
- ```
154
-
155
- 2. Make sure `config.js` exists in `out/backend/` (copy `example.config.js` if
156
- missing) and fill in your values.
157
-
158
- 3. Start it in a new screen:
159
- ```bash
160
- screen -S node-backend
161
- # In the new screen terminal:
162
- sudo node /var/www/SITE_FOLDER/backend/_core/index.js
163
- curl http://127.0.0.1:3000/api/example-public
164
- ```
165
-
166
- 4. Exit the screen without closing the process with `CTRL + A`, `D`. To resume
167
- the screen type `screen -r node-backend`.
168
-
169
- 5. For production use **systemd**, which also restarts on crash and reboot.
170
- Create `/etc/systemd/system/backend-node.service`:
171
-
172
- ```ini
173
- [Unit]
174
- Description=Nibula Node backend
175
- After=network.target
176
-
177
- [Service]
178
- Type=simple
179
- User=www-data
180
- WorkingDirectory=/var/www/SITE_FOLDER/backend
181
- ExecStart=/usr/bin/node /var/www/SITE_FOLDER/backend/_core/index.js
182
- Restart=always
183
- RestartSec=5
184
-
185
- [Install]
186
- WantedBy=multi-user.target
187
- ```
188
-
189
- Adjust `WorkingDirectory` and the `node` path (`which node`), then:
190
-
191
- ```bash
192
- sudo systemctl daemon-reload
193
- sudo systemctl enable --now backend-node
194
- sudo systemctl status backend-node
195
- ```
196
-
197
- (`pm2` works too: `pm2 start _core/index.js --name backend-node`.)
198
-
199
- ### Environment variables
200
-
201
- Read by the Node backend at startup. Set them in the systemd unit with
202
- `Environment=KEY=value`.
203
-
204
- | Variable | Default | Purpose |
205
- |---|---|---|
206
- | `PORT` | `3000` | Port Node listens on (must match the proxy target in `nginx.conf`) |
207
- | `HOST` | `127.0.0.1` | Bind address — keep it local; the web server is the public face |
208
- | `DOCUMENT_ROOT` | auto (`SITE_FOLDER/`) | Where `404.html` lives; detected as the folder above `backend/` |
209
-
210
- Error verbosity is **not** an environment variable: it is the `APP_ENV` key in
1
+ # Deploy
2
+
3
+ Nibula builds a static site into `out`. Publishing means uploading that folder to
4
+ a web server. What you need depends on **where** you publish and **which
5
+ backend** you chose (see `docs/Backend.md`).
6
+
7
+ ## The one constraint that decides everything
8
+
9
+ The two backends run in fundamentally different ways:
10
+
11
+ - **PHP** is executed **per request** by the web server through PHP-FPM. There is
12
+ no process to keep alive — the server starts it, it answers, it exits.
13
+ - **Node** **is** the server: a long-running process listening on
14
+ `127.0.0.1:3000`, which the web server reverse-proxies `/api` to. Something has
15
+ to start it and keep it alive across reboots and crashes.
16
+
17
+ This is why **shared hosting cannot run the Node backend**. On Aruba, cPanel and
18
+ similar, you upload files into a web root — you have no shell to start a daemon,
19
+ no systemd, and any process you did manage to launch would be killed. If your
20
+ host is shared hosting, choose PHP. It is not a limitation of Nibula.
21
+
22
+ ## Where you can publish
23
+
24
+ | Target | Frontend | PHP backend | Node backend |
25
+ |---|---|---|---|
26
+ | Shared hosting (Apache — Aruba, cPanel) | ✅ | ✅ | ❌ no persistent process |
27
+ | Windows hosting (IIS) | ✅ | ✅ FastCGI | ⚠️ needs ARR reverse proxy |
28
+ | Your own VPS (Nginx on Ubuntu) | ✅ | ✅ | ✅ |
29
+ | Static hosting (Netlify, Vercel, GitHub Pages) | ✅ | ❌ | ❌ |
30
+
31
+ Static hosting serves files and nothing else — fine if your site has no `/api`
32
+ endpoints, unusable otherwise.
33
+
34
+ ## Requirements
35
+
36
+ **PHP backend:** a server with PHP support and Composer for the backend
37
+ dependencies.
38
+
39
+ **Node backend:** Node.js 18+ and shell access to run a persistent process — a
40
+ VPS you control.
41
+
42
+ ---
43
+
44
+ ## Shared hosting (Apache)
45
+
46
+ Upload the **contents of `out`** to the web root (often `htdocs`, `public_html`
47
+ or `www`). Done — `.htaccess` is already inside `out` and Apache reads it
48
+ automatically: directory listing off, 403/404 → `/404.html`, sensitive files
49
+ blocked, backend source sealed, `/api/*` routed.
50
+
51
+ **Backend routing:** if `mod_proxy` is available, `/api` is proxied to Node on
52
+ `127.0.0.1:3000`; if not — the usual case on shared hosting — `/api` is
53
+ rewritten to the PHP front controller. To force PHP on a proxy-enabled server,
54
+ comment the `mod_proxy` block in `.htaccess`.
55
+
56
+ ## Windows hosting (IIS)
57
+
58
+ Same idea: upload the contents of `out`, `web.config` is already there and read
59
+ automatically.
60
+
61
+ **Backend routing:** `/api` is rewritten to the PHP front controller. To use the
62
+ Node backend instead, uncomment the `ApiToNode` rule in `web.config` and delete
63
+ `ApiToPhp` — this needs the ARR and URL Rewrite modules with proxying enabled,
64
+ so a server you control, not shared hosting.
65
+
66
+ > ⚠️ **If you chose the Node backend and your host has no ARR** (Aruba and other
67
+ > Windows shared hosting), don't upload the `backend` folder at all. The static
68
+ > site works, and `/api/*` answers with your `404.html`. Upload it and every
69
+ > `/api` request returns an empty 404 instead: IIS rewrites it onto the PHP
70
+ > front controller, which a Node project doesn't contain.
71
+
72
+ ---
73
+
74
+ ## Your own server (Nginx on a VPS)
75
+
76
+ Nginx doesn't read per-directory config files — the whole site lives in one file.
77
+ Nibula ships `nginx.conf` in the project root as a ready-to-use site file that
78
+ **covers both backends without edits**: `/api` goes to Node, and if Node is
79
+ unreachable the request falls through to PHP automatically.
80
+
81
+ Upload the contents of `out` to `/var/www/SITE_FOLDER`, then follow the steps
82
+ below.
83
+
84
+ ### 1. Replace
85
+
86
+ | Placeholder | Where |
87
+ |---|---|
88
+ | `YOUR_DOMAIN` | `server_name`, twice (port 80 and 443) |
89
+ | `SITE_FOLDER` | document root under `/var/www/` |
90
+ | `YOUR_CERTIFICATE` | dir under `/etc/letsencrypt/live/` |
91
+ | `SITE_NAME` | file name in the commands below |
92
+
93
+ ### 2. Install (skip if already present)
94
+
95
+ ```bash
96
+ sudo apt update
97
+ sudo apt install -y nginx certbot python3-certbot-nginx
98
+ ```
99
+
100
+ If you are using PHP as backend:
101
+
102
+ ```bash
103
+ sudo apt install -y php-fpm
104
+ ```
105
+
106
+ ### 3. Certificate
107
+
108
+ ```bash
109
+ sudo certbot certonly --nginx --cert-name SITE_NAME -d YOUR_DOMAIN
110
+ sudo systemctl enable --now certbot.timer # auto-renew every 90 days
111
+ ```
112
+
113
+ ### 4. Install the site
114
+
115
+ ```bash
116
+ # Move to nginx folders
117
+ cd /etc/nginx/sites-available
118
+
119
+ # Create and write a new file
120
+ sudo nano SITE_NAME
121
+ # CTRL + O, ENTER, CTRL + X
122
+
123
+ # Copy the config to sites-enabled
124
+ sudo cp SITE_NAME ../sites-enabled/
125
+
126
+ # Test and reload the nginx configuration
127
+ sudo nginx -t && sudo systemctl reload nginx
128
+ ```
129
+
130
+ ### If it fails
131
+
132
+ | Symptom | Cause |
133
+ |---|---|
134
+ | `cannot load certificate ... Permission denied` | `nginx -t` needs sudo |
135
+ | `cannot load certificate ... No such file` | wrong certificate name |
136
+ | `no alternative certificate subject name` | certificate doesn't cover domain |
137
+ | `unknown directive "http2"` | nginx < 1.25, check with `nginx -v` |
138
+ | NXDOMAIN / timeout during certbot | DNS not pointing here |
139
+ | 500 instead of the 404 page | `404.html` missing |
140
+ | 502 on `/api`, Node deployed | Node process not running |
141
+ | 502 on `/api`, PHP deployed | wrong php-fpm socket path |
142
+
143
+ ---
144
+
145
+ ## Starting the Node backend on the server
146
+
147
+ After uploading `out`:
148
+
149
+ 1. Install the backend's runtime deps:
150
+ ```bash
151
+ cd /var/www/SITE_FOLDER/backend
152
+ npm install
153
+ ```
154
+
155
+ 2. Make sure `config.js` exists in `out/backend/` (copy `example.config.js` if
156
+ missing) and fill in your values.
157
+
158
+ 3. Start it in a new screen:
159
+ ```bash
160
+ screen -S node-backend
161
+ # In the new screen terminal:
162
+ sudo node /var/www/SITE_FOLDER/backend/_core/index.js
163
+ curl http://127.0.0.1:3000/api/example-public
164
+ ```
165
+
166
+ 4. Exit the screen without closing the process with `CTRL + A`, `D`. To resume
167
+ the screen type `screen -r node-backend`.
168
+
169
+ 5. For production use **systemd**, which also restarts on crash and reboot.
170
+ Create `/etc/systemd/system/backend-node.service`:
171
+
172
+ ```ini
173
+ [Unit]
174
+ Description=Nibula Node backend
175
+ After=network.target
176
+
177
+ [Service]
178
+ Type=simple
179
+ User=www-data
180
+ WorkingDirectory=/var/www/SITE_FOLDER/backend
181
+ ExecStart=/usr/bin/node /var/www/SITE_FOLDER/backend/_core/index.js
182
+ Restart=always
183
+ RestartSec=5
184
+
185
+ [Install]
186
+ WantedBy=multi-user.target
187
+ ```
188
+
189
+ Adjust `WorkingDirectory` and the `node` path (`which node`), then:
190
+
191
+ ```bash
192
+ sudo systemctl daemon-reload
193
+ sudo systemctl enable --now backend-node
194
+ sudo systemctl status backend-node
195
+ ```
196
+
197
+ (`pm2` works too: `pm2 start _core/index.js --name backend-node`.)
198
+
199
+ ### Environment variables
200
+
201
+ Read by the Node backend at startup. Set them in the systemd unit with
202
+ `Environment=KEY=value`.
203
+
204
+ | Variable | Default | Purpose |
205
+ |---|---|---|
206
+ | `PORT` | `3000` | Port Node listens on (must match the proxy target in `nginx.conf`) |
207
+ | `HOST` | `127.0.0.1` | Bind address — keep it local; the web server is the public face |
208
+ | `DOCUMENT_ROOT` | auto (`SITE_FOLDER/`) | Where `404.html` lives; detected as the folder above `backend/` |
209
+
210
+ Error verbosity is **not** an environment variable: it is the `APP_ENV` key in
211
211
  `config.js` / `config.php`. See `docs/Backend.md`.