mdsmith 1.1.0 β†’ 1.1.1

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