mdsmith 1.1.0 β†’ 1.1.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.
package/README-MDSMITH.md CHANGED
@@ -1,30 +1,30 @@
1
1
 
2
- # mdsmith
2
+ # Docuapi
3
3
 
4
4
  CLI para gerar READMEs e arquivos Markdown
5
5
 
6
- ## πŸ”– InformaΓ§Γ΅es
7
- - **VersΓ£o:** 1.0.2
8
- - **Gerenciador:** npm
9
- - **Tipo:** Projeto Node.js
6
+ ## πŸ”– Project Info
7
+ - **Version:** 1.1.1
8
+ - **Package Manager:** npm
9
+ - **Type:** Node.js Project
10
10
 
11
- ## πŸš€ DependΓͺncias
12
- Projeto sem dependΓͺncias.
11
+ ## πŸš€ Dependencies
12
+ No dependencies found.
13
13
 
14
- ## πŸ“ Estrutura do Projeto
14
+
15
+ ## πŸ“ Project Structure
15
16
  ```
16
17
  πŸ“‚ bin
17
18
  πŸ“„ beta.js
18
19
  πŸ“„ index.js
19
- πŸ“‚ node_modules
20
- πŸ“„ package-lock.json
20
+ πŸ“„ mdsmith.config.json
21
21
  πŸ“„ package.json
22
22
  πŸ“„ README-MDSMITH.md
23
23
 
24
24
  ```
25
25
 
26
- ## πŸ“œ Scripts disponΓ­veis
27
- Projeto sem scripts.
26
+ ## πŸ“œ Available Scripts
27
+ No scripts available.
28
28
 
29
29
 
30
- πŸ“„ *README gerado automaticamente pelo **mdSmith***
30
+ Generated by **mdSmith**
package/bin/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // npx mdsmith --help # ajuda
4
- // npx mdsmith --tree # mostra estrutura
5
- // npx mdsmith --deps # mostra dependΓͺncias
6
- // npx mdsmith --readme # gera README
3
+ // npx mdsmith --help # show help
4
+ // npx mdsmith --init # create config file
5
+ // npx mdsmith --tree # show project structure
6
+ // npx mdsmith --deps # list dependencies
7
+ // npx mdsmith --readme # generate README
8
+
7
9
 
8
10
  const fs = require("fs");
9
11
 
@@ -19,7 +21,10 @@ const rl = readline.createInterface({
19
21
  const projectRoot = process.cwd();
20
22
 
21
23
  if(!fs.existsSync(path.join(process.cwd(), "package.json"))){
22
- console.log("Package.json nΓ£o encontrado.\nVerifique se vocΓͺ estΓ‘ rodando o comando na raiz do projeto.")
24
+ console.log(`
25
+ Error: package.json not found.
26
+ Please run mdsmith from the project root.
27
+ `)
23
28
  process.exit(1)
24
29
  }
25
30
 
@@ -27,11 +32,15 @@ const packageJson = JSON.parse(fs.readFileSync(path.join(projectRoot, "package.j
27
32
 
28
33
  const args = process.argv.slice(2)
29
34
 
30
- const IGNORE_DIRS = ["node_modules", ".git", ".vscode"];
35
+ const defaultConfig = {
36
+ ignore: ["node_modules", ".git", ".vscode"],
37
+ depth: Infinity
38
+ }
39
+
31
40
 
32
41
  function formatDependencies(deps) {
33
42
  if (!deps || Object.keys(deps).length === 0) {
34
- return "Projeto sem dependΓͺncias.";
43
+ return "No dependencies found.\n";
35
44
  }
36
45
 
37
46
  return Object.entries(deps)
@@ -39,8 +48,13 @@ function formatDependencies(deps) {
39
48
  .join("\n");
40
49
  }
41
50
 
42
- function scanDir(dirPath, padding) {
43
- const entries = fs.readdirSync(dirPath, { withFileTypes: true });
51
+ function scanDir(dirPath, padding, config) {
52
+ const entries = fs.readdirSync(dirPath, { withFileTypes: true })
53
+ .sort((a, b) => {
54
+ if (a.isDirectory() && !b.isDirectory()) return -1
55
+ if (!a.isDirectory() && b.isDirectory()) return 1
56
+ return a.name.localeCompare(b.name)
57
+ })
44
58
 
45
59
  let treeContent = ""
46
60
 
@@ -50,16 +64,24 @@ function scanDir(dirPath, padding) {
50
64
  const fullPath = path.join(dirPath, entry.name);
51
65
 
52
66
  if (entry.isDirectory()) {
53
- if (IGNORE_DIRS.includes(entry.name)){
54
- treeContent += `${" ".repeat(padding*2)} πŸ“‚ ${entry.name}\n`
67
+ if (config.ignore.includes(entry.name)){
68
+ continue
55
69
  } else {
56
70
  treeContent += `${" ".repeat(padding*2)} πŸ“‚ ${entry.name}\n`
57
- padding ++
58
- treeContent += scanDir(fullPath, padding)
59
- padding --
71
+ if (config.depth === null || padding < config.depth){
72
+ padding ++
73
+ treeContent += scanDir(fullPath, padding, config)
74
+ padding --
75
+ } else {
76
+ treeContent += `${" ".repeat((padding + 1) * 2)} Β·Β·Β· \n`
77
+ }
60
78
  }
61
79
  } else {
62
- treeContent += `${" ".repeat(padding*2)} πŸ“„ ${entry.name}\n`
80
+ if (config.ignore.includes(entry.name)){
81
+ continue
82
+ } else{
83
+ treeContent += `${" ".repeat(padding*2)} πŸ“„ ${entry.name}\n`
84
+ }
63
85
  }
64
86
  }
65
87
 
@@ -78,26 +100,28 @@ async function buscarNome(nome){
78
100
  let respostaValida = false
79
101
  let resposta = ""
80
102
  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()
103
+ resposta = await perguntar(`
104
+ Project name not found in package.json.
105
+ Would you like to provide one? (y/n): `)
106
+ resposta = resposta.trim().toLowerCase()
83
107
 
84
108
  if(resposta == "y" || resposta == "n"){
85
109
  respostaValida = true
86
110
  }else {
87
- console.log("Digite Y ou N caso queira prosseguir.")
111
+ console.log("Please type y or n.")
88
112
  }
89
113
  }
90
114
 
91
115
 
92
116
  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"
117
+ console.log("\nProject name will be set as Unnamed Project.\n")
118
+ return "Unnamed Project"
95
119
  }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!")
120
+ let nome = await perguntar("Enter the project name: ")
121
+ console.log(`Project name set to "${nome}".`)
98
122
  return nome
99
123
  }else{
100
- console.error("Erro ao gerar o nome do readme.")
124
+ console.error("Failed to generate project name.")
101
125
  process.exit(1)
102
126
  }
103
127
  }
@@ -111,26 +135,28 @@ async function buscarDescricao(descricao){
111
135
  let respostaValida = false
112
136
  let resposta = ""
113
137
  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()
138
+ resposta = await perguntar(`
139
+ Project description not found.
140
+ Would you like to provide one? (y/n): `)
141
+ resposta = resposta.trim().toLowerCase()
116
142
 
117
143
  if(resposta == "y" || resposta == "n"){
118
144
  respostaValida = true
119
145
  }else {
120
- console.log("Digite Y ou N caso queira prosseguir.")
146
+ console.log("Please type y or n.")
121
147
  }
122
148
  }
123
149
 
124
150
 
125
151
  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*"
152
+ console.log("\nDescription placeholder added.\n")
153
+ return "*Project description goes here*"
128
154
  }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")
155
+ let descricao = await perguntar("Enter the project description: ")
156
+ console.log("\nDescription saved.\n")
131
157
  return descricao
132
158
  }else{
133
- console.error("Erro ao gerar o a descriΓ§Γ£o do readme.")
159
+ console.error("Failed to generate project description.")
134
160
  process.exit(1)
135
161
  }
136
162
  }
@@ -149,12 +175,12 @@ function detectarTipoProjeto(packageJson) {
149
175
  if (deps.express) return "API REST (Express)"
150
176
  if (deps.typescript) return "Projeto TypeScript"
151
177
 
152
- return "Projeto Node.js"
178
+ return "Node.js Project"
153
179
  }
154
180
 
155
181
  function formatScripts(scripts) {
156
182
  if (!scripts || Object.keys(scripts).length === 0) {
157
- return "Projeto sem scripts.";
183
+ return "No scripts available.\n";
158
184
  }
159
185
 
160
186
  return Object.entries(scripts)
@@ -173,62 +199,152 @@ const content = `
173
199
 
174
200
  ${descricaoProjeto}
175
201
 
176
- ## πŸ”– InformaΓ§Γ΅es
177
- - **VersΓ£o:** ${packageJson.version || "VersΓ£o nΓ£o informada."}
178
- - **Gerenciador:** npm
179
- - **Tipo:** ${detectarTipoProjeto(packageJson)}
202
+ ## πŸ”– Project Info
203
+ - **Version:** ${packageJson.version || "Not specified"}
204
+ - **Package Manager:** npm
205
+ - **Type:** ${detectarTipoProjeto(packageJson)}
180
206
 
181
- ## πŸš€ DependΓͺncias
207
+ ## πŸš€ Dependencies
182
208
  ${formatDependencies(packageJson.dependencies)}
183
209
 
184
- ## πŸ“ Estrutura do Projeto
210
+ ## πŸ“ Project Structure
185
211
  \`\`\`
186
212
  ${tree}
187
213
  \`\`\`
188
214
 
189
- ## πŸ“œ Scripts disponΓ­veis
215
+ ## πŸ“œ Available Scripts
190
216
  ${formatScripts(packageJson.scripts)}
191
217
 
192
-
193
- πŸ“„ *README gerado automaticamente pelo **mdSmith***
218
+ Generated by **mdSmith**
194
219
  `
195
220
 
196
221
  return content
197
222
 
198
223
  }
199
224
 
225
+ function loadConfig(projectRoot) {
226
+ const configPath = path.join(projectRoot, "mdsmith.config.json")
227
+
228
+ if (!fs.existsSync(configPath)) {
229
+ return defaultConfig
230
+ }
231
+
232
+ try {
233
+ const fileContent = fs.readFileSync(configPath, "utf-8")
234
+ const userConfig = JSON.parse(fileContent)
235
+
236
+ return {
237
+ ...defaultConfig,
238
+ ...userConfig,
239
+ ignore: [
240
+ ...defaultConfig.ignore,
241
+ ...(userConfig.ignore || [])
242
+ ]
243
+ }
244
+
245
+
246
+ } catch (error) {
247
+ console.log("Failed to read mdsmith.config.json. Using default configuration.")
248
+ return defaultConfig
249
+ }
250
+ }
251
+
200
252
  async function main() {
253
+ const config = loadConfig(projectRoot)
254
+
201
255
  if(args.length == 0){
202
256
  console.log(`
203
- Bem vindo ao mdSmith!
204
- Analisador de projetos Node.js
257
+ mdSmith
258
+ Node.js project analyzer
259
+ ────────────────────────
205
260
 
206
- Digite npx mdsmith --help se quiser ver os comandos disponΓ­veis
261
+ Run "mdsmith --help" to view available commands.
207
262
  `);
208
263
  process.exit(0);
264
+ }else if (args.includes("--init")) {
265
+
266
+ const configPath = path.join(projectRoot, "mdsmith.config.json")
267
+
268
+ if (fs.existsSync(configPath)) {
269
+ console.log("mdsmith.config.json already exists.")
270
+ process.exit(0)
271
+ }
272
+
273
+ fs.writeFileSync(
274
+ configPath,
275
+ JSON.stringify(defaultConfig, null, 2)
276
+ )
277
+
278
+ console.log("Configuration file created.")
279
+ process.exit(0)
280
+
209
281
  } else if(args.includes("--help")){
210
282
  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
283
+ mdSmith β€” Available Commands
284
+ ────────────────────────
285
+
286
+ --help Show help
287
+ --init Create config file
288
+ --tree Show project structure
289
+ --deps List dependencies
290
+ --readme Generate README
215
291
  `)
292
+ process.exit(0)
216
293
  } else if (args.includes("--tree")){
217
- console.log("\n🌳 Estrutura do projeto:\n");
218
- console.log(scanDir(projectRoot, 0))
294
+ console.log(`
295
+ Project Structure
296
+ ────────────────────────
297
+ `);
298
+ console.log(scanDir(projectRoot, 0, config))
299
+ process.exit(0)
219
300
  } 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"
301
+ console.log(`
302
+ Dependencies
303
+ ────────────────────────
304
+ `)
305
+ const deps = formatDependencies(packageJson.dependencies)
222
306
  console.log(deps)
307
+ process.exit(0)
223
308
  } else if (args.includes("--readme")){
224
- const content = await generateReadme(packageJson, scanDir(projectRoot, 0))
309
+ const content = await generateReadme(packageJson, scanDir(projectRoot, 0, config))
225
310
 
226
- fs.writeFileSync("README-MDSMITH.md", content)
227
- console.log("βœ… README-MDSMITH.md gerado com sucesso!")
228
- process.exit(0);
311
+ console.log(`
312
+ README Preview
313
+ ────────────────────────
314
+ `)
315
+
316
+ console.log(content)
317
+
318
+ let respostaValida = false
319
+ let confirm = ""
320
+
321
+ while (!respostaValida) {
322
+ confirm = await perguntar("\nGenerate README-MDSMITH.md? (y/n): ")
323
+ confirm = confirm.trim().toLowerCase()
324
+
325
+ if (confirm === "y" || confirm === "n") {
326
+ respostaValida = true
327
+ } else {
328
+ console.log("\nPlease type y or n.")
329
+ }
330
+ }
331
+
332
+ if (confirm === "y") {
333
+ fs.writeFileSync("README-MDSMITH.md", content)
334
+ console.log("\nREADME-MDSMITH.md created.\n")
335
+ process.exit(0)
336
+ } else {
337
+ console.log("\nOperation cancelled.\n")
338
+ process.exit(0)
339
+ }
229
340
  } else {
230
- console.log("❌ Comando não reconhecido. Use npx mdsmith --help para ver as opçáes.")
341
+ console.log(`
342
+ Unknown command.
343
+ Run "mdsmith --help" for usage.
344
+ `)
345
+ process.exit(0)
231
346
  }
232
347
  }
233
348
 
234
- main()
349
+ main()
350
+
@@ -0,0 +1,8 @@
1
+ {
2
+ "ignore": [
3
+ "node_modules",
4
+ ".git",
5
+ ".vscode"
6
+ ],
7
+ "depth": 1
8
+ }
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package.json",
2
3
  "name": "mdsmith",
3
- "version": "1.1.0",
4
+ "version": "1.1.2",
4
5
  "description": "CLI para gerar READMEs e arquivos Markdown",
5
6
  "bin": {
6
7
  "mdsmith": "./bin/index.js"