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