qa360 1.4.5 → 2.0.1
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/README.md +1 -1
- package/dist/commands/ai.d.ts +41 -0
- package/dist/commands/ai.js +499 -0
- package/dist/commands/ask.js +12 -12
- package/dist/commands/coverage.d.ts +8 -0
- package/dist/commands/coverage.js +252 -0
- package/dist/commands/explain.d.ts +27 -0
- package/dist/commands/explain.js +630 -0
- package/dist/commands/flakiness.d.ts +73 -0
- package/dist/commands/flakiness.js +435 -0
- package/dist/commands/generate.d.ts +66 -0
- package/dist/commands/generate.js +438 -0
- package/dist/commands/init.d.ts +56 -9
- package/dist/commands/init.js +217 -10
- package/dist/commands/monitor.d.ts +27 -0
- package/dist/commands/monitor.js +225 -0
- package/dist/commands/ollama.d.ts +40 -0
- package/dist/commands/ollama.js +301 -0
- package/dist/commands/pack.d.ts +37 -9
- package/dist/commands/pack.js +240 -141
- package/dist/commands/regression.d.ts +8 -0
- package/dist/commands/regression.js +340 -0
- package/dist/commands/repair.d.ts +26 -0
- package/dist/commands/repair.js +307 -0
- package/dist/commands/retry.d.ts +43 -0
- package/dist/commands/retry.js +275 -0
- package/dist/commands/run.d.ts +8 -3
- package/dist/commands/run.js +45 -31
- package/dist/commands/slo.d.ts +8 -0
- package/dist/commands/slo.js +327 -0
- package/dist/core/adapters/playwright-native-api.d.ts +183 -0
- package/dist/core/adapters/playwright-native-api.js +461 -0
- package/dist/core/adapters/playwright-ui.d.ts +7 -0
- package/dist/core/adapters/playwright-ui.js +29 -1
- package/dist/core/ai/anthropic-provider.d.ts +50 -0
- package/dist/core/ai/anthropic-provider.js +211 -0
- package/dist/core/ai/deepseek-provider.d.ts +81 -0
- package/dist/core/ai/deepseek-provider.js +254 -0
- package/dist/core/ai/index.d.ts +60 -0
- package/dist/core/ai/index.js +18 -0
- package/dist/core/ai/llm-client.d.ts +45 -0
- package/dist/core/ai/llm-client.js +7 -0
- package/dist/core/ai/mock-provider.d.ts +49 -0
- package/dist/core/ai/mock-provider.js +121 -0
- package/dist/core/ai/ollama-provider.d.ts +78 -0
- package/dist/core/ai/ollama-provider.js +192 -0
- package/dist/core/ai/openai-provider.d.ts +48 -0
- package/dist/core/ai/openai-provider.js +188 -0
- package/dist/core/ai/provider-factory.d.ts +160 -0
- package/dist/core/ai/provider-factory.js +269 -0
- package/dist/core/auth/api-key-provider.d.ts +16 -0
- package/dist/core/auth/api-key-provider.js +63 -0
- package/dist/core/auth/aws-iam-provider.d.ts +35 -0
- package/dist/core/auth/aws-iam-provider.js +177 -0
- package/dist/core/auth/azure-ad-provider.d.ts +15 -0
- package/dist/core/auth/azure-ad-provider.js +99 -0
- package/dist/core/auth/basic-auth-provider.d.ts +26 -0
- package/dist/core/auth/basic-auth-provider.js +111 -0
- package/dist/core/auth/gcp-adc-provider.d.ts +27 -0
- package/dist/core/auth/gcp-adc-provider.js +126 -0
- package/dist/core/auth/index.d.ts +238 -0
- package/dist/core/auth/index.js +82 -0
- package/dist/core/auth/jwt-provider.d.ts +19 -0
- package/dist/core/auth/jwt-provider.js +160 -0
- package/dist/core/auth/manager.d.ts +84 -0
- package/dist/core/auth/manager.js +230 -0
- package/dist/core/auth/oauth2-provider.d.ts +17 -0
- package/dist/core/auth/oauth2-provider.js +114 -0
- package/dist/core/auth/totp-provider.d.ts +31 -0
- package/dist/core/auth/totp-provider.js +134 -0
- package/dist/core/auth/ui-login-provider.d.ts +26 -0
- package/dist/core/auth/ui-login-provider.js +198 -0
- package/dist/core/cache/index.d.ts +7 -0
- package/dist/core/cache/index.js +6 -0
- package/dist/core/cache/lru-cache.d.ts +203 -0
- package/dist/core/cache/lru-cache.js +397 -0
- package/dist/core/coverage/analyzer.d.ts +101 -0
- package/dist/core/coverage/analyzer.js +415 -0
- package/dist/core/coverage/collector.d.ts +74 -0
- package/dist/core/coverage/collector.js +459 -0
- package/dist/core/coverage/config.d.ts +37 -0
- package/dist/core/coverage/config.js +156 -0
- package/dist/core/coverage/index.d.ts +11 -0
- package/dist/core/coverage/index.js +15 -0
- package/dist/core/coverage/types.d.ts +267 -0
- package/dist/core/coverage/types.js +6 -0
- package/dist/core/coverage/vault.d.ts +95 -0
- package/dist/core/coverage/vault.js +405 -0
- package/dist/core/dashboard/assets.d.ts +6 -0
- package/dist/core/dashboard/assets.js +690 -0
- package/dist/core/dashboard/index.d.ts +6 -0
- package/dist/core/dashboard/index.js +5 -0
- package/dist/core/dashboard/server.d.ts +72 -0
- package/dist/core/dashboard/server.js +354 -0
- package/dist/core/dashboard/types.d.ts +70 -0
- package/dist/core/dashboard/types.js +5 -0
- package/dist/core/discoverer/index.d.ts +115 -0
- package/dist/core/discoverer/index.js +250 -0
- package/dist/core/flakiness/index.d.ts +228 -0
- package/dist/core/flakiness/index.js +384 -0
- package/dist/core/generation/code-formatter.d.ts +111 -0
- package/dist/core/generation/code-formatter.js +307 -0
- package/dist/core/generation/code-generator.d.ts +144 -0
- package/dist/core/generation/code-generator.js +293 -0
- package/dist/core/generation/generator.d.ts +40 -0
- package/dist/core/generation/generator.js +76 -0
- package/dist/core/generation/index.d.ts +30 -0
- package/dist/core/generation/index.js +28 -0
- package/dist/core/generation/pack-generator.d.ts +107 -0
- package/dist/core/generation/pack-generator.js +416 -0
- package/dist/core/generation/prompt-builder.d.ts +132 -0
- package/dist/core/generation/prompt-builder.js +672 -0
- package/dist/core/generation/source-analyzer.d.ts +213 -0
- package/dist/core/generation/source-analyzer.js +657 -0
- package/dist/core/generation/test-optimizer.d.ts +117 -0
- package/dist/core/generation/test-optimizer.js +328 -0
- package/dist/core/generation/types.d.ts +214 -0
- package/dist/core/generation/types.js +4 -0
- package/dist/core/index.d.ts +23 -1
- package/dist/core/index.js +39 -0
- package/dist/core/pack/validator.js +31 -1
- package/dist/core/pack-v2/index.d.ts +9 -0
- package/dist/core/pack-v2/index.js +8 -0
- package/dist/core/pack-v2/loader.d.ts +62 -0
- package/dist/core/pack-v2/loader.js +231 -0
- package/dist/core/pack-v2/migrator.d.ts +56 -0
- package/dist/core/pack-v2/migrator.js +455 -0
- package/dist/core/pack-v2/validator.d.ts +61 -0
- package/dist/core/pack-v2/validator.js +577 -0
- package/dist/core/regression/detector.d.ts +107 -0
- package/dist/core/regression/detector.js +497 -0
- package/dist/core/regression/index.d.ts +9 -0
- package/dist/core/regression/index.js +11 -0
- package/dist/core/regression/trend-analyzer.d.ts +102 -0
- package/dist/core/regression/trend-analyzer.js +345 -0
- package/dist/core/regression/types.d.ts +222 -0
- package/dist/core/regression/types.js +7 -0
- package/dist/core/regression/vault.d.ts +87 -0
- package/dist/core/regression/vault.js +289 -0
- package/dist/core/repair/engine/fixer.d.ts +24 -0
- package/dist/core/repair/engine/fixer.js +226 -0
- package/dist/core/repair/engine/suggestion-engine.d.ts +18 -0
- package/dist/core/repair/engine/suggestion-engine.js +187 -0
- package/dist/core/repair/index.d.ts +10 -0
- package/dist/core/repair/index.js +13 -0
- package/dist/core/repair/repairer.d.ts +90 -0
- package/dist/core/repair/repairer.js +284 -0
- package/dist/core/repair/types.d.ts +91 -0
- package/dist/core/repair/types.js +6 -0
- package/dist/core/repair/utils/error-analyzer.d.ts +28 -0
- package/dist/core/repair/utils/error-analyzer.js +264 -0
- package/dist/core/retry/flakiness-integration.d.ts +60 -0
- package/dist/core/retry/flakiness-integration.js +228 -0
- package/dist/core/retry/index.d.ts +14 -0
- package/dist/core/retry/index.js +16 -0
- package/dist/core/retry/retry-engine.d.ts +80 -0
- package/dist/core/retry/retry-engine.js +296 -0
- package/dist/core/retry/types.d.ts +178 -0
- package/dist/core/retry/types.js +52 -0
- package/dist/core/retry/vault.d.ts +77 -0
- package/dist/core/retry/vault.js +304 -0
- package/dist/core/runner/e2e-helpers.d.ts +102 -0
- package/dist/core/runner/e2e-helpers.js +153 -0
- package/dist/core/runner/phase3-runner.d.ts +101 -2
- package/dist/core/runner/phase3-runner.js +559 -24
- package/dist/core/self-healing/assertion-healer.d.ts +97 -0
- package/dist/core/self-healing/assertion-healer.js +371 -0
- package/dist/core/self-healing/engine.d.ts +122 -0
- package/dist/core/self-healing/engine.js +538 -0
- package/dist/core/self-healing/index.d.ts +10 -0
- package/dist/core/self-healing/index.js +11 -0
- package/dist/core/self-healing/selector-healer.d.ts +103 -0
- package/dist/core/self-healing/selector-healer.js +372 -0
- package/dist/core/self-healing/types.d.ts +152 -0
- package/dist/core/self-healing/types.js +6 -0
- package/dist/core/slo/config.d.ts +107 -0
- package/dist/core/slo/config.js +360 -0
- package/dist/core/slo/index.d.ts +11 -0
- package/dist/core/slo/index.js +15 -0
- package/dist/core/slo/sli-calculator.d.ts +92 -0
- package/dist/core/slo/sli-calculator.js +364 -0
- package/dist/core/slo/slo-tracker.d.ts +148 -0
- package/dist/core/slo/slo-tracker.js +379 -0
- package/dist/core/slo/types.d.ts +281 -0
- package/dist/core/slo/types.js +7 -0
- package/dist/core/slo/vault.d.ts +102 -0
- package/dist/core/slo/vault.js +427 -0
- package/dist/core/tui/index.d.ts +7 -0
- package/dist/core/tui/index.js +6 -0
- package/dist/core/tui/monitor.d.ts +92 -0
- package/dist/core/tui/monitor.js +271 -0
- package/dist/core/tui/renderer.d.ts +33 -0
- package/dist/core/tui/renderer.js +218 -0
- package/dist/core/tui/types.d.ts +63 -0
- package/dist/core/tui/types.js +5 -0
- package/dist/core/types/pack-v2.d.ts +425 -0
- package/dist/core/types/pack-v2.js +8 -0
- package/dist/core/vault/index.d.ts +116 -0
- package/dist/core/vault/index.js +400 -5
- package/dist/core/watch/index.d.ts +7 -0
- package/dist/core/watch/index.js +6 -0
- package/dist/core/watch/watch-mode.d.ts +213 -0
- package/dist/core/watch/watch-mode.js +389 -0
- package/dist/index.js +68 -68
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.js +136 -0
- package/package.json +5 -1
- package/dist/core/adapters/playwright-api.d.ts +0 -82
- package/dist/core/adapters/playwright-api.js +0 -264
package/dist/core/index.js
CHANGED
|
@@ -33,7 +33,46 @@ export { SecretsCrypto } from './secrets/crypto.js';
|
|
|
33
33
|
// Pack Validation & Migration
|
|
34
34
|
export { PackValidator } from './pack/validator.js';
|
|
35
35
|
export { PackMigrator } from './pack/migrator.js';
|
|
36
|
+
// AI Module (Ollama integration)
|
|
37
|
+
export * from './ai/index.js';
|
|
38
|
+
// Test Discoverer
|
|
39
|
+
export * from './discoverer/index.js';
|
|
40
|
+
// Pack v2 Types
|
|
41
|
+
export * from './types/pack-v2.js';
|
|
42
|
+
// Pack v2 Module (Validation, Migration, Loading)
|
|
43
|
+
export * from './pack-v2/index.js';
|
|
44
|
+
// Explicit exports for TypeScript resolution
|
|
45
|
+
export { PackLoaderV2, PackValidatorV2 } from './pack-v2/index.js';
|
|
46
|
+
// Authentication Module
|
|
47
|
+
export * from './auth/index.js';
|
|
48
|
+
// Generation Module (Phase 4 - AI Test Generation)
|
|
49
|
+
export * from './generation/index.js';
|
|
36
50
|
// Server & Observability
|
|
37
51
|
export { QA360Server } from './serve/server.js';
|
|
38
52
|
// Runner
|
|
39
53
|
export { Phase3Runner } from './runner/phase3-runner.js';
|
|
54
|
+
// Adapters
|
|
55
|
+
export { PlaywrightNativeApiAdapter, createPlaywrightNativeApiAdapter } from './adapters/playwright-native-api.js';
|
|
56
|
+
// Note: PlaywrightApiAdapter was replaced by PlaywrightNativeApiAdapter (zero overhead)
|
|
57
|
+
// Auto-Repair Module (Phase 7)
|
|
58
|
+
export * from './repair/index.js';
|
|
59
|
+
// TUI Module (Phase 8 - Terminal UI)
|
|
60
|
+
export * from './tui/index.js';
|
|
61
|
+
// Dashboard Module (Phase 8 - Web Dashboard)
|
|
62
|
+
export * from './dashboard/index.js';
|
|
63
|
+
// Flakiness Detection Engine (Vision 2.0 - Phase 1)
|
|
64
|
+
export * from './flakiness/index.js';
|
|
65
|
+
// Smart Retry Module (Vision 2.0 - Phase 2 - F8)
|
|
66
|
+
export * from './retry/index.js';
|
|
67
|
+
// Cache Module (Phase 2 - LRU Cache for HTTP responses)
|
|
68
|
+
export * from './cache/index.js';
|
|
69
|
+
// Watch Module (Phase 3 - Continuous testing and benchmarking)
|
|
70
|
+
export * from './watch/index.js';
|
|
71
|
+
// Self-Healing Module (Vision 2.0 - Phase 2 - F7)
|
|
72
|
+
export * from './self-healing/index.js';
|
|
73
|
+
// Coverage Analytics Module (Vision 2.0 - Phase 2 - F11)
|
|
74
|
+
export * from './coverage/index.js';
|
|
75
|
+
// SLO/SLI Management Module (Vision 2.0 - Phase 2)
|
|
76
|
+
export * from './slo/index.js';
|
|
77
|
+
// Regression Detection Module (Vision 2.0 - Phase 2 - F12)
|
|
78
|
+
export * from './regression/index.js';
|
|
@@ -30,7 +30,37 @@ export class PackValidator {
|
|
|
30
30
|
validate(pack) {
|
|
31
31
|
const errors = [];
|
|
32
32
|
const warnings = [];
|
|
33
|
-
//
|
|
33
|
+
// Check version first to determine which schema to use
|
|
34
|
+
const version = pack.version;
|
|
35
|
+
if (version === 2) {
|
|
36
|
+
// Version 2 uses a different structure (object gates)
|
|
37
|
+
// For now, return a helpful message that v2 is not fully supported
|
|
38
|
+
errors.push({
|
|
39
|
+
code: 'QP200',
|
|
40
|
+
path: 'version',
|
|
41
|
+
message: 'Pack version 2 is not yet supported in this release',
|
|
42
|
+
suggestion: 'Use version: 1 with the v1 format. See docs for v1 format examples.'
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
valid: false,
|
|
46
|
+
errors,
|
|
47
|
+
warnings
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (version > 2 || version < 1) {
|
|
51
|
+
errors.push({
|
|
52
|
+
code: 'QP201',
|
|
53
|
+
path: 'version',
|
|
54
|
+
message: `Unsupported pack version: ${version}`,
|
|
55
|
+
suggestion: 'Use version: 1 (current) or version: 2 (coming soon)'
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
valid: false,
|
|
59
|
+
errors,
|
|
60
|
+
warnings
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Schema validation for v1
|
|
34
64
|
const valid = this.ajv.validate('pack-v1', pack);
|
|
35
65
|
if (!valid && this.ajv.errors) {
|
|
36
66
|
for (const error of this.ajv.errors) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QA360 Pack v2 Module
|
|
3
|
+
*
|
|
4
|
+
* Provides validation, migration, and loading for Pack v2 configurations.
|
|
5
|
+
*/
|
|
6
|
+
export { PackValidatorV2 } from './validator.js';
|
|
7
|
+
export { PackMigrator } from './migrator.js';
|
|
8
|
+
export { PackLoaderV2, PackLoadResult } from './loader.js';
|
|
9
|
+
export type { PackConfigV2, AuthConfigV2, AuthProfile, AuthTypeV2, AuthCacheConfig, GateConfigV2, GateBudgets, GateOptions, HooksConfig, Hook, ExecutionConfigV2, ResourceLimits, SecurityBudgets, PerformanceTargets, JWTAuthProfileV2, OAuth2AuthProfileV2, UILoginAuthProfileV2, GCPADCProfileV2, AWSIamProfileV2, TargetConfig, ApiTarget, WebTarget, ApiRequest, WebPage, PageAction, PackValidationResultV2, ValidationError, PackMigrationResultV2 } from '../types/pack-v2.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QA360 Pack v2 Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and parses pack.yml v2 files from the filesystem.
|
|
5
|
+
*/
|
|
6
|
+
import { PackConfigV2, PackValidationResultV2, ValidationError } from '../types/pack-v2.js';
|
|
7
|
+
export interface PackLoadResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
pack?: PackConfigV2 | any;
|
|
10
|
+
validation?: PackValidationResultV2;
|
|
11
|
+
valid?: boolean;
|
|
12
|
+
error?: Error;
|
|
13
|
+
sourcePath?: string;
|
|
14
|
+
format?: 'v1' | 'v2' | 'unknown';
|
|
15
|
+
migrated?: boolean;
|
|
16
|
+
changes?: string[];
|
|
17
|
+
warnings?: string[];
|
|
18
|
+
foundFiles?: string[];
|
|
19
|
+
missingFiles?: string[];
|
|
20
|
+
validationErrors?: ValidationError[];
|
|
21
|
+
}
|
|
22
|
+
export declare class PackLoaderV2 {
|
|
23
|
+
private cache;
|
|
24
|
+
/**
|
|
25
|
+
* Load a pack configuration from a file path
|
|
26
|
+
*/
|
|
27
|
+
load(packPath: string, options?: {
|
|
28
|
+
validate?: boolean;
|
|
29
|
+
checkFilesExist?: boolean;
|
|
30
|
+
useCache?: boolean;
|
|
31
|
+
migrate?: boolean;
|
|
32
|
+
}): Promise<PackLoadResult>;
|
|
33
|
+
/**
|
|
34
|
+
* Load and validate in one step
|
|
35
|
+
*/
|
|
36
|
+
loadAndValidate(packPath: string, options?: {
|
|
37
|
+
checkFilesExist?: boolean;
|
|
38
|
+
}): Promise<PackLoadResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Load multiple packs from a directory
|
|
41
|
+
*/
|
|
42
|
+
loadFromDir(dirPath: string, options?: {
|
|
43
|
+
pattern?: string;
|
|
44
|
+
validate?: boolean;
|
|
45
|
+
checkFilesExist?: boolean;
|
|
46
|
+
}): Promise<PackLoadResult[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Load from a YAML string (useful for testing or dynamic configs)
|
|
49
|
+
*/
|
|
50
|
+
loadFromString(yamlContent: string, options?: {
|
|
51
|
+
validate?: boolean;
|
|
52
|
+
filename?: string;
|
|
53
|
+
}): Promise<PackLoadResult>;
|
|
54
|
+
/**
|
|
55
|
+
* Clear the cache
|
|
56
|
+
*/
|
|
57
|
+
clearCache(path?: string): void;
|
|
58
|
+
/**
|
|
59
|
+
* Get cache size
|
|
60
|
+
*/
|
|
61
|
+
getCacheSize(): number;
|
|
62
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QA360 Pack v2 Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and parses pack.yml v2 files from the filesystem.
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync, existsSync } from 'fs';
|
|
7
|
+
import { resolve } from 'path';
|
|
8
|
+
import * as yaml from 'js-yaml';
|
|
9
|
+
import { PackValidatorV2 } from './validator.js';
|
|
10
|
+
import { PackMigrator } from './migrator.js';
|
|
11
|
+
export class PackLoaderV2 {
|
|
12
|
+
cache = new Map();
|
|
13
|
+
/**
|
|
14
|
+
* Load a pack configuration from a file path
|
|
15
|
+
*/
|
|
16
|
+
async load(packPath, options) {
|
|
17
|
+
try {
|
|
18
|
+
// Resolve absolute path
|
|
19
|
+
const resolvedPath = resolve(packPath);
|
|
20
|
+
// Check if file exists
|
|
21
|
+
if (!existsSync(resolvedPath)) {
|
|
22
|
+
return {
|
|
23
|
+
success: false,
|
|
24
|
+
error: new Error(`Pack file not found: ${resolvedPath}`),
|
|
25
|
+
sourcePath: resolvedPath,
|
|
26
|
+
format: 'unknown'
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Read file
|
|
30
|
+
const content = readFileSync(resolvedPath, 'utf-8');
|
|
31
|
+
// Parse YAML
|
|
32
|
+
const parsed = yaml.load(content);
|
|
33
|
+
// Detect version
|
|
34
|
+
const migrator = new PackMigrator();
|
|
35
|
+
const detectedVersion = migrator.detectVersion(parsed);
|
|
36
|
+
// Set format
|
|
37
|
+
const format = detectedVersion === 1 ? 'v1' : detectedVersion === 2 ? 'v2' : 'unknown';
|
|
38
|
+
// For v1 without migration
|
|
39
|
+
if (detectedVersion === 1 && options?.migrate === false) {
|
|
40
|
+
return {
|
|
41
|
+
success: true,
|
|
42
|
+
pack: parsed,
|
|
43
|
+
format: 'v1',
|
|
44
|
+
migrated: false,
|
|
45
|
+
sourcePath: resolvedPath
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
let pack;
|
|
49
|
+
let migrated = false;
|
|
50
|
+
let changes = [];
|
|
51
|
+
let migrationWarnings = [];
|
|
52
|
+
if (detectedVersion === 1) {
|
|
53
|
+
// Migrate v1 to v2
|
|
54
|
+
const migrationResult = migrator.migrate(parsed);
|
|
55
|
+
if (!migrationResult.success) {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
error: new Error(`Migration failed: ${migrationResult.warnings.join(', ')}`),
|
|
59
|
+
sourcePath: resolvedPath,
|
|
60
|
+
format: 'v1'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
pack = migrationResult.migrated;
|
|
64
|
+
migrated = true;
|
|
65
|
+
changes = migrationResult.changes;
|
|
66
|
+
migrationWarnings = migrationResult.warnings;
|
|
67
|
+
}
|
|
68
|
+
else if (detectedVersion === 2) {
|
|
69
|
+
pack = parsed;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return {
|
|
73
|
+
success: false,
|
|
74
|
+
error: new Error(`Unknown pack format. Version: ${parsed.version}`),
|
|
75
|
+
sourcePath: resolvedPath,
|
|
76
|
+
format: 'unknown'
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// Cache the pack
|
|
80
|
+
if (options?.useCache !== false) {
|
|
81
|
+
this.cache.set(resolvedPath, pack);
|
|
82
|
+
}
|
|
83
|
+
// Validate if requested (or by default)
|
|
84
|
+
const shouldValidate = options?.validate !== false;
|
|
85
|
+
if (shouldValidate) {
|
|
86
|
+
const validator = new PackValidatorV2(resolvedPath);
|
|
87
|
+
const validation = await validator.validate(pack, { checkFilesExist: options?.checkFilesExist });
|
|
88
|
+
return {
|
|
89
|
+
success: validation.valid,
|
|
90
|
+
pack,
|
|
91
|
+
valid: validation.valid,
|
|
92
|
+
validation,
|
|
93
|
+
validationErrors: validation.errors,
|
|
94
|
+
sourcePath: resolvedPath,
|
|
95
|
+
format: 'v2',
|
|
96
|
+
migrated,
|
|
97
|
+
changes,
|
|
98
|
+
warnings: migrationWarnings,
|
|
99
|
+
foundFiles: validation.info?.totalTests ? [`found ${validation.info.totalTests} tests`] : undefined
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
success: true,
|
|
104
|
+
pack,
|
|
105
|
+
valid: true,
|
|
106
|
+
sourcePath: resolvedPath,
|
|
107
|
+
format: 'v2',
|
|
108
|
+
migrated,
|
|
109
|
+
changes,
|
|
110
|
+
warnings: migrationWarnings
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return {
|
|
115
|
+
success: false,
|
|
116
|
+
error: error,
|
|
117
|
+
sourcePath: packPath,
|
|
118
|
+
format: 'unknown'
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Load and validate in one step
|
|
124
|
+
*/
|
|
125
|
+
async loadAndValidate(packPath, options) {
|
|
126
|
+
return this.load(packPath, {
|
|
127
|
+
validate: true,
|
|
128
|
+
checkFilesExist: options?.checkFilesExist,
|
|
129
|
+
useCache: false
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Load multiple packs from a directory
|
|
134
|
+
*/
|
|
135
|
+
async loadFromDir(dirPath, options) {
|
|
136
|
+
const { glob } = await import('glob');
|
|
137
|
+
const pattern = options?.pattern || '**/*.yml';
|
|
138
|
+
const results = [];
|
|
139
|
+
try {
|
|
140
|
+
const files = await glob(pattern, {
|
|
141
|
+
cwd: dirPath,
|
|
142
|
+
absolute: true,
|
|
143
|
+
ignore: ['**/node_modules/**']
|
|
144
|
+
});
|
|
145
|
+
for (const file of files) {
|
|
146
|
+
const result = await this.load(file, options);
|
|
147
|
+
results.push(result);
|
|
148
|
+
}
|
|
149
|
+
return results;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
return [{
|
|
153
|
+
success: false,
|
|
154
|
+
error: new Error(`Failed to scan directory: ${error.message}`)
|
|
155
|
+
}];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Load from a YAML string (useful for testing or dynamic configs)
|
|
160
|
+
*/
|
|
161
|
+
async loadFromString(yamlContent, options) {
|
|
162
|
+
try {
|
|
163
|
+
const parsed = yaml.load(yamlContent);
|
|
164
|
+
// Detect version and migrate if needed
|
|
165
|
+
const migrator = new PackMigrator();
|
|
166
|
+
const detectedVersion = migrator.detectVersion(parsed);
|
|
167
|
+
let pack;
|
|
168
|
+
let migrated = false;
|
|
169
|
+
if (detectedVersion === 1) {
|
|
170
|
+
const migrationResult = migrator.migrate(parsed);
|
|
171
|
+
if (!migrationResult.success) {
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
error: new Error(`Migration failed: ${migrationResult.warnings.join(', ')}`)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
pack = migrationResult.migrated;
|
|
178
|
+
migrated = true;
|
|
179
|
+
}
|
|
180
|
+
else if (detectedVersion === 2) {
|
|
181
|
+
pack = parsed;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return {
|
|
185
|
+
success: false,
|
|
186
|
+
error: new Error(`Unknown pack format. Version: ${parsed.version}`)
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
// Validate if requested
|
|
190
|
+
if (options?.validate !== false) {
|
|
191
|
+
const fakePath = options?.filename || 'pack.yml';
|
|
192
|
+
const validator = new PackValidatorV2(fakePath);
|
|
193
|
+
const validation = await validator.validate(pack);
|
|
194
|
+
return {
|
|
195
|
+
success: validation.valid,
|
|
196
|
+
pack,
|
|
197
|
+
validation,
|
|
198
|
+
migrated
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
success: true,
|
|
203
|
+
pack,
|
|
204
|
+
migrated
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
catch (error) {
|
|
208
|
+
return {
|
|
209
|
+
success: false,
|
|
210
|
+
error: new Error(`Failed to parse YAML: ${error.message}`)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Clear the cache
|
|
216
|
+
*/
|
|
217
|
+
clearCache(path) {
|
|
218
|
+
if (path) {
|
|
219
|
+
this.cache.delete(resolve(path));
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this.cache.clear();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Get cache size
|
|
227
|
+
*/
|
|
228
|
+
getCacheSize() {
|
|
229
|
+
return this.cache.size;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QA360 Pack v1 to v2 Migrator
|
|
3
|
+
*
|
|
4
|
+
* Migrates Pack v1 configurations to Pack v2 format.
|
|
5
|
+
*/
|
|
6
|
+
import { PackConfigV1 } from '../types/pack-v1.js';
|
|
7
|
+
import { PackMigrationResultV2 } from '../types/pack-v2.js';
|
|
8
|
+
/**
|
|
9
|
+
* Migrate Pack v1 to v2
|
|
10
|
+
*/
|
|
11
|
+
export declare class PackMigrator {
|
|
12
|
+
/**
|
|
13
|
+
* Migrate a v1 pack to v2 format
|
|
14
|
+
*/
|
|
15
|
+
migrate(v1Pack: PackConfigV1): PackMigrationResultV2;
|
|
16
|
+
/**
|
|
17
|
+
* Migrate gates from v1 to v2
|
|
18
|
+
*/
|
|
19
|
+
private migrateGates;
|
|
20
|
+
/**
|
|
21
|
+
* Migrate authentication from v1 to v2
|
|
22
|
+
*/
|
|
23
|
+
private migrateAuth;
|
|
24
|
+
/**
|
|
25
|
+
* Migrate hooks from v1 to v2
|
|
26
|
+
*/
|
|
27
|
+
private migrateHooks;
|
|
28
|
+
/**
|
|
29
|
+
* Migrate execution config from v1 to v2
|
|
30
|
+
*/
|
|
31
|
+
private migrateExecution;
|
|
32
|
+
/**
|
|
33
|
+
* Migrate budgets to individual gates
|
|
34
|
+
*/
|
|
35
|
+
private migrateBudgetsToGates;
|
|
36
|
+
/**
|
|
37
|
+
* Migrate security config to individual gates
|
|
38
|
+
*/
|
|
39
|
+
private migrateSecurityToGates;
|
|
40
|
+
/**
|
|
41
|
+
* Migrate targets to gate configs
|
|
42
|
+
*/
|
|
43
|
+
private migrateTargetsToGates;
|
|
44
|
+
/**
|
|
45
|
+
* Find a secret in environment variables by trying common names
|
|
46
|
+
*/
|
|
47
|
+
private findSecretInEnv;
|
|
48
|
+
/**
|
|
49
|
+
* Sanitize gate name for v2 format
|
|
50
|
+
*/
|
|
51
|
+
private sanitizeGateName;
|
|
52
|
+
/**
|
|
53
|
+
* Detect pack version
|
|
54
|
+
*/
|
|
55
|
+
detectVersion(pack: any): 1 | 2 | 'unknown';
|
|
56
|
+
}
|