mddd-cli 1.0.2 → 1.0.3
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/bin/cli.js +28 -36
- package/package.json +1 -1
- package/readme.md +7 -1
package/bin/cli.js
CHANGED
|
@@ -130,64 +130,56 @@ program
|
|
|
130
130
|
.option('-m, --macro', 'Define se o novo arquivo será um macro de módulo contendo stateDiagram-v2')
|
|
131
131
|
.option('-p, --parent <parentFile>', 'Caminho de um arquivo spec (.spec.md) existente para conectar este novo fluxo')
|
|
132
132
|
.action((targetPath, options) => {
|
|
133
|
+
// Garante que o diretório base exista
|
|
133
134
|
if (!fs.existsSync(targetPath)) {
|
|
134
135
|
fs.mkdirSync(targetPath, { recursive: true });
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
// Correção: Extrai o nome da feature para o arquivo
|
|
139
|
+
// Se targetPath terminar em /routing, folderName será 'routing'.
|
|
140
|
+
// O arquivo será 'routing.spec.md'.
|
|
137
141
|
const folderName = path.basename(targetPath);
|
|
138
|
-
const isMacro = options.macro;
|
|
139
|
-
|
|
140
|
-
// Extensão universal .spec.md para absolutamente tudo
|
|
141
142
|
const finalFile = path.join(targetPath, `${folderName}.spec.md`);
|
|
142
143
|
|
|
144
|
+
// Segurança: Verifica se o caminho final existe e é um diretório
|
|
145
|
+
if (fs.existsSync(finalFile) && fs.lstatSync(finalFile).isDirectory()) {
|
|
146
|
+
console.log(pc.red(`❌ Erro: Já existe um diretório com o nome ${finalFile}. Não é possível criar o arquivo spec.`));
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
|
|
143
150
|
if (fs.existsSync(finalFile)) {
|
|
144
151
|
console.log(pc.yellow(`⚠️ A especificação já existe em: ${finalFile}`));
|
|
145
152
|
return;
|
|
146
153
|
}
|
|
147
154
|
|
|
148
|
-
|
|
149
|
-
let template = '';
|
|
155
|
+
const isMacro = options.macro;
|
|
150
156
|
const version = 'v1.0.0';
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
`## 2. Matriz de Decisão\n| Condição | Ação | Próximo Estado |\n| :--- | :--- | :--- |\n| | | |\n\n` +
|
|
160
|
-
`## 3. Histórico de Auditoria\n<details>\n<summary>Clique para expandir</summary>\n\n\n\n</details>\n`;
|
|
161
|
-
}
|
|
157
|
+
let template = isMacro
|
|
158
|
+
? `\n# Macro Módulo: ${folderName} | ${version}\n\n` +
|
|
159
|
+
`\`\`\`mermaid\n%% @spec-version ${version}\nstateDiagram-v2\n [*] --> Inicial_${folderName}\n\`\`\`\n\n` +
|
|
160
|
+
`## 3. Histórico de Auditoria\n<details>\n<summary>Clique para expandir</summary>\n\n\n\n</details>\n`
|
|
161
|
+
: `\n# Especificação: ${folderName} | ${version}\n\n` +
|
|
162
|
+
`## 1. Contrato de Fluxo (Mermaid)\n\`\`\`mermaid\n%% @spec-version ${version}\ngraph LR\n A([Início]) --> B[Processo]\n\`\`\`\n\n` +
|
|
163
|
+
`## 2. Matriz de Decisão\n| Condição | Ação | Próximo Estado |\n| :--- | :--- | :--- |\n| | | |\n\n` +
|
|
164
|
+
`## 3. Histórico de Auditoria\n<details>\n<summary>Clique para expandir</summary>\n\n\n\n</details>\n`;
|
|
162
165
|
|
|
163
166
|
fs.writeFileSync(finalFile, template);
|
|
164
|
-
console.log(pc.green(`✅ Novo arquivo Markdown criado
|
|
165
|
-
|
|
166
|
-
// Lógica de Vinculação
|
|
167
|
-
let macroPath = null;
|
|
168
|
-
if (options.parent) {
|
|
169
|
-
if (fs.existsSync(options.parent)) {
|
|
170
|
-
macroPath = options.parent;
|
|
171
|
-
console.log(pc.cyan('🎯 Usando o arquivo pai explícito enviado por parâmetro.'));
|
|
172
|
-
} else {
|
|
173
|
-
console.log(pc.red(`❌ O arquivo pai indicado não foi encontrado: ${options.parent}`));
|
|
174
|
-
process.exit(1);
|
|
175
|
-
}
|
|
176
|
-
} else if (!isMacro) {
|
|
177
|
-
macroPath = findClosestMacro(targetPath);
|
|
178
|
-
}
|
|
167
|
+
console.log(pc.green(`✅ Novo arquivo Markdown criado: ${finalFile}`));
|
|
168
|
+
|
|
169
|
+
// Lógica de Vinculação
|
|
170
|
+
let macroPath = options.parent || (!isMacro ? findClosestMacro(targetPath) : null);
|
|
179
171
|
|
|
180
172
|
if (macroPath) {
|
|
173
|
+
if (!fs.existsSync(macroPath)) {
|
|
174
|
+
console.log(pc.red(`❌ Arquivo pai não encontrado: ${macroPath}`));
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
181
177
|
const relativePath = path.relative(path.dirname(macroPath), finalFile);
|
|
182
|
-
const cleanLinkPath = relativePath.replace(/\\/g, '/');
|
|
183
|
-
|
|
184
|
-
// Como o pai é um arquivo Markdown, injetamos uma seção de navegação limpa no fim do documento
|
|
178
|
+
const cleanLinkPath = relativePath.replace(/\\/g, '/');
|
|
185
179
|
const injection = `\n\n%% Conexão automática para sub-fluxo\n- [Ir para as regras de ${folderName}](file://./${cleanLinkPath})\n`;
|
|
186
180
|
|
|
187
181
|
fs.appendFileSync(macroPath, injection);
|
|
188
182
|
console.log(pc.blue(`🔗 Vinculado com sucesso no arquivo pai: ${macroPath}`));
|
|
189
|
-
} else if (!isMacro) {
|
|
190
|
-
console.log(pc.yellow('⚠️ Aviso: Nenhum arquivo macro (*.spec.md) acima na árvore foi encontrado para auto-vinculação.'));
|
|
191
183
|
}
|
|
192
184
|
});
|
|
193
185
|
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -36,6 +36,9 @@ No **Mermaid Diagram Driven Development**, invertemos o ciclo tradicional de des
|
|
|
36
36
|
|
|
37
37
|
## ✅ Pré-visualização dos Diagramas Mermaid
|
|
38
38
|
|
|
39
|
+
### Exemplo diagrama de inicialização de um app Flutter
|
|
40
|
+
<img width="1316" height="444" alt="image" src="https://github.com/user-attachments/assets/5cacc283-e517-4468-a8cd-d67442a75bf2" />
|
|
41
|
+
|
|
39
42
|
Para visualizar os diagramas Mermaid diretamente no seu editor durante o fluxo MDDD, você pode utilizar extensões que renderizam blocos ````mermaid```` em arquivos Markdown:
|
|
40
43
|
|
|
41
44
|
### VS Code
|
|
@@ -196,6 +199,9 @@ In **Mermaid Diagram Driven Development**, we invert the traditional AI chat-dri
|
|
|
196
199
|
|
|
197
200
|
To preview Mermaid diagrams directly in your editor during the MDDD workflow, you can use extensions that render ````mermaid```` blocks in Markdown files:
|
|
198
201
|
|
|
202
|
+
### Exemplo diagrama de inicialização de um app Flutter
|
|
203
|
+
<img width="1316" height="444" alt="image" src="https://github.com/user-attachments/assets/5cacc283-e517-4468-a8cd-d67442a75bf2" />
|
|
204
|
+
|
|
199
205
|
### VS Code
|
|
200
206
|
- **Markdown Preview Mermaid Support** — Adds Mermaid diagram support to the native Markdown preview.
|
|
201
207
|
- **Mermaid Editor** — Visual editor with side-by-side preview and export.
|
|
@@ -323,4 +329,4 @@ If you encounter any issues, open a [GitHub Issue](https://github.com/JulioCRFil
|
|
|
323
329
|
|
|
324
330
|
## 📄 License
|
|
325
331
|
|
|
326
|
-
Distributed under the MIT license. See the [LICENSE](LICENSE) file for more information.
|
|
332
|
+
Distributed under the MIT license. See the [LICENSE](LICENSE) file for more information.
|