mega-brain-ai 1.2.3 → 1.2.5
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.
Potentially problematic release.
This version of mega-brain-ai might be problematic. Click here for more details.
- package/bin/lib/installer.js +29 -24
- package/package.json +1 -1
package/bin/lib/installer.js
CHANGED
|
@@ -261,45 +261,50 @@ async function selectEdition() {
|
|
|
261
261
|
* This installer runs on other people's machines — we never risk data loss.
|
|
262
262
|
*/
|
|
263
263
|
async function fetchPremiumContent(targetDir, token, spinner) {
|
|
264
|
-
const premiumRepo = 'https://github.com/thiagofinch/mega-brain-premium.git';
|
|
265
264
|
const tempDir = join(targetDir, '.layer-sync', 'premium-fetch');
|
|
266
265
|
|
|
267
|
-
// Safety: ensure tempDir is strictly INSIDE targetDir
|
|
266
|
+
// Safety: ensure tempDir is strictly INSIDE targetDir
|
|
268
267
|
const resolvedTemp = resolve(tempDir);
|
|
269
268
|
const resolvedTarget = resolve(targetDir);
|
|
270
269
|
if (!resolvedTemp.startsWith(resolvedTarget + '/') && !resolvedTemp.startsWith(resolvedTarget + '\\')) {
|
|
271
270
|
throw new Error('Erro interno: caminho de download fora do diretório de instalação.');
|
|
272
271
|
}
|
|
273
272
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
273
|
+
mkdirSync(dirname(tempDir), { recursive: true });
|
|
274
|
+
|
|
275
|
+
// Clone with token in URL — .layer-sync/ is in .gitignore so token stays local
|
|
276
|
+
const authUrl = `https://x-access-token:${token}@github.com/thiagofinch/mega-brain-premium.git`;
|
|
277
277
|
|
|
278
|
-
// If a previous clone exists, reuse it (no delete + re-clone)
|
|
279
278
|
if (!existsSync(join(tempDir, '.git'))) {
|
|
280
|
-
spinner.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
);
|
|
279
|
+
spinner.succeed(chalk.cyan('Iniciando download do conteúdo premium (~300 MB)...'));
|
|
280
|
+
console.log(chalk.dim(' Isso pode levar alguns minutos dependendo da sua conexão.\n'));
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
execSync(`git clone --depth 1 "${authUrl}" "${tempDir}"`, {
|
|
284
|
+
stdio: 'inherit',
|
|
285
|
+
timeout: 600000,
|
|
286
|
+
});
|
|
287
|
+
} catch (cloneErr) {
|
|
288
|
+
throw new Error(`Git clone falhou. Verifique sua conexão e tente novamente.`);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
console.log();
|
|
292
|
+
spinner.start('Verificando download...');
|
|
294
293
|
} else {
|
|
295
294
|
spinner.text = 'Download anterior encontrado, reutilizando...';
|
|
296
295
|
}
|
|
297
296
|
|
|
297
|
+
// Verify clone has content
|
|
298
|
+
if (!existsSync(tempDir) || readdirSync(tempDir).length <= 1) {
|
|
299
|
+
throw new Error('Repositório premium clonado mas vazio.');
|
|
300
|
+
}
|
|
301
|
+
|
|
298
302
|
spinner.text = 'Integrando conteúdo premium na estrutura...';
|
|
299
303
|
|
|
300
304
|
// Copy premium content over the shell (merge, not replace)
|
|
301
305
|
const premiumExclude = ['.git', 'node_modules', 'bin', '.layer-sync'];
|
|
302
306
|
const premiumEntries = readdirSync(tempDir, { withFileTypes: true });
|
|
307
|
+
let copied = 0;
|
|
303
308
|
|
|
304
309
|
for (const entry of premiumEntries) {
|
|
305
310
|
if (premiumExclude.includes(entry.name)) continue;
|
|
@@ -312,12 +317,12 @@ async function fetchPremiumContent(targetDir, token, spinner) {
|
|
|
312
317
|
} else {
|
|
313
318
|
cpSync(srcPath, destPath, { force: true });
|
|
314
319
|
}
|
|
320
|
+
copied++;
|
|
315
321
|
}
|
|
316
322
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
// We NEVER use recursive delete operations on user machines.
|
|
323
|
+
if (copied === 0) {
|
|
324
|
+
throw new Error('Nenhum conteúdo premium copiado.');
|
|
325
|
+
}
|
|
321
326
|
}
|
|
322
327
|
|
|
323
328
|
/**
|