r2pde-ai 0.1.6 → 0.1.7
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.
|
@@ -167,7 +167,7 @@ export async function initCommand() {
|
|
|
167
167
|
- r2pde-ai: 0.1.0
|
|
168
168
|
`;
|
|
169
169
|
fs.writeFileSync(paths.index, indexContent, { encoding: 'utf8' });
|
|
170
|
-
// Step 6 – Copy templates
|
|
170
|
+
// Step 6 – Copy templates to .r2pde-ai/templates
|
|
171
171
|
const templateFiles = [
|
|
172
172
|
{ src: path.resolve(__dirname, '../../templates/manifest.template.md'), dest: path.resolve(paths.templates, 'manifest.template.md') },
|
|
173
173
|
{ src: path.resolve(__dirname, '../../templates/contract.template.md'), dest: path.resolve(paths.templates, 'contract.template.md') },
|
|
@@ -176,18 +176,18 @@ export async function initCommand() {
|
|
|
176
176
|
for (const { src, dest } of templateFiles) {
|
|
177
177
|
fs.copyFileSync(src, dest);
|
|
178
178
|
}
|
|
179
|
-
//
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
// Step 7 – Copy README.md and scaffold-guide.yaml to project root, always overwrite
|
|
180
|
+
const readmeSrc = path.resolve(__dirname, '../../README.md');
|
|
181
|
+
const readmeDest = path.resolve(cwd, 'README.md');
|
|
182
|
+
if (fs.existsSync(readmeSrc)) {
|
|
183
|
+
fs.copyFileSync(readmeSrc, readmeDest);
|
|
184
|
+
logInfo('README.md criado/atualizado na raiz do projeto.');
|
|
183
185
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
else {
|
|
190
|
-
logWarn('Arquivo scaffold.yaml já existe na raiz do projeto. Não sobrescrito.');
|
|
186
|
+
const scaffoldGuideSrc = path.resolve(__dirname, '../../scaffold-guide.yaml');
|
|
187
|
+
const scaffoldGuideDest = path.resolve(cwd, 'scaffold-guide.yaml');
|
|
188
|
+
if (fs.existsSync(scaffoldGuideSrc)) {
|
|
189
|
+
fs.copyFileSync(scaffoldGuideSrc, scaffoldGuideDest);
|
|
190
|
+
logInfo('scaffold-guide.yaml criado/atualizado na raiz do projeto.');
|
|
191
191
|
}
|
|
192
192
|
const guideContent = [
|
|
193
193
|
'# r2pde-ai GUIDE',
|
|
@@ -147,10 +147,23 @@ export const scaffoldCreateCommand = new Command('scaffold-create')
|
|
|
147
147
|
.description('Gera um projeto de exemplo a partir de um arquivo de guia YAML. Se --guide não for informado, será usado ./scaffold.yaml da raiz do projeto.')
|
|
148
148
|
.option('--guide <yaml>', 'Caminho para o arquivo de guia YAML (opcional, padrão: ./scaffold.yaml na raiz do projeto)')
|
|
149
149
|
.action((opts) => {
|
|
150
|
-
|
|
150
|
+
const cwd = process.cwd();
|
|
151
|
+
let guidePath = opts.guide ? path.resolve(opts.guide) : path.resolve(cwd, 'scaffold.yaml');
|
|
152
|
+
// Se não existir scaffold.yaml na raiz, copiar do template
|
|
151
153
|
if (!fs.existsSync(guidePath)) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
// Tenta copiar de dist/templates primeiro, depois de templates
|
|
155
|
+
let templatePath = path.resolve(__dirname, '../../dist/templates/scaffold.yaml');
|
|
156
|
+
if (!fs.existsSync(templatePath)) {
|
|
157
|
+
templatePath = path.resolve(__dirname, '../../templates/scaffold.yaml');
|
|
158
|
+
}
|
|
159
|
+
if (fs.existsSync(templatePath)) {
|
|
160
|
+
fs.copyFileSync(templatePath, guidePath);
|
|
161
|
+
logSuccess('Arquivo scaffold.yaml copiado para a raiz do projeto.');
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
console.error('Arquivo scaffold.yaml não encontrado nem na raiz nem nos templates do pacote.');
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
154
167
|
}
|
|
155
168
|
scaffoldCreateHandler({ guide: guidePath }).catch((err) => {
|
|
156
169
|
console.error(err);
|
package/package.json
CHANGED