nibula 1.0.0
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/.eleventy.js +96 -0
- package/.eleventyignore +4 -0
- package/CHANGELOG.md +0 -0
- package/LICENSE +170 -0
- package/NOTICE +5 -0
- package/README.md +105 -0
- package/_tools/assistant.js +152 -0
- package/_tools/buildJs.js +37 -0
- package/_tools/cleanOutput.js +25 -0
- package/_tools/modules/constants.js +66 -0
- package/_tools/modules/pageComponents.js +77 -0
- package/_tools/modules/updateData.js +90 -0
- package/_tools/modules/updateOutputPath.js +112 -0
- package/_tools/modules/updatePage.js +162 -0
- package/_tools/modules/utils.js +27 -0
- package/_tools/modules/validation.js +30 -0
- package/_tools/res/templates/template.js +5 -0
- package/_tools/res/templates/template.njk +9 -0
- package/_tools/res/templates/template.scss +23 -0
- package/_tools/res/templates/template.ts +5 -0
- package/bin/create.js +407 -0
- package/bin/nibula.js +281 -0
- package/docs/Assistant CLI.md +66 -0
- package/docs/Backend.md +151 -0
- package/docs/Components.md +96 -0
- package/docs/Creating pages.md +65 -0
- package/docs/Deploy.md +101 -0
- package/docs/Head and SEO.md +117 -0
- package/docs/Javascript.md +53 -0
- package/docs/Styling with SCSS.md +136 -0
- package/nginx.conf +47 -0
- package/nibula-1.0.0.tgz +0 -0
- package/package.json +74 -0
- package/src/backend/.htaccess +7 -0
- package/src/backend/_core/composer.json +5 -0
- package/src/backend/_core/composer.lock +492 -0
- package/src/backend/_core/index.php +148 -0
- package/src/backend/_core/init.php +34 -0
- package/src/backend/_core/modules/RateLimiter.php +31 -0
- package/src/backend/_core/modules/Response.php +49 -0
- package/src/backend/api/protected/example-protected.php +17 -0
- package/src/backend/api/public/example-public.php +17 -0
- package/src/backend/database/Database.php +24 -0
- package/src/backend/database/migrations/create_example_db.sql +1 -0
- package/src/backend/example.config.php +28 -0
- package/src/backend/web.config +17 -0
- package/src/frontend/.htaccess +16 -0
- package/src/frontend/404.njk +17 -0
- package/src/frontend/assets/brand/favicon.svg +37 -0
- package/src/frontend/assets/brand/logo.svg +37 -0
- package/src/frontend/components/global/footer.njk +25 -0
- package/src/frontend/components/global/header.njk +7 -0
- package/src/frontend/components/welcome.njk +116 -0
- package/src/frontend/data/site.json +54 -0
- package/src/frontend/index.njk +9 -0
- package/src/frontend/js/modules/exampleModule.js +3 -0
- package/src/frontend/js/pages/404.js +7 -0
- package/src/frontend/js/pages/homepage.js +7 -0
- package/src/frontend/layouts/base.njk +142 -0
- package/src/frontend/layouts/page-components.njk +14 -0
- package/src/frontend/llms.njk +18 -0
- package/src/frontend/robots.njk +8 -0
- package/src/frontend/scss/modules/_animations.scss +25 -0
- package/src/frontend/scss/modules/_footer.scss +28 -0
- package/src/frontend/scss/modules/_global.scss +44 -0
- package/src/frontend/scss/modules/_header.scss +28 -0
- package/src/frontend/scss/modules/_mobile.scss +30 -0
- package/src/frontend/scss/modules/_root.scss +35 -0
- package/src/frontend/scss/modules/_typography.scss +15 -0
- package/src/frontend/scss/modules/frameworks/_bootstrap.scss +110 -0
- package/src/frontend/scss/modules/frameworks/_bulma.scss +109 -0
- package/src/frontend/scss/modules/frameworks/_foundation.scss +139 -0
- package/src/frontend/scss/modules/frameworks/_uikit.scss +110 -0
- package/src/frontend/scss/pages/404.scss +28 -0
- package/src/frontend/scss/pages/homepage.scss +23 -0
- package/src/frontend/sitemap.njk +18 -0
- package/src/frontend/ts/modules/exampleModule.ts +3 -0
- package/src/frontend/ts/pages/404.ts +7 -0
- package/src/frontend/ts/pages/homepage.ts +7 -0
- package/src/frontend/web.config +27 -0
- package/tsconfig.json +25 -0
package/.eleventy.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const esbuild = require("esbuild");
|
|
2
|
+
const glob = require("glob");
|
|
3
|
+
const Image = require("@11ty/eleventy-img");
|
|
4
|
+
const markdownIt = require('markdown-it');
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
8
|
+
const OUTPUT_DIR = "out";
|
|
9
|
+
|
|
10
|
+
module.exports = function (eleventyConfig) {
|
|
11
|
+
|
|
12
|
+
function copyRecursiveSync(src, dest) {
|
|
13
|
+
if (!fs.existsSync(src)) return;
|
|
14
|
+
if (src.includes('.git')) return;
|
|
15
|
+
const stat = fs.statSync(src);
|
|
16
|
+
if (stat.isDirectory()) {
|
|
17
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
18
|
+
for (const child of fs.readdirSync(src)) {
|
|
19
|
+
copyRecursiveSync(path.join(src, child), path.join(dest, child));
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
23
|
+
fs.copyFileSync(src, dest);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const md = markdownIt({ html: true });
|
|
28
|
+
|
|
29
|
+
eleventyConfig.addShortcode('mdFile', function(filePath) {
|
|
30
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
31
|
+
return md.render(content);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
eleventyConfig.addPassthroughCopy({
|
|
35
|
+
"node_modules/github-markdown-css/github-markdown-dark.css": "css/github-markdown-dark.css",
|
|
36
|
+
"node_modules/github-markdown-css/github-markdown-light.css": "css/github-markdown-light.css",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
eleventyConfig.on("eleventy.before", () => {
|
|
40
|
+
copyRecursiveSync("src/backend", `${OUTPUT_DIR}/backend`);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
eleventyConfig.addPassthroughCopy("src/frontend/.htaccess");
|
|
44
|
+
eleventyConfig.addPassthroughCopy("src/frontend/web.config");
|
|
45
|
+
eleventyConfig.addPassthroughCopy("src/frontend/assets");
|
|
46
|
+
eleventyConfig.addPassthroughCopy("src/frontend/data");
|
|
47
|
+
eleventyConfig.addPassthroughCopy("src/frontend/robots.txt");
|
|
48
|
+
|
|
49
|
+
eleventyConfig.addPassthroughCopy({
|
|
50
|
+
"node_modules/bootstrap/dist/js/bootstrap.bundle.min.js": "js/bootstrap.bundle.min.js",
|
|
51
|
+
"node_modules/bootstrap-icons/font/fonts": "css/fonts",
|
|
52
|
+
|
|
53
|
+
// Foundation
|
|
54
|
+
// "node_modules/foundation-sites/dist/js/foundation.min.js": "js/foundation.min.js",
|
|
55
|
+
|
|
56
|
+
// UIkit
|
|
57
|
+
// "node_modules/uikit/dist/js/uikit.min.js": "js/uikit.min.js",
|
|
58
|
+
// "node_modules/uikit/dist/js/uikit-icons.min.js": "js/uikit-icons.min.js",
|
|
59
|
+
|
|
60
|
+
// Bulma — CSS only, no JS passthrough needed
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
eleventyConfig.addShortcode("image", async function (src, alt) {
|
|
64
|
+
let metadata = await Image(src, {
|
|
65
|
+
widths: [320, 480, 720, 1280, 1920, 2048, 2560, 3840, 4096, 7680],
|
|
66
|
+
formats: ["webp", "jpeg"],
|
|
67
|
+
outputDir: `${OUTPUT_DIR}/assets/images/`,
|
|
68
|
+
urlPath: "/assets/images/",
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return Image.generateHTML(metadata, {
|
|
72
|
+
alt,
|
|
73
|
+
sizes: "(max-width: 768px) 100vw, 50vw",
|
|
74
|
+
loading: "lazy",
|
|
75
|
+
decoding: "async",
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
eleventyConfig.addWatchTarget("./src/frontend/scss");
|
|
80
|
+
eleventyConfig.addWatchTarget("./src/frontend/_routes");
|
|
81
|
+
eleventyConfig.addWatchTarget("./src/frontend/data");
|
|
82
|
+
|
|
83
|
+
eleventyConfig.setServerOptions({
|
|
84
|
+
watch: [`${OUTPUT_DIR}/js/**/*.js`]
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
dir: {
|
|
89
|
+
input: "src/frontend",
|
|
90
|
+
output: OUTPUT_DIR,
|
|
91
|
+
includes: "components",
|
|
92
|
+
layouts: "layouts",
|
|
93
|
+
data: "data",
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
};
|
package/.eleventyignore
ADDED
package/CHANGELOG.md
ADDED
|
File without changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other
|
|
43
|
+
modifications represent, as a whole, an original work of authorship.
|
|
44
|
+
For the purposes of this License, Derivative Works shall not include
|
|
45
|
+
works that remain separable from, or merely link (or bind by name)
|
|
46
|
+
to the interfaces of, the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
49
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
50
|
+
authorized to submit on behalf of the copyright owner. For the
|
|
51
|
+
purposes of this definition, "submitted" means any form of electronic,
|
|
52
|
+
verbal, or written communication sent to the Licensor or its
|
|
53
|
+
representatives, including but not limited to communication on
|
|
54
|
+
electronic mailing lists, source code control systems, and issue
|
|
55
|
+
tracking systems that are managed by, or on behalf of, the Licensor
|
|
56
|
+
for the purpose of discussing and improving the Work, but excluding
|
|
57
|
+
communication that is conspicuously marked or otherwise designated
|
|
58
|
+
in writing by the copyright owner as "Not a Contribution."
|
|
59
|
+
|
|
60
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
61
|
+
whom a Contribution has been received by the Licensor and incorporated
|
|
62
|
+
within the Work.
|
|
63
|
+
|
|
64
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
65
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
66
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
67
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
68
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
69
|
+
Work and such Derivative Works in Source or Object form.
|
|
70
|
+
|
|
71
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
72
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
73
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
74
|
+
(except as stated in this section) patent license to make, have made,
|
|
75
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
76
|
+
where such license applies only to those patent claims licensable
|
|
77
|
+
by such Contributor that are necessarily infringed by their
|
|
78
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
79
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
80
|
+
institute patent litigation against any entity (including a
|
|
81
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
82
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
83
|
+
or contributory patent infringement, then any patent licenses
|
|
84
|
+
granted to You under this License for that Work shall terminate
|
|
85
|
+
as of the date such litigation is filed.
|
|
86
|
+
|
|
87
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
88
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
89
|
+
modifications, and in Source or Object form, provided that You
|
|
90
|
+
meet the following conditions:
|
|
91
|
+
|
|
92
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
93
|
+
Works a copy of this License; and
|
|
94
|
+
|
|
95
|
+
(b) You must cause any modified files to carry prominent notices
|
|
96
|
+
stating that You changed the files; and
|
|
97
|
+
|
|
98
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
99
|
+
that You distribute, all copyright, patent, trademark, and
|
|
100
|
+
attribution notices from the Source form of the Work,
|
|
101
|
+
excluding those notices that do not pertain to any part of
|
|
102
|
+
the Derivative Works; and
|
|
103
|
+
|
|
104
|
+
(d) If the Work includes a NOTICE text file, You must include a
|
|
105
|
+
readable copy of the attribution notices contained within such
|
|
106
|
+
NOTICE file, in at least one of the following places: within
|
|
107
|
+
a NOTICE text file distributed as part of the Derivative Works;
|
|
108
|
+
within the Source form or documentation, if provided along with
|
|
109
|
+
the Derivative Works; or, within a display generated by the
|
|
110
|
+
Derivative Works, if and wherever such third-party notices
|
|
111
|
+
normally appear. The contents of the NOTICE file are for
|
|
112
|
+
informational purposes only and do not modify the License.
|
|
113
|
+
|
|
114
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
115
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
116
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
117
|
+
this License, without any additional terms or conditions.
|
|
118
|
+
|
|
119
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
120
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
121
|
+
except as required for reasonable and customary use in describing the
|
|
122
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
123
|
+
|
|
124
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed
|
|
125
|
+
to in writing, Licensor provides the Work (and each Contributor
|
|
126
|
+
provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
|
|
127
|
+
OR CONDITIONS OF ANY KIND, either express or implied, including,
|
|
128
|
+
without limitation, any warranties or conditions of TITLE,
|
|
129
|
+
NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
|
130
|
+
PURPOSE. You are solely responsible for determining the
|
|
131
|
+
appropriateness of using or reproducing the Work and assume any
|
|
132
|
+
risks associated with Your exercise of permissions under this License.
|
|
133
|
+
|
|
134
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
135
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
136
|
+
unless required by applicable law (such as deliberate and grossly
|
|
137
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
138
|
+
liable to You for damages, including any direct, indirect, special,
|
|
139
|
+
incidental, or exemplary damages of any character arising as a
|
|
140
|
+
result of this License or out of the use or inability to use the
|
|
141
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
142
|
+
work stoppage, computer failure or malfunction, or all other
|
|
143
|
+
commercial damages or losses), even if such Contributor has been
|
|
144
|
+
advised of the possibility of such damages.
|
|
145
|
+
|
|
146
|
+
9. Accepting Warranty or Liability While Redistributing. You may choose
|
|
147
|
+
to offer, and charge a fee for, acceptance of support, warranty,
|
|
148
|
+
indemnity, or other liability obligations and/or rights consistent
|
|
149
|
+
with this License. However, in accepting such obligations, You may
|
|
150
|
+
act only on Your own behalf and on Your sole responsibility, not on
|
|
151
|
+
behalf of any other Contributor, and only if You agree to indemnify,
|
|
152
|
+
defend, and hold each Contributor harmless for any liability incurred
|
|
153
|
+
by, or claims asserted against, such Contributor by reason of your
|
|
154
|
+
accepting any such warranty or additional liability.
|
|
155
|
+
|
|
156
|
+
END OF TERMS AND CONDITIONS
|
|
157
|
+
|
|
158
|
+
Copyright 2026 Michele Garofalo
|
|
159
|
+
|
|
160
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
161
|
+
you may not use this file except in compliance with the License.
|
|
162
|
+
You may obtain a copy of the License at
|
|
163
|
+
|
|
164
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
165
|
+
|
|
166
|
+
Unless required by applicable law or agreed to in writing, software
|
|
167
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
168
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
169
|
+
implied. See the License for the specific language governing
|
|
170
|
+
permissions and limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# ✏️ Nibula
|
|
2
|
+
|
|
3
|
+
**Nibula** is an open source static site generator built on top of [Eleventy](https://www.11ty.dev/), with one clear mission: make the jump from plain, hand-written websites to a real project setup as gentle as possible — without ever pulling you away from the web you already know.
|
|
4
|
+
|
|
5
|
+
If you've only ever written HTML, CSS, and a bit of JavaScript, moving to a "framework" usually feels like starting over: new syntax, new rules, new folder structures, and a pile of documentation before you can even see a page on screen. Nibula is designed to avoid exactly that. You keep working with the **three languages that matter — HTML, CSS, and JavaScript** — and the tool quietly handles the tedious parts around them. The goal is simple: even someone with little experience should always know *where to put their hands*.
|
|
6
|
+
|
|
7
|
+
It's a great fit for **showcase and brochure-style websites** (portfolios, landing pages, small business sites), where you want something clean and fast without dragging in a heavy framework.
|
|
8
|
+
|
|
9
|
+
### ✨ Why Nibula?
|
|
10
|
+
|
|
11
|
+
Building a website from scratch involves a lot of moving parts: templating, build steps, SEO files, server config, project structure. Nibula takes care of all of that for you, so you can focus on what actually matters — **your content and your ideas** — while still learning skills that transfer anywhere on the web.
|
|
12
|
+
|
|
13
|
+
- 🔧 **Zero-config ready** — install, create, and you're live in minutes
|
|
14
|
+
- 🧭 **Stays close to vanilla** — real HTML, CSS, and JS, so nothing you learn goes to waste
|
|
15
|
+
- 🔎 **SEO made simple** — managed from one central place; `sitemap`, `llms.txt`, and `robots.txt` are generated automatically
|
|
16
|
+
- 🖱️ **A helpful CLI** — create a page with one command instead of hand-writing ten separate files
|
|
17
|
+
- ⚙️ **Server configs handled for you** — `.htaccess` and `web.config` are generated automatically, and an `nginx.conf` is provided so that anyone comfortable with nginx already has what they need to run the site outside of shared hosting
|
|
18
|
+
- 🎨 **Pick your CSS framework** — choose from 4 pre-installed options (or none), and switch later in a few guided steps
|
|
19
|
+
- 🧩 **Your own modules** — add your own CSS and JS/TS modules freely and easily
|
|
20
|
+
- 🪶 **Lightweight by default** — SCSS frameworks can be filtered so you ship only what you actually use
|
|
21
|
+
- 🌍 **Open source** — free to use, free to modify, free to share
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+

|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
## JavaScript or TypeScript — your choice
|
|
28
|
+
|
|
29
|
+
When you create a project, you decide how you want to work:
|
|
30
|
+
|
|
31
|
+
- **JavaScript** — the simplest path, ideal if you're still getting comfortable.
|
|
32
|
+
- **TypeScript** — for more experienced users who want stronger typing and tooling.
|
|
33
|
+
|
|
34
|
+
Either way, the project structure stays the same, so you can start easy and level up later.
|
|
35
|
+
|
|
36
|
+
## Backend included
|
|
37
|
+
|
|
38
|
+
Essential server-side functionality comes built in — no extra setup required. Backend support will soon let you **choose between PHP, Node, and Python**, so the project can grow with you.
|
|
39
|
+
|
|
40
|
+
## Customizable, but with sensible defaults
|
|
41
|
+
|
|
42
|
+
Nibula ships with a clean, opinionated layout so beginners are never lost. But it isn't a cage: as long as you follow a few small conventions and the defined paths, you're free to customize the subpaths of your **components, backend endpoints, and JS/SCSS modules** however you like.
|
|
43
|
+
|
|
44
|
+
## Prerequisites
|
|
45
|
+
|
|
46
|
+
* **Node.js**: v18.0.0 or higher
|
|
47
|
+
* **Composer**: latest stable version
|
|
48
|
+
* *Optional:* the **Better Nunjucks** VS Code extension by Ed Heltzel
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
Install the Nibula CLI once, globally:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
npm install -g nibula
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
This gives you the `nib` command (Alternatives: `nbl`, `nibula`).
|
|
59
|
+
|
|
60
|
+
## Create a project
|
|
61
|
+
|
|
62
|
+
From the folder where you keep your websites, run:
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
nib new your-project
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The scaffolder is interactive: you choose the language (JavaScript/TypeScript) and the CSS framework, and all dependencies are installed automatically.
|
|
69
|
+
|
|
70
|
+
Then start the dev server and visit `localhost:8080`:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
cd your-project
|
|
74
|
+
nib run
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Commands
|
|
78
|
+
|
|
79
|
+
Run these from anywhere inside a project (except `nib new`, which you run wherever you want to create the project):
|
|
80
|
+
|
|
81
|
+
| Command | Description |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `nib new <name>` | Create your new project |
|
|
84
|
+
| `nib run` | Start the dev server and build the output folder at runtime |
|
|
85
|
+
| `nib cli` | Open the page-management assistant |
|
|
86
|
+
| `nib build` | Build the output folder runtime |
|
|
87
|
+
| `nib clean` | Remove the output directory |
|
|
88
|
+
| `nib update` | Update the CLI to the latest version |
|
|
89
|
+
|
|
90
|
+
Before scaffolding, `nib new` checks the npm registry for a newer version and offers to update first (via `nib update`). If the registry is unreachable, the check is skipped and creation proceeds normally.
|
|
91
|
+
|
|
92
|
+
## Managing pages
|
|
93
|
+
|
|
94
|
+
Instead of creating and wiring up multiple files by hand, let the interactive assistant do it for you. To create, remove, or rename pages and configure the output path, run:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
nib cli
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
See [docs/Assistant CLI.md](docs/Assistant%20CLI.md) for details.
|
|
101
|
+
|
|
102
|
+
## Roadmap
|
|
103
|
+
|
|
104
|
+
* [ ] Add support for multiple themes
|
|
105
|
+
* [ ] Backend integration choice — switch between PHP, Python, or Node
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
const readline = require('readline');
|
|
2
|
+
|
|
3
|
+
const { addPage, removePage, renamePage, pageExists } = require('./modules/updatePage');
|
|
4
|
+
const { updateOutputPath, getCurrentOutputPath } = require('./modules/updateOutputPath');
|
|
5
|
+
const { validatePageName, validateOutputPath, checkRequiredFiles } = require('./modules/validation');
|
|
6
|
+
const { toKebabCase } = require('./modules/utils');
|
|
7
|
+
const { color } = require('./modules/constants');
|
|
8
|
+
|
|
9
|
+
const rl = readline.createInterface({
|
|
10
|
+
input: process.stdin,
|
|
11
|
+
output: process.stdout,
|
|
12
|
+
terminal: true,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
function sanitizeInput(value) {
|
|
16
|
+
return (value ?? '').replace(/[\x00-\x1F\x7F]/g, '').trim();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function ask(prompt) {
|
|
20
|
+
return new Promise((resolve) => {
|
|
21
|
+
const onClose = () => resolve(null);
|
|
22
|
+
rl.once('close', onClose);
|
|
23
|
+
rl.question(prompt, (answer) => {
|
|
24
|
+
rl.off('close', onClose);
|
|
25
|
+
resolve(sanitizeInput(answer));
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function confirm(prompt) {
|
|
31
|
+
const answer = await ask(`${prompt} ${color.dim}[y/N]${color.reset} `);
|
|
32
|
+
return /^y(es)?$/i.test((answer ?? '').trim());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function askPageName(prompt) {
|
|
36
|
+
const raw = await ask(prompt);
|
|
37
|
+
if (raw === null) return null;
|
|
38
|
+
|
|
39
|
+
const name = toKebabCase(raw);
|
|
40
|
+
const error = validatePageName(name);
|
|
41
|
+
if (error) {
|
|
42
|
+
console.log(`\n${color.red}✖ ${error}${color.reset}`);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function handleCreate() {
|
|
49
|
+
const name = await askPageName(`\n${color.green}❯${color.reset} Name of the new page: `);
|
|
50
|
+
if (name) addPage(name);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function handleRemove() {
|
|
54
|
+
const name = await askPageName(`\n${color.red}❯${color.reset} Name of the page to remove: `);
|
|
55
|
+
if (!name) return;
|
|
56
|
+
|
|
57
|
+
if (!pageExists(name)) {
|
|
58
|
+
console.log(`\n${color.yellow}⚠ Page "${name}" does not exist.${color.reset}`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const confirmed = await confirm(`This permanently deletes all files for "${name}".`);
|
|
63
|
+
if (!confirmed) {
|
|
64
|
+
console.log(`\n${color.dim}Cancelled.${color.reset}`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
removePage(name);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function handleRename() {
|
|
71
|
+
const oldName = await askPageName(`\n${color.yellow}❯${color.reset} Page to rename: `);
|
|
72
|
+
if (!oldName) return;
|
|
73
|
+
|
|
74
|
+
const newName = await askPageName(`${color.yellow}❯${color.reset} New name: `);
|
|
75
|
+
if (!newName) return;
|
|
76
|
+
|
|
77
|
+
if (oldName === newName) {
|
|
78
|
+
console.log(`\n${color.yellow}⚠ Old and new name are the same.${color.reset}`);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
renamePage(oldName, newName);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function handleOutputPath() {
|
|
85
|
+
const current = getCurrentOutputPath();
|
|
86
|
+
const label = current ? `\n${color.dim}Current path: "${current}"${color.reset}\n` : '\n';
|
|
87
|
+
|
|
88
|
+
const input = await ask(`${label}${color.magenta}❯${color.reset} New output path: `);
|
|
89
|
+
if (input === null) return;
|
|
90
|
+
|
|
91
|
+
const error = validateOutputPath(input);
|
|
92
|
+
if (error) {
|
|
93
|
+
console.log(`\n${color.red}✖ ${error}${color.reset}`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
updateOutputPath(input);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const MENU_ACTIONS = {
|
|
100
|
+
'1': handleCreate,
|
|
101
|
+
'2': handleRemove,
|
|
102
|
+
'3': handleRename,
|
|
103
|
+
'4': handleOutputPath,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function renderMenu() {
|
|
107
|
+
console.log(`\n${color.cyan}${color.bold}╭─────────────────╮`);
|
|
108
|
+
console.log(`│ Nibula CLI │`);
|
|
109
|
+
console.log(`╰─────────────────╯${color.reset}\n`);
|
|
110
|
+
console.log(` ${color.green}1.${color.reset} Create page`);
|
|
111
|
+
console.log(` ${color.red}2.${color.reset} Remove page`);
|
|
112
|
+
console.log(` ${color.yellow}3.${color.reset} Rename page`);
|
|
113
|
+
console.log(` ${color.magenta}4.${color.reset} Configure output path`);
|
|
114
|
+
console.log(` ${color.dim}CTRL + C to exit\n`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function main() {
|
|
118
|
+
const missing = checkRequiredFiles();
|
|
119
|
+
if (missing.length > 0) {
|
|
120
|
+
console.log(`\n${color.red}✖ This project is missing required files:${color.reset}`);
|
|
121
|
+
for (const item of missing) {
|
|
122
|
+
console.log(` ${color.red}-${color.reset} ${item.label}`);
|
|
123
|
+
}
|
|
124
|
+
console.log(`\n${color.dim}The project may be incomplete or created with a different Nibula version.${color.reset}`);
|
|
125
|
+
rl.close();
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
while (true) {
|
|
130
|
+
renderMenu();
|
|
131
|
+
|
|
132
|
+
const choice = await ask(`${color.cyan}❯${color.reset} Choose an option: `);
|
|
133
|
+
if (choice === null) break;
|
|
134
|
+
|
|
135
|
+
const action = MENU_ACTIONS[choice];
|
|
136
|
+
if (!action) {
|
|
137
|
+
console.log(`\n${color.red}✖ Invalid option.${color.reset}`);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
await action();
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.log(`\n${color.red}✖ Unexpected error: ${err.message}${color.reset}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
rl.close();
|
|
149
|
+
process.exit(0);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
main();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const esbuild = require('esbuild');
|
|
2
|
+
const glob = require('glob');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const { findProjectRoot, NOT_INSIDE_PROJECT_MESSAGE } = require('./modules/constants');
|
|
6
|
+
|
|
7
|
+
const root = findProjectRoot(process.cwd());
|
|
8
|
+
if (!root) {
|
|
9
|
+
console.error(NOT_INSIDE_PROJECT_MESSAGE);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf-8'));
|
|
14
|
+
const outputDir = pkg.outputDir || 'out';
|
|
15
|
+
const isWatch = process.argv.includes('--watch');
|
|
16
|
+
|
|
17
|
+
const posix = (p) => p.split(path.sep).join('/');
|
|
18
|
+
const jsFiles = glob.sync(posix(path.join(root, 'src/frontend/js/pages/*.js')));
|
|
19
|
+
const tsFiles = glob.sync(posix(path.join(root, 'src/frontend/ts/pages/*.ts')));
|
|
20
|
+
const entryPoints = [...jsFiles, ...tsFiles];
|
|
21
|
+
|
|
22
|
+
if (entryPoints.length === 0) {
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const options = {
|
|
27
|
+
entryPoints,
|
|
28
|
+
bundle: true,
|
|
29
|
+
outdir: path.join(root, outputDir, 'js/pages'),
|
|
30
|
+
minify: !isWatch,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (isWatch) {
|
|
34
|
+
esbuild.context(options).then((ctx) => ctx.watch()).catch(() => process.exit(1));
|
|
35
|
+
} else {
|
|
36
|
+
esbuild.build(options).catch(() => process.exit(1));
|
|
37
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { findProjectRoot, NOT_INSIDE_PROJECT_MESSAGE } = require('./modules/constants');
|
|
4
|
+
|
|
5
|
+
const root = findProjectRoot(process.cwd());
|
|
6
|
+
if (!root) {
|
|
7
|
+
console.error(NOT_INSIDE_PROJECT_MESSAGE);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf-8'));
|
|
12
|
+
|
|
13
|
+
if (!pkg.outputDir) {
|
|
14
|
+
console.log('(!) outputDir not found in package.json');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const outputDir = path.resolve(root, pkg.outputDir);
|
|
19
|
+
|
|
20
|
+
if (fs.existsSync(outputDir)) {
|
|
21
|
+
fs.rmSync(outputDir, { recursive: true, force: true });
|
|
22
|
+
console.log(`(✓) cleaned → ${outputDir}`);
|
|
23
|
+
} else {
|
|
24
|
+
console.log(`(i) nothing to clean → ${outputDir}`);
|
|
25
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const PACKAGE_ROOT = path.resolve(__dirname, '..', '..');
|
|
5
|
+
const TEMPLATES_DIR = path.join(PACKAGE_ROOT, '_tools', 'res', 'templates');
|
|
6
|
+
|
|
7
|
+
const PROJECT_MARKER = '.eleventy.js';
|
|
8
|
+
|
|
9
|
+
const PROTECTED_PAGES = Object.freeze(['homepage', '404']);
|
|
10
|
+
|
|
11
|
+
const color = Object.freeze({
|
|
12
|
+
reset: '\x1b[0m',
|
|
13
|
+
bold: '\x1b[1m',
|
|
14
|
+
dim: '\x1b[2m',
|
|
15
|
+
red: '\x1b[31m',
|
|
16
|
+
green: '\x1b[32m',
|
|
17
|
+
yellow: '\x1b[33m',
|
|
18
|
+
blue: '\x1b[34m',
|
|
19
|
+
magenta: '\x1b[35m',
|
|
20
|
+
cyan: '\x1b[36m',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const NOT_INSIDE_PROJECT_MESSAGE = `${color.red}Not inside a Nibula project.${color.reset}`;
|
|
24
|
+
|
|
25
|
+
function findProjectRoot(start) {
|
|
26
|
+
let dir = path.resolve(start ?? process.cwd());
|
|
27
|
+
while (true) {
|
|
28
|
+
if (fs.existsSync(path.join(dir, PROJECT_MARKER))) return dir;
|
|
29
|
+
const parent = path.dirname(dir);
|
|
30
|
+
if (parent === dir) return null;
|
|
31
|
+
dir = parent;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let cachedRoot = null;
|
|
36
|
+
|
|
37
|
+
function projectRoot() {
|
|
38
|
+
if (cachedRoot) return cachedRoot;
|
|
39
|
+
const root = findProjectRoot();
|
|
40
|
+
if (!root) {
|
|
41
|
+
console.error(NOT_INSIDE_PROJECT_MESSAGE);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
cachedRoot = root;
|
|
45
|
+
return root;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function frontendDir() {
|
|
49
|
+
return path.join(projectRoot(), 'src', 'frontend');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const PATHS = Object.freeze({
|
|
53
|
+
get root() { return projectRoot(); },
|
|
54
|
+
get routes() { return path.join(frontendDir(), '_routes'); },
|
|
55
|
+
get scssPages() { return path.join(frontendDir(), 'scss', 'pages'); },
|
|
56
|
+
get jsPages() { return path.join(frontendDir(), 'js', 'pages'); },
|
|
57
|
+
get tsPages() { return path.join(frontendDir(), 'ts', 'pages'); },
|
|
58
|
+
get siteData() { return path.join(frontendDir(), 'data', 'site.json'); },
|
|
59
|
+
get pageComponents() { return path.join(frontendDir(), 'layouts', 'page-components.njk'); },
|
|
60
|
+
get eleventyConfig() { return path.join(projectRoot(), '.eleventy.js'); },
|
|
61
|
+
get packageJson() { return path.join(projectRoot(), 'package.json'); },
|
|
62
|
+
get tsconfig() { return path.join(projectRoot(), 'tsconfig.json'); },
|
|
63
|
+
templates: TEMPLATES_DIR,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
module.exports = { PATHS, PROJECT_MARKER, PROTECTED_PAGES, color, NOT_INSIDE_PROJECT_MESSAGE, findProjectRoot };
|