@silasfmartins/testhub 1.0.0

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.
Files changed (296) hide show
  1. package/.github/copilot-instructions.md +520 -0
  2. package/biome.json +37 -0
  3. package/dist/index.d.ts +45 -0
  4. package/dist/index.js +169 -0
  5. package/dist/scripts/consumer-postinstall.d.ts +15 -0
  6. package/dist/scripts/consumer-postinstall.js +785 -0
  7. package/dist/scripts/generate-docs.d.ts +16 -0
  8. package/dist/scripts/generate-docs.js +1363 -0
  9. package/dist/scripts/generate-index.d.ts +2 -0
  10. package/dist/scripts/generate-index.js +314 -0
  11. package/dist/scripts/init-api.d.ts +2 -0
  12. package/dist/scripts/init-api.js +525 -0
  13. package/dist/scripts/init-banco.d.ts +2 -0
  14. package/dist/scripts/init-banco.js +347 -0
  15. package/dist/scripts/init-frontend.d.ts +2 -0
  16. package/dist/scripts/init-frontend.js +627 -0
  17. package/dist/scripts/init-mobile.d.ts +2 -0
  18. package/dist/scripts/init-mobile.js +481 -0
  19. package/dist/scripts/init-scenarios.d.ts +2 -0
  20. package/dist/scripts/init-scenarios.js +846 -0
  21. package/dist/scripts/init-ssh.d.ts +2 -0
  22. package/dist/scripts/init-ssh.js +639 -0
  23. package/dist/scripts/package-versions.d.ts +57 -0
  24. package/dist/scripts/package-versions.js +768 -0
  25. package/dist/scripts/postinstall.d.ts +1 -0
  26. package/dist/scripts/postinstall.js +527 -0
  27. package/dist/scripts/robust-build.d.ts +7 -0
  28. package/dist/scripts/robust-build.js +88 -0
  29. package/dist/scripts/setup-local-packages.d.ts +31 -0
  30. package/dist/scripts/setup-local-packages.js +237 -0
  31. package/dist/scripts/smart-override.d.ts +2 -0
  32. package/dist/scripts/smart-override.js +1360 -0
  33. package/dist/scripts/sync-configs.d.ts +27 -0
  34. package/dist/scripts/sync-configs.js +248 -0
  35. package/dist/scripts/test-biome-parse.d.ts +5 -0
  36. package/dist/scripts/test-biome-parse.js +84 -0
  37. package/dist/scripts/ultracite-setup.d.ts +4 -0
  38. package/dist/scripts/ultracite-setup.js +310 -0
  39. package/dist/scripts/update-all-init-scripts.d.ts +2 -0
  40. package/dist/scripts/update-all-init-scripts.js +52 -0
  41. package/dist/scripts/update-biome-schema.d.ts +15 -0
  42. package/dist/scripts/update-biome-schema.js +124 -0
  43. package/dist/src/AutoCoreFacade.d.ts +145 -0
  44. package/dist/src/AutoCoreFacade.js +217 -0
  45. package/dist/src/api/ApiActions.d.ts +297 -0
  46. package/dist/src/api/ApiActions.js +1905 -0
  47. package/dist/src/api/Certificate.d.ts +60 -0
  48. package/dist/src/api/Certificate.js +79 -0
  49. package/dist/src/api/JsonResponse.d.ts +116 -0
  50. package/dist/src/api/JsonResponse.js +206 -0
  51. package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
  52. package/dist/src/appium/DeviceFarmViewer.js +1083 -0
  53. package/dist/src/appium/MobileActions.d.ts +347 -0
  54. package/dist/src/appium/MobileActions.js +1632 -0
  55. package/dist/src/appium/MobileConnection.d.ts +160 -0
  56. package/dist/src/appium/MobileConnection.js +772 -0
  57. package/dist/src/config/envLoader.d.ts +123 -0
  58. package/dist/src/config/envLoader.js +361 -0
  59. package/dist/src/config/jest-safe-setup.d.ts +19 -0
  60. package/dist/src/config/jest-safe-setup.js +369 -0
  61. package/dist/src/config/timeouts.d.ts +32 -0
  62. package/dist/src/config/timeouts.js +38 -0
  63. package/dist/src/desktop/DesktopActions.d.ts +46 -0
  64. package/dist/src/desktop/DesktopActions.js +398 -0
  65. package/dist/src/desktop/DesktopConnection.d.ts +32 -0
  66. package/dist/src/desktop/DesktopConnection.js +84 -0
  67. package/dist/src/domain/entities/TestExecution.d.ts +117 -0
  68. package/dist/src/domain/entities/TestExecution.js +150 -0
  69. package/dist/src/domain/entities/TestReport.d.ts +114 -0
  70. package/dist/src/domain/entities/TestReport.js +179 -0
  71. package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
  72. package/dist/src/domain/repositories/ITestRepository.js +14 -0
  73. package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
  74. package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
  75. package/dist/src/functions/errors/BaseError.d.ts +78 -0
  76. package/dist/src/functions/errors/BaseError.js +245 -0
  77. package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
  78. package/dist/src/functions/errors/ConfigurationError.js +48 -0
  79. package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
  80. package/dist/src/functions/errors/ErrorCatalog.js +157 -0
  81. package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
  82. package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
  83. package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
  84. package/dist/src/functions/errors/IntegrationError.js +51 -0
  85. package/dist/src/functions/errors/SecurityError.d.ts +14 -0
  86. package/dist/src/functions/errors/SecurityError.js +42 -0
  87. package/dist/src/functions/errors/SystemError.d.ts +12 -0
  88. package/dist/src/functions/errors/SystemError.js +36 -0
  89. package/dist/src/functions/errors/ValidationError.d.ts +14 -0
  90. package/dist/src/functions/errors/ValidationError.js +61 -0
  91. package/dist/src/functions/errors/index.d.ts +12 -0
  92. package/dist/src/functions/errors/index.js +13 -0
  93. package/dist/src/global-setup.d.ts +1 -0
  94. package/dist/src/global-setup.js +1037 -0
  95. package/dist/src/helpers/BancoActions.d.ts +188 -0
  96. package/dist/src/helpers/BancoActions.js +581 -0
  97. package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
  98. package/dist/src/helpers/EnviromentHelper.js +66 -0
  99. package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
  100. package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
  101. package/dist/src/helpers/SyncSignal.d.ts +15 -0
  102. package/dist/src/helpers/SyncSignal.js +44 -0
  103. package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
  104. package/dist/src/hubdocs/CategoryDetector.js +401 -0
  105. package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
  106. package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
  107. package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
  108. package/dist/src/hubdocs/ExecutionTracker.js +702 -0
  109. package/dist/src/hubdocs/HubDocs.d.ts +395 -0
  110. package/dist/src/hubdocs/HubDocs.js +3586 -0
  111. package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
  112. package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
  113. package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
  114. package/dist/src/hubdocs/StatementTracker.js +2419 -0
  115. package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
  116. package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
  117. package/dist/src/hubdocs/index.d.ts +9 -0
  118. package/dist/src/hubdocs/index.js +9 -0
  119. package/dist/src/hubdocs/types.d.ts +114 -0
  120. package/dist/src/hubdocs/types.js +5 -0
  121. package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
  122. package/dist/src/infrastructure/DependencyContainer.js +250 -0
  123. package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
  124. package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
  125. package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
  126. package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
  127. package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
  128. package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
  129. package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
  130. package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
  131. package/dist/src/interfaces.d.ts +501 -0
  132. package/dist/src/interfaces.js +25 -0
  133. package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
  134. package/dist/src/internal/fakes/__fake-actions__.js +21 -0
  135. package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
  136. package/dist/src/internal/fakes/__forbidden__.js +18 -0
  137. package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
  138. package/dist/src/internal/fakes/__honeypot__.js +24 -0
  139. package/dist/src/octane/OctaneReporter.d.ts +13 -0
  140. package/dist/src/octane/OctaneReporter.js +61 -0
  141. package/dist/src/playwright/CryptoActions.d.ts +20 -0
  142. package/dist/src/playwright/CryptoActions.js +75 -0
  143. package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
  144. package/dist/src/playwright/EnhancedWebActions.js +65 -0
  145. package/dist/src/playwright/WebActions.d.ts +1599 -0
  146. package/dist/src/playwright/WebActions.js +11788 -0
  147. package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
  148. package/dist/src/playwright/actions/ActionTimeline.js +101 -0
  149. package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
  150. package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
  151. package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
  152. package/dist/src/playwright/actions/SelectorCache.js +96 -0
  153. package/dist/src/playwright/actions/index.d.ts +13 -0
  154. package/dist/src/playwright/actions/index.js +14 -0
  155. package/dist/src/playwright/actions/types.d.ts +147 -0
  156. package/dist/src/playwright/actions/types.js +5 -0
  157. package/dist/src/playwright/fixtures.d.ts +112 -0
  158. package/dist/src/playwright/fixtures.js +718 -0
  159. package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
  160. package/dist/src/playwright/network-logs-reporter.js +66 -0
  161. package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
  162. package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
  163. package/dist/src/security/BuildSecurity.d.ts +12 -0
  164. package/dist/src/security/BuildSecurity.js +138 -0
  165. package/dist/src/security/EulaProtection.d.ts +70 -0
  166. package/dist/src/security/EulaProtection.js +155 -0
  167. package/dist/src/security/HoneypotManager.d.ts +46 -0
  168. package/dist/src/security/HoneypotManager.js +234 -0
  169. package/dist/src/security/KeysManager.d.ts +36 -0
  170. package/dist/src/security/KeysManager.js +158 -0
  171. package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
  172. package/dist/src/security/ProofOfWorkIntegration.js +206 -0
  173. package/dist/src/security/SecurityValidation.d.ts +21 -0
  174. package/dist/src/security/SecurityValidation.js +163 -0
  175. package/dist/src/security/SourceMapProtection.d.ts +55 -0
  176. package/dist/src/security/SourceMapProtection.js +220 -0
  177. package/dist/src/security/protector.d.ts +1 -0
  178. package/dist/src/security/protector.js +97 -0
  179. package/dist/src/ssh/SSHActions.d.ts +262 -0
  180. package/dist/src/ssh/SSHActions.js +790 -0
  181. package/dist/src/ssh/SSHClient.d.ts +99 -0
  182. package/dist/src/ssh/SSHClient.js +409 -0
  183. package/dist/src/statements/BaseStatement.d.ts +38 -0
  184. package/dist/src/statements/BaseStatement.js +78 -0
  185. package/dist/src/testContext/AuthStateManager.d.ts +93 -0
  186. package/dist/src/testContext/AuthStateManager.js +256 -0
  187. package/dist/src/testContext/CoverageManager.d.ts +198 -0
  188. package/dist/src/testContext/CoverageManager.js +917 -0
  189. package/dist/src/testContext/TestAnnotations.d.ts +476 -0
  190. package/dist/src/testContext/TestAnnotations.js +2647 -0
  191. package/dist/src/testContext/TestContext.d.ts +138 -0
  192. package/dist/src/testContext/TestContext.js +369 -0
  193. package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
  194. package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
  195. package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
  196. package/dist/src/testContext/UnifiedReportManager.js +1206 -0
  197. package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
  198. package/dist/src/testhub/DynamicConfigManager.js +320 -0
  199. package/dist/src/testhub/SystemsManager.d.ts +119 -0
  200. package/dist/src/testhub/SystemsManager.js +365 -0
  201. package/dist/src/testhub/TestHubClient.d.ts +335 -0
  202. package/dist/src/testhub/TestHubClient.js +1215 -0
  203. package/dist/src/testhub/TestHubReporter.d.ts +62 -0
  204. package/dist/src/testhub/TestHubReporter.js +576 -0
  205. package/dist/src/testhub/TestHubVars.d.ts +116 -0
  206. package/dist/src/testhub/TestHubVars.js +273 -0
  207. package/dist/src/utils/ActionInterceptor.d.ts +59 -0
  208. package/dist/src/utils/ActionInterceptor.js +741 -0
  209. package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
  210. package/dist/src/utils/ArtifactsCompressor.js +181 -0
  211. package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
  212. package/dist/src/utils/AutoLogsFinal.js +148 -0
  213. package/dist/src/utils/CodeGenSession.d.ts +114 -0
  214. package/dist/src/utils/CodeGenSession.js +264 -0
  215. package/dist/src/utils/ConfigLogger.d.ts +133 -0
  216. package/dist/src/utils/ConfigLogger.js +611 -0
  217. package/dist/src/utils/CustomReporter.d.ts +22 -0
  218. package/dist/src/utils/CustomReporter.js +352 -0
  219. package/dist/src/utils/DataStore.d.ts +171 -0
  220. package/dist/src/utils/DataStore.js +484 -0
  221. package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
  222. package/dist/src/utils/DatabaseInterceptor.js +295 -0
  223. package/dist/src/utils/DateHelper.d.ts +16 -0
  224. package/dist/src/utils/DateHelper.js +120 -0
  225. package/dist/src/utils/DateValidator.d.ts +4 -0
  226. package/dist/src/utils/DateValidator.js +51 -0
  227. package/dist/src/utils/DocumentGenerator.d.ts +35 -0
  228. package/dist/src/utils/DocumentGenerator.js +129 -0
  229. package/dist/src/utils/EvidenceCapture.d.ts +90 -0
  230. package/dist/src/utils/EvidenceCapture.js +600 -0
  231. package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
  232. package/dist/src/utils/EvidenceReportGenerator.js +799 -0
  233. package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
  234. package/dist/src/utils/FrameManagementUtil.js +75 -0
  235. package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
  236. package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
  237. package/dist/src/utils/HTMLTemplate.d.ts +1 -0
  238. package/dist/src/utils/HTMLTemplate.js +1034 -0
  239. package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
  240. package/dist/src/utils/InterceptacaoMagica.js +365 -0
  241. package/dist/src/utils/LogSanitizer.d.ts +35 -0
  242. package/dist/src/utils/LogSanitizer.js +110 -0
  243. package/dist/src/utils/Logger.d.ts +65 -0
  244. package/dist/src/utils/Logger.js +284 -0
  245. package/dist/src/utils/McpLocalClient.d.ts +141 -0
  246. package/dist/src/utils/McpLocalClient.js +871 -0
  247. package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
  248. package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
  249. package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
  250. package/dist/src/utils/SpecFileAnalyzer.js +209 -0
  251. package/dist/src/utils/StatementInterceptor.d.ts +18 -0
  252. package/dist/src/utils/StatementInterceptor.js +87 -0
  253. package/dist/src/utils/StatementLogger.d.ts +33 -0
  254. package/dist/src/utils/StatementLogger.js +113 -0
  255. package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
  256. package/dist/src/utils/StatementsInterceptor.js +1 -0
  257. package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
  258. package/dist/src/utils/TeamsFlushHook.js +168 -0
  259. package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
  260. package/dist/src/utils/TerminalLogCapture.js +531 -0
  261. package/dist/src/utils/TestMethodLogger.d.ts +70 -0
  262. package/dist/src/utils/TestMethodLogger.js +95 -0
  263. package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
  264. package/dist/src/utils/UnifiedTeardown.js +400 -0
  265. package/dist/src/utils/XPathCatalog.d.ts +152 -0
  266. package/dist/src/utils/XPathCatalog.js +350 -0
  267. package/dist/src/utils/generators.d.ts +90 -0
  268. package/dist/src/utils/generators.js +167 -0
  269. package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
  270. package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
  271. package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
  272. package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
  273. package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
  274. package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
  275. package/dist/vitest.config.d.ts +2 -0
  276. package/dist/vitest.config.js +59 -0
  277. package/dist/wdio.conf.d.ts +1 -0
  278. package/dist/wdio.conf.js +420 -0
  279. package/package.json +137 -0
  280. package/protect-loader.mjs +643 -0
  281. package/scripts/consumer-postinstall.ts +975 -0
  282. package/scripts/generate-index.ts +343 -0
  283. package/scripts/init-api.ts +613 -0
  284. package/scripts/init-banco.ts +437 -0
  285. package/scripts/init-frontend.ts +727 -0
  286. package/scripts/init-mobile.ts +558 -0
  287. package/scripts/init-scenarios.ts +925 -0
  288. package/scripts/init-ssh.ts +734 -0
  289. package/scripts/package-versions.ts +978 -0
  290. package/scripts/postinstall.ts +605 -0
  291. package/scripts/smart-override.ts +1675 -0
  292. package/scripts/sync-configs.ts +302 -0
  293. package/scripts/ultracite-setup.ts +370 -0
  294. package/src/types/globals.d.ts +48 -0
  295. package/tsconfig.json +29 -0
  296. package/types/autocore-sync-signal.d.ts +10 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,527 @@
