kaelum 1.3.3 → 1.3.4
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/README.md +9 -3
- package/cli/create.js +60 -4
- package/cli/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<h1>Kaelum</h1>
|
|
2
4
|
|
|
3
5
|
[](https://www.npmjs.com/package/kaelum)
|
|
4
6
|
[](https://github.com/MatheusCampagnolo/kaelum/actions)
|
|
5
7
|
[](LICENSE)
|
|
6
8
|
[](https://matheuscampagnolo.github.io/kaelum/)
|
|
7
9
|
|
|
8
|
-
**Kaelum.
|
|
10
|
+
**Kaelum.js** — Minimalist Node.js framework to simplify creation of web pages and REST APIs.
|
|
9
11
|
Designed for students and developers who want a fast, opinionated project scaffold and a small, friendly API that encapsulates common Express.js boilerplate.
|
|
10
12
|
|
|
11
13
|
👉 [**Read the full documentation here**](https://matheuscampagnolo.github.io/kaelum/)
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
**If Kaelum helps you, consider supporting its development:**
|
|
16
|
+
|
|
17
|
+
<a href='https://ko-fi.com/Z8Z51NK4KT' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
|
|
18
|
+
|
|
19
|
+
</div>
|
|
14
20
|
|
|
15
21
|
## 🚀 Quick start
|
|
16
22
|
|
package/cli/create.js
CHANGED
|
@@ -3,12 +3,42 @@ const inq = inquirer.default || inquirer;
|
|
|
3
3
|
const path = require("path");
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const { copyTemplate } = require("./utils");
|
|
6
|
+
const { spawn } = require("child_process");
|
|
6
7
|
|
|
7
8
|
const templatesDir = path.resolve(__dirname, "templates");
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* runInstall - runs `npm ci` if package-lock exists, otherwise `npm install`
|
|
12
|
+
* @param {string} cwd - target directory where install runs
|
|
13
|
+
* @returns {Promise<void>}
|
|
14
|
+
*/
|
|
15
|
+
function runInstall(cwd) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
const lockExists = fs.existsSync(path.join(cwd, "package-lock.json"));
|
|
18
|
+
const cmd = "npm";
|
|
19
|
+
const args = lockExists ? ["ci"] : ["install"];
|
|
20
|
+
|
|
21
|
+
// Spawn child process and inherit stdio so user sees progress
|
|
22
|
+
const child = spawn(cmd, args, {
|
|
23
|
+
cwd,
|
|
24
|
+
stdio: "inherit",
|
|
25
|
+
shell: process.platform === "win32", // improves compatibility on Windows
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.on("error", (err) => {
|
|
29
|
+
reject(err);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
child.on("exit", (code) => {
|
|
33
|
+
if (code === 0) return resolve();
|
|
34
|
+
reject(new Error(`${cmd} ${args.join(" ")} exited with code ${code}`));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
9
39
|
/**
|
|
10
40
|
* createProject - create project from template
|
|
11
|
-
* @param {Object} defaults - optional { projectName, template }
|
|
41
|
+
* @param {Object} defaults - optional { projectName, template, autoInstall }
|
|
12
42
|
*/
|
|
13
43
|
async function createProject(defaults = {}) {
|
|
14
44
|
console.log("🚀 Bem-vindo ao Kaelum CLI!");
|
|
@@ -47,9 +77,19 @@ async function createProject(defaults = {}) {
|
|
|
47
77
|
},
|
|
48
78
|
default: defaults.template || "web",
|
|
49
79
|
},
|
|
80
|
+
{
|
|
81
|
+
type: "confirm",
|
|
82
|
+
name: "autoInstall",
|
|
83
|
+
message:
|
|
84
|
+
"Deseja que eu execute 'npm install' agora (recomendado)?",
|
|
85
|
+
default:
|
|
86
|
+
typeof defaults.autoInstall === "boolean"
|
|
87
|
+
? defaults.autoInstall
|
|
88
|
+
: true,
|
|
89
|
+
},
|
|
50
90
|
]);
|
|
51
91
|
|
|
52
|
-
const { projectName, template } = answers;
|
|
92
|
+
const { projectName, template, autoInstall } = answers;
|
|
53
93
|
const targetDir = path.resolve(process.cwd(), projectName);
|
|
54
94
|
const templateDir = path.join(templatesDir, template);
|
|
55
95
|
|
|
@@ -76,10 +116,26 @@ async function createProject(defaults = {}) {
|
|
|
76
116
|
|
|
77
117
|
console.log(`\n✅ Projeto "${projectName}" criado com sucesso!`);
|
|
78
118
|
console.log(`➡️ Acesse a pasta: cd ${projectName}`);
|
|
79
|
-
|
|
119
|
+
|
|
120
|
+
if (autoInstall) {
|
|
121
|
+
console.log("⬇️ Instalando dependências (npm)... (isso pode levar alguns minutos)");
|
|
122
|
+
try {
|
|
123
|
+
await runInstall(targetDir);
|
|
124
|
+
console.log("\n✅ Dependências instaladas com sucesso!");
|
|
125
|
+
console.log("➡️ Para iniciar o projeto, execute: npm start\n");
|
|
126
|
+
} catch (installErr) {
|
|
127
|
+
console.error(
|
|
128
|
+
"\n❌ Falha ao instalar dependências automaticamente:",
|
|
129
|
+
installErr.message || installErr
|
|
130
|
+
);
|
|
131
|
+
console.log(`➡️ Tente manualmente: cd ${projectName} && npm install`);
|
|
132
|
+
}
|
|
133
|
+
} else {
|
|
134
|
+
console.log(`➡️ Inicie o projeto com: cd ${projectName} && npm install && npm start\n`);
|
|
135
|
+
}
|
|
80
136
|
} catch (err) {
|
|
81
137
|
console.error("❌ Erro inesperado:", err.message || err);
|
|
82
138
|
}
|
|
83
139
|
}
|
|
84
140
|
|
|
85
|
-
module.exports = { createProject };
|
|
141
|
+
module.exports = { createProject };
|
package/cli/index.js
CHANGED