mdsmith 1.0.2 → 1.1.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/README-MDSMITH.md +30 -0
- package/bin/{fundamentos.js → beta.js} +15 -14
- package/bin/index.js +151 -34
- package/package.json +1 -1
- package/bin/versaobeta.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
# mdsmith
|
|
3
|
+
|
|
4
|
+
CLI para gerar READMEs e arquivos Markdown
|
|
5
|
+
|
|
6
|
+
## 🔖 Informações
|
|
7
|
+
- **Versão:** 1.0.2
|
|
8
|
+
- **Gerenciador:** npm
|
|
9
|
+
- **Tipo:** Projeto Node.js
|
|
10
|
+
|
|
11
|
+
## 🚀 Dependências
|
|
12
|
+
Projeto sem dependências.
|
|
13
|
+
|
|
14
|
+
## 📁 Estrutura do Projeto
|
|
15
|
+
```
|
|
16
|
+
📂 bin
|
|
17
|
+
📄 beta.js
|
|
18
|
+
📄 index.js
|
|
19
|
+
📂 node_modules
|
|
20
|
+
📄 package-lock.json
|
|
21
|
+
📄 package.json
|
|
22
|
+
📄 README-MDSMITH.md
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 📜 Scripts disponíveis
|
|
27
|
+
Projeto sem scripts.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
📄 *README gerado automaticamente pelo **mdSmith***
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// npx
|
|
4
|
-
// npx
|
|
5
|
-
// npx
|
|
6
|
-
// npx
|
|
3
|
+
// npx mdsmith --help # ajuda
|
|
4
|
+
// npx mdsmith --tree # mostra estrutura
|
|
5
|
+
// npx mdsmith --deps # mostra dependências
|
|
6
|
+
// npx mdsmith --readme # gera README
|
|
7
7
|
|
|
8
8
|
const fs = require("fs");
|
|
9
9
|
|
|
@@ -63,7 +63,7 @@ function generateReadme(packageJson, tree){
|
|
|
63
63
|
const content = `
|
|
64
64
|
# ${packageJson.name || "Nome não informado."}
|
|
65
65
|
|
|
66
|
-
${packageJson.description || "Projeto Node.js analisado automaticamente pelo
|
|
66
|
+
${packageJson.description || "Projeto Node.js analisado automaticamente pelo mdSmith."}
|
|
67
67
|
|
|
68
68
|
## 🔖 Informações
|
|
69
69
|
- **Versão:** ${packageJson.version || "Versão não informada."}
|
|
@@ -78,7 +78,7 @@ ${formatDependencies(packageJson.dependencies)}
|
|
|
78
78
|
${tree}
|
|
79
79
|
\`\`\`
|
|
80
80
|
|
|
81
|
-
📄 *README gerado automaticamente pelo **
|
|
81
|
+
📄 *README gerado automaticamente pelo **mdSmith***
|
|
82
82
|
`
|
|
83
83
|
|
|
84
84
|
return content
|
|
@@ -87,18 +87,18 @@ ${tree}
|
|
|
87
87
|
|
|
88
88
|
if(args.length == 0){
|
|
89
89
|
console.log(`
|
|
90
|
-
Bem vindo ao
|
|
90
|
+
Bem vindo ao mdSmith!
|
|
91
91
|
Analisador de projetos Node.js
|
|
92
92
|
|
|
93
|
-
Digite
|
|
93
|
+
Digite npx mdsmith --help se quiser ver os comandos disponíveis
|
|
94
94
|
`);
|
|
95
95
|
process.exit(0);
|
|
96
96
|
} else if(args.includes("--help")){
|
|
97
97
|
console.log(`
|
|
98
|
-
npx
|
|
99
|
-
npx
|
|
100
|
-
npx
|
|
101
|
-
npx
|
|
98
|
+
npx mdsmith --help Mostra os comandos possíveis
|
|
99
|
+
npx mdsmith --tree Mostra a estrutura do projeto
|
|
100
|
+
npx mdsmith --deps Mostra as dependências
|
|
101
|
+
npx mdsmith --readme Gera um README automaticamente
|
|
102
102
|
`)
|
|
103
103
|
} else if (args.includes("--tree")){
|
|
104
104
|
console.log("\n🌳 Estrutura do projeto:\n");
|
|
@@ -110,7 +110,8 @@ if(args.length == 0){
|
|
|
110
110
|
} else if (args.includes("--readme")){
|
|
111
111
|
const content = generateReadme(packageJson, scanDir(projectRoot, 0))
|
|
112
112
|
|
|
113
|
-
fs.writeFileSync("README-
|
|
113
|
+
fs.writeFileSync("README-MDSMITH.md", content)
|
|
114
|
+
console.log("✅ README-MDSMITH.md gerado com sucesso!")
|
|
114
115
|
} else {
|
|
115
|
-
console.log("❌ Comando não reconhecido. Use --help para ver as opções.")
|
|
116
|
+
console.log("❌ Comando não reconhecido. Use npx mdsmith --help para ver as opções.")
|
|
116
117
|
}
|
package/bin/index.js
CHANGED
|
@@ -9,6 +9,13 @@ const fs = require("fs");
|
|
|
9
9
|
|
|
10
10
|
const path = require("path");
|
|
11
11
|
|
|
12
|
+
const readline = require("readline");
|
|
13
|
+
|
|
14
|
+
const rl = readline.createInterface({
|
|
15
|
+
input: process.stdin,
|
|
16
|
+
output: process.stdout
|
|
17
|
+
});
|
|
18
|
+
|
|
12
19
|
const projectRoot = process.cwd();
|
|
13
20
|
|
|
14
21
|
if(!fs.existsSync(path.join(process.cwd(), "package.json"))){
|
|
@@ -59,16 +66,117 @@ function scanDir(dirPath, padding) {
|
|
|
59
66
|
return treeContent
|
|
60
67
|
}
|
|
61
68
|
|
|
62
|
-
function
|
|
69
|
+
function perguntar(pergunta) {
|
|
70
|
+
return new Promise(resolve => {
|
|
71
|
+
rl.question(pergunta, resolve);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function buscarNome(nome){
|
|
76
|
+
if(!nome || nome == "" || nome == false){
|
|
77
|
+
|
|
78
|
+
let respostaValida = false
|
|
79
|
+
let resposta = ""
|
|
80
|
+
while(!respostaValida){
|
|
81
|
+
resposta = await perguntar("Não achamos o nome do projeto nos arquivos do Package.json, gostaria de informar pelo terminal? (y/n): ")
|
|
82
|
+
resposta = resposta.toLowerCase()
|
|
83
|
+
|
|
84
|
+
if(resposta == "y" || resposta == "n"){
|
|
85
|
+
respostaValida = true
|
|
86
|
+
}else {
|
|
87
|
+
console.log("Digite Y ou N caso queira prosseguir.")
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
if(resposta == "n"){
|
|
93
|
+
console.log("Escolha feita. O título do Readme ficará como NOME DO PROJETO NÃO INFORMADO.")
|
|
94
|
+
return "Nome do projeto não informado"
|
|
95
|
+
}if(resposta == "y"){
|
|
96
|
+
let nome = await perguntar("Informe o nome desejado para colocarmos no nome do projeto: ")
|
|
97
|
+
console.log("Obrigado por informar o nome!")
|
|
98
|
+
return nome
|
|
99
|
+
}else{
|
|
100
|
+
console.error("Erro ao gerar o nome do readme.")
|
|
101
|
+
process.exit(1)
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return nome
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function buscarDescricao(descricao){
|
|
109
|
+
if(!descricao || descricao == "" || descricao == false){
|
|
110
|
+
|
|
111
|
+
let respostaValida = false
|
|
112
|
+
let resposta = ""
|
|
113
|
+
while(!respostaValida){
|
|
114
|
+
resposta = await perguntar("Não achamos a descrição do projeto nos arquivos do Package.json, gostaria de informar pelo terminal? (y/n): ")
|
|
115
|
+
resposta = resposta.toLowerCase()
|
|
116
|
+
|
|
117
|
+
if(resposta == "y" || resposta == "n"){
|
|
118
|
+
respostaValida = true
|
|
119
|
+
}else {
|
|
120
|
+
console.log("Digite Y ou N caso queira prosseguir.")
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if(resposta == "n"){
|
|
126
|
+
console.log("\nEscolha feita. O campo da descrição ficará presente para preenchimento posterior.\n")
|
|
127
|
+
return "*Digite aqui a descrição do projeto*"
|
|
128
|
+
}if(resposta == "y"){
|
|
129
|
+
let descricao = await perguntar("Conte-me sobre seu projeto: ")
|
|
130
|
+
console.log("\nObrigado por informar os dados do seu projeto!\n")
|
|
131
|
+
return descricao
|
|
132
|
+
}else{
|
|
133
|
+
console.error("Erro ao gerar o a descrição do readme.")
|
|
134
|
+
process.exit(1)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return descricao
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function detectarTipoProjeto(packageJson) {
|
|
142
|
+
const deps = {
|
|
143
|
+
...packageJson.dependencies,
|
|
144
|
+
...packageJson.devDependencies
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (deps.react) return "Frontend React"
|
|
148
|
+
if (deps.next) return "Next.js Application"
|
|
149
|
+
if (deps.express) return "API REST (Express)"
|
|
150
|
+
if (deps.typescript) return "Projeto TypeScript"
|
|
151
|
+
|
|
152
|
+
return "Projeto Node.js"
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function formatScripts(scripts) {
|
|
156
|
+
if (!scripts || Object.keys(scripts).length === 0) {
|
|
157
|
+
return "Projeto sem scripts.";
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return Object.entries(scripts)
|
|
161
|
+
.map(([name, script]) => `- ${name} -> ${script}`)
|
|
162
|
+
.join("\n");
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
async function generateReadme(packageJson, tree){
|
|
167
|
+
|
|
168
|
+
const nomeProjeto = await buscarNome(packageJson.name);
|
|
169
|
+
const descricaoProjeto = await buscarDescricao(packageJson.description);
|
|
170
|
+
|
|
63
171
|
const content = `
|
|
64
|
-
# ${
|
|
172
|
+
# ${nomeProjeto}
|
|
65
173
|
|
|
66
|
-
${
|
|
174
|
+
${descricaoProjeto}
|
|
67
175
|
|
|
68
176
|
## 🔖 Informações
|
|
69
177
|
- **Versão:** ${packageJson.version || "Versão não informada."}
|
|
70
178
|
- **Gerenciador:** npm
|
|
71
|
-
- **Tipo:**
|
|
179
|
+
- **Tipo:** ${detectarTipoProjeto(packageJson)}
|
|
72
180
|
|
|
73
181
|
## 🚀 Dependências
|
|
74
182
|
${formatDependencies(packageJson.dependencies)}
|
|
@@ -78,6 +186,10 @@ ${formatDependencies(packageJson.dependencies)}
|
|
|
78
186
|
${tree}
|
|
79
187
|
\`\`\`
|
|
80
188
|
|
|
189
|
+
## 📜 Scripts disponíveis
|
|
190
|
+
${formatScripts(packageJson.scripts)}
|
|
191
|
+
|
|
192
|
+
|
|
81
193
|
📄 *README gerado automaticamente pelo **mdSmith***
|
|
82
194
|
`
|
|
83
195
|
|
|
@@ -85,33 +197,38 @@ ${tree}
|
|
|
85
197
|
|
|
86
198
|
}
|
|
87
199
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
200
|
+
async function main() {
|
|
201
|
+
if(args.length == 0){
|
|
202
|
+
console.log(`
|
|
203
|
+
Bem vindo ao mdSmith!
|
|
204
|
+
Analisador de projetos Node.js
|
|
205
|
+
|
|
206
|
+
Digite npx mdsmith --help se quiser ver os comandos disponíveis
|
|
207
|
+
`);
|
|
208
|
+
process.exit(0);
|
|
209
|
+
} else if(args.includes("--help")){
|
|
210
|
+
console.log(`
|
|
211
|
+
npx mdsmith --help Mostra os comandos possíveis
|
|
212
|
+
npx mdsmith --tree Mostra a estrutura do projeto
|
|
213
|
+
npx mdsmith --deps Mostra as dependências
|
|
214
|
+
npx mdsmith --readme Gera um README automaticamente
|
|
215
|
+
`)
|
|
216
|
+
} else if (args.includes("--tree")){
|
|
217
|
+
console.log("\n🌳 Estrutura do projeto:\n");
|
|
218
|
+
console.log(scanDir(projectRoot, 0))
|
|
219
|
+
} else if (args.includes("--deps")){
|
|
220
|
+
console.log(`O projeto ${packageJson.name} na versão ${packageJson.version}, tem as seguintes dependencias:`)
|
|
221
|
+
const deps = packageJson.dependencies || "Projeto sem depedencias"
|
|
222
|
+
console.log(deps)
|
|
223
|
+
} else if (args.includes("--readme")){
|
|
224
|
+
const content = await generateReadme(packageJson, scanDir(projectRoot, 0))
|
|
225
|
+
|
|
226
|
+
fs.writeFileSync("README-MDSMITH.md", content)
|
|
227
|
+
console.log("✅ README-MDSMITH.md gerado com sucesso!")
|
|
228
|
+
process.exit(0);
|
|
229
|
+
} else {
|
|
230
|
+
console.log("❌ Comando não reconhecido. Use npx mdsmith --help para ver as opções.")
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
main()
|
package/package.json
CHANGED
package/bin/versaobeta.js
DELETED
|
File without changes
|