@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,302 @@
1
+ #!/usr/bin/env node
2
+ // @ts-nocheck
3
+ /**
4
+ * 🔄 Sync Configs Script
5
+ * @description Sincroniza biome.json e tsconfig.json do AutoCore para o projeto consumidor
6
+ * @author TestHUB Team
7
+ * @version 1.0.0
8
+ *
9
+ * Este script atualiza automaticamente os arquivos de configuração do projeto
10
+ * baseados nas configurações mais recentes do AutoCore.
11
+ */
12
+
13
+ import fs from 'node:fs'
14
+ import path from 'node:path'
15
+ import { fileURLToPath } from 'node:url'
16
+
17
+ // ✅ ESM Compatibility
18
+ const __filename = fileURLToPath(import.meta.url)
19
+ const __dirname = path.dirname(__filename)
20
+
21
+ /**
22
+ * ✅ Parse JSONC (suporta comentários, trailing commas e caracteres de controle)
23
+ */
24
+ function parseJsonc(content: string): any {
25
+ try {
26
+ // 1. Remover comentários de bloco /* */
27
+ let cleaned = content.replace(/\/\*[\s\S]*?\*\//g, '')
28
+
29
+ // 2. Remover comentários de linha // respeitando strings
30
+ const lines = cleaned.split('\n')
31
+ const processedLines = lines.map((line) => {
32
+ if (!line.includes('//')) {
33
+ return line
34
+ }
35
+
36
+ const commentPos = line.indexOf('//')
37
+ if (commentPos === -1) {
38
+ return line
39
+ }
40
+
41
+ const beforeComment = line.substring(0, commentPos)
42
+ const quoteCount = (beforeComment.match(/"/g) || []).length
43
+
44
+ // Se estamos dentro de uma string, manter linha inteira
45
+ if (quoteCount % 2 === 1) {
46
+ return line
47
+ }
48
+
49
+ return beforeComment
50
+ })
51
+
52
+ cleaned = processedLines.join('\n')
53
+
54
+ // 3. Normalizar quebras de linha
55
+ cleaned = cleaned.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
56
+
57
+ // 4. Remover caracteres de controle inválidos
58
+ cleaned = cleaned.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '')
59
+
60
+ // 5. Remover trailing commas
61
+ cleaned = cleaned.replace(/,(\s*[}\]])/g, '$1')
62
+
63
+ return JSON.parse(cleaned.trim())
64
+ } catch (error) {
65
+ console.warn('⚠️ Erro ao fazer parse JSONC:', error)
66
+ throw error
67
+ }
68
+ }
69
+
70
+ /**
71
+ * 🔍 Detecta o tipo de projeto baseado no package.json
72
+ */
73
+ function detectProjectType():
74
+ | 'api'
75
+ | 'frontend'
76
+ | 'mobile'
77
+ | 'ssh'
78
+ | 'banco'
79
+ | 'scenarios'
80
+ | 'unknown' {
81
+ try {
82
+ const packageJsonPath = path.join(process.cwd(), 'package.json')
83
+ if (!fs.existsSync(packageJsonPath)) {
84
+ return 'unknown'
85
+ }
86
+
87
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
88
+ const projectName = packageJson.name || ''
89
+
90
+ if (projectName.includes('scenarios') || projectName.includes('cenarios')) {
91
+ return 'scenarios'
92
+ }
93
+ if (projectName.includes('api')) {
94
+ return 'api'
95
+ }
96
+ if (projectName.includes('mobile')) {
97
+ return 'mobile'
98
+ }
99
+ if (projectName.includes('ssh')) {
100
+ return 'ssh'
101
+ }
102
+ if (projectName.includes('banco') || projectName.includes('db')) {
103
+ return 'banco'
104
+ }
105
+ if (projectName.includes('frontend') || projectName.includes('web')) {
106
+ return 'frontend'
107
+ }
108
+
109
+ return 'unknown'
110
+ } catch (error) {
111
+ console.warn('⚠️ Erro ao detectar tipo de projeto:', error)
112
+ return 'unknown'
113
+ }
114
+ }
115
+
116
+ /**
117
+ * 📋 Lê o biome.json do AutoCore
118
+ */
119
+ function getAutocoreBiomeConfig(): any {
120
+ try {
121
+ // Caminhos a serem tentados (em ordem de prioridade)
122
+ // __dirname quando compilado via bin: node_modules/@silasfmartins/testhub/dist/scripts
123
+ // __dirname quando executado via tsx: node_modules/@silasfmartins/testhub/scripts
124
+ const autoCorePaths = [
125
+ // 1. Instalado via npm/pnpm - caminho absoluto (MAIS CONFIÁVEL)
126
+ path.join(
127
+ process.cwd(),
128
+ 'node_modules',
129
+ '@rbqa',
130
+ 'autocore',
131
+ 'biome.json',
132
+ ),
133
+ // 2. Quando executado do dist/scripts (via bin)
134
+ path.resolve(__dirname, '..', '..', 'biome.json'),
135
+ // 3. Quando executado do scripts/ (via tsx)
136
+ path.resolve(__dirname, '..', 'biome.json'),
137
+ // 4. Fallback - subindo mais níveis
138
+ path.resolve(__dirname, '..', '..', '..', 'biome.json'),
139
+ // 5. Desenvolvimento local (projeto autocore)
140
+ path.resolve(process.cwd(), 'biome.json'),
141
+ ]
142
+
143
+ for (const biomePath of autoCorePaths) {
144
+ if (fs.existsSync(biomePath)) {
145
+ const biomeContent = fs.readFileSync(biomePath, 'utf8')
146
+ console.log(`✅ biome.json carregado de: ${biomePath}`)
147
+ return JSON.parse(biomeContent)
148
+ }
149
+ }
150
+
151
+ console.warn('⚠️ biome.json do AutoCore não encontrado')
152
+ console.warn(' Caminhos verificados:')
153
+ for (const p of autoCorePaths) {
154
+ console.warn(` - ${p}`)
155
+ }
156
+ return null
157
+ } catch (error) {
158
+ console.error('❌ Erro ao ler biome.json:', error)
159
+ return null
160
+ }
161
+ }
162
+
163
+ /**
164
+ * 📋 Lê o tsconfig.json do AutoCore
165
+ */
166
+ function getAutocoreTsConfig(): any {
167
+ try {
168
+ // Caminhos a serem tentados (em ordem de prioridade)
169
+ // __dirname quando compilado via bin: node_modules/@silasfmartins/testhub/dist/scripts
170
+ // __dirname quando executado via tsx: node_modules/@silasfmartins/testhub/scripts
171
+ const autoCorePaths = [
172
+ // 1. Instalado via npm/pnpm - caminho absoluto (MAIS CONFIÁVEL)
173
+ path.join(
174
+ process.cwd(),
175
+ 'node_modules',
176
+ '@rbqa',
177
+ 'autocore',
178
+ 'tsconfig.json',
179
+ ),
180
+ // 2. Quando executado do dist/scripts (via bin)
181
+ path.resolve(__dirname, '..', '..', 'tsconfig.json'),
182
+ // 3. Quando executado do scripts/ (via tsx)
183
+ path.resolve(__dirname, '..', 'tsconfig.json'),
184
+ // 4. Fallback - subindo mais níveis
185
+ path.resolve(__dirname, '..', '..', '..', 'tsconfig.json'),
186
+ // 5. Desenvolvimento local (projeto autocore)
187
+ path.resolve(process.cwd(), 'tsconfig.json'),
188
+ ]
189
+
190
+ for (const tsconfigPath of autoCorePaths) {
191
+ if (fs.existsSync(tsconfigPath)) {
192
+ const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf8')
193
+ console.log(`✅ tsconfig.json carregado de: ${tsconfigPath}`)
194
+ return parseJsonc(tsconfigContent)
195
+ }
196
+ }
197
+
198
+ console.warn('⚠️ tsconfig.json do AutoCore não encontrado')
199
+ console.warn(' Caminhos verificados:')
200
+ for (const p of autoCorePaths) {
201
+ console.warn(` - ${p}`)
202
+ }
203
+ return null
204
+ } catch (error) {
205
+ console.error('❌ Erro ao ler tsconfig.json:', error)
206
+ return null
207
+ }
208
+ }
209
+
210
+ /**
211
+ * 💾 Atualiza biome.json no projeto consumidor
212
+ */
213
+ function syncBiomeConfig(): boolean {
214
+ try {
215
+ const biomeConfig = getAutocoreBiomeConfig()
216
+ if (!biomeConfig) {
217
+ return false
218
+ }
219
+
220
+ const targetPath = path.join(process.cwd(), 'biome.json')
221
+ fs.writeFileSync(targetPath, JSON.stringify(biomeConfig, null, 2), 'utf8')
222
+ console.log('✅ biome.json atualizado com sucesso!')
223
+ return true
224
+ } catch (error) {
225
+ console.error('❌ Erro ao atualizar biome.json:', error)
226
+ return false
227
+ }
228
+ }
229
+
230
+ /**
231
+ * 💾 Atualiza tsconfig.json no projeto consumidor
232
+ */
233
+ function syncTsConfig(): boolean {
234
+ try {
235
+ const tsconfigConfig = getAutocoreTsConfig()
236
+ if (!tsconfigConfig) {
237
+ return false
238
+ }
239
+
240
+ const targetPath = path.join(process.cwd(), 'tsconfig.json')
241
+ fs.writeFileSync(
242
+ targetPath,
243
+ JSON.stringify(tsconfigConfig, null, 2),
244
+ 'utf8',
245
+ )
246
+ console.log('✅ tsconfig.json atualizado com sucesso!')
247
+ return true
248
+ } catch (error) {
249
+ console.error('❌ Erro ao atualizar tsconfig.json:', error)
250
+ return false
251
+ }
252
+ }
253
+
254
+ /**
255
+ * 🔄 Sincroniza todas as configurações
256
+ */
257
+ async function syncAllConfigs() {
258
+ console.log('\n🔄 Sincronizando configurações do AutoCore...\n')
259
+
260
+ const projectType = detectProjectType()
261
+ console.log(`📦 Tipo de projeto detectado: ${projectType}\n`)
262
+
263
+ let biomeSuccess = false
264
+ let tsconfigSuccess = false
265
+
266
+ // Sincronizar biome.json
267
+ console.log('📋 Sincronizando biome.json...')
268
+ biomeSuccess = syncBiomeConfig()
269
+
270
+ // Sincronizar tsconfig.json
271
+ console.log('\n📋 Sincronizando tsconfig.json...')
272
+ tsconfigSuccess = syncTsConfig()
273
+
274
+ console.log('\n' + '='.repeat(60))
275
+ console.log('📊 RESUMO DA SINCRONIZAÇÃO:')
276
+ console.log('='.repeat(60))
277
+ console.log(` ${biomeSuccess ? '✅' : '❌'} biome.json`)
278
+ console.log(` ${tsconfigSuccess ? '✅' : '❌'} tsconfig.json`)
279
+ console.log('='.repeat(60))
280
+
281
+ if (biomeSuccess && tsconfigSuccess) {
282
+ console.log('\n✨ Todas as configurações foram sincronizadas com sucesso!')
283
+ } else {
284
+ console.log('\n⚠️ Algumas configurações não puderam ser sincronizadas.')
285
+ console.log(' Verifique se o @silasfmartins/testhub está instalado corretamente.')
286
+ }
287
+ }
288
+
289
+ // 🚀 Executar sincronização se for chamado diretamente
290
+ const isMainModule =
291
+ process.argv[1]?.endsWith('sync-configs.ts') ||
292
+ process.argv[1]?.endsWith('sync-configs.js')
293
+
294
+ if (isMainModule) {
295
+ syncAllConfigs().catch((error) => {
296
+ console.error('❌ Erro fatal na sincronização:', error)
297
+ process.exit(1)
298
+ })
299
+ }
300
+
301
+ // Exportar funções para uso em outros scripts
302
+ export { syncAllConfigs, syncBiomeConfig, syncTsConfig, detectProjectType }
@@ -0,0 +1,370 @@
1
+ // @ts-nocheck
2
+ import fs from 'node:fs'
3
+ import { execSync } from 'child_process'
4
+ import path from 'path'
5
+
6
+ /**
7
+ * Configuração automatizada do Ultracite com GitHub Copilot
8
+ */
9
+ export async function setupUltracite(projectRoot: string): Promise<void> {
10
+ console.log('🤖 Configurando Ultracite com GitHub Copilot...')
11
+
12
+ try {
13
+ // Verificar se o Ultracite foi instalado
14
+ const packageJsonPath = path.join(projectRoot, 'package.json')
15
+ if (!fs.existsSync(packageJsonPath)) {
16
+ throw new Error('package.json não encontrado')
17
+ }
18
+
19
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
20
+
21
+ if (!packageJson.devDependencies?.ultracite) {
22
+ console.log(
23
+ '⚠️ Ultracite não encontrado nas dependências, pulando configuração',
24
+ )
25
+ return
26
+ }
27
+
28
+ console.log(
29
+ '🔧 Configurando Ultracite automaticamente com GitHub Copilot...',
30
+ )
31
+
32
+ // ✅ PRIMEIRO: Criar configuração VS Code com GitHub Copilot
33
+ await createVSCodeConfig(projectRoot)
34
+
35
+ // ✅ SEGUNDO: Executar ultracite init com parâmetros específicos
36
+ await runUltraciteInit(projectRoot)
37
+
38
+ console.log('✅ Ultracite configurado com sucesso')
39
+ console.log('🎯 GitHub Copilot habilitado para desenvolvimento')
40
+ console.log('💡 Para configuração avançada, execute: npx ultracite init')
41
+ } catch (error) {
42
+ console.warn(`⚠️ Erro na configuração do Ultracite: ${error}`)
43
+ console.log(
44
+ '💡 Você pode configurar manualmente executando: npx ultracite init',
45
+ )
46
+
47
+ // ✅ FALLBACK: Aplicar configuração básica do GitHub Copilot mesmo se o Ultracite falhar
48
+ try {
49
+ await createGitHubCopilotVSCodeConfig(projectRoot)
50
+ console.log('✅ Configuração básica do GitHub Copilot aplicada')
51
+ } catch (fallbackError) {
52
+ console.warn(
53
+ '⚠️ Não foi possível configurar GitHub Copilot automaticamente',
54
+ )
55
+ }
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Executar ultracite init de forma automatizada com GitHub Copilot
61
+ */
62
+ async function runUltraciteInit(projectRoot: string): Promise<void> {
63
+ try {
64
+ console.log('🔄 Executando ultracite init com GitHub Copilot...')
65
+
66
+ // ✅ NOVO: Criar arquivo de configuração com GitHub Copilot
67
+ const ultraciteConfig = {
68
+ editor: 'vscode',
69
+ frameworks: ['playwright'],
70
+ tools: [],
71
+ additionalOptions: [],
72
+ }
73
+
74
+ // ✅ NOVO: Tentar executar com parâmetros específicos para GitHub Copilot
75
+ try {
76
+ const initCommand = [
77
+ 'npx ultracite init',
78
+ '--yes',
79
+ '--editor=vscode',
80
+ '--editor-rules=github-copilot',
81
+ '--frameworks=playwright',
82
+ ].join(' ')
83
+
84
+ console.log(`🎯 Executando: ${initCommand}`)
85
+
86
+ execSync(initCommand, {
87
+ cwd: projectRoot,
88
+ stdio: 'pipe',
89
+ timeout: 45_000, // Aumentar timeout para 45s
90
+ encoding: 'utf8',
91
+ })
92
+
93
+ console.log('✅ Ultracite configurado com GitHub Copilot')
94
+ } catch (execError) {
95
+ console.log(
96
+ 'ℹ️ Comando automático falhou, tentando configuração interativa simulada...',
97
+ )
98
+
99
+ // ✅ FALLBACK: Tentar configuração manual programática
100
+ await setupUltraciteManually(projectRoot)
101
+ }
102
+ } catch (error) {
103
+ console.log(
104
+ 'ℹ️ Aplicando configuração manual do Ultracite com GitHub Copilot',
105
+ )
106
+ await setupUltraciteManually(projectRoot)
107
+ }
108
+ }
109
+
110
+ /**
111
+ * ✅ NOVO: Setup manual do Ultracite com GitHub Copilot
112
+ */
113
+ async function setupUltraciteManually(projectRoot: string): Promise<void> {
114
+ try {
115
+ // ✅ Criar configurações específicas do GitHub Copilot para VS Code
116
+ await createGitHubCopilotVSCodeConfig(projectRoot)
117
+
118
+ console.log(
119
+ '✅ Configuração manual do Ultracite aplicada com GitHub Copilot',
120
+ )
121
+ } catch (error) {
122
+ console.warn(`⚠️ Erro na configuração manual: ${error}`)
123
+ }
124
+ }
125
+
126
+ /**
127
+ * ✅ ATUALIZADO: Criar configurações específicas do GitHub Copilot para VS Code (SEM ESLint)
128
+ */
129
+ async function createGitHubCopilotVSCodeConfig(
130
+ projectRoot: string,
131
+ ): Promise<void> {
132
+ const vscodeDir = path.join(projectRoot, '.vscode')
133
+
134
+ if (!fs.existsSync(vscodeDir)) {
135
+ fs.mkdirSync(vscodeDir, { recursive: true })
136
+ }
137
+
138
+ // ✅ Configurações específicas do GitHub Copilot + Pretty TypeScript Errors
139
+ const copilotSettings = {
140
+ // Configurações do GitHub Copilot
141
+ 'github.copilot.enable': {
142
+ '*': true,
143
+ plaintext: true,
144
+ markdown: true,
145
+ typescript: true,
146
+ javascript: true,
147
+ },
148
+ 'github.copilot.inlineSuggest.enable': true,
149
+ 'github.copilot.chat.enabled': true,
150
+
151
+ // Configurações para melhor integração com Playwright
152
+ 'github.copilot.autocomplete.enable': true,
153
+ 'github.copilot.suggest.showDiffs': true,
154
+
155
+ // ✅ Pretty TypeScript Errors
156
+ 'typescript.preferences.includePackageJsonAutoImports': 'auto',
157
+ 'typescript.suggest.autoImports': true,
158
+ 'typescript.updateImportsOnFileMove.enabled': 'always',
159
+ 'typescript.preferences.importModuleSpecifier': 'relative',
160
+
161
+ // Configurações específicas para testes
162
+ 'files.associations': {
163
+ '*.spec.ts': 'typescript',
164
+ '*.test.ts': 'typescript',
165
+ '*.page.ts': 'typescript',
166
+ },
167
+
168
+ // ✅ Configurações de formatação (sem ESLint)
169
+ 'editor.formatOnSave': true,
170
+ 'editor.codeActionsOnSave': {
171
+ 'source.organizeImports': true,
172
+ },
173
+ 'editor.defaultFormatter': 'biomejs.biome',
174
+ '[typescript]': {
175
+ 'editor.defaultFormatter': 'biomejs.biome',
176
+ },
177
+ '[javascript]': {
178
+ 'editor.defaultFormatter': 'biomejs.biome',
179
+ },
180
+
181
+ // Snippets e IntelliSense aprimorados
182
+ 'typescript.suggest.completeFunctionCalls': true,
183
+ 'typescript.suggest.includeCompletionsForImportStatements': true,
184
+ 'typescript.inlayHints.enumMemberValues.enabled': true,
185
+ 'typescript.inlayHints.functionLikeReturnTypes.enabled': true,
186
+ 'typescript.inlayHints.parameterNames.enabled': 'all',
187
+ 'typescript.inlayHints.parameterTypes.enabled': true,
188
+ 'typescript.inlayHints.propertyDeclarationTypes.enabled': true,
189
+ 'typescript.inlayHints.variableTypes.enabled': true,
190
+ }
191
+
192
+ const settingsPath = path.join(vscodeDir, 'settings.json')
193
+
194
+ // Mesclar com configurações existentes
195
+ let existingSettings = {}
196
+ if (fs.existsSync(settingsPath)) {
197
+ try {
198
+ const existingContent = fs.readFileSync(settingsPath, 'utf8')
199
+ existingSettings = JSON.parse(existingContent)
200
+ } catch (error) {
201
+ console.warn('⚠️ Erro ao ler settings.json existente')
202
+ }
203
+ }
204
+
205
+ const mergedSettings = { ...existingSettings, ...copilotSettings }
206
+ fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 2))
207
+
208
+ // ✅ ATUALIZADO: Extensões recomendadas (SEM ESLint)
209
+ const extensions = {
210
+ recommendations: [
211
+ 'github.copilot', // ✅ GitHub Copilot principal
212
+ 'github.copilot-chat', // ✅ GitHub Copilot Chat
213
+ 'ms-playwright.playwright', // Playwright
214
+ 'biomejs.biome', // Biome (formatação/linting)
215
+ 'yoavbls.pretty-ts-errors', // ✅ Pretty TypeScript Errors
216
+ 'ms-vscode.vscode-typescript-next', // TypeScript
217
+ 'bradlc.vscode-tailwindcss', // Tailwind (se usar)
218
+ 'ms-vscode.vscode-json', // JSON
219
+ 'esbenp.prettier-vscode', // Prettier (backup do Biome)
220
+ 'gruntfuggly.todo-tree', // TODO Tree (útil para desenvolvimento)
221
+ 'streetsidesoftware.code-spell-checker', // Spell Checker
222
+ ],
223
+ }
224
+
225
+ const extensionsPath = path.join(vscodeDir, 'extensions.json')
226
+
227
+ // Mesclar extensões sem duplicatas
228
+ let existingExtensions = { recommendations: [] }
229
+ if (fs.existsSync(extensionsPath)) {
230
+ try {
231
+ const existingContent = fs.readFileSync(extensionsPath, 'utf8')
232
+ existingExtensions = JSON.parse(existingContent)
233
+ } catch (error) {
234
+ console.warn('⚠️ Erro ao ler extensions.json existente')
235
+ }
236
+ }
237
+
238
+ const allRecommendations = [
239
+ ...new Set([
240
+ ...(existingExtensions.recommendations || []),
241
+ ...extensions.recommendations,
242
+ ]),
243
+ ]
244
+
245
+ const mergedExtensions = {
246
+ ...existingExtensions,
247
+ recommendations: allRecommendations,
248
+ }
249
+
250
+ fs.writeFileSync(extensionsPath, JSON.stringify(mergedExtensions, null, 2))
251
+
252
+ console.log(
253
+ '✅ Configuração GitHub Copilot + Pretty TypeScript Errors aplicada ao VS Code',
254
+ )
255
+ }
256
+
257
+ /**
258
+ * Criar configuração do VS Code para desenvolvimento
259
+ */
260
+ async function createVSCodeConfig(projectRoot: string): Promise<void> {
261
+ const vscodeDir = path.join(projectRoot, '.vscode')
262
+
263
+ // Criar diretório .vscode se não existir
264
+ if (!fs.existsSync(vscodeDir)) {
265
+ fs.mkdirSync(vscodeDir, { recursive: true })
266
+ }
267
+
268
+ // Configuração básica do VS Code para TypeScript/Playwright (SEM ESLint)
269
+ const vscodeSettings = {
270
+ 'typescript.preferences.includePackageJsonAutoImports': 'auto',
271
+ 'typescript.suggest.autoImports': true,
272
+ 'typescript.preferences.importModuleSpecifier': 'relative',
273
+ 'editor.codeActionsOnSave': {
274
+ 'source.fixAll': 'explicit',
275
+ 'source.organizeImports': 'explicit',
276
+ },
277
+ 'editor.formatOnSave': true,
278
+ 'editor.defaultFormatter': 'biomejs.biome',
279
+ 'files.associations': {
280
+ '*.spec.ts': 'typescript',
281
+ '*.test.ts': 'typescript',
282
+ },
283
+ 'search.exclude': {
284
+ '**/node_modules': true,
285
+ '**/dist': true,
286
+ '**/.git': true,
287
+ '**/test-results': true,
288
+ '**/playwright-report': true,
289
+ },
290
+ 'files.exclude': {
291
+ '**/node_modules': true,
292
+ '**/dist': true,
293
+ '**/.git': true,
294
+ },
295
+ 'typescript.preferences.quoteStyle': 'single',
296
+ 'javascript.preferences.quoteStyle': 'single',
297
+ }
298
+
299
+ const settingsPath = path.join(vscodeDir, 'settings.json')
300
+
301
+ // Mesclar com configurações existentes se houver
302
+ let existingSettings = {}
303
+ if (fs.existsSync(settingsPath)) {
304
+ try {
305
+ const existingContent = fs.readFileSync(settingsPath, 'utf8')
306
+ existingSettings = JSON.parse(existingContent)
307
+ } catch (error) {
308
+ console.warn('⚠️ Erro ao ler settings.json existente, criando novo')
309
+ }
310
+ }
311
+
312
+ const mergedSettings = { ...existingSettings, ...vscodeSettings }
313
+ fs.writeFileSync(settingsPath, JSON.stringify(mergedSettings, null, 2))
314
+
315
+ // Extensões recomendadas (SEM ESLint)
316
+ const extensions = {
317
+ recommendations: ['ms-playwright.playwright', 'biomejs.biome'],
318
+ }
319
+
320
+ const extensionsPath = path.join(vscodeDir, 'extensions.json')
321
+
322
+ // Mesclar extensões se já existirem
323
+ let existingExtensions = { recommendations: [] }
324
+ if (fs.existsSync(extensionsPath)) {
325
+ try {
326
+ const existingContent = fs.readFileSync(extensionsPath, 'utf8')
327
+ existingExtensions = JSON.parse(existingContent)
328
+ } catch (error) {
329
+ console.warn('⚠️ Erro ao ler extensions.json existente, criando novo')
330
+ }
331
+ }
332
+
333
+ // Combinar recomendações sem duplicatas
334
+ const allRecommendations = [
335
+ ...new Set([
336
+ ...(existingExtensions.recommendations || []),
337
+ ...extensions.recommendations,
338
+ ]),
339
+ ]
340
+
341
+ const mergedExtensions = {
342
+ ...existingExtensions,
343
+ recommendations: allRecommendations,
344
+ }
345
+
346
+ fs.writeFileSync(extensionsPath, JSON.stringify(mergedExtensions, null, 2))
347
+
348
+ // Criar launch.json para debug
349
+ const launchConfig = {
350
+ version: '0.2.0',
351
+ configurations: [
352
+ {
353
+ name: 'Debug Playwright Tests',
354
+ type: 'node',
355
+ request: 'launch',
356
+ program: '${workspaceFolder}/node_modules/@playwright/test/cli.js',
357
+ args: ['test', '--debug'],
358
+ console: 'integratedTerminal',
359
+ internalConsoleOptions: 'neverOpen',
360
+ },
361
+ ],
362
+ }
363
+
364
+ const launchPath = path.join(vscodeDir, 'launch.json')
365
+ if (!fs.existsSync(launchPath)) {
366
+ fs.writeFileSync(launchPath, JSON.stringify(launchConfig, null, 2))
367
+ }
368
+
369
+ console.log('✅ Configuração VS Code criada/atualizada')
370
+ }