@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.
- package/.github/copilot-instructions.md +520 -0
- package/biome.json +37 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +169 -0
- package/dist/scripts/consumer-postinstall.d.ts +15 -0
- package/dist/scripts/consumer-postinstall.js +785 -0
- package/dist/scripts/generate-docs.d.ts +16 -0
- package/dist/scripts/generate-docs.js +1363 -0
- package/dist/scripts/generate-index.d.ts +2 -0
- package/dist/scripts/generate-index.js +314 -0
- package/dist/scripts/init-api.d.ts +2 -0
- package/dist/scripts/init-api.js +525 -0
- package/dist/scripts/init-banco.d.ts +2 -0
- package/dist/scripts/init-banco.js +347 -0
- package/dist/scripts/init-frontend.d.ts +2 -0
- package/dist/scripts/init-frontend.js +627 -0
- package/dist/scripts/init-mobile.d.ts +2 -0
- package/dist/scripts/init-mobile.js +481 -0
- package/dist/scripts/init-scenarios.d.ts +2 -0
- package/dist/scripts/init-scenarios.js +846 -0
- package/dist/scripts/init-ssh.d.ts +2 -0
- package/dist/scripts/init-ssh.js +639 -0
- package/dist/scripts/package-versions.d.ts +57 -0
- package/dist/scripts/package-versions.js +768 -0
- package/dist/scripts/postinstall.d.ts +1 -0
- package/dist/scripts/postinstall.js +527 -0
- package/dist/scripts/robust-build.d.ts +7 -0
- package/dist/scripts/robust-build.js +88 -0
- package/dist/scripts/setup-local-packages.d.ts +31 -0
- package/dist/scripts/setup-local-packages.js +237 -0
- package/dist/scripts/smart-override.d.ts +2 -0
- package/dist/scripts/smart-override.js +1360 -0
- package/dist/scripts/sync-configs.d.ts +27 -0
- package/dist/scripts/sync-configs.js +248 -0
- package/dist/scripts/test-biome-parse.d.ts +5 -0
- package/dist/scripts/test-biome-parse.js +84 -0
- package/dist/scripts/ultracite-setup.d.ts +4 -0
- package/dist/scripts/ultracite-setup.js +310 -0
- package/dist/scripts/update-all-init-scripts.d.ts +2 -0
- package/dist/scripts/update-all-init-scripts.js +52 -0
- package/dist/scripts/update-biome-schema.d.ts +15 -0
- package/dist/scripts/update-biome-schema.js +124 -0
- package/dist/src/AutoCoreFacade.d.ts +145 -0
- package/dist/src/AutoCoreFacade.js +217 -0
- package/dist/src/api/ApiActions.d.ts +297 -0
- package/dist/src/api/ApiActions.js +1905 -0
- package/dist/src/api/Certificate.d.ts +60 -0
- package/dist/src/api/Certificate.js +79 -0
- package/dist/src/api/JsonResponse.d.ts +116 -0
- package/dist/src/api/JsonResponse.js +206 -0
- package/dist/src/appium/DeviceFarmViewer.d.ts +79 -0
- package/dist/src/appium/DeviceFarmViewer.js +1083 -0
- package/dist/src/appium/MobileActions.d.ts +347 -0
- package/dist/src/appium/MobileActions.js +1632 -0
- package/dist/src/appium/MobileConnection.d.ts +160 -0
- package/dist/src/appium/MobileConnection.js +772 -0
- package/dist/src/config/envLoader.d.ts +123 -0
- package/dist/src/config/envLoader.js +361 -0
- package/dist/src/config/jest-safe-setup.d.ts +19 -0
- package/dist/src/config/jest-safe-setup.js +369 -0
- package/dist/src/config/timeouts.d.ts +32 -0
- package/dist/src/config/timeouts.js +38 -0
- package/dist/src/desktop/DesktopActions.d.ts +46 -0
- package/dist/src/desktop/DesktopActions.js +398 -0
- package/dist/src/desktop/DesktopConnection.d.ts +32 -0
- package/dist/src/desktop/DesktopConnection.js +84 -0
- package/dist/src/domain/entities/TestExecution.d.ts +117 -0
- package/dist/src/domain/entities/TestExecution.js +150 -0
- package/dist/src/domain/entities/TestReport.d.ts +114 -0
- package/dist/src/domain/entities/TestReport.js +179 -0
- package/dist/src/domain/repositories/ITestRepository.d.ts +196 -0
- package/dist/src/domain/repositories/ITestRepository.js +14 -0
- package/dist/src/domain/schemas/ValidationSchemas.d.ts +159 -0
- package/dist/src/domain/schemas/ValidationSchemas.js +181 -0
- package/dist/src/functions/errors/BaseError.d.ts +78 -0
- package/dist/src/functions/errors/BaseError.js +245 -0
- package/dist/src/functions/errors/ConfigurationError.d.ts +16 -0
- package/dist/src/functions/errors/ConfigurationError.js +48 -0
- package/dist/src/functions/errors/ErrorCatalog.d.ts +148 -0
- package/dist/src/functions/errors/ErrorCatalog.js +157 -0
- package/dist/src/functions/errors/GlobalErrorHandler.d.ts +101 -0
- package/dist/src/functions/errors/GlobalErrorHandler.js +281 -0
- package/dist/src/functions/errors/IntegrationError.d.ts +17 -0
- package/dist/src/functions/errors/IntegrationError.js +51 -0
- package/dist/src/functions/errors/SecurityError.d.ts +14 -0
- package/dist/src/functions/errors/SecurityError.js +42 -0
- package/dist/src/functions/errors/SystemError.d.ts +12 -0
- package/dist/src/functions/errors/SystemError.js +36 -0
- package/dist/src/functions/errors/ValidationError.d.ts +14 -0
- package/dist/src/functions/errors/ValidationError.js +61 -0
- package/dist/src/functions/errors/index.d.ts +12 -0
- package/dist/src/functions/errors/index.js +13 -0
- package/dist/src/global-setup.d.ts +1 -0
- package/dist/src/global-setup.js +1037 -0
- package/dist/src/helpers/BancoActions.d.ts +188 -0
- package/dist/src/helpers/BancoActions.js +581 -0
- package/dist/src/helpers/EnviromentHelper.d.ts +17 -0
- package/dist/src/helpers/EnviromentHelper.js +66 -0
- package/dist/src/helpers/ParallelExecutionHelper.d.ts +183 -0
- package/dist/src/helpers/ParallelExecutionHelper.js +375 -0
- package/dist/src/helpers/SyncSignal.d.ts +15 -0
- package/dist/src/helpers/SyncSignal.js +44 -0
- package/dist/src/hubdocs/CategoryDetector.d.ts +83 -0
- package/dist/src/hubdocs/CategoryDetector.js +401 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.d.ts +54 -0
- package/dist/src/hubdocs/DirectStatementInterceptor.js +243 -0
- package/dist/src/hubdocs/ExecutionTracker.d.ts +107 -0
- package/dist/src/hubdocs/ExecutionTracker.js +702 -0
- package/dist/src/hubdocs/HubDocs.d.ts +395 -0
- package/dist/src/hubdocs/HubDocs.js +3586 -0
- package/dist/src/hubdocs/StatementMethodFilter.d.ts +71 -0
- package/dist/src/hubdocs/StatementMethodFilter.js +618 -0
- package/dist/src/hubdocs/StatementTracker.d.ts +417 -0
- package/dist/src/hubdocs/StatementTracker.js +2419 -0
- package/dist/src/hubdocs/SwaggerGenerator.d.ts +59 -0
- package/dist/src/hubdocs/SwaggerGenerator.js +405 -0
- package/dist/src/hubdocs/index.d.ts +9 -0
- package/dist/src/hubdocs/index.js +9 -0
- package/dist/src/hubdocs/types.d.ts +114 -0
- package/dist/src/hubdocs/types.js +5 -0
- package/dist/src/infrastructure/DependencyContainer.d.ts +142 -0
- package/dist/src/infrastructure/DependencyContainer.js +250 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.d.ts +168 -0
- package/dist/src/infrastructure/adapters/AppiumAdapter.js +468 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.d.ts +150 -0
- package/dist/src/infrastructure/adapters/OracleAdapter.js +388 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.d.ts +192 -0
- package/dist/src/infrastructure/adapters/PlaywrightAdapter.js +382 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.d.ts +141 -0
- package/dist/src/infrastructure/adapters/SSHAdapter.js +428 -0
- package/dist/src/interfaces.d.ts +501 -0
- package/dist/src/interfaces.js +25 -0
- package/dist/src/internal/fakes/__fake-actions__.d.ts +17 -0
- package/dist/src/internal/fakes/__fake-actions__.js +21 -0
- package/dist/src/internal/fakes/__forbidden__.d.ts +10 -0
- package/dist/src/internal/fakes/__forbidden__.js +18 -0
- package/dist/src/internal/fakes/__honeypot__.d.ts +15 -0
- package/dist/src/internal/fakes/__honeypot__.js +24 -0
- package/dist/src/octane/OctaneReporter.d.ts +13 -0
- package/dist/src/octane/OctaneReporter.js +61 -0
- package/dist/src/playwright/CryptoActions.d.ts +20 -0
- package/dist/src/playwright/CryptoActions.js +75 -0
- package/dist/src/playwright/EnhancedWebActions.d.ts +7 -0
- package/dist/src/playwright/EnhancedWebActions.js +65 -0
- package/dist/src/playwright/WebActions.d.ts +1599 -0
- package/dist/src/playwright/WebActions.js +11788 -0
- package/dist/src/playwright/actions/ActionTimeline.d.ts +36 -0
- package/dist/src/playwright/actions/ActionTimeline.js +101 -0
- package/dist/src/playwright/actions/RecoveryQueue.d.ts +82 -0
- package/dist/src/playwright/actions/RecoveryQueue.js +130 -0
- package/dist/src/playwright/actions/SelectorCache.d.ts +53 -0
- package/dist/src/playwright/actions/SelectorCache.js +96 -0
- package/dist/src/playwright/actions/index.d.ts +13 -0
- package/dist/src/playwright/actions/index.js +14 -0
- package/dist/src/playwright/actions/types.d.ts +147 -0
- package/dist/src/playwright/actions/types.js +5 -0
- package/dist/src/playwright/fixtures.d.ts +112 -0
- package/dist/src/playwright/fixtures.js +718 -0
- package/dist/src/playwright/network-logs-reporter.d.ts +7 -0
- package/dist/src/playwright/network-logs-reporter.js +66 -0
- package/dist/src/playwright/registerRecoveryWrappers.d.ts +1 -0
- package/dist/src/playwright/registerRecoveryWrappers.js +54 -0
- package/dist/src/security/BuildSecurity.d.ts +12 -0
- package/dist/src/security/BuildSecurity.js +138 -0
- package/dist/src/security/EulaProtection.d.ts +70 -0
- package/dist/src/security/EulaProtection.js +155 -0
- package/dist/src/security/HoneypotManager.d.ts +46 -0
- package/dist/src/security/HoneypotManager.js +234 -0
- package/dist/src/security/KeysManager.d.ts +36 -0
- package/dist/src/security/KeysManager.js +158 -0
- package/dist/src/security/ProofOfWorkIntegration.d.ts +64 -0
- package/dist/src/security/ProofOfWorkIntegration.js +206 -0
- package/dist/src/security/SecurityValidation.d.ts +21 -0
- package/dist/src/security/SecurityValidation.js +163 -0
- package/dist/src/security/SourceMapProtection.d.ts +55 -0
- package/dist/src/security/SourceMapProtection.js +220 -0
- package/dist/src/security/protector.d.ts +1 -0
- package/dist/src/security/protector.js +97 -0
- package/dist/src/ssh/SSHActions.d.ts +262 -0
- package/dist/src/ssh/SSHActions.js +790 -0
- package/dist/src/ssh/SSHClient.d.ts +99 -0
- package/dist/src/ssh/SSHClient.js +409 -0
- package/dist/src/statements/BaseStatement.d.ts +38 -0
- package/dist/src/statements/BaseStatement.js +78 -0
- package/dist/src/testContext/AuthStateManager.d.ts +93 -0
- package/dist/src/testContext/AuthStateManager.js +256 -0
- package/dist/src/testContext/CoverageManager.d.ts +198 -0
- package/dist/src/testContext/CoverageManager.js +917 -0
- package/dist/src/testContext/TestAnnotations.d.ts +476 -0
- package/dist/src/testContext/TestAnnotations.js +2647 -0
- package/dist/src/testContext/TestContext.d.ts +138 -0
- package/dist/src/testContext/TestContext.js +369 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.d.ts +7 -0
- package/dist/src/testContext/UnifiedHtmlGenerator.js +264 -0
- package/dist/src/testContext/UnifiedReportManager.d.ts +211 -0
- package/dist/src/testContext/UnifiedReportManager.js +1206 -0
- package/dist/src/testhub/DynamicConfigManager.d.ts +121 -0
- package/dist/src/testhub/DynamicConfigManager.js +320 -0
- package/dist/src/testhub/SystemsManager.d.ts +119 -0
- package/dist/src/testhub/SystemsManager.js +365 -0
- package/dist/src/testhub/TestHubClient.d.ts +335 -0
- package/dist/src/testhub/TestHubClient.js +1215 -0
- package/dist/src/testhub/TestHubReporter.d.ts +62 -0
- package/dist/src/testhub/TestHubReporter.js +576 -0
- package/dist/src/testhub/TestHubVars.d.ts +116 -0
- package/dist/src/testhub/TestHubVars.js +273 -0
- package/dist/src/utils/ActionInterceptor.d.ts +59 -0
- package/dist/src/utils/ActionInterceptor.js +741 -0
- package/dist/src/utils/ArtifactsCompressor.d.ts +43 -0
- package/dist/src/utils/ArtifactsCompressor.js +181 -0
- package/dist/src/utils/AutoLogsFinal.d.ts +47 -0
- package/dist/src/utils/AutoLogsFinal.js +148 -0
- package/dist/src/utils/CodeGenSession.d.ts +114 -0
- package/dist/src/utils/CodeGenSession.js +264 -0
- package/dist/src/utils/ConfigLogger.d.ts +133 -0
- package/dist/src/utils/ConfigLogger.js +611 -0
- package/dist/src/utils/CustomReporter.d.ts +22 -0
- package/dist/src/utils/CustomReporter.js +352 -0
- package/dist/src/utils/DataStore.d.ts +171 -0
- package/dist/src/utils/DataStore.js +484 -0
- package/dist/src/utils/DatabaseInterceptor.d.ts +19 -0
- package/dist/src/utils/DatabaseInterceptor.js +295 -0
- package/dist/src/utils/DateHelper.d.ts +16 -0
- package/dist/src/utils/DateHelper.js +120 -0
- package/dist/src/utils/DateValidator.d.ts +4 -0
- package/dist/src/utils/DateValidator.js +51 -0
- package/dist/src/utils/DocumentGenerator.d.ts +35 -0
- package/dist/src/utils/DocumentGenerator.js +129 -0
- package/dist/src/utils/EvidenceCapture.d.ts +90 -0
- package/dist/src/utils/EvidenceCapture.js +600 -0
- package/dist/src/utils/EvidenceReportGenerator.d.ts +70 -0
- package/dist/src/utils/EvidenceReportGenerator.js +799 -0
- package/dist/src/utils/FrameManagementUtil.d.ts +42 -0
- package/dist/src/utils/FrameManagementUtil.js +75 -0
- package/dist/src/utils/GlobalStatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/GlobalStatementsInterceptor.js +1 -0
- package/dist/src/utils/HTMLTemplate.d.ts +1 -0
- package/dist/src/utils/HTMLTemplate.js +1034 -0
- package/dist/src/utils/InterceptacaoMagica.d.ts +23 -0
- package/dist/src/utils/InterceptacaoMagica.js +365 -0
- package/dist/src/utils/LogSanitizer.d.ts +35 -0
- package/dist/src/utils/LogSanitizer.js +110 -0
- package/dist/src/utils/Logger.d.ts +65 -0
- package/dist/src/utils/Logger.js +284 -0
- package/dist/src/utils/McpLocalClient.d.ts +141 -0
- package/dist/src/utils/McpLocalClient.js +871 -0
- package/dist/src/utils/PDFEvidenceGenerator.d.ts +20 -0
- package/dist/src/utils/PDFEvidenceGenerator.js +156 -0
- package/dist/src/utils/SpecFileAnalyzer.d.ts +35 -0
- package/dist/src/utils/SpecFileAnalyzer.js +209 -0
- package/dist/src/utils/StatementInterceptor.d.ts +18 -0
- package/dist/src/utils/StatementInterceptor.js +87 -0
- package/dist/src/utils/StatementLogger.d.ts +33 -0
- package/dist/src/utils/StatementLogger.js +113 -0
- package/dist/src/utils/StatementsInterceptor.d.ts +1 -0
- package/dist/src/utils/StatementsInterceptor.js +1 -0
- package/dist/src/utils/TeamsFlushHook.d.ts +17 -0
- package/dist/src/utils/TeamsFlushHook.js +168 -0
- package/dist/src/utils/TerminalLogCapture.d.ts +158 -0
- package/dist/src/utils/TerminalLogCapture.js +531 -0
- package/dist/src/utils/TestMethodLogger.d.ts +70 -0
- package/dist/src/utils/TestMethodLogger.js +95 -0
- package/dist/src/utils/UnifiedTeardown.d.ts +4 -0
- package/dist/src/utils/UnifiedTeardown.js +400 -0
- package/dist/src/utils/XPathCatalog.d.ts +152 -0
- package/dist/src/utils/XPathCatalog.js +350 -0
- package/dist/src/utils/generators.d.ts +90 -0
- package/dist/src/utils/generators.js +167 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.d.ts +152 -0
- package/dist/src/utils/testRecovery/ResilientPlaywright.js +715 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.d.ts +801 -0
- package/dist/src/utils/testRecovery/TestRecoveryClient.js +1415 -0
- package/dist/src/utils/testRecovery/autoFixCode.d.ts +65 -0
- package/dist/src/utils/testRecovery/autoFixCode.js +32 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +59 -0
- package/dist/wdio.conf.d.ts +1 -0
- package/dist/wdio.conf.js +420 -0
- package/package.json +137 -0
- package/protect-loader.mjs +643 -0
- package/scripts/consumer-postinstall.ts +975 -0
- package/scripts/generate-index.ts +343 -0
- package/scripts/init-api.ts +613 -0
- package/scripts/init-banco.ts +437 -0
- package/scripts/init-frontend.ts +727 -0
- package/scripts/init-mobile.ts +558 -0
- package/scripts/init-scenarios.ts +925 -0
- package/scripts/init-ssh.ts +734 -0
- package/scripts/package-versions.ts +978 -0
- package/scripts/postinstall.ts +605 -0
- package/scripts/smart-override.ts +1675 -0
- package/scripts/sync-configs.ts +302 -0
- package/scripts/ultracite-setup.ts +370 -0
- package/src/types/globals.d.ts +48 -0
- package/tsconfig.json +29 -0
- package/types/autocore-sync-signal.d.ts +10 -0
|
@@ -0,0 +1,978 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import { execSync } from 'child_process'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
|
|
7
|
+
// ✅ ESM Compatibility: Define __dirname for ES modules
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
9
|
+
const __dirname = path.dirname(__filename)
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Versões centralizadas das dependências
|
|
13
|
+
* Atualizado automaticamente via npm-check-updates
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export interface PackageVersions {
|
|
17
|
+
dependencies: Record<string, string>
|
|
18
|
+
devDependencies: Record<string, string>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Busca as versões mais atuais das dependências
|
|
23
|
+
*/
|
|
24
|
+
export async function getLatestVersions(): Promise<PackageVersions> {
|
|
25
|
+
try {
|
|
26
|
+
console.log('🔍 Verificando versões mais recentes...')
|
|
27
|
+
|
|
28
|
+
// Lista de pacotes base que sempre usamos
|
|
29
|
+
const baseDependencies = [
|
|
30
|
+
'@silasfmartins/testhub',
|
|
31
|
+
'cross-env',
|
|
32
|
+
'dotenv',
|
|
33
|
+
'tsx',
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
const baseDevDependencies = [
|
|
37
|
+
'@biomejs/biome',
|
|
38
|
+
'@playwright/test',
|
|
39
|
+
'@vitest/coverage-v8',
|
|
40
|
+
'typescript',
|
|
41
|
+
'ultracite',
|
|
42
|
+
'vitest',
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
// Buscar versões mais recentes via npm view
|
|
46
|
+
const getLatestVersion = (packageName: string): string => {
|
|
47
|
+
try {
|
|
48
|
+
const result = execSync(`npm view ${packageName} version`, {
|
|
49
|
+
encoding: 'utf8',
|
|
50
|
+
})
|
|
51
|
+
return `^${result.trim()}`
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.warn(
|
|
54
|
+
`⚠️ Erro ao buscar versão de ${packageName}, usando fallback`,
|
|
55
|
+
)
|
|
56
|
+
return getVersionFallback(packageName)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Versões de fallback caso npm view falhe
|
|
61
|
+
const getVersionFallback = (packageName: string): string => {
|
|
62
|
+
const fallbacks: Record<string, string> = {
|
|
63
|
+
'@silasfmartins/testhub': '^1.0.90',
|
|
64
|
+
'cross-env': '^7.0.3',
|
|
65
|
+
'@biomejs/biome': '2.0.6',
|
|
66
|
+
tsx: '^4.20.3',
|
|
67
|
+
'@playwright/test': '^1.53.2',
|
|
68
|
+
'@vitest/coverage-v8': '^3.2.4',
|
|
69
|
+
'@vitest/ui': '^3.2.4',
|
|
70
|
+
'happy-dom': '^18.0.1',
|
|
71
|
+
typescript: '^5.8.3',
|
|
72
|
+
ultracite: '5.0.32',
|
|
73
|
+
vitest: '^3.2.4',
|
|
74
|
+
}
|
|
75
|
+
return fallbacks[packageName] || '^1.0.0'
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const dependencies: Record<string, string> = {}
|
|
79
|
+
const devDependencies: Record<string, string> = {}
|
|
80
|
+
|
|
81
|
+
// Buscar versões das dependências
|
|
82
|
+
for (const pkg of baseDependencies) {
|
|
83
|
+
dependencies[pkg] = getLatestVersion(pkg)
|
|
84
|
+
console.log(` ✓ ${pkg}: ${dependencies[pkg]}`)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Buscar versões das devDependencies
|
|
88
|
+
for (const pkg of baseDevDependencies) {
|
|
89
|
+
devDependencies[pkg] = getLatestVersion(pkg)
|
|
90
|
+
console.log(` ✓ ${pkg}: ${devDependencies[pkg]}`)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
console.log('✅ Versões atualizadas obtidas com sucesso')
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
dependencies,
|
|
97
|
+
devDependencies,
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
console.warn('⚠️ Erro ao buscar versões, usando fallbacks')
|
|
101
|
+
|
|
102
|
+
// Retornar versões de fallback
|
|
103
|
+
return {
|
|
104
|
+
dependencies: {
|
|
105
|
+
'@silasfmartins/testhub': '^2.0.0',
|
|
106
|
+
'cross-env': '^10.1.0'
|
|
107
|
+
},
|
|
108
|
+
devDependencies: {
|
|
109
|
+
'@biomejs/biome': '2.2.5',
|
|
110
|
+
tsx: '^4.20.5',
|
|
111
|
+
'@playwright/test': '^1.56.0',
|
|
112
|
+
typescript: '^5.9.3',
|
|
113
|
+
ultracite: '5.6.1',
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* ✅ NOVO - Lê o vitest.config.ts do projeto AutoCore para manter consistência
|
|
121
|
+
*/
|
|
122
|
+
export function getAutocoreVitestConfig(): any {
|
|
123
|
+
try {
|
|
124
|
+
// Obter caminho do arquivo atual
|
|
125
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|
126
|
+
// Navegar para o diretório raiz do projeto
|
|
127
|
+
// Se estivermos em dist/scripts/, subir 2 níveis; se em scripts/, subir 1 nível
|
|
128
|
+
const autocoreRoot = currentDir.includes('dist')
|
|
129
|
+
? path.resolve(currentDir, '..', '..') // dist/scripts/ -> raiz
|
|
130
|
+
: path.resolve(currentDir, '..') // scripts/ -> raiz
|
|
131
|
+
const vitestConfigPath = path.join(autocoreRoot, 'vitest.config.ts')
|
|
132
|
+
|
|
133
|
+
console.log(`🔍 Procurando vitest.config.ts em: ${vitestConfigPath}`)
|
|
134
|
+
|
|
135
|
+
if (fs.existsSync(vitestConfigPath)) {
|
|
136
|
+
const vitestConfigContent = fs.readFileSync(vitestConfigPath, 'utf8')
|
|
137
|
+
|
|
138
|
+
// Parse simples extraindo a configuração do defineConfig
|
|
139
|
+
// Removemos imports e export e mantemos só a configuração
|
|
140
|
+
const configMatch = vitestConfigContent.match(
|
|
141
|
+
/defineConfig\(([\s\S]*)\)/m,
|
|
142
|
+
)
|
|
143
|
+
if (configMatch) {
|
|
144
|
+
// Parseando manualmente para manter comentários e estrutura
|
|
145
|
+
const configStr = configMatch[1]
|
|
146
|
+
|
|
147
|
+
// Estrutura base similar ao que temos no AutoCore
|
|
148
|
+
const baseConfig = {
|
|
149
|
+
test: {
|
|
150
|
+
globals: false, // Sempre false para evitar conflitos Jest/Vitest
|
|
151
|
+
environment: 'node',
|
|
152
|
+
setupFiles: ['./tests/unit/setup.ts'],
|
|
153
|
+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
|
|
154
|
+
coverage: {
|
|
155
|
+
provider: 'v8',
|
|
156
|
+
reporter: ['text', 'html', 'lcov'],
|
|
157
|
+
include: ['src/**/*.ts'],
|
|
158
|
+
exclude: [
|
|
159
|
+
'tests/**',
|
|
160
|
+
'node_modules/',
|
|
161
|
+
'dist/',
|
|
162
|
+
'**/*.d.ts',
|
|
163
|
+
'**/*.config.ts',
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
console.log('✅ vitest.config.ts do AutoCore carregado com sucesso')
|
|
170
|
+
return baseConfig
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
console.warn(
|
|
174
|
+
'⚠️ vitest.config.ts do AutoCore não encontrado, usando configuração padrão',
|
|
175
|
+
)
|
|
176
|
+
return getDefaultVitestConfig()
|
|
177
|
+
} catch (error) {
|
|
178
|
+
console.warn(
|
|
179
|
+
`⚠️ Erro ao ler vitest.config.ts do AutoCore: ${error}, usando configuração padrão`,
|
|
180
|
+
)
|
|
181
|
+
return getDefaultVitestConfig()
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* ✅ NOVO - Configuração padrão de fallback para vitest.config.ts
|
|
187
|
+
*/
|
|
188
|
+
function getDefaultVitestConfig(): any {
|
|
189
|
+
return {
|
|
190
|
+
test: {
|
|
191
|
+
// Default safe config
|
|
192
|
+
globals: false,
|
|
193
|
+
environment: 'node',
|
|
194
|
+
setupFiles: ['./tests/unit/setup.ts'],
|
|
195
|
+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
|
|
196
|
+
coverage: {
|
|
197
|
+
provider: 'v8',
|
|
198
|
+
reporter: ['text', 'html', 'lcov'],
|
|
199
|
+
include: ['src/**/*.ts'],
|
|
200
|
+
exclude: [
|
|
201
|
+
'tests/**',
|
|
202
|
+
'node_modules/',
|
|
203
|
+
'dist/',
|
|
204
|
+
'**/*.d.ts',
|
|
205
|
+
'**/*.config.ts',
|
|
206
|
+
'**/coverage/**',
|
|
207
|
+
],
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* ✅ NOVO - Gera vitest.config.ts para projeto consumidor
|
|
215
|
+
*/
|
|
216
|
+
export function generateVitestConfigForProject(
|
|
217
|
+
projectType: 'api' | 'frontend' | 'mobile' | 'ssh' | 'banco' | 'scenarios',
|
|
218
|
+
): any {
|
|
219
|
+
const baseVitestConfig = getAutocoreVitestConfig()
|
|
220
|
+
|
|
221
|
+
// Personaliza configuração baseada no tipo de projeto
|
|
222
|
+
const projectVitestConfig = {
|
|
223
|
+
...baseVitestConfig,
|
|
224
|
+
test: {
|
|
225
|
+
...baseVitestConfig.test,
|
|
226
|
+
// Ajustes específicos por tipo de projeto
|
|
227
|
+
...(projectType === 'scenarios' && {
|
|
228
|
+
// Para cenários, incluir coverage mais abrangente
|
|
229
|
+
coverage: {
|
|
230
|
+
...baseVitestConfig.test.coverage,
|
|
231
|
+
include: ['src/**/*.ts', 'tests/helpers/**/*.ts'],
|
|
232
|
+
reporter: ['text', 'html', 'lcov', 'json'],
|
|
233
|
+
},
|
|
234
|
+
}),
|
|
235
|
+
...(projectType === 'api' && {
|
|
236
|
+
// Para API, incluir testes de integração
|
|
237
|
+
include: [
|
|
238
|
+
'tests/**/*.test.ts',
|
|
239
|
+
'src/**/*.test.ts',
|
|
240
|
+
'tests/**/*.integration.test.ts',
|
|
241
|
+
],
|
|
242
|
+
}),
|
|
243
|
+
},
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
console.log(
|
|
247
|
+
`✅ vitest.config.ts gerado para projeto ${projectType} (sincronizado com AutoCore)`,
|
|
248
|
+
)
|
|
249
|
+
return projectVitestConfig
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* ✅ NOVO - Gera vitest.config.ts como string TypeScript (IGUAL AO AUTOCORE)
|
|
254
|
+
*/
|
|
255
|
+
export function generateVitestConfigString(
|
|
256
|
+
projectType: 'api' | 'frontend' | 'mobile' | 'ssh' | 'banco' | 'scenarios',
|
|
257
|
+
): string {
|
|
258
|
+
// 🔧 Configuração otimizada para evitar conflitos Jest/Vitest/Playwright
|
|
259
|
+
return `import { defineConfig } from 'vitest/config'
|
|
260
|
+
|
|
261
|
+
export default defineConfig({
|
|
262
|
+
test: {
|
|
263
|
+
// ✅ CRÍTICO: globals: false evita conflitos com Jest/Playwright
|
|
264
|
+
globals: false,
|
|
265
|
+
environment: 'node',
|
|
266
|
+
|
|
267
|
+
// ✅ Jest-safe setup para resolver conflitos de símbolos
|
|
268
|
+
setupFiles: [
|
|
269
|
+
'@silasfmartins/testhub/jest-safe', // ← Deve ser PRIMEIRO
|
|
270
|
+
'./tests/unit/setup.ts'
|
|
271
|
+
],
|
|
272
|
+
|
|
273
|
+
// 🎯 CRÍTICO: Apenas .test.ts para evitar conflito com Playwright .spec.ts
|
|
274
|
+
include: ['tests/**/*.test.ts'],
|
|
275
|
+
|
|
276
|
+
// 🔧 Excluir arquivos que podem causar conflito
|
|
277
|
+
exclude: [
|
|
278
|
+
'node_modules/**',
|
|
279
|
+
'dist/**',
|
|
280
|
+
'.git/**',
|
|
281
|
+
'coverage/**',
|
|
282
|
+
'playwright-report/**',
|
|
283
|
+
'test-results/**',
|
|
284
|
+
'**/*.spec.ts', // ← EXCLUIR .spec.ts (são do Playwright)
|
|
285
|
+
'tests/e2e/**' // ← EXCLUIR testes E2E (são do Playwright)
|
|
286
|
+
],
|
|
287
|
+
|
|
288
|
+
// ✅ Configurações de isolamento para evitar conflitos de símbolos
|
|
289
|
+
isolate: true,
|
|
290
|
+
pool: 'forks', // Forks em vez de threads
|
|
291
|
+
|
|
292
|
+
// ✅ Execução sequencial para evitar race conditions
|
|
293
|
+
sequence: {
|
|
294
|
+
concurrent: false,
|
|
295
|
+
shuffle: false
|
|
296
|
+
},
|
|
297
|
+
|
|
298
|
+
// ✅ Worker único para evitar conflitos de Symbol registry
|
|
299
|
+
maxWorkers: 1,
|
|
300
|
+
retry: 0,
|
|
301
|
+
testTimeout: 30_000,
|
|
302
|
+
hookTimeout: 10_000,
|
|
303
|
+
|
|
304
|
+
coverage: {
|
|
305
|
+
provider: 'v8',
|
|
306
|
+
reporter: ['text', 'html', 'lcov'],
|
|
307
|
+
include: ['src/**/*.ts'],
|
|
308
|
+
exclude: [
|
|
309
|
+
'tests/**',
|
|
310
|
+
'src/**/*.d.ts',
|
|
311
|
+
'src/**/*.test.ts',
|
|
312
|
+
'src/**/*.spec.ts'
|
|
313
|
+
],
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
esbuild: {
|
|
317
|
+
target: 'node24'
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
`
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Lê o tsconfig.json do projeto AutoCore para manter consistência
|
|
325
|
+
*/
|
|
326
|
+
export function getAutocoreTsConfig(): any {
|
|
327
|
+
try {
|
|
328
|
+
// Obter caminho do arquivo atual
|
|
329
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|
330
|
+
// Navegar para o diretório raiz do projeto
|
|
331
|
+
// Se estivermos em dist/scripts/, subir 2 níveis; se em scripts/, subir 1 nível
|
|
332
|
+
const autocoreRoot = currentDir.includes('dist')
|
|
333
|
+
? path.resolve(currentDir, '..', '..') // dist/scripts/ -> raiz
|
|
334
|
+
: path.resolve(currentDir, '..') // scripts/ -> raiz
|
|
335
|
+
const tsconfigPath = path.join(autocoreRoot, 'tsconfig.json')
|
|
336
|
+
|
|
337
|
+
console.log(`🔍 Procurando tsconfig.json em: ${tsconfigPath}`)
|
|
338
|
+
|
|
339
|
+
if (fs.existsSync(tsconfigPath)) {
|
|
340
|
+
const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf8')
|
|
341
|
+
const tsconfig = JSON.parse(tsconfigContent)
|
|
342
|
+
|
|
343
|
+
console.log('✅ tsconfig.json do AutoCore carregado com sucesso')
|
|
344
|
+
return tsconfig
|
|
345
|
+
}
|
|
346
|
+
console.warn(
|
|
347
|
+
'⚠️ tsconfig.json do AutoCore não encontrado, usando configuração padrão',
|
|
348
|
+
)
|
|
349
|
+
return getDefaultTsConfig()
|
|
350
|
+
} catch (error) {
|
|
351
|
+
console.warn(
|
|
352
|
+
`⚠️ Erro ao ler tsconfig.json do AutoCore: ${error}, usando configuração padrão`,
|
|
353
|
+
)
|
|
354
|
+
return getDefaultTsConfig()
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Configuração padrão de fallback para tsconfig.json
|
|
360
|
+
*/
|
|
361
|
+
function getDefaultTsConfig(): any {
|
|
362
|
+
return {
|
|
363
|
+
$schema: 'https://json.schemastore.org/tsconfig',
|
|
364
|
+
compilerOptions: {
|
|
365
|
+
// ✅ IMPORTANTE: manter checks básicos como strictNullChecks
|
|
366
|
+
strictNullChecks: true,
|
|
367
|
+
},
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* ✅ CORRIGIDO: Função única para gerar tsconfig.json
|
|
373
|
+
*/
|
|
374
|
+
export function generateTsConfigForProject(
|
|
375
|
+
projectType: 'api' | 'frontend' | 'mobile' | 'ssh' | 'banco' | 'scenarios',
|
|
376
|
+
): any {
|
|
377
|
+
const baseTsConfig = getAutocoreTsConfig()
|
|
378
|
+
|
|
379
|
+
// Retorna cópia idêntica do AutoCore sem modificações
|
|
380
|
+
const projectTsConfig = {
|
|
381
|
+
...baseTsConfig,
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
console.log(
|
|
385
|
+
`✅ tsconfig.json gerado para projeto ${projectType} (sincronizado com AutoCore)`,
|
|
386
|
+
)
|
|
387
|
+
return projectTsConfig
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Gera package.json com versões específicas por tipo de projeto
|
|
392
|
+
*/
|
|
393
|
+
export function generatePackageJson(
|
|
394
|
+
projectName: string,
|
|
395
|
+
projectType: 'api' | 'frontend' | 'mobile' | 'ssh' | 'banco' | 'scenarios',
|
|
396
|
+
versions: PackageVersions,
|
|
397
|
+
): any {
|
|
398
|
+
// ✅ NOVO: Package.json base para scenarios (sem main)
|
|
399
|
+
const basePackageJsonScenarios = {
|
|
400
|
+
name: `@rbqa/${projectName}`,
|
|
401
|
+
version: '1.0.0',
|
|
402
|
+
type: 'module',
|
|
403
|
+
keywords: [],
|
|
404
|
+
author: '',
|
|
405
|
+
license: 'ISC',
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// ✅ Package.json base para outros tipos (com main)
|
|
409
|
+
const basePackageJson = {
|
|
410
|
+
name: `@rbqa/${projectName}`,
|
|
411
|
+
version: '1.0.0',
|
|
412
|
+
type: 'module',
|
|
413
|
+
main: 'dist/index.js',
|
|
414
|
+
keywords: [],
|
|
415
|
+
author: '',
|
|
416
|
+
license: 'ISC',
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
// ✅ Escolher configuração base baseada no tipo de projeto
|
|
420
|
+
const selectedBase =
|
|
421
|
+
projectType === 'scenarios' ? basePackageJsonScenarios : basePackageJson
|
|
422
|
+
|
|
423
|
+
// Scripts específicos por tipo de projeto
|
|
424
|
+
const scriptsConfig = getScriptsForProjectType(projectType)
|
|
425
|
+
|
|
426
|
+
// Dependências específicas por tipo
|
|
427
|
+
const specificDependencies = getSpecificDependencies(projectType, versions)
|
|
428
|
+
|
|
429
|
+
// Build base package object
|
|
430
|
+
const pkg: any = {
|
|
431
|
+
...selectedBase,
|
|
432
|
+
description: `Projeto ${getProjectTypeDescription(projectType)} baseado no AutoCore para Automação`,
|
|
433
|
+
scripts: scriptsConfig,
|
|
434
|
+
devDependencies: {
|
|
435
|
+
...versions.devDependencies,
|
|
436
|
+
...specificDependencies.devDependencies,
|
|
437
|
+
},
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if (projectType === 'scenarios') {
|
|
441
|
+
// For scenarios: keep runtime deps minimal (only specificDependencies)
|
|
442
|
+
pkg.dependencies = {
|
|
443
|
+
...specificDependencies.dependencies,
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Move common system packages (that represent other "system" projects) to peerDependencies
|
|
447
|
+
// so they are declared but NOT installed automatically on `npm install`.
|
|
448
|
+
const systemPatterns = [/^@sfa\//i, /test-sanity/i]
|
|
449
|
+
const peerDeps: Record<string, string> = {}
|
|
450
|
+
|
|
451
|
+
for (const [name, ver] of Object.entries(versions.dependencies || {})) {
|
|
452
|
+
const isSystem = systemPatterns.some((rx) => rx.test(name))
|
|
453
|
+
if (isSystem) {
|
|
454
|
+
peerDeps[name] = ver
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
if (Object.keys(peerDeps).length > 0) {
|
|
459
|
+
pkg.peerDependencies = peerDeps
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
pkg.dependencies = {
|
|
463
|
+
// Remover automaticamente `zod` dos packages gerados para consumidores
|
|
464
|
+
...Object.fromEntries(
|
|
465
|
+
Object.entries(versions.dependencies || {}).filter(([k]) => k !== 'zod'),
|
|
466
|
+
),
|
|
467
|
+
...specificDependencies.dependencies,
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return pkg
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Dependências específicas por tipo de projeto
|
|
476
|
+
*/
|
|
477
|
+
function getSpecificDependencies(
|
|
478
|
+
projectType: string,
|
|
479
|
+
versions: PackageVersions,
|
|
480
|
+
): {
|
|
481
|
+
dependencies: Record<string, string>
|
|
482
|
+
devDependencies: Record<string, string>
|
|
483
|
+
} {
|
|
484
|
+
const specific = {
|
|
485
|
+
dependencies: {} as Record<string, string>,
|
|
486
|
+
devDependencies: {} as Record<string, string>,
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
switch (projectType) {
|
|
490
|
+
case 'scenarios':
|
|
491
|
+
// ✅ Scenarios: keep dependencies minimal to avoid heavy installs on `npm i`
|
|
492
|
+
// Only install @silasfmartins/testhub by default; move other tools to devDependencies
|
|
493
|
+
specific.dependencies['@silasfmartins/testhub'] =
|
|
494
|
+
versions.dependencies?.['@silasfmartins/testhub'] || '^1.0.0'
|
|
495
|
+
|
|
496
|
+
// Minimal devDependencies helpful for development (tsx/biome if present)
|
|
497
|
+
specific.devDependencies['tsx'] =
|
|
498
|
+
versions.devDependencies?.['tsx'] || versions.dependencies?.['tsx'] || '^4.20.0'
|
|
499
|
+
specific.devDependencies['@biomejs/biome'] =
|
|
500
|
+
versions.devDependencies?.['@biomejs/biome'] || '^2.0.0'
|
|
501
|
+
break
|
|
502
|
+
|
|
503
|
+
default:
|
|
504
|
+
// Para outros tipos, manter tsx nas dependencies normais
|
|
505
|
+
break
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return specific
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Scripts específicos por tipo de projeto
|
|
513
|
+
*/
|
|
514
|
+
function getScriptsForProjectType(projectType: string): Record<string, string> {
|
|
515
|
+
const baseScripts = {
|
|
516
|
+
generate: 'npx autocore-generate',
|
|
517
|
+
update: 'npx autocore-sync-configs && npm run generate && rimraf dist && tsc && rimraf index.ts',
|
|
518
|
+
build: 'npm run update',
|
|
519
|
+
sync: 'npx autocore-sync-configs',
|
|
520
|
+
format: 'npx @biomejs/biome format --write',
|
|
521
|
+
"check-updates": "npx npm-check-updates -u",
|
|
522
|
+
register: "npx tsx node_modules/@silasfmartins/testhub/scripts/smart-override.ts register",
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// ✅ Scripts do Vitest para testes unitários de utilitários
|
|
526
|
+
const vitestScripts = {
|
|
527
|
+
'test:unit': 'vitest run',
|
|
528
|
+
'test:unit:watch': 'vitest',
|
|
529
|
+
'test:unit:ui': 'vitest --ui',
|
|
530
|
+
'test:unit:coverage': 'vitest run',
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
const testScripts = {
|
|
534
|
+
test: 'cross-env NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
535
|
+
'test:esteira1':
|
|
536
|
+
'cross-env NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
537
|
+
'test:esteira2':
|
|
538
|
+
'cross-env NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
539
|
+
'test:preprod':
|
|
540
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
541
|
+
'test:prodlike':
|
|
542
|
+
'cross-env NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// ✅ Scripts de CodeGen com contexto do AutoCore
|
|
546
|
+
const codegenScripts = {
|
|
547
|
+
codegen:
|
|
548
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright codegen',
|
|
549
|
+
'codegen:esteira1':
|
|
550
|
+
'cross-env NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright codegen',
|
|
551
|
+
'codegen:esteira2':
|
|
552
|
+
'cross-env NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright codegen',
|
|
553
|
+
'codegen:preprod':
|
|
554
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright codegen',
|
|
555
|
+
'codegen:prodlike':
|
|
556
|
+
'cross-env NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright codegen',
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// ✅ Scripts de Debug com contexto do AutoCore
|
|
560
|
+
const debugScripts = {
|
|
561
|
+
debug:
|
|
562
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
563
|
+
'debug:esteira1':
|
|
564
|
+
'cross-env NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
565
|
+
'debug:esteira2':
|
|
566
|
+
'cross-env NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
567
|
+
'debug:preprod':
|
|
568
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
569
|
+
'debug:prodlike':
|
|
570
|
+
'cross-env NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// ✅ Scripts de UI com contexto do AutoCore (Web/Frontend)
|
|
574
|
+
const uiScripts = {
|
|
575
|
+
ui: 'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
576
|
+
'ui:esteira1':
|
|
577
|
+
'cross-env NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
578
|
+
'ui:esteira2':
|
|
579
|
+
'cross-env NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
580
|
+
'ui:preprod':
|
|
581
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
582
|
+
'ui:prodlike':
|
|
583
|
+
'cross-env NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const uiScriptsChromium = {
|
|
587
|
+
'ui:chromium': 'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
588
|
+
'ui:esteira1:chromium':
|
|
589
|
+
'cross-env NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
590
|
+
'ui:esteira2:chromium':
|
|
591
|
+
'cross-env NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
592
|
+
'ui:preprod:chromium':
|
|
593
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
594
|
+
'ui:prodlike:chromium':
|
|
595
|
+
'cross-env NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
const testScriptsChromium = {
|
|
599
|
+
ui: 'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
600
|
+
'ui:esteira1':
|
|
601
|
+
'cross-env NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
602
|
+
'ui:esteira2':
|
|
603
|
+
'cross-env NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
604
|
+
'ui:preprod':
|
|
605
|
+
'cross-env NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
606
|
+
'ui:prodlike':
|
|
607
|
+
'cross-env NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui --project=chromium',
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// ✅ Scripts MOBILE em modo HEADLESS (sem Appium Inspector - para CI/CD)
|
|
611
|
+
const mobileTestScripts = {
|
|
612
|
+
'test:esteira1':
|
|
613
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
614
|
+
'test:esteira2':
|
|
615
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
616
|
+
'test:preprod':
|
|
617
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
618
|
+
'test:prodlike':
|
|
619
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
// ✅ Scripts MOBILE DEBUG em modo HEADLESS
|
|
623
|
+
const mobileDebugScripts = {
|
|
624
|
+
debug:
|
|
625
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
626
|
+
'debug:esteira1':
|
|
627
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
628
|
+
'debug:esteira2':
|
|
629
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
630
|
+
'debug:preprod':
|
|
631
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
632
|
+
'debug:prodlike':
|
|
633
|
+
'cross-env MOBILE_UI_MODE=false NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// ✅ Scripts MOBILE com UI (Appium Inspector VISÍVEL - para desenvolvimento)
|
|
637
|
+
const mobileUiScripts = {
|
|
638
|
+
'ui:esteira1':
|
|
639
|
+
'cross-env MOBILE_UI_MODE=true NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
640
|
+
'ui:esteira2':
|
|
641
|
+
'cross-env MOBILE_UI_MODE=true NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
642
|
+
'ui:preprod':
|
|
643
|
+
'cross-env MOBILE_UI_MODE=true NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
644
|
+
'ui:prodlike':
|
|
645
|
+
'cross-env MOBILE_UI_MODE=true NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
646
|
+
'ui:esteira1:debug':
|
|
647
|
+
'cross-env MOBILE_UI_MODE=true AUTOCORE_DEBUG_LOGS=true NODE_ENV=esteira1 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
648
|
+
'ui:esteira2:debug':
|
|
649
|
+
'cross-env MOBILE_UI_MODE=true AUTOCORE_DEBUG_LOGS=true NODE_ENV=esteira2 NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
650
|
+
'ui:preprod:debug':
|
|
651
|
+
'cross-env MOBILE_UI_MODE=true AUTOCORE_DEBUG_LOGS=true NODE_ENV=preprod NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
652
|
+
'ui:prodlike:debug':
|
|
653
|
+
'cross-env MOBILE_UI_MODE=true AUTOCORE_DEBUG_LOGS=true NODE_ENV=prodlike NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// ✅ Script de postinstall AUTOMÁTICO (roda após npm install)
|
|
657
|
+
// Sincroniza tsconfig.json, biome.json e instala extensões VS Code
|
|
658
|
+
// Usa binários do AutoCore (evita erros de .ts não encontrado)
|
|
659
|
+
const postinstallScript = {
|
|
660
|
+
postinstall: 'npx autocore-postinstall',
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
switch (projectType) {
|
|
664
|
+
case 'api':
|
|
665
|
+
return {
|
|
666
|
+
...testScripts,
|
|
667
|
+
...debugScripts,
|
|
668
|
+
...baseScripts,
|
|
669
|
+
...postinstallScript,
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
case 'scenarios':
|
|
673
|
+
// ✅ CORRIGIDO: Scenarios usa preinstall (antes) + postinstall (depois)
|
|
674
|
+
return {
|
|
675
|
+
sync: 'npx autocore-sync-configs',
|
|
676
|
+
'test:esteira1':
|
|
677
|
+
'cross-env NODE_ENV=esteira1 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
678
|
+
'test:esteira2':
|
|
679
|
+
'cross-env NODE_ENV=esteira2 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
680
|
+
'test:preprod':
|
|
681
|
+
'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
682
|
+
'test:prodlike':
|
|
683
|
+
'cross-env NODE_ENV=prodlike NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
684
|
+
// ✅ Debug para cenários
|
|
685
|
+
debug:
|
|
686
|
+
'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
687
|
+
'debug:esteira1':
|
|
688
|
+
'cross-env NODE_ENV=esteira1 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
689
|
+
'debug:esteira2':
|
|
690
|
+
'cross-env NODE_ENV=esteira2 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
691
|
+
'debug:preprod':
|
|
692
|
+
'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
693
|
+
'debug:prodlike':
|
|
694
|
+
'cross-env NODE_ENV=prodlike NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
695
|
+
ui: 'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
696
|
+
'ui:esteira1':
|
|
697
|
+
'cross-env NODE_ENV=esteira1 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
698
|
+
'ui:esteira2':
|
|
699
|
+
'cross-env NODE_ENV=esteira2 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
700
|
+
'ui:preprod':
|
|
701
|
+
'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
702
|
+
'ui:prodlike':
|
|
703
|
+
'cross-env NODE_ENV=prodlike NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --ui',
|
|
704
|
+
...uiScriptsChromium,
|
|
705
|
+
...testScriptsChromium,
|
|
706
|
+
postinstall: "node -e \"const fs=require('fs'), cp=require('child_process'); if(!fs.existsSync('node_modules/@silasfmartins/testhub')){console.log('@silasfmartins/testhub missing - installing'); cp.execSync('npm install @silasfmartins/testhub --no-audit --no-fund --silent',{stdio:'inherit'});} try{ cp.execSync('npx tsx ./node_modules/@silasfmartins/testhub/scripts/consumer-postinstall.ts',{stdio:'inherit'});}catch(e){ console.warn('consumer-postinstall failed', e); }\""
|
|
707
|
+
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
case 'banco':
|
|
711
|
+
return {
|
|
712
|
+
'test:esteira1':
|
|
713
|
+
'cross-env NODE_ENV=esteira1 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
714
|
+
'test:esteira2':
|
|
715
|
+
'cross-env NODE_ENV=esteira2 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
716
|
+
'test:preprod':
|
|
717
|
+
'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
718
|
+
'test:prodlike':
|
|
719
|
+
'cross-env NODE_ENV=prodlike NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test',
|
|
720
|
+
debug:
|
|
721
|
+
'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
722
|
+
'debug:esteira1':
|
|
723
|
+
'cross-env NODE_ENV=esteira1 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
724
|
+
'debug:esteira2':
|
|
725
|
+
'cross-env NODE_ENV=esteira2 NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
726
|
+
'debug:preprod':
|
|
727
|
+
'cross-env NODE_ENV=preprod NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
728
|
+
'debug:prodlike':
|
|
729
|
+
'cross-env NODE_ENV=prodlike NODE_ORACLEDB_DRIVER_MODE=thick NODE_OPTIONS="--loader ./node_modules/@silasfmartins/testhub/protect-loader.mjs" playwright test --debug',
|
|
730
|
+
...baseScripts,
|
|
731
|
+
...postinstallScript
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
case 'frontend':
|
|
735
|
+
return {
|
|
736
|
+
...testScripts,
|
|
737
|
+
...debugScripts,
|
|
738
|
+
...baseScripts,
|
|
739
|
+
...uiScripts,
|
|
740
|
+
...uiScriptsChromium,
|
|
741
|
+
...testScriptsChromium,
|
|
742
|
+
...postinstallScript
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
case 'mobile':
|
|
746
|
+
return {
|
|
747
|
+
...mobileTestScripts,
|
|
748
|
+
...mobileDebugScripts,
|
|
749
|
+
...mobileUiScripts,
|
|
750
|
+
...baseScripts,
|
|
751
|
+
...postinstallScript
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
case 'ssh':
|
|
755
|
+
return {
|
|
756
|
+
...testScripts,
|
|
757
|
+
...debugScripts,
|
|
758
|
+
...baseScripts,
|
|
759
|
+
...postinstallScript
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
default:
|
|
763
|
+
return {
|
|
764
|
+
...testScripts,
|
|
765
|
+
...debugScripts,
|
|
766
|
+
...baseScripts,
|
|
767
|
+
...postinstallScript
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Descrição por tipo de projeto
|
|
774
|
+
*/
|
|
775
|
+
function getProjectTypeDescription(projectType: string): string {
|
|
776
|
+
const descriptions = {
|
|
777
|
+
api: 'de API',
|
|
778
|
+
frontend: 'Frontend',
|
|
779
|
+
mobile: 'Mobile',
|
|
780
|
+
ssh: 'de SSH',
|
|
781
|
+
banco: 'de Banco de Dados',
|
|
782
|
+
scenarios: 'de Cenários',
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
return descriptions[projectType as keyof typeof descriptions] || 'AutoCore'
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/**
|
|
789
|
+
* Tipo para configuração do Biome
|
|
790
|
+
*/
|
|
791
|
+
type BiomeConfig = {
|
|
792
|
+
$schema?: string
|
|
793
|
+
extends?: string[]
|
|
794
|
+
[key: string]: unknown
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* ✅ NOVO - Gera biome.json sincronizado com o AutoCore
|
|
799
|
+
*/
|
|
800
|
+
export function generateBiomeConfigForProject(): BiomeConfig {
|
|
801
|
+
// Lê o biome.json do AutoCore como template
|
|
802
|
+
const autocoreBiomeConfig = getAutocoreBiomeConfig()
|
|
803
|
+
|
|
804
|
+
console.log('✅ biome.json sincronizado com AutoCore')
|
|
805
|
+
return autocoreBiomeConfig
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* ✅ Parse robusto de JSONC - Remove comentários e caracteres de controle
|
|
810
|
+
*/
|
|
811
|
+
function parseJsonc(content: string): BiomeConfig {
|
|
812
|
+
// 1. Remover comentários de bloco /* */
|
|
813
|
+
let cleaned = content.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
814
|
+
|
|
815
|
+
// 2. Remover comentários de linha // (processar linha por linha para não afetar URLs)
|
|
816
|
+
const lines = cleaned.split('\n')
|
|
817
|
+
const processedLines = lines.map((line) => {
|
|
818
|
+
// Se a linha tem aspas, verificar se // está dentro de string
|
|
819
|
+
if (line.includes('"')) {
|
|
820
|
+
const commentPos = line.indexOf('//')
|
|
821
|
+
if (commentPos === -1) {
|
|
822
|
+
return line
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// Verificar se // está dentro de string (contar aspas antes)
|
|
826
|
+
const beforeComment = line.substring(0, commentPos)
|
|
827
|
+
const quoteCount = (beforeComment.match(/"/g) || []).length
|
|
828
|
+
|
|
829
|
+
// Se número ímpar de aspas, // está dentro de string
|
|
830
|
+
if (quoteCount % 2 === 1) {
|
|
831
|
+
return line // Manter linha inteira (// está dentro de string)
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// // está fora de string, remover comentário
|
|
835
|
+
return line.substring(0, commentPos)
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// Linha sem aspas, pode remover // normalmente
|
|
839
|
+
const commentPos = line.indexOf('//')
|
|
840
|
+
return commentPos === -1 ? line : line.substring(0, commentPos)
|
|
841
|
+
})
|
|
842
|
+
|
|
843
|
+
cleaned = processedLines.join('\n')
|
|
844
|
+
|
|
845
|
+
// 3. Normalizar quebras de linha
|
|
846
|
+
cleaned = cleaned.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
|
|
847
|
+
|
|
848
|
+
// 4. ✅ CORRIGIDO: Remover caracteres de controle inválidos (ASCII 0-8, 11-12, 14-31)
|
|
849
|
+
// Remove caracteres de controle que causam "Bad control character in string literal"
|
|
850
|
+
// Mantém apenas tab(9), newline(10), carriage return(13) e caracteres imprimíveis (32+)
|
|
851
|
+
cleaned = cleaned.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '')
|
|
852
|
+
|
|
853
|
+
// 5. Remover trailing commas antes de } ou ]
|
|
854
|
+
cleaned = cleaned.replace(/,(\s*[}\]])/g, '$1')
|
|
855
|
+
|
|
856
|
+
// 6. Trim e fazer parse com try/catch para debugging
|
|
857
|
+
try {
|
|
858
|
+
return JSON.parse(cleaned.trim()) as BiomeConfig
|
|
859
|
+
} catch (error) {
|
|
860
|
+
console.warn('❌ Erro ao fazer parse do biome.json:', error)
|
|
861
|
+
console.warn(
|
|
862
|
+
'📝 Conteúdo problemático (primeiros 200 chars):',
|
|
863
|
+
cleaned.trim().substring(0, 200),
|
|
864
|
+
)
|
|
865
|
+
throw error
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* ✅ NOVO - Obtém configuração do Biome do AutoCore
|
|
871
|
+
*/
|
|
872
|
+
function getAutocoreBiomeConfig(): BiomeConfig {
|
|
873
|
+
try {
|
|
874
|
+
// Tentar ler o biome.json do AutoCore
|
|
875
|
+
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
|
876
|
+
// Navegar para o diretório raiz do projeto
|
|
877
|
+
// Se estivermos em dist/scripts/, subir 2 níveis; se em scripts/, subir 1 nível
|
|
878
|
+
const autocoreRoot = currentDir.includes('dist')
|
|
879
|
+
? path.resolve(currentDir, '..', '..') // dist/scripts/ -> raiz
|
|
880
|
+
: path.resolve(currentDir, '..') // scripts/ -> raiz
|
|
881
|
+
const autoCorePath = path.join(autocoreRoot, 'biome.json')
|
|
882
|
+
|
|
883
|
+
if (fs.existsSync(autoCorePath)) {
|
|
884
|
+
const biomeContent = fs.readFileSync(autoCorePath, 'utf-8')
|
|
885
|
+
const biomeConfig = parseJsonc(biomeContent)
|
|
886
|
+
console.log('📋 Configuração do Biome carregada do AutoCore')
|
|
887
|
+
return biomeConfig
|
|
888
|
+
}
|
|
889
|
+
} catch (error) {
|
|
890
|
+
console.warn('⚠️ Erro ao ler biome.json do AutoCore:', error)
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// Fallback para configuração padrão
|
|
894
|
+
console.log('📋 Usando configuração padrão do Biome')
|
|
895
|
+
return getDefaultBiomeConfig()
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* ✅ NOVO - Configuração padrão do Biome (fallback)
|
|
900
|
+
*/
|
|
901
|
+
function getDefaultBiomeConfig(): BiomeConfig {
|
|
902
|
+
return {
|
|
903
|
+
$schema: 'https://biomejs.dev/schemas/2.0.6/schema.json',
|
|
904
|
+
extends: ['ultracite'],
|
|
905
|
+
javascript: {
|
|
906
|
+
formatter: {
|
|
907
|
+
semicolons: 'asNeeded',
|
|
908
|
+
},
|
|
909
|
+
},
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* ✅ ATUALIZADO - Função helper para gerar biome.json como string
|
|
915
|
+
*/
|
|
916
|
+
export function generateBiomeConfigString(): string {
|
|
917
|
+
const biomeConfig = generateBiomeConfigForProject()
|
|
918
|
+
return JSON.stringify(biomeConfig, null, 2)
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* 📊 NOVO - Gera README de cobertura personalizado para o projeto
|
|
923
|
+
*/
|
|
924
|
+
export function generateCoverageReadme(projectName: string): string {
|
|
925
|
+
// ✅ ESM-compatible __dirname definition
|
|
926
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
927
|
+
const __dirname = path.dirname(__filename)
|
|
928
|
+
|
|
929
|
+
const templatePaths = [
|
|
930
|
+
path.join(__dirname, 'templates', 'coverage-readme.template.md'),
|
|
931
|
+
path.join(
|
|
932
|
+
process.cwd(),
|
|
933
|
+
'node_modules/@silasfmartins/testhub/dist/scripts/templates/coverage-readme.template.md',
|
|
934
|
+
),
|
|
935
|
+
path.join(process.cwd(), 'scripts/templates/coverage-readme.template.md'),
|
|
936
|
+
]
|
|
937
|
+
|
|
938
|
+
let template = ''
|
|
939
|
+
|
|
940
|
+
for (const templatePath of templatePaths) {
|
|
941
|
+
try {
|
|
942
|
+
template = fs.readFileSync(templatePath, 'utf-8')
|
|
943
|
+
break
|
|
944
|
+
} catch (error) {}
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
if (!template) {
|
|
948
|
+
// Fallback: template inline se nenhum arquivo for encontrado
|
|
949
|
+
template = `# 📊 Cobertura de Testes - \${projectName}
|
|
950
|
+
|
|
951
|
+
Este documento contém informações sobre a cobertura de testes do projeto **\${projectName}**.
|
|
952
|
+
|
|
953
|
+
## 🎯 Objetivos de Cobertura
|
|
954
|
+
|
|
955
|
+
- **Statements**: >= 80%
|
|
956
|
+
- **Branches**: >= 75%
|
|
957
|
+
- **Functions**: >= 85%
|
|
958
|
+
- **Lines**: >= 80%
|
|
959
|
+
|
|
960
|
+
## 📈 Como Visualizar a Cobertura
|
|
961
|
+
|
|
962
|
+
### 1. Executar testes com cobertura:
|
|
963
|
+
\`\`\`bash
|
|
964
|
+
npm test
|
|
965
|
+
\`\`\`
|
|
966
|
+
|
|
967
|
+
### 2. Visualizar relatório HTML:
|
|
968
|
+
\`\`\`bash
|
|
969
|
+
npm run coverage:open
|
|
970
|
+
\`\`\`
|
|
971
|
+
|
|
972
|
+
---
|
|
973
|
+
|
|
974
|
+
📊 **Gerado automaticamente pelo @silasfmartins/testhub**`
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
return template.replace(/\$\{projectName\}/g, projectName)
|
|
978
|
+
}
|