1
+ // @ts-nocheck
2
+ import { ensureInstallationKeys } from '../src/security/KeysManager.js';
3
+ import { spawnSync } from 'node:child_process';
4
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
5
+ import path from 'node:path';
6
+ import { fileURLToPath } from 'node:url';
7
+ // ✅ ESM Compatibility
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = path.dirname(__filename);
10
+ /**
11
+ * PostInstall do AutoCore - APENAS configuração, SEM BUILD
12
+ */
13
+ console.log('AutoCore: Iniciando PostInstall (configuração apenas)...');
14
+ // ✅ Caracteres zero-width para marcadores invisíveis (igual ao HoneypotManager)
15
+ const PROTECTION_MARKERS = '\u200B\u200C\u200D\uFEFF';
16
+ // ✅ Injetar marcadores invisíveis em arquivos críticos (EXCETO JSON)
17
+ function injectProtectionMarkers(filePath, content) {
18
+ // ❌ NUNCA adicionar marcadores invisíveis em arquivos JSON
19
+ if (filePath.endsWith('.json')) {
20
+ return content; // Retornar conteúdo sem marcadores para JSON
21
+ }
22
+ // Verificar se já tem marcadores
23
+ const hasMarkers = PROTECTION_MARKERS.split('').some((char) => content.includes(char));
24
+ if (hasMarkers) {
25
+ return content; // Já protegido
26
+ }
27
+ // Adicionar marcadores invisíveis no início do arquivo (apenas para não-JSON)
28
+ return PROTECTION_MARKERS + content;
29
+ }
30
+ // ✅ Proteger arquivos críticos do sistema
31
+ async function protectCriticalFiles() {
32
+ const criticalFiles = ['package.json', 'tsconfig.json', '.gitignore'];
33
+ for (const fileName of criticalFiles) {
34
+ try {
35
+ const filePath = path.join(process.cwd(), fileName);
36
+ if (existsSync(filePath)) {
37
+ const content = readFileSync(filePath, 'utf8');
38
+ const protectedContent = injectProtectionMarkers(filePath, content);
39
+ if (protectedContent !== content) {
40
+ writeFileSync(filePath, protectedContent, 'utf8');
41
+ console.log(`AutoCore: Marcadores de proteção adicionados a ${fileName}`);
42
+ }
43
+ }
44
+ }
45
+ catch (error) {
46
+ const errorMessage = error instanceof Error ? error.message : String(error);
47
+ console.warn(`AutoCore: Erro ao proteger ${fileName}:`, errorMessage);
48
+ }
49
+ }
50
+ }
51
+ // ✅ Configurar segurança SEM build
52
+ async function setupSecurity() {
53
+ try {
54
+ // Apenas em ambiente de produção/build explícito
55
+ if (process.env.AUTOCORE_BUILD_SECURITY === 'true') {
56
+ console.log('AutoCore: Modo build detectado - configurando segurança...');
57
+ const keys = ensureInstallationKeys();
58
+ console.log(`AutoCore: Chaves geradas - ID: ${keys.installId.substring(0, 8)}...`);
59
+ }
60
+ else {
61
+ console.log('AutoCore: Configuração básica aplicada (sem build)');
62
+ }
63
+ }
64
+ catch (error) {
65
+ const errorMessage = error instanceof Error ? error.message : String(error);
66
+ console.warn('AutoCore: Aviso na configuração:', errorMessage);
67
+ }
68
+ }
69
+ // ✅ Atualizar .gitignore
70
+ async function updateGitignoreWithProtections() {
71
+ try {
72
+ const cwd = process.cwd();
73
+ const gitignorePath = path.join(cwd, '.gitignore');
74
+ const protectionEntries = [
75
+ '',
76
+ '# AutoCore Protection (gerado automaticamente)',
77
+ '.generated/',
78
+ '.rbqa/',
79
+ '.helpers/',
80
+ '.automation/',
81
+ '.rbqa-*',
82
+ '.test-automation.*',
83
+ '.appium-helpers.*',
84
+ '*.rbqa.json',
85
+ '*.protection.key',
86
+ '.install.lock',
87
+ '.build.lock',
88
+ ];
89
+ if (existsSync(gitignorePath)) {
90
+ const currentContent = readFileSync(gitignorePath, 'utf8');
91
+ if (!currentContent.includes('# AutoCore Protection')) {
92
+ const newContent = currentContent + '\n' + protectionEntries.join('\n') + '\n';
93
+ writeFileSync(gitignorePath, newContent);
94
+ console.log('AutoCore: .gitignore atualizado');
95
+ }
96
+ }
97
+ else {
98
+ writeFileSync(gitignorePath, protectionEntries.join('\n') + '\n');
99
+ console.log('AutoCore: .gitignore criado');
100
+ }
101
+ }
102
+ catch {
103
+ // Falha silenciosa
104
+ }
105
+ }
106
+ // 🌐 Registry privado do Azure Artifacts (único registry para pacotes @rbqa)
107
+ const AZURE_REGISTRY = 'https://pkgs.dev.azure.com/telefonica-vivo-brasil/_packaging/DevOps/npm/registry/';
108
+ // 🔧 Executa comando npm com environment configurado
109
+ function execNpmSync(args, timeoutMs = 30000) {
110
+ try {
111
+ const result = spawnSync('npm', args, {
112
+ stdio: 'pipe',
113
+ shell: true,
114
+ windowsHide: true,
115
+ timeout: timeoutMs,
116
+ env: { ...process.env, npm_config_registry: AZURE_REGISTRY }
117
+ });
118
+ return {
119
+ stdout: result.stdout?.toString() || '',
120
+ status: result.status
121
+ };
122
+ }
123
+ catch {
124
+ return { stdout: '', status: null };
125
+ }
126
+ }
127
+ // ✅ Obter versão instalada globalmente do pacote MCP
128
+ function getInstalledMcpVersion() {
129
+ try {
130
+ const result = execNpmSync(['list', '-g', '@silasfmartins/testhub-orchestrator-mcp', '--depth=0', '--json']);
131
+ if (result.status === 0) {
132
+ const data = JSON.parse(result.stdout);
133
+ return data.dependencies?.['@silasfmartins/testhub-orchestrator-mcp']?.version || null;
134
+ }
135
+ return null;
136
+ }
137
+ catch {
138
+ return null;
139
+ }
140
+ }
141
+ // ✅ Verificar acesso ao registry e obter última versão do MCP
142
+ function checkRegistryAndGetLatestVersion() {
143
+ try {
144
+ const result = execNpmSync(['view', '@silasfmartins/testhub-orchestrator-mcp', 'version', `--registry=${AZURE_REGISTRY}`], 30000);
145
+ if (result.status === 0 && result.stdout.trim()) {
146
+ return result.stdout.trim();
147
+ }
148
+ return null;
149
+ }
150
+ catch {
151
+ return null;
152
+ }
153
+ }
154
+ // ✅ Verificar se o pacote @silasfmartins/testhub-orchestrator-mcp está instalado globalmente
155
+ function checkGlobalMcpPackage() {
156
+ const result = execNpmSync(['list', '-g', '@silasfmartins/testhub-orchestrator-mcp', '--depth=0']);
157
+ return result.status === 0 && result.stdout.includes('@silasfmartins/testhub-orchestrator-mcp');
158
+ }
159
+ // ✅ Instalar ou atualizar pacote MCP globalmente
160
+ // 🎯 COMPORTAMENTO:
161
+ // - Se já está na última versão: NÃO reinstala
162
+ // - Se versão antiga: atualiza automaticamente
163
+ // - Se não instalado: instala globalmente
164
+ // - Se offline: usa versão local existente
165
+ function installOrUpdateMcpPackage() {
166
+ console.log('AutoCore: ======================================================');
167
+ console.log('AutoCore: MCP - Verificando instalação global');
168
+ console.log('AutoCore: ======================================================');
169
+ const installedVersion = getInstalledMcpVersion();
170
+ if (installedVersion) {
171
+ console.log(`AutoCore: Versão global instalada: ${installedVersion}`);
172
+ }
173
+ else {
174
+ console.log('AutoCore: MCP não encontrado globalmente');
175
+ }
176
+ // Verificar acesso ao registry e obter última versão
177
+ console.log('AutoCore: Verificando registry Azure Artifacts...');
178
+ const latestVersion = checkRegistryAndGetLatestVersion();
179
+ if (!latestVersion) {
180
+ console.log('AutoCore: Sem acesso ao registry Azure Artifacts (modo offline)');
181
+ if (installedVersion) {
182
+ console.log(`AutoCore: Usando versão global existente: ${installedVersion} ✓`);
183
+ return { installed: true, updated: false, version: installedVersion };
184
+ }
185
+ console.log('AutoCore: MCP será executado via npx quando necessário');
186
+ return { installed: false, updated: false, version: null };
187
+ }
188
+ console.log(`AutoCore: Última versão disponível: ${latestVersion}`);
189
+ // Comparar versões se já instalado
190
+ if (installedVersion) {
191
+ if (installedVersion === latestVersion) {
192
+ console.log('AutoCore: MCP já está na última versão global - nada a fazer! ✓');
193
+ return { installed: true, updated: false, version: installedVersion };
194
+ }
195
+ // Versão desatualizada - atualizar
196
+ console.log(`AutoCore: Atualizando MCP: ${installedVersion} → ${latestVersion}`);
197
+ }
198
+ else {
199
+ console.log('AutoCore: Instalando MCP globalmente...');
200
+ }
201
+ // Executar instalação/atualização
202
+ const installResult = execNpmSync(['install', '-g', `@silasfmartins/testhub-orchestrator-mcp@${latestVersion}`, `--registry=${AZURE_REGISTRY}`], 60000);
203
+ if (installResult.status === 0) {
204
+ const newVersion = getInstalledMcpVersion();
205
+ if (installedVersion) {
206
+ console.log(`AutoCore: MCP atualizado: ${installedVersion} → ${newVersion || latestVersion} ✓`);
207
+ }
208
+ else {
209
+ console.log(`AutoCore: MCP instalado globalmente (v${newVersion || latestVersion}) ✓`);
210
+ }
211
+ console.log('AutoCore: Disponível para todos os projetos da máquina');
212
+ return { installed: true, updated: !!installedVersion, version: newVersion || latestVersion };
213
+ }
214
+ console.warn('AutoCore: Falha ao instalar/atualizar MCP');
215
+ if (installedVersion) {
216
+ console.log(`AutoCore: Usando versão global existente: ${installedVersion}`);
217
+ return { installed: true, updated: false, version: installedVersion };
218
+ }
219
+ console.log('AutoCore: MCP será executado via npx');
220
+ return { installed: false, updated: false, version: null };
221
+ }
222
+ // ✅ Extrair user_hash de uma URL existente
223
+ function extractUserHash(url) {
224
+ const match = url.match(/user_hash=([a-zA-Z0-9]+)/);
225
+ return match ? match[1] : '';
226
+ }
227
+ // ✅ Copiar copilot-instructions.md para .github/ do projeto consumidor
228
+ async function copyCopilotInstructions() {
229
+ try {
230
+ const cwd = process.cwd();
231
+ // Se estiver em dist/scripts, subir dois níveis; senão, um nível
232
+ const isDist = __dirname.includes('dist');
233
+ const levelsUp = isDist ? '../..' : '..';
234
+ const sourceFile = path.join(__dirname, levelsUp, '.github', 'copilot-instructions.md');
235
+ const targetDir = path.join(cwd, '.github');
236
+ const targetFile = path.join(targetDir, 'copilot-instructions.md');
237
+ // Verificar se o arquivo fonte existe no pacote
238
+ if (!existsSync(sourceFile)) {
239
+ console.log('AutoCore: copilot-instructions.md não encontrado no pacote');
240
+ console.log(` Caminho: ${sourceFile}`);
241
+ return;
242
+ }
243
+ // Criar a pasta .github se não existir
244
+ if (!existsSync(targetDir)) {
245
+ console.log('AutoCore: Criando a pasta .github...');
246
+ mkdirSync(targetDir, { recursive: true });
247
+ }
248
+ // Copiar o arquivo
249
+ const content = readFileSync(sourceFile, 'utf8');
250
+ writeFileSync(targetFile, content, 'utf8');
251
+ console.log('AutoCore: copilot-instructions.md copiado para .github/ ✓');
252
+ }
253
+ catch (error) {
254
+ const errorMessage = error instanceof Error ? error.message : String(error);
255
+ console.warn('AutoCore: Erro ao copiar copilot-instructions.md:', errorMessage);
256
+ }
257
+ }
258
+ // ✅ Criar ou validar o arquivo .vscode/mcp.json (preservando hashes existentes)
259
+ async function ensureMcpConfig() {
260
+ try {
261
+ const vscodeDir = path.join(process.cwd(), '.vscode');
262
+ const mcpFile = path.join(vscodeDir, 'mcp.json');
263
+ // Criar a pasta .vscode se não existir
264
+ if (!existsSync(vscodeDir)) {
265
+ console.log('AutoCore: Criando a pasta .vscode...');
266
+ mkdirSync(vscodeDir, { recursive: true });
267
+ }
268
+ // Instalar/atualizar o MCP apenas em CI (ex.: agentes Azure Pipelines).
269
+ // Em máquinas dos usuários, não instalar globalmente — usar `npx` quando necessário.
270
+ const isCiEnv = process.env.AZURE_PIPELINES === 'true' ||
271
+ process.env.CI === 'true' ||
272
+ !!process.env.BUILD_BUILDID ||
273
+ !!process.env.SYSTEM_TEAMFOUNDATIONSERVERURI;
274
+ const isWindows = process.platform === 'win32';
275
+ // Instalar/atualizar o MCP apenas em máquinas Windows locais (desenvolvedores).
276
+ // NÃO instalar em CI (ex.: Azure Pipelines Linux agents).
277
+ if (!isCiEnv && isWindows) {
278
+ console.log('AutoCore: Ambiente Windows local detectado - verificando/instalando MCP globalmente');
279
+ try {
280
+ installOrUpdateMcpPackage();
281
+ }
282
+ catch (e) {
283
+ console.warn('AutoCore: Falha ao instalar/atualizar MCP:', e);
284
+ console.log('AutoCore: O MCP será executado via npx quando necessário');
285
+ }
286
+ }
287
+ else if (isCiEnv) {
288
+ console.log('AutoCore: Ambiente CI detectado - ignorando instalação global do MCP (use npx)');
289
+ }
290
+ else {
291
+ console.log('AutoCore: Ignorando instalação/atualização global do MCP (use npx quando necessário)');
292
+ }
293
+ // Configuração padrão
294
+ const defaultConfig = {
295
+ servers: {
296
+ 'mcp-estimative': {
297
+ url: 'http://brtlvlty0559pl:8080/estimative/mcp?user_hash=',
298
+ type: 'http',
299
+ },
300
+ 'autocore-orchestrator': {
301
+ command: 'npx',
302
+ args: ['-y', '@silasfmartins/testhub-orchestrator-mcp'],
303
+ env: {
304
+ HUB_BACKEND_URL: 'http://brtlvlty0559pl:3333',
305
+ },
306
+ type: 'stdio',
307
+ },
308
+ },
309
+ inputs: [],
310
+ };
311
+ if (existsSync(mcpFile)) {
312
+ // Arquivo existe - preservar hashes do usuário
313
+ const currentContent = JSON.parse(readFileSync(mcpFile, 'utf8'));
314
+ // Preservar hash do mcp-estimative
315
+ let existingEstimativeHash = '';
316
+ if (currentContent.servers?.['mcp-estimative']?.url) {
317
+ existingEstimativeHash = extractUserHash(currentContent.servers['mcp-estimative'].url);
318
+ }
319
+ // Construir configuração atualizada preservando hashes
320
+ const updatedConfig = {
321
+ servers: {
322
+ 'mcp-estimative': {
323
+ url: `http://brtlvlty0559pl:8080/estimative/mcp?user_hash=${existingEstimativeHash}`,
324
+ type: 'http',
325
+ },
326
+ 'autocore-orchestrator': {
327
+ command: 'npx',
328
+ args: ['-y', '@silasfmartins/testhub-orchestrator-mcp'],
329
+ env: {
330
+ HUB_BACKEND_URL: 'http://brtlvlty0559pl:3333',
331
+ },
332
+ type: 'stdio',
333
+ },
334
+ },
335
+ inputs: currentContent.inputs || [],
336
+ };
337
+ writeFileSync(mcpFile, JSON.stringify(updatedConfig, null, 2));
338
+ if (existingEstimativeHash) {
339
+ console.log('AutoCore: Arquivo mcp.json atualizado (hash mcp-estimative preservado) ✓');
340
+ }
341
+ else {
342
+ console.log('AutoCore: Arquivo mcp.json atualizado ✓');
343
+ }
344
+ }
345
+ else {
346
+ // Criar novo arquivo com configuração padrão
347
+ writeFileSync(mcpFile, JSON.stringify(defaultConfig, null, 2));
348
+ console.log('AutoCore: Arquivo mcp.json criado ✓');
349
+ }
350
+ // Mensagem sobre configuração do user_hash
351
+ console.log('');
352
+ console.log('AutoCore: 🔑 Para usar o MCP, configure seu user_hash:');
353
+ console.log('AutoCore: - mcp-estimative: Adicione seu hash na URL em .vscode/mcp.json');
354
+ console.log('AutoCore: - autocore-orchestrator: No Windows, defina a variável de ambiente');
355
+ console.log('AutoCore: do usuário HUB_MCP_USER_HASH com seu hash e reinicie o VS Code.');
356
+ }
357
+ catch (error) {
358
+ const errorMessage = error instanceof Error ? error.message : String(error);
359
+ console.warn('AutoCore: Erro ao configurar mcp.json:', errorMessage);
360
+ }
361
+ }
362
+ // ✅ Verificar se o Playwright está instalado (para projetos Frontend/Scenarios)
363
+ async function ensurePlaywrightInstalled() {
364
+ try {
365
+ const cwd = process.cwd();
366
+ const pkgFile = path.join(cwd, 'package.json');
367
+ if (!existsSync(pkgFile))
368
+ return;
369
+ const content = readFileSync(pkgFile, 'utf8');
370
+ const pkg = JSON.parse(content);
371
+ // Verificar se é projeto Frontend ou Scenarios (tem @playwright/test nas dependências)
372
+ const hasPlaywright = pkg.dependencies?.['@playwright/test'] ||
373
+ pkg.devDependencies?.['@playwright/test'] ||
374
+ pkg.dependencies?.['@silasfmartins/testhub'] ||
375
+ pkg.devDependencies?.['@silasfmartins/testhub'];
376
+ // Determinar se devemos instalar browsers Playwright
377
+ // Prioridade 1: variável de ambiente PROJECT_TYPE (WEB/FRONTEND or SCENARIOS)
378
+ const projectTypeEnv = (process.env.PROJECT_TYPE || process.env.PROJECTTYPE || '').toUpperCase();
379
+ const isProjectTypeWebOrScenarios = projectTypeEnv === 'WEB' || projectTypeEnv === 'FRONTEND' || projectTypeEnv === 'SCENARIOS';
380
+ // Fallback: Verificar se tem scripts de frontend/scenarios (indica que precisa de browsers)
381
+ const hasFrontendScripts = !!pkg.scripts?.['test:preprod']?.includes('playwright test') ||
382
+ !!pkg.scripts?.['ui:preprod'] ||
383
+ !!pkg.scripts?.['codegen:preprod'];
384
+ // Só instalar se o projeto for Web/Frontend ou Scenarios (por env ou por scripts indicativos)
385
+ if (!hasPlaywright || !(isProjectTypeWebOrScenarios || hasFrontendScripts))
386
+ return;
387
+ // Verificar se os browsers já estão instalados em vários locais comuns
388
+ function browsersPresent(dir) {
389
+ try {
390
+ if (!existsSync(dir))
391
+ return false;
392
+ const stat = require('node:fs').statSync(dir);
393
+ return !!stat;
394
+ }
395
+ catch {
396
+ return false;
397
+ }
398
+ }
399
+ const possiblePaths = [
400
+ path.join(cwd, 'node_modules', '.cache', 'ms-playwright'),
401
+ path.join(cwd, 'node_modules', 'playwright-core', '.local-browsers'),
402
+ path.join(cwd, 'node_modules', 'playwright', '.local-browsers'),
403
+ path.join(cwd, 'node_modules', '.playwright'),
404
+ path.join(cwd, 'node_modules', 'playwright-core', '.playwright'),
405
+ ];
406
+ const browsersInstalled = possiblePaths.some(browsersPresent);
407
+ if (browsersInstalled) {
408
+ console.log('AutoCore: Browsers Playwright já instalados ✓');
409
+ return;
410
+ }
411
+ // Tentar instalar browsers Playwright com tentativas e flags úteis
412
+ console.log('AutoCore: Browsers Playwright não encontrados. Tentando instalar...');
413
+ const installCommands = [
414
+ { args: ['playwright', 'install', '--with-deps'], desc: 'install --with-deps' },
415
+ { args: ['playwright', 'install'], desc: 'install' },
416
+ { args: ['playwright', 'install', '--force'], desc: 'install --force' },
417
+ ];
418
+ let installed = false;
419
+ for (const cmd of installCommands) {
420
+ try {
421
+ console.log(`AutoCore: Executando: npx ${cmd.args.join(' ')} (cwd=${cwd})`);
422
+ const result = spawnSync('npx', cmd.args, {
423
+ stdio: 'pipe',
424
+ shell: true,
425
+ windowsHide: true,
426
+ cwd,
427
+ timeout: 300000, // 5 minutos
428
+ });
429
+ if (result.status === 0) {
430
+ // Rechecar se os browsers foram instalados
431
+ const nowInstalled = possiblePaths.some(browsersPresent);
432
+ if (nowInstalled) {
433
+ console.log(`AutoCore: Browsers Playwright instalados com sucesso (${cmd.desc}) ✓`);
434
+ installed = true;
435
+ break;
436
+ }
437
+ else {
438
+ console.log(`AutoCore: Comando '${cmd.desc}' finalizou sem erro, mas browsers não foram detectados. Tentando próxima opção...`);
439
+ }
440
+ }
441
+ else {
442
+ console.warn(`AutoCore: Comando 'npx ${cmd.args.join(' ')}' falhou com código ${result.status}`);
443
+ }
444
+ }
445
+ catch (err) {
446
+ console.warn(`AutoCore: Erro ao executar 'npx ${cmd.args.join(' ')}': ${err}`);
447
+ }
448
+ }
449
+ if (!installed) {
450
+ console.warn('AutoCore: Falha ao instalar browsers Playwright automaticamente');
451
+ console.log('AutoCore: Instrução: execute manualmente: npx playwright install');
452
+ }
453
+ }
454
+ catch (error) {
455
+ const errorMessage = error instanceof Error ? error.message : String(error);
456
+ console.warn('AutoCore: Erro ao verificar Playwright:', errorMessage);
457
+ }
458
+ }
459
+ // ✅ Função principal async
460
+ async function main() {
461
+ // ✅ PRIMEIRO: Proteger arquivos críticos
462
+ await protectCriticalFiles();
463
+ try {
464
+ // ✅ Configurar scripts de proteção (SEM executar)
465
+ const cwd = process.cwd();
466
+ const pkgFile = path.join(cwd, 'package.json');
467
+ if (existsSync(pkgFile)) {
468
+ const content = readFileSync(pkgFile, 'utf8');
469
+ const pkg = JSON.parse(content);
470
+ pkg.scripts ||= {};
471
+ const loaderFlag = '--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs';
472
+ const ensurePre = (key) => {
473
+ const pre = `pre${key}`;
474
+ const current = pkg.scripts[pre];
475
+ if (current?.includes(loaderFlag))
476
+ return;
477
+ const exportCmd = process.platform === 'win32'
478
+ ? `set NODE_OPTIONS=%NODE_OPTIONS% ${loaderFlag}`
479
+ : `export NODE_OPTIONS="$NODE_OPTIONS ${loaderFlag}"`;
480
+ pkg.scripts[pre] = current ? `${exportCmd} && ${current}` : exportCmd;
481
+ };
482
+ ['test', 'build'].forEach(ensurePre);
483
+ // Atualizar .gitignore
484
+ await updateGitignoreWithProtections();
485
+ // ✅ Salvar com marcadores de proteção
486
+ const newContent = JSON.stringify(pkg, null, 2);
487
+ const protectedContent = injectProtectionMarkers(pkgFile, newContent);
488
+ writeFileSync(pkgFile, protectedContent);
489
+ console.log('AutoCore: Scripts de proteção configurados');
490
+ }
491
+ }
492
+ catch (error) {
493
+ const errorMessage = error instanceof Error ? error.message : String(error);
494
+ console.warn('AutoCore: Erro na configuração de scripts:', errorMessage);
495
+ }
496
+ // ✅ Verificar smart-override usando binário
497
+ try {
498
+ const result = spawnSync('npx', ['autocore-sync', 'check', '--quiet'], {
499
+ stdio: 'pipe',
500
+ shell: true,
501
+ windowsHide: true,
502
+ });
503
+ if (result.status === 0) {
504
+ console.log('AutoCore: Smart-override verificado');
505
+ }
506
+ }
507
+ catch (e) {
508
+ // Ignorar erro se binário não existir ainda
509
+ }
510
+ // ✅ Configurar segurança (SEM BUILD)
511
+ await setupSecurity();
512
+ // ✅ Criar ou validar o arquivo .vscode/mcp.json
513
+ await ensureMcpConfig();
514
+ // ✅ Copiar copilot-instructions.md para .github/
515
+ await copyCopilotInstructions();
516
+ // ✅ NOVO: Verificar e instalar Playwright para projetos Frontend/Scenarios
517
+ await ensurePlaywrightInstalled();
518
+ // ✅ FINAL: Re-proteger após modificações
519
+ await protectCriticalFiles();
520
+ console.log('AutoCore: PostInstall concluído SEM build!');
521
+ }
522
+ // ✅ Executar função principal (SEM BUILD)
523
+ main().catch((error) => {
524
+ const errorMessage = error instanceof Error ? error.message : String(error);
525
+ console.warn('AutoCore: PostInstall falhou:', errorMessage);
526
+ // Não falhar o processo - apenas avisar
527
+ });
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 🔧 Build Robusto para Projetos Consumidores
4
+ * Fallback para quando tsx/esbuild falha em ambientes Linux
5
+ */
6
+ declare function robustBuild(): void;
7
+ export { robustBuild };
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env node
2
+ // @ts-nocheck
3
+ /**
4
+ * 🔧 Build Robusto para Projetos Consumidores
5
+ * Fallback para quando tsx/esbuild falha em ambientes Linux
6
+ */
7
+ import { execSync } from 'child_process';
8
+ import { existsSync, rmSync, writeFileSync } from 'fs';
9
+ import path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+ // ES module compatibility
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = path.dirname(__filename);
14
+ function log(message, type = 'info') {
15
+ const colors = {
16
+ info: '\x1b[36m', // Cyan
17
+ warn: '\x1b[33m', // Yellow
18
+ error: '\x1b[31m', // Red
19
+ reset: '\x1b[0m',
20
+ };
21
+ const prefix = {
22
+ info: '🔧',
23
+ warn: '⚠️',
24
+ error: '❌',
25
+ };
26
+ console.log(`${colors[type]}${prefix[type]} ${message}${colors.reset}`);
27
+ }
28
+ function robustBuild() {
29
+ log('Iniciando build robusto (fallback para esbuild)');
30
+ try {
31
+ // 1. Limpar dist
32
+ if (existsSync('dist')) {
33
+ log('Limpando pasta dist...');
34
+ rmSync('dist', { recursive: true, force: true });
35
+ }
36
+ // 2. Tentar gerar index via TypeScript diretamente
37
+ log('Gerando index.ts...');
38
+ try {
39
+ execSync('npx tsx ./scripts/generate-index.ts', {
40
+ stdio: 'inherit',
41
+ timeout: 30_000, // 30 segundos timeout
42
+ });
43
+ }
44
+ catch (error) {
45
+ log('Erro ao gerar index via tsx, tentando fallback...', 'warn');
46
+ // Fallback: usar Node.js puro para gerar index básico
47
+ const basicIndex = `// Index gerado automaticamente (fallback)
48
+ export * from './dist/index.js'
49
+ `;
50
+ writeFileSync('index.ts', basicIndex);
51
+ log('Index básico gerado via fallback');
52
+ }
53
+ // 3. Compilar TypeScript
54
+ log('Compilando TypeScript...');
55
+ execSync('npx tsc', {
56
+ stdio: 'inherit',
57
+ timeout: 60_000, // 60 segundos timeout
58
+ });
59
+ // 4. Limpar index.ts temporário
60
+ if (existsSync('index.ts')) {
61
+ rmSync('index.ts');
62
+ log('index.ts temporário removido');
63
+ }
64
+ // 5. Tentar registrar override (opcional)
65
+ log('Tentando registrar smart override...');
66
+ try {
67
+ execSync('npx tsx ./scripts/smart-override.ts register', {
68
+ stdio: 'inherit',
69
+ timeout: 15_000, // 15 segundos timeout
70
+ });
71
+ log('Smart override registrado com sucesso');
72
+ }
73
+ catch (error) {
74
+ log('Smart override falhou, mas build continua', 'warn');
75
+ }
76
+ log('✅ Build robusto concluído com sucesso!', 'info');
77
+ }
78
+ catch (error) {
79
+ log(`Build robusto falhou: ${error}`, 'error');
80
+ process.exit(1);
81
+ }
82
+ }
83
+ // Executar apenas se chamado diretamente
84
+ const isMainModule = process.argv[1]?.endsWith('robust-build.ts');
85
+ if (isMainModule) {
86
+ robustBuild();
87
+ }
88
+ export { robustBuild };
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ declare class LocalPackagesSetup {
3
+ private projectRoot;
4
+ private packageJsonPath;
5
+ constructor();
6
+ /**
7
+ * 🚀 Executa setup completo de pacotes locais
8
+ */
9
+ run(): Promise<void>;
10
+ /**
11
+ * Verifica se AutoCore está instalado
12
+ */
13
+ private isAutocoreInstalled;
14
+ /**
15
+ * Detecta pacotes locais disponíveis
16
+ */
17
+ private promptForLocalPackages;
18
+ /**
19
+ * Atualiza package.json com file: paths
20
+ */
21
+ private updatePackageJson;
22
+ /**
23
+ * Imprime resumo final
24
+ */
25
+ private printSummary;
26
+ /**
27
+ * Reverte para usar pacotes do Azure
28
+ */
29
+ revertToAzure(): Promise<void>;
30
+ }
31
+ export { LocalPackagesSetup };