@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,613 @@
1
+ #!/usr/bin/env node
2
+ // @ts-nocheck
3
+
4
+ import fs from 'node:fs'
5
+ import { execSync } from 'child_process'
6
+ import yaml from 'js-yaml'
7
+ import path from 'path'
8
+ import {
9
+ generateBiomeConfigString,
10
+ generatePackageJson,
11
+ generateTsConfigForProject,
12
+ generateVitestConfigString,
13
+ getLatestVersions,
14
+ } from './package-versions.js'
15
+ import { setupUltracite } from './ultracite-setup.js'
16
+
17
+ const root = process.cwd()
18
+ const catalogPath = path.join(root, 'catalog-info.yaml')
19
+
20
+ if (!fs.existsSync(catalogPath)) {
21
+ console.error('❌ Arquivo catalog-info.yaml não encontrado.')
22
+ process.exit(1)
23
+ }
24
+
25
+ const catalog = yaml.load(fs.readFileSync(catalogPath, 'utf-8')) as any
26
+ const projectName = catalog?.metadata?.name || 'meu-projeto'
27
+ const projectNameUnderscore = projectName.replace(/-/g, '_')
28
+
29
+ const write = (filePath: string, content: string) => {
30
+ const fullPath = path.join(root, filePath)
31
+ fs.mkdirSync(path.dirname(fullPath), { recursive: true })
32
+ fs.writeFileSync(fullPath, content)
33
+ }
34
+
35
+ async function main() {
36
+ console.log('🚀 Inicializando projeto API com versões atualizadas...')
37
+ console.log(`📦 Projeto: ${projectName}`)
38
+ console.log('')
39
+
40
+ // ✅ Buscar versões mais recentes
41
+ const versions = await getLatestVersions()
42
+
43
+ // ✅ Gerar package.json com versões atualizadas
44
+ const packageJsonContent = generatePackageJson(projectName, 'api', versions)
45
+
46
+ // ✅ Gerar tsconfig.json baseado no AutoCore
47
+ const tsconfigContent = generateTsConfigForProject('api')
48
+
49
+ // ✅ Gerar vitest.config.ts sincronizado com o AutoCore (corrige ReferenceError)
50
+ const vitestConfigContent = generateVitestConfigString('api')
51
+
52
+ // ✅ Gerar biome.json sincronizado com AutoCore
53
+ const biomeConfigContent = generateBiomeConfigString()
54
+
55
+ console.log('📝 Criando arquivos do projeto...')
56
+
57
+ // package.json com versões dinâmicas
58
+ write('package.json', JSON.stringify(packageJsonContent, null, 2))
59
+
60
+ // ✅ tsconfig.json sempre sincronizado com o AutoCore
61
+ write('tsconfig.json', JSON.stringify(tsconfigContent, null, 2))
62
+
63
+ // ✅ biome.json sincronizado automaticamente com o AutoCore
64
+ write('biome.json', biomeConfigContent)
65
+
66
+ // playwright.config.ts
67
+ write(
68
+ 'playwright.config.ts',
69
+ `import { defineConfig } from '@playwright/test'
70
+ export default defineConfig({
71
+ globalSetup: '@silasfmartins/testhub/setup',
72
+ reporter: [
73
+ ['list'],
74
+ ['html', { open: 'never' }],
75
+ ['@silasfmartins/testhub/reporter'],
76
+ ],
77
+ testDir: './tests',
78
+ testMatch: ['**/*.spec.ts', '**/*.test.ts'],
79
+ // Timeouts adequados para testes rápidos
80
+ timeout: 120_000,
81
+ expect: {
82
+ timeout: 60_000,
83
+ },
84
+ use: {
85
+ trace: 'on',
86
+ },
87
+ })`,
88
+ )
89
+
90
+ // .npmrc
91
+ write(
92
+ '.npmrc',
93
+ `registry=https://pkgs.dev.azure.com/telefonica-vivo-brasil/_packaging/DevOps/npm/registry/`,
94
+ )
95
+
96
+ // .gitignore
97
+ write(
98
+ '.gitignore',
99
+ `# Playwright
100
+ node_modules/
101
+ /test-results/
102
+ /playwright-report/
103
+ /blob-report/
104
+ /playwright/.cache/
105
+
106
+ # Tests e logs
107
+ /tests
108
+ /logs
109
+ docs
110
+ docs/
111
+
112
+ # Environment files
113
+ .env
114
+ .env.preprod
115
+ .env.esteira1
116
+ .env.esteira2
117
+ .env.prodlike
118
+ .env.prod
119
+
120
+ .vscode
121
+ .vscode/
122
+
123
+ # AutoCore específicos
124
+ .test-data-store.json
125
+ .env.lock
126
+ .configlogger.lock
127
+
128
+ # VS Code
129
+ .vscode/settings.json
130
+ .github/
131
+ .github
132
+
133
+ # Biome
134
+ .biome.log
135
+
136
+ # Coverage
137
+ coverage/
138
+ *.lcov
139
+
140
+ # Screenshots e videos
141
+ /test-results/
142
+ /playwright-report/`,
143
+ )
144
+
145
+ // Arquivo de environment padrão
146
+ write(
147
+ '.env',
148
+ `# Arquivo que seleciona o ambiente a ser utilizado
149
+ ENV=PREPROD`,
150
+ )
151
+
152
+ // Arquivo de environment padrão
153
+ write(
154
+ '.env.preprod',
155
+ `# Configurações de ambiente para preprod
156
+ # Adicione suas variáveis de ambiente aqui`,
157
+ )
158
+
159
+ // Arquivo de environment esteira1
160
+ write(
161
+ '.env.esteira1',
162
+ `# Configurações de ambiente para esteira1
163
+ # Adicione suas variáveis de ambiente aqui`,
164
+ )
165
+
166
+ // Arquivo de environment esteira2
167
+ write(
168
+ '.env.esteira2',
169
+ `# Configurações de ambiente para esteira2
170
+ # Adicione suas variáveis de ambiente aqui`,
171
+ )
172
+
173
+ // ✅ Estrutura de testes
174
+ console.log('📝 Criando estrutura de testes...')
175
+
176
+ // tests/example.spec.ts - Teste E2E com Playwright
177
+ write(
178
+ 'tests/example.spec.ts',
179
+ `import { type TestInfo, test, TestAnnotations, ApiActions } from '@silasfmartins/testhub'
180
+
181
+ test.describe('API Tests - ${projectName}', () => {
182
+ TestAnnotations.stopOnFailure() // opcional: para o runner ao falhar um CT
183
+
184
+ test('CT001 - Exemplo de requisição API', async ({ }, testInfo: TestInfo) => {
185
+ TestAnnotations.Api.testInfo = testInfo
186
+ await TestAnnotations.setSystem('MEU_SISTEMA')
187
+
188
+ // Exemplo de requisição - substitua pelo seu statement
189
+ // await new StatementsToken().getToken()
190
+
191
+ // Exemplo de chamada API direta
192
+ await ApiActions.executeGet(
193
+ 'Buscar dados do endpoint',
194
+ '/api/endpoint'
195
+ )
196
+ })
197
+ })
198
+ `,
199
+ )
200
+
201
+ // Arquivo de environment prodlike
202
+ write(
203
+ '.env.prodlike',
204
+ `# Configurações de ambiente para prodlike
205
+ # Adicione suas variáveis de ambiente aqui`,
206
+ )
207
+
208
+ // Exemplo de Request Token
209
+ write(
210
+ 'src/request/token/RequestToken.ts',
211
+ `import type { ApiRequest } from '@silasfmartins/testhub'
212
+
213
+ export class RequestToken {
214
+ requestToken(): ApiRequest {
215
+ const headers = {
216
+ authorization: 'Basic exemplo',
217
+ 'Content-Type': 'application/json',
218
+ }
219
+
220
+ const data = 'exemplo'
221
+
222
+ return {
223
+ url: '/ms_oauth/oauth2/endpoints/vivooauthservice/tokens',
224
+ options: { headers, data },
225
+ }
226
+ }
227
+ }
228
+ `,
229
+ )
230
+
231
+ // Exemplo de statements
232
+ write(
233
+ 'src/statements/token/StatementsToken.ts',
234
+ `import { ApiActions, DataStore, Logger } from "@silasfmartins/testhub"
235
+ import { RequestToken } from "../request/token/RequestToken.js"
236
+
237
+ export class StatementsToken {
238
+ /**
239
+ * Obter token sistêmico para autenticação
240
+ */
241
+ async getToken(): Promise<void> {
242
+ Logger.info("Executando o método: getToken");
243
+ Logger.info("Iniciando Get Token Sistêmico");
244
+
245
+ const VALIDATE_TOKEN = 200
246
+
247
+ const tokenResponse = await ApiActions.post(
248
+ new RequestToken().requestToken(),
249
+ "Requisição Token Sistêmico",
250
+ true
251
+ );
252
+
253
+ ApiActions.validateEquals(
254
+ tokenResponse.status(),
255
+ VALIDATE_TOKEN,
256
+ "Validação do status code da requisição de token"
257
+ );
258
+
259
+ // Armazenar token para uso posterior
260
+ DataStore.set("ACCESS_TOKEN", tokenResponse.get("token"))
261
+
262
+ Logger.info("Token obtido e armazenado com sucesso");
263
+ }
264
+ }
265
+ `,
266
+ )
267
+
268
+ // Exemplo de teste básico
269
+ write(
270
+ 'tests/example.spec.ts',
271
+ `import { type TestInfo, test, TestAnnotations } from '@silasfmartins/testhub'
272
+ import { StatementsToken } from '../src/statements/token/StatementsToken.js';
273
+
274
+ test.describe('Exemplo API Tests', () => {
275
+ TestAnnotations.Api.testInfo = testInfo;
276
+ await TestAnnotations.setSystem('MEU_SISTEMA');
277
+ test('Deve obter token com sucesso', async () => {
278
+ // Obter token
279
+ await new StatementsToken().getToken()
280
+ });
281
+ });`,
282
+ )
283
+
284
+ //env.ts
285
+ write('src/env.ts', `import { config } from 'dotenv'
286
+
287
+ config()
288
+
289
+ const rawEnv = {
290
+ ENV: process.env.ENV,
291
+ }
292
+ export const env = rawEnv
293
+ `)
294
+
295
+ // Pipeline Azure DevOps
296
+ write(
297
+ '.azuredevops/azure-pipeline.yml',
298
+ `trigger:
299
+ batch: true
300
+ branches:
301
+ include:
302
+ - 'master'
303
+ paths:
304
+ include:
305
+ - '*'
306
+ exclude:
307
+ - .azuredevops/*
308
+ - docs/*
309
+ - catalog-info.yaml
310
+ - mkdocs.yml
311
+ - scripts.py
312
+ - catalog/*
313
+
314
+ resources:
315
+ repositories:
316
+ - repository: CodePlay
317
+ name: DevOps/Vivo.CodePlay.Pipelines
318
+ type: git
319
+ ref: refs/heads/test-playwright
320
+ endpoint: CodePlay
321
+
322
+ pool:
323
+ name: GeneralPurposeLinuxAgentsCI
324
+
325
+ extends:
326
+ template: tech_products/qa/build/pipeline_node_npm.yml@CodePlay
327
+ parameters:
328
+ jobName: 'build_${projectNameUnderscore}_pkg'
329
+ commitSHA: '$(Build.SourceVersion)'
330
+ registryServiceConnection: 'ACR-DEVOPS'
331
+ govAppAcronym: ''
332
+ skipScan: false # Alterado para false para executar Fortify e SonarQube
333
+ `,
334
+ )
335
+
336
+ // SonarQube configuration
337
+ write(
338
+ '.azuredevops/sonar-project.properties',
339
+ `################### NÃO ALTERAR!!! ###################
340
+ # Informações gerais sobre o projeto. #
341
+ # Todas as variáveis de ambiente são fornecidas pela #
342
+ # automação, não alterar! #
343
+ ######################################################
344
+
345
+ sonar.projectDescription=Projeto de API com AutoCore
346
+ sonar.analysis.orgName=\${env.AZ_ORG_NAME}
347
+ sonar.analysis.buildAuthor=\${env.AZ_BUILD_AUTHOR}
348
+ sonar.scm.exclusions.disabled=false
349
+ sonar.scm.forceReloadAll=true
350
+ sonar.log.level=DEBUG
351
+ sonar.verbose=true
352
+ sonar.sourceEncoding=UTF-8
353
+
354
+ # Diretórios e arquivos relevantes para Node.js/TypeScript
355
+ sonar.sources=src
356
+ sonar.inclusions=**/*.ts
357
+ sonar.test.inclusions=**/*.spec.ts,**/*.test.ts
358
+ sonar.typescript.lcov.reportPaths=coverage/lcov.info
359
+ sonar.javascript.lcov.reportPaths=coverage/lcov.info
360
+
361
+ # Exclusões de cobertura e análise
362
+ sonar.exclusions=node_modules/**,dist/**,coverage/**,**/*.config.js,**/*.config.ts
363
+ sonar.coverage.exclusions=**/*.d.ts,node_modules/**,dist/**,coverage/**,**/*.config.js,**/*.config.ts,**/*.spec.ts,**/*.test.ts
364
+ sonar.test.exclusions=node_modules/**,dist/**,coverage/**
365
+
366
+ # Configurações específicas para projetos API
367
+ sonar.javascript.environments=node
368
+ sonar.typescript.node=true
369
+ `,
370
+ )
371
+
372
+ // README.md
373
+ write(
374
+ 'README.md',
375
+ `# ${projectName}
376
+
377
+ Projeto de automação de testes de API baseado no AutoCore.
378
+
379
+ ## 🚀 Como usar
380
+
381
+ ### Instalação de dependências
382
+ \`\`\`bash
383
+ npm install
384
+ \`\`\`
385
+
386
+ ### Executar testes
387
+ \`\`\`bash
388
+ # Ambiente preprod
389
+ npm run test:preprod
390
+
391
+ # Ambiente esteira1
392
+ npm run test:esteira1
393
+
394
+ # Ambiente esteira2
395
+ npm run test:esteira2
396
+
397
+ # Ambiente prodlike
398
+ npm run test:prodlike
399
+ \`\`\`
400
+
401
+ ### Gerar Artefato para Projetos de Cenários
402
+ npm run build
403
+
404
+ ### Configuração de ambiente
405
+
406
+ 1. Configure as variáveis de ambiente nos arquivos \`.env.*\`
407
+ 2. Adicione suas URLs de API e credenciais
408
+ 3. Execute os testes
409
+
410
+ ## 📋 Estrutura do projeto
411
+
412
+ \`\`\`
413
+ ${projectName}/
414
+ ├── src/
415
+ │ ├── statements/ # Lógica de negócio dos testes
416
+ │ └── request/ # Configurações de requisições
417
+ | └── env.ts # Configuração de environment
418
+ ├── tests/ # Arquivos de teste
419
+ ├── .env.* # Variáveis de ambiente por ambiente
420
+ ├── playwright.config.ts # Configuração do Playwright
421
+ ├── tsconfig.json # Configuração TypeScript (sincronizada)
422
+ ├── biome.json # Configuração Biome (sincronizada)
423
+ └── README.md # Esta documentação
424
+ \`\`\`
425
+
426
+ ## 🔧 Desenvolvimento
427
+
428
+ - **TypeScript**: Configurado e sincronizado com AutoCore
429
+ - **Playwright**: Framework de testes
430
+ - **AutoCore**: Biblioteca de utilitários para automação
431
+ - **Biome**: Linting e formatação (configuração sincronizada)
432
+ - **Ultracite**: Experiência de desenvolvimento aprimorada
433
+
434
+ ## 📊 Relatórios
435
+
436
+ Os relatórios são gerados automaticamente em:
437
+ - \`playwright-report/\` - Relatório HTML visual
438
+ - \`test-results/\` - Resultados detalhados e artifacts
439
+ - Logs estruturados no console
440
+
441
+ ## 🧪 Exemplos de Uso
442
+
443
+ ### Teste básico de API
444
+ \`\`\`typescript
445
+ import { type TestInfo, test, TestAnnotations } from '@silasfmartins/testhub'
446
+
447
+ test('Meu teste de API', async ({ }, testInfo) => {
448
+ TestAnnotations.Api.testInfo = testInfo;
449
+
450
+ const response = await ApiActions.get({
451
+ url: 'https://api.example.com/endpoint',
452
+ options: {}
453
+ }, 'Descrição da requisição');
454
+
455
+ ApiActions.validateEquals(response.status, 200, 'Status deve ser 200');
456
+ });
457
+ \`\`\`
458
+
459
+ ### Fluxo com autenticação
460
+ \`\`\`typescript
461
+ import { StatementsToken } from '../src/statements/StatementsToken.js';
462
+ import { DataStore } from '@silasfmartins/testhub';
463
+
464
+ test('Fluxo autenticado', async () => {
465
+ // Obter token
466
+ const statements = new StatementsToken();
467
+ await statements.getToken();
468
+
469
+ // Usar token
470
+ const token = DataStore.get('ACCESS_TOKEN');
471
+ // ... usar token em requisições subsequentes
472
+ });
473
+ \`\`\`
474
+
475
+ ## 🔧 Comandos Úteis
476
+
477
+ \`\`\`bash
478
+ # Desenvolvimento
479
+ npm run test:preprod # Executar testes em preprod
480
+ npm run build # Compilar projeto (se necessário)
481
+ npm run update # Atualizar índices
482
+
483
+ # Qualidade de código
484
+ npx biome check # Verificar código com Biome
485
+ npx biome format # Formatar código com Biome
486
+ npx biome check --apply # Aplicar correções automáticas
487
+
488
+ # Debug
489
+ npm run test:preprod -- --debug # Executar em modo debug
490
+ npm run test:preprod -- --headed # Executar com interface visual
491
+ npm run test:preprod -- --ui # Executar com UI do Playwright
492
+ \`\`\`
493
+
494
+ ## 🔄 Sincronização com AutoCore
495
+
496
+ Este projeto mantém sincronização automática com o AutoCore para:
497
+
498
+ - **tsconfig.json**: Configuração de compilação TypeScript
499
+ - **biome.json**: Configuração de linting e formatação
500
+ - **Versões de dependências**: Sempre atualizadas
501
+
502
+ Para sincronizar manualmente:
503
+ \`\`\`bash
504
+ npx autocore-sync-configs
505
+ \`\`\`
506
+
507
+ ## 📈 Métricas e Monitoramento
508
+
509
+ - **Relatórios HTML**: Visualização rica dos resultados
510
+ - **Logs estruturados**: Para análise e debugging
511
+ - **Screenshots automáticos**: Em caso de falhas
512
+ - **Traces**: Para análise detalhada de execução
513
+
514
+ ## 🆘 Resolução de Problemas
515
+
516
+ ### Erro de autenticação npm
517
+ \`\`\`bash
518
+ npm config set registry https://pkgs.dev.azure.com/telefonica-vivo-brasil/_packaging/DevOps/npm/registry/
519
+ npm login
520
+ \`\`\`
521
+
522
+ ### Problemas de certificado
523
+ \`\`\`bash
524
+ npm config set strict-ssl false
525
+ \`\`\`
526
+
527
+ ### Atualizar dependências
528
+ \`\`\`bash
529
+ npx npm-check-updates -u && npm install
530
+ \`\`\`
531
+
532
+ ## 📝 Contribuição
533
+
534
+ 1. Mantenha os padrões de código (Biome configurado)
535
+ 2. Adicione testes para novas funcionalidades
536
+ 3. Use o sistema de logging do AutoCore
537
+ 4. Documente mudanças significativas
538
+
539
+ ---
540
+
541
+ **Gerado automaticamente pelo AutoCore v${versions?.dependencies?.['@silasfmartins/testhub'] || 'latest'}**`,
542
+ )
543
+
544
+ console.log('📦 Instalando dependências...')
545
+
546
+ const installLockPath = path.join(root, '.install.lock')
547
+ if (fs.existsSync(installLockPath)) {
548
+ // Pula npm install se o lock já existe
549
+ console.log('🔄 Dependências já instaladas, pulando npm install')
550
+ } else {
551
+ // Executa npm install e cria o lock
552
+ console.log('📦 Instalando dependências...')
553
+ try {
554
+ execSync('npm install', {
555
+ stdio: 'inherit',
556
+ cwd: root,
557
+ })
558
+ fs.writeFileSync(installLockPath, 'ok')
559
+ console.log('✅ Dependências instaladas com sucesso')
560
+ } catch (error) {
561
+ console.warn('⚠️ Erro ao instalar dependências automaticamente')
562
+ console.log('💡 Execute manualmente: npm install')
563
+ }
564
+ }
565
+
566
+ // ✅ Configurar Ultracite automaticamente
567
+ console.log('🤖 Configurando ambiente de desenvolvimento...')
568
+ await setupUltracite(root)
569
+
570
+ // ✅ Garantir sincronização final do biome.json
571
+ console.log('🔧 Sincronizando configuração do Biome...')
572
+ const finalBiomeConfig = generateBiomeConfigString()
573
+ write('biome.json', finalBiomeConfig)
574
+
575
+ // Remover o lock após tudo finalizar
576
+ if (fs.existsSync(installLockPath)) {
577
+ fs.unlinkSync(installLockPath)
578
+ console.log('🗑️ Lock de instalação removido')
579
+ }
580
+
581
+ console.log('')
582
+ console.log('🎉 Projeto API gerado com sucesso!')
583
+ console.log('')
584
+ console.log('📋 Próximos passos:')
585
+ console.log(' 1. Configure suas variáveis de ambiente nos arquivos .env.*')
586
+ console.log(' 2. Adicione suas URLs de API no .env.preprod')
587
+ console.log(' 3. Execute: npm run test:preprod')
588
+ console.log(' 4. O Ultracite está configurado para VS Code')
589
+ console.log('')
590
+ console.log('🛠️ Comandos úteis:')
591
+ console.log(' npm run test:preprod - Executar testes em preprod')
592
+ console.log(' npm run test:esteira1 - Executar testes em esteira1')
593
+ console.log(' npm run test:esteira2 - Executar testes em esteira2')
594
+ console.log(' npm run test:prodlike - Executar testes em prodlike')
595
+ console.log(' npm run build - Compilar projeto')
596
+ console.log(' npm run update - Atualizar índices')
597
+ console.log(' npx biome check - Verificar código com Biome')
598
+ console.log(' npx biome format - Formatar código com Biome')
599
+ console.log('')
600
+ console.log('✅ Configurações sincronizadas com AutoCore:')
601
+ console.log(' 📝 tsconfig.json - Compilação TypeScript')
602
+ console.log(' 🎨 biome.json - Linting e formatação (SINCRONIZADO)')
603
+ console.log(' 🤖 Ultracite - Experiência de desenvolvimento')
604
+ console.log(' 📦 Dependências - Versões mais recentes')
605
+ console.log('')
606
+ console.log('🚀 Projeto pronto para desenvolvimento!')
607
+ }
608
+
609
+ // Executar função principal
610
+ main().catch((error) => {
611
+ console.error('❌ Erro durante inicialização:', error)
612
+ process.exit(1)
613
+ })