mega-brain-ai 1.2.2 → 1.2.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/lib/installer.js +47 -40
- package/package.json +1 -1
package/bin/lib/installer.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 6. Post-install summary
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { existsSync, mkdirSync, cpSync, writeFileSync, readFileSync } from 'fs';
|
|
16
|
+
import { existsSync, mkdirSync, cpSync, writeFileSync, readFileSync, readdirSync } from 'fs';
|
|
17
17
|
import { resolve, dirname, join } from 'path';
|
|
18
18
|
import { fileURLToPath } from 'url';
|
|
19
19
|
import { execSync } from 'child_process';
|
|
@@ -298,22 +298,21 @@ async function fetchPremiumContent(targetDir, token, spinner) {
|
|
|
298
298
|
spinner.text = 'Integrando conteúdo premium na estrutura...';
|
|
299
299
|
|
|
300
300
|
// Copy premium content over the shell (merge, not replace)
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
});
|
|
301
|
+
const premiumExclude = ['.git', 'node_modules', 'bin', '.layer-sync'];
|
|
302
|
+
const premiumEntries = readdirSync(tempDir, { withFileTypes: true });
|
|
303
|
+
|
|
304
|
+
for (const entry of premiumEntries) {
|
|
305
|
+
if (premiumExclude.includes(entry.name)) continue;
|
|
306
|
+
|
|
307
|
+
const srcPath = join(tempDir, entry.name);
|
|
308
|
+
const destPath = join(targetDir, entry.name);
|
|
309
|
+
|
|
310
|
+
if (entry.isDirectory()) {
|
|
311
|
+
cpSync(srcPath, destPath, { recursive: true, force: true });
|
|
312
|
+
} else {
|
|
313
|
+
cpSync(srcPath, destPath, { force: true });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
317
316
|
|
|
318
317
|
// NOTE: .layer-sync/ is intentionally NOT deleted.
|
|
319
318
|
// It is listed in .gitignore and contains no sensitive data
|
|
@@ -369,30 +368,38 @@ function showPostInstallCommunity() {
|
|
|
369
368
|
}
|
|
370
369
|
|
|
371
370
|
function copyTemplateFiles(source, target, excludeDirs) {
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
if (!existsSync(source)) {
|
|
372
|
+
throw new Error(`Template não encontrado: ${source}`);
|
|
373
|
+
}
|
|
374
374
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
375
|
+
const entries = readdirSync(source, { withFileTypes: true });
|
|
376
|
+
|
|
377
|
+
if (entries.length === 0) {
|
|
378
|
+
throw new Error(`Template vazio: ${source}`);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
let copied = 0;
|
|
382
|
+
for (const entry of entries) {
|
|
383
|
+
if (excludeDirs.includes(entry.name)) continue;
|
|
384
|
+
|
|
385
|
+
const srcPath = join(source, entry.name);
|
|
386
|
+
const destPath = join(target, entry.name);
|
|
387
|
+
|
|
388
|
+
try {
|
|
389
|
+
if (entry.isDirectory()) {
|
|
390
|
+
cpSync(srcPath, destPath, { recursive: true, force: true });
|
|
391
|
+
} else {
|
|
392
|
+
mkdirSync(dirname(destPath), { recursive: true });
|
|
393
|
+
cpSync(srcPath, destPath, { force: true });
|
|
394
|
+
}
|
|
395
|
+
copied++;
|
|
396
|
+
} catch (err) {
|
|
397
|
+
console.error(` Aviso: falha ao copiar ${entry.name}: ${err.message}`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
if (copied === 0) {
|
|
402
|
+
throw new Error(`Nenhum arquivo copiado. Source: ${source} (${entries.length} entries, ${excludeDirs.length} excluded)`);
|
|
396
403
|
}
|
|
397
404
|
}
|
|
398
405
|
